cookie-law-info
Last commit date
languages
9 months ago
legacy
9 months ago
lite
9 months ago
public
9 months ago
class-autoloader.php
9 months ago
cookie-law-info.php
9 months ago
license.txt
9 months ago
readme.txt
9 months ago
uninstall.php
9 months ago
wpml-config.xml
9 months ago
uninstall.php
75 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Fired when the plugin is uninstalled. |
| 4 | * |
| 5 | * When populating this file, consider the following flow |
| 6 | * of control: |
| 7 | * |
| 8 | * - This method should be static |
| 9 | * - Check if the $_REQUEST content actually is the plugin name |
| 10 | * - Run an admin referrer check to make sure it goes through authentication |
| 11 | * - Verify the output of $_GET makes sense |
| 12 | * - Repeat with other user roles. Best directly by using the links/query string parameters. |
| 13 | * - Repeat things for multisite. Once for a single site in the network, once sitewide. |
| 14 | * |
| 15 | * This file may be updated more in future version of the Boilerplate; however, this is the |
| 16 | * general skeleton and outline for how the file should work. |
| 17 | * |
| 18 | * For more information, see the following discussion: |
| 19 | * https://github.com/tommcfarlin/WordPress-Plugin-Boilerplate/pull/123#issuecomment-28541913 |
| 20 | * |
| 21 | * @link https://www.webtoffee.com/ |
| 22 | * @since 3.0.0 |
| 23 | * |
| 24 | * @package CookieYes |
| 25 | */ |
| 26 | |
| 27 | // If uninstall not called from WordPress, then exit. |
| 28 | if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
| 29 | exit; |
| 30 | } |
| 31 | |
| 32 | delete_option( 'cky_connect_notice' ); |
| 33 | |
| 34 | if ( defined( 'CKY_REMOVE_ALL_DATA' ) && true === CKY_REMOVE_ALL_DATA ) { |
| 35 | try { |
| 36 | global $wpdb; |
| 37 | $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'cky_banners' ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery |
| 38 | $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'cky_cookie_categories' ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery |
| 39 | $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'cky_cookies' ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery |
| 40 | |
| 41 | $prefix = $wpdb->esc_like( '_transient_cky' ) . '%'; |
| 42 | $keys = $wpdb->get_results( $wpdb->prepare( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE %s", $prefix ), ARRAY_A ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery |
| 43 | if ( ! is_wp_error( $keys ) ) { |
| 44 | $transients = array_map( |
| 45 | function( $key ) { |
| 46 | return ltrim( $key['option_name'], '_transient_' ); |
| 47 | }, |
| 48 | $keys |
| 49 | ); |
| 50 | foreach ( $transients as $key ) { |
| 51 | delete_transient( $key ); |
| 52 | } |
| 53 | } |
| 54 | $options = array( |
| 55 | 'cky_banners_table_version', |
| 56 | 'cky_cookie_category_table_version', |
| 57 | 'cky_cookie_table_version', |
| 58 | 'cky_consent_table_version', |
| 59 | 'cky_scan_details', |
| 60 | 'cky_settings', |
| 61 | 'cky_admin_notices', |
| 62 | 'wt_cli_version', |
| 63 | 'CookieLawInfo-0.9', |
| 64 | 'cky_cookie_consent_lite_db_version', |
| 65 | 'cky_missing_tables', |
| 66 | 'cky_migration_options', |
| 67 | ); |
| 68 | foreach ( $options as $option_name ) { |
| 69 | delete_option( $option_name ); |
| 70 | } |
| 71 | } catch ( Exception $e ) { |
| 72 | error_log( __( 'Failed to delete CookieYes plugin data!', 'cookie-law-info' ) ); //phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log |
| 73 | } |
| 74 | } |
| 75 |