| @@ -1,11 +1,8 @@ | ||
| 1 | 1 | <?php |
| 2 | -/** | |
| 3 | - * @package Polylang | |
| 4 | - */ | |
| 5 | 2 | |
| 6 | 3 | if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { // If uninstall not called from WordPress exit |
| 7 | - exit; | |
| 4 | + exit(); | |
| 8 | 5 | } |
| 9 | 6 | |
| 10 | 7 | /** |
| 11 | 8 | * Manages Polylang uninstallation |
| @@ -22,13 +19,8 @@ | ||
| 22 | 19 | */ |
| 23 | 20 | public function __construct() { |
| 24 | 21 | global $wpdb; |
| 25 | 22 | |
| 26 | - // Don't do anything except if the constant PLL_REMOVE_ALL_DATA is explicitely defined and true. | |
| 27 | - if ( ! defined( 'PLL_REMOVE_ALL_DATA' ) || ! PLL_REMOVE_ALL_DATA ) { | |
| 28 | - return; | |
| 29 | - } | |
| 30 | - | |
| 31 | 23 | // Check if it is a multisite uninstall - if so, run the uninstall function for each blog id |
| 32 | 24 | if ( is_multisite() ) { |
| 33 | 25 | foreach ( $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" ) as $blog_id ) { |
| 34 | 26 | switch_to_blog( $blog_id ); |
| @@ -47,14 +39,17 @@ | ||
| 47 | 39 | * |
| 48 | 40 | * @since 0.5 |
| 49 | 41 | */ |
| 50 | 42 | public function uninstall() { |
| 51 | - global $wpdb; | |
| 43 | + $options = get_option( 'polylang' ); | |
| 52 | 44 | |
| 53 | - do_action( 'pll_uninstall' ); | |
| 45 | + if ( empty( $options['uninstall'] ) ) { | |
| 46 | + return; | |
| 47 | + } | |
| 54 | 48 | |
| 55 | 49 | // Suppress data of the old model < 1.2 |
| 56 | 50 | // FIXME: to remove when support for v1.1.6 will be dropped |
| 51 | + global $wpdb; | |
| 57 | 52 | $wpdb->termmeta = $wpdb->prefix . 'termmeta'; // registers the termmeta table in wpdb |
| 58 | 53 | |
| 59 | 54 | // Do nothing if the termmeta table does not exists |
| 60 | 55 | if ( count( $wpdb->get_results( "SHOW TABLES LIKE '$wpdb->termmeta'" ) ) ) { |
| @@ -74,9 +69,9 @@ | ||
| 74 | 69 | |
| 75 | 70 | // Delete users options |
| 76 | 71 | foreach ( get_users( array( 'fields' => 'ID' ) ) as $user_id ) { |
| 77 | 72 | delete_user_meta( $user_id, 'pll_filter_content' ); |
| 78 | - delete_user_meta( $user_id, 'pll_dismissed_notices' ); // Legacy meta. | |
| 73 | + delete_user_meta( $user_id, 'pll_duplicate_content' ); | |
| 79 | 74 | foreach ( $languages as $lang ) { |
| 80 | 75 | delete_user_meta( $user_id, 'description_' . $lang->slug ); |
| 81 | 76 | } |
| 82 | 77 | } |
| @@ -117,11 +112,8 @@ | ||
| 117 | 112 | wp_delete_post( $id, true ); |
| 118 | 113 | } |
| 119 | 114 | |
| 120 | 115 | // Delete all what is related to languages and translations |
| 121 | - $term_ids = array(); | |
| 122 | - $tt_ids = array(); | |
| 123 | - | |
| 124 | 116 | foreach ( get_terms( $pll_taxonomies, array( 'hide_empty' => false ) ) as $term ) { |
| 125 | 117 | $term_ids[] = (int) $term->term_id; |
| 126 | 118 | $tt_ids[] = (int) $term->term_taxonomy_id; |
| 127 | 119 | } |
| @@ -141,13 +133,13 @@ | ||
| 141 | 133 | delete_option( 'polylang' ); |
| 142 | 134 | delete_option( 'widget_polylang' ); // Automatically created by WP |
| 143 | 135 | delete_option( 'polylang_wpml_strings' ); // Strings registered with icl_register_string |
| 144 | 136 | delete_option( 'polylang_licenses' ); |
| 145 | - delete_option( 'pll_dismissed_notices' ); | |
| 146 | 137 | |
| 147 | 138 | // Delete transients |
| 148 | 139 | delete_transient( 'pll_languages_list' ); |
| 149 | 140 | delete_transient( 'pll_upgrade_1_4' ); |
| 141 | + delete_transient( 'pll_translated_slugs' ); | |
| 150 | 142 | } |
| 151 | 143 | } |
| 152 | 144 | |
| 153 | 145 | new PLL_Uninstall(); |