PluginProbe
Commerce7 for WordPress / trunk
Commerce7 for WordPress vtrunk
1.8.1 1.8.0 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.1.0 1.1.1 1.1.3 1.2.0 1.2.1 1.2.2 1.2.3 1.2.5 1.2.6 1.3.0 1.3.1 1.3.2 1.3.4 1.3.5 1.4.0 1.4.1 All 37 releases
wp-commerce7 / uninstall.php

uninstall.php in Commerce7 for WordPress trunk, at uninstall.php

59 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Uninstall script for Commerce7 for WordPress
4 *
5 * This file is executed when the plugin is uninstalled (deleted).
6 * It removes all plugin data from the database.
7 *
8 * @package wp-commerce7
9 * @author Michael Bourne
10 * @license GPL3
11 * @link https://ursa6.com
12 * @since 1.5.5
13 */
14
15 // If uninstall not called from WordPress, then exit.
16 if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
17 exit;
18 }
19
20 // Check user permissions
21 if ( ! current_user_can( 'activate_plugins' ) ) {
22 return;
23 }
24
25 // Remove plugin options
26 delete_option( 'c7wp_settings' );
27 delete_option( 'c7wp_activation' );
28
29 // Remove transients
30 delete_transient( 'c7wp_remote_notices' );
31 delete_transient( 'c7wp-admin-notice-pages' );
32 delete_transient( 'c7wp-admin-notice-pages-missing' );
33
34 // Remove callout transients (these have dynamic names)
35 global $wpdb;
36 $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_c7wp_%'" );
37 $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_timeout_c7wp_%'" );
38
39 // Remove user meta for dismissed notices
40 $wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key LIKE 'c7wp_notice_dismissed_%'" );
41
42 // Clear scheduled cron jobs
43 wp_clear_scheduled_hook( 'c7wp_fetch_remote_notices' );
44
45 // Optionally remove created pages (with user confirmation via filter)
46 if ( apply_filters( 'c7wp_uninstall_remove_pages', false ) ) {
47 $pages_to_remove = array( 'profile', 'collection', 'product', 'club', 'checkout', 'cart', 'reservation' );
48
49 foreach ( $pages_to_remove as $page_slug ) {
50 $page_obj = get_page_by_path( $page_slug, OBJECT, 'page' );
51 if ( $page_obj ) {
52 wp_delete_post( $page_obj->ID, true ); // true = force delete (bypass trash)
53 }
54 }
55 }
56
57 // Flush rewrite rules to clean up custom routes
58 flush_rewrite_rules();
59