PluginProbe
Polylang / 2.3.6
Polylang v2.3.6
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 +26 -46 2.72.3.6 View file →
@@ -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
@@ -16,16 +16,11 @@
16 16 * Constructor: manages uninstall for multisite
17 17 *
18 18 * @since 0.5
19 19 */
20 - public function __construct() {
20 + 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 );
@@ -43,26 +38,18 @@
43 38 * only when the relevant option is active
44 39 *
45 40 * @since 0.5
46 41 */
47 - public function uninstall() {
48 - global $wpdb;
42 + function uninstall() {
43 + $options = get_option( 'polylang' );
49 44
50 - // Executes each module's uninstall script, if it exists
51 - $pll_modules_dir = dirname( __FILE__ ) . '/modules';
52 - opendir( $pll_modules_dir );
53 - while ( ( $module = readdir() ) != false ) {
54 - if ( substr( $module, 0, 1 ) !== '.' ) {
55 - $uninstall_script = $pll_modules_dir . '/' . $module . '/uninstall.php';
56 - if ( file_exists( $uninstall_script ) ) {
57 - require $uninstall_script; // phpcs:ignore WordPressVIPMinimum.Files.IncludingFile.UsingVariable
58 - }
59 - }
45 + if ( empty( $options['uninstall'] ) ) {
46 + return;
60 47 }
61 - closedir();
62 48
63 49 // Suppress data of the old model < 1.2
64 50 // FIXME: to remove when support for v1.1.6 will be dropped
51 + global $wpdb;
65 52 $wpdb->termmeta = $wpdb->prefix . 'termmeta'; // registers the termmeta table in wpdb
66 53
67 54 // Do nothing if the termmeta table does not exists
68 55 if ( count( $wpdb->get_results( "SHOW TABLES LIKE '$wpdb->termmeta'" ) ) ) {
@@ -82,9 +69,9 @@
82 69
83 70 // Delete users options
84 71 foreach ( get_users( array( 'fields' => 'ID' ) ) as $user_id ) {
85 72 delete_user_meta( $user_id, 'pll_filter_content' );
86 - delete_user_meta( $user_id, 'pll_dismissed_notices' ); // Legacy meta.
73 + delete_user_meta( $user_id, 'pll_duplicate_content' );
87 74 foreach ( $languages as $lang ) {
88 75 delete_user_meta( $user_id, 'description_' . $lang->slug );
89 76 }
90 77 }
@@ -89,17 +76,15 @@
89 76 }
90 77 }
91 78
92 79 // Delete menu language switchers
93 - $ids = get_posts(
94 - array(
95 - 'post_type' => 'nav_menu_item',
96 - 'numberposts' => -1,
97 - 'nopaging' => true,
98 - 'fields' => 'ids',
99 - 'meta_key' => '_pll_menu_item',
100 - )
101 - );
80 + $ids = get_posts( array(
81 + 'post_type' => 'nav_menu_item',
82 + 'numberposts' => -1,
83 + 'nopaging' => true,
84 + 'fields' => 'ids',
85 + 'meta_key' => '_pll_menu_item',
86 + ) );
102 87
103 88 foreach ( $ids as $id ) {
104 89 wp_delete_post( $id, true );
105 90 }
@@ -111,25 +96,20 @@
111 96 }
112 97
113 98 // Delete the strings translations 1.2+
114 99 register_post_type( 'polylang_mo', array( 'rewrite' => false, 'query_var' => false ) );
115 - $ids = get_posts(
116 - array(
117 - 'post_type' => 'polylang_mo',
118 - 'post_status' => 'any',
119 - 'numberposts' => -1,
120 - 'nopaging' => true,
121 - 'fields' => 'ids',
122 - )
123 - );
100 + $ids = get_posts( array(
101 + 'post_type' => 'polylang_mo',
102 + 'post_status' => 'any',
103 + 'numberposts' => -1,
104 + 'nopaging' => true,
105 + 'fields' => 'ids',
106 + ) );
124 107 foreach ( $ids as $id ) {
125 108 wp_delete_post( $id, true );
126 109 }
127 110
128 111 // Delete all what is related to languages and translations
129 - $term_ids = array();
130 - $tt_ids = array();
131 -
132 112 foreach ( get_terms( $pll_taxonomies, array( 'hide_empty' => false ) ) as $term ) {
133 113 $term_ids[] = (int) $term->term_id;
134 114 $tt_ids[] = (int) $term->term_taxonomy_id;
135 115 }
@@ -135,15 +115,15 @@
135 115 }
136 116
137 117 if ( ! empty( $term_ids ) ) {
138 118 $term_ids = array_unique( $term_ids );
139 - $wpdb->query( "DELETE FROM {$wpdb->terms} WHERE term_id IN ( " . implode( ',', $term_ids ) . ' )' ); // PHPCS:ignore WordPress.DB.PreparedSQL.NotPrepared
140 - $wpdb->query( "DELETE FROM {$wpdb->term_taxonomy} WHERE term_id IN ( " . implode( ',', $term_ids ) . ' )' ); // PHPCS:ignore WordPress.DB.PreparedSQL.NotPrepared
119 + $wpdb->query( "DELETE FROM $wpdb->terms WHERE term_id IN ( " . implode( ',', $term_ids ) . ' )' );
120 + $wpdb->query( "DELETE FROM $wpdb->term_taxonomy WHERE term_id IN ( " . implode( ',', $term_ids ) . ' )' );
141 121 }
142 122
143 123 if ( ! empty( $tt_ids ) ) {
144 124 $tt_ids = array_unique( $tt_ids );
145 - $wpdb->query( "DELETE FROM {$wpdb->term_relationships} WHERE term_taxonomy_id IN ( " . implode( ',', $tt_ids ) . ' )' ); // PHPCS:ignore WordPress.DB.PreparedSQL.NotPrepared
125 + $wpdb->query( "DELETE FROM $wpdb->term_relationships WHERE term_taxonomy_id IN ( " . implode( ',', $tt_ids ) . ' )' );
146 126 }
147 127
148 128 // Delete options
149 129 delete_option( 'polylang' );
@@ -149,13 +129,13 @@
149 129 delete_option( 'polylang' );
150 130 delete_option( 'widget_polylang' ); // Automatically created by WP
151 131 delete_option( 'polylang_wpml_strings' ); // Strings registered with icl_register_string
152 132 delete_option( 'polylang_licenses' );
153 - delete_option( 'pll_dismissed_notices' );
154 133
155 134 // Delete transients
156 135 delete_transient( 'pll_languages_list' );
157 136 delete_transient( 'pll_upgrade_1_4' );
137 + delete_transient( 'pll_translated_slugs' );
158 138 }
159 139 }
160 140
161 141 new PLL_Uninstall();