PluginProbe
Polylang / 2.6.2
Polylang v2.6.2
3.8.9 3.8.8 3.8.7 3.8.6 3.8.5 3.8.4 3.8.3 2.7 2.7.0.1 2.7.1 2.7.2 2.7.3 2.7.4 2.8 2.8.1 2.8.2 2.8.3 2.8.4 2.9 2.9.1 2.9.2 3.0 3.0.1 3.0.2 3.0.3 All 233 releases
← All changes | uninstall.php +19 -15 2.82.6.2 View file →
@@ -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,11 +39,28 @@
47 39 *
48 40 * @since 0.5
49 41 */
50 42 public function uninstall() {
43 + $options = get_option( 'polylang' );
44 +
45 + if ( empty( $options['uninstall'] ) ) {
46 + return;
47 + }
48 +
51 49 global $wpdb;
52 50
53 - do_action( 'pll_uninstall' );
51 + // Executes each module's uninstall script, if it exists
52 + $pll_modules_dir = dirname( __FILE__ ) . '/modules';
53 + opendir( $pll_modules_dir );
54 + while ( ( $module = readdir() ) != false ) {
55 + if ( substr( $module, 0, 1 ) !== '.' ) {
56 + $uninstall_script = $pll_modules_dir . '/' . $module . '/uninstall.php';
57 + if ( file_exists( $uninstall_script ) ) {
58 + require $uninstall_script;
59 + }
60 + }
61 + }
62 + closedir();
54 63
55 64 // Suppress data of the old model < 1.2
56 65 // FIXME: to remove when support for v1.1.6 will be dropped
57 66 $wpdb->termmeta = $wpdb->prefix . 'termmeta'; // registers the termmeta table in wpdb
@@ -74,9 +83,8 @@
74 83
75 84 // Delete users options
76 85 foreach ( get_users( array( 'fields' => 'ID' ) ) as $user_id ) {
77 86 delete_user_meta( $user_id, 'pll_filter_content' );
78 - delete_user_meta( $user_id, 'pll_dismissed_notices' ); // Legacy meta.
79 87 foreach ( $languages as $lang ) {
80 88 delete_user_meta( $user_id, 'description_' . $lang->slug );
81 89 }
82 90 }
@@ -117,11 +125,8 @@
117 125 wp_delete_post( $id, true );
118 126 }
119 127
120 128 // Delete all what is related to languages and translations
121 - $term_ids = array();
122 - $tt_ids = array();
123 -
124 129 foreach ( get_terms( $pll_taxonomies, array( 'hide_empty' => false ) ) as $term ) {
125 130 $term_ids[] = (int) $term->term_id;
126 131 $tt_ids[] = (int) $term->term_taxonomy_id;
127 132 }
@@ -141,9 +146,8 @@
141 146 delete_option( 'polylang' );
142 147 delete_option( 'widget_polylang' ); // Automatically created by WP
143 148 delete_option( 'polylang_wpml_strings' ); // Strings registered with icl_register_string
144 149 delete_option( 'polylang_licenses' );
145 - delete_option( 'pll_dismissed_notices' );
146 150
147 151 // Delete transients
148 152 delete_transient( 'pll_languages_list' );
149 153 delete_transient( 'pll_upgrade_1_4' );