| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { // If uninstall not called from WordPress exit |
| 4 | - exit; | |
| 4 | + exit(); | |
| 5 | 5 | } |
| 6 | 6 | |
| 7 | 7 | /** |
| 8 | 8 | * Manages Polylang uninstallation |
| @@ -19,13 +19,8 @@ | ||
| 19 | 19 | */ |
| 20 | 20 | public function __construct() { |
| 21 | 21 | global $wpdb; |
| 22 | 22 | |
| 23 | - // Don't do anything except if the constant PLL_REMOVE_ALL_DATA is explicitely defined and true. | |
| 24 | - if ( ! defined( 'PLL_REMOVE_ALL_DATA' ) || ! PLL_REMOVE_ALL_DATA ) { | |
| 25 | - return; | |
| 26 | - } | |
| 27 | - | |
| 28 | 23 | // Check if it is a multisite uninstall - if so, run the uninstall function for each blog id |
| 29 | 24 | if ( is_multisite() ) { |
| 30 | 25 | foreach ( $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" ) as $blog_id ) { |
| 31 | 26 | switch_to_blog( $blog_id ); |
| @@ -44,8 +39,14 @@ | ||
| 44 | 39 | * |
| 45 | 40 | * @since 0.5 |
| 46 | 41 | */ |
| 47 | 42 | public function uninstall() { |
| 43 | + $options = get_option( 'polylang' ); | |
| 44 | + | |
| 45 | + if ( empty( $options['uninstall'] ) ) { | |
| 46 | + return; | |
| 47 | + } | |
| 48 | + | |
| 48 | 49 | global $wpdb; |
| 49 | 50 | |
| 50 | 51 | // Executes each module's uninstall script, if it exists |
| 51 | 52 | $pll_modules_dir = dirname( __FILE__ ) . '/modules'; |
| @@ -53,9 +54,9 @@ | ||
| 53 | 54 | while ( ( $module = readdir() ) != false ) { |
| 54 | 55 | if ( substr( $module, 0, 1 ) !== '.' ) { |
| 55 | 56 | $uninstall_script = $pll_modules_dir . '/' . $module . '/uninstall.php'; |
| 56 | 57 | if ( file_exists( $uninstall_script ) ) { |
| 57 | - require $uninstall_script; // phpcs:ignore WordPressVIPMinimum.Files.IncludingFile.UsingVariable | |
| 58 | + require $uninstall_script; | |
| 58 | 59 | } |
| 59 | 60 | } |
| 60 | 61 | } |
| 61 | 62 | closedir(); |
| @@ -82,9 +83,8 @@ | ||
| 82 | 83 | |
| 83 | 84 | // Delete users options |
| 84 | 85 | foreach ( get_users( array( 'fields' => 'ID' ) ) as $user_id ) { |
| 85 | 86 | delete_user_meta( $user_id, 'pll_filter_content' ); |
| 86 | - delete_user_meta( $user_id, 'pll_dismissed_notices' ); // Legacy meta. | |
| 87 | 87 | foreach ( $languages as $lang ) { |
| 88 | 88 | delete_user_meta( $user_id, 'description_' . $lang->slug ); |
| 89 | 89 | } |
| 90 | 90 | } |
| @@ -125,11 +125,8 @@ | ||
| 125 | 125 | wp_delete_post( $id, true ); |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | // Delete all what is related to languages and translations |
| 129 | - $term_ids = array(); | |
| 130 | - $tt_ids = array(); | |
| 131 | - | |
| 132 | 129 | foreach ( get_terms( $pll_taxonomies, array( 'hide_empty' => false ) ) as $term ) { |
| 133 | 130 | $term_ids[] = (int) $term->term_id; |
| 134 | 131 | $tt_ids[] = (int) $term->term_taxonomy_id; |
| 135 | 132 | } |
| @@ -149,9 +146,8 @@ | ||
| 149 | 146 | delete_option( 'polylang' ); |
| 150 | 147 | delete_option( 'widget_polylang' ); // Automatically created by WP |
| 151 | 148 | delete_option( 'polylang_wpml_strings' ); // Strings registered with icl_register_string |
| 152 | 149 | delete_option( 'polylang_licenses' ); |
| 153 | - delete_option( 'pll_dismissed_notices' ); | |
| 154 | 150 | |
| 155 | 151 | // Delete transients |
| 156 | 152 | delete_transient( 'pll_languages_list' ); |
| 157 | 153 | delete_transient( 'pll_upgrade_1_4' ); |