PluginProbe
Polylang / 3.6.7
Polylang v3.6.7
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 +12 -29 2.93.6.7 View file →
@@ -22,9 +22,9 @@
22 22 */
23 23 public function __construct() {
24 24 global $wpdb;
25 25
26 - // Don't do anything except if the constant PLL_REMOVE_ALL_DATA is explicitely defined and true.
26 + // Don't do anything except if the constant PLL_REMOVE_ALL_DATA is explicitly defined and true.
27 27 if ( ! defined( 'PLL_REMOVE_ALL_DATA' ) || ! PLL_REMOVE_ALL_DATA ) {
28 28 return;
29 29 }
30 30
@@ -51,20 +51,8 @@
51 51 global $wpdb;
52 52
53 53 do_action( 'pll_uninstall' );
54 54
55 - // Suppress data of the old model < 1.2
56 - // FIXME: to remove when support for v1.1.6 will be dropped
57 - $wpdb->termmeta = $wpdb->prefix . 'termmeta'; // registers the termmeta table in wpdb
58 -
59 - // Do nothing if the termmeta table does not exists
60 - if ( count( $wpdb->get_results( "SHOW TABLES LIKE '$wpdb->termmeta'" ) ) ) {
61 - $wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_key = '_translations'" );
62 - $wpdb->query( "DELETE FROM $wpdb->termmeta WHERE meta_key = '_language'" );
63 - $wpdb->query( "DELETE FROM $wpdb->termmeta WHERE meta_key = '_rtl'" );
64 - $wpdb->query( "DELETE FROM $wpdb->termmeta WHERE meta_key = '_translations'" );
65 - }
66 -
67 55 // Need to register the taxonomies
68 56 $pll_taxonomies = array( 'language', 'term_language', 'post_translations', 'term_translations' );
69 57 foreach ( $pll_taxonomies as $taxonomy ) {
70 58 register_taxonomy( $taxonomy, null, array( 'label' => false, 'public' => false, 'query_var' => false, 'rewrite' => false ) );
@@ -69,17 +57,15 @@
69 57 foreach ( $pll_taxonomies as $taxonomy ) {
70 58 register_taxonomy( $taxonomy, null, array( 'label' => false, 'public' => false, 'query_var' => false, 'rewrite' => false ) );
71 59 }
72 60
73 - $languages = get_terms( 'language', array( 'hide_empty' => false ) );
61 + $languages = get_terms( array( 'taxonomy' => 'language', 'hide_empty' => false ) );
74 62
75 63 // Delete users options
76 - foreach ( get_users( array( 'fields' => 'ID' ) ) as $user_id ) {
77 - delete_user_meta( $user_id, 'pll_filter_content' );
78 - delete_user_meta( $user_id, 'pll_dismissed_notices' ); // Legacy meta.
79 - foreach ( $languages as $lang ) {
80 - delete_user_meta( $user_id, 'description_' . $lang->slug );
81 - }
64 + delete_metadata( 'user', 0, 'pll_filter_content', '', true );
65 + delete_metadata( 'user', 0, 'pll_dismissed_notices', '', true ); // Legacy meta.
66 + foreach ( $languages as $lang ) {
67 + delete_metadata( 'user', 0, "description_{$lang->slug}", '', true );
82 68 }
83 69
84 70 // Delete menu language switchers
85 71 $ids = get_posts(
@@ -95,15 +81,12 @@
95 81 foreach ( $ids as $id ) {
96 82 wp_delete_post( $id, true );
97 83 }
98 84
99 - // Delete the strings translations ( <1.2 )
100 - // FIXME: to remove when support for v1.1.6 will be dropped
101 - foreach ( $languages as $lang ) {
102 - delete_option( 'polylang_mo' . $lang->term_id );
103 - }
104 -
105 - // Delete the strings translations 1.2+
85 + /*
86 + * Backward compatibility with Polylang < 3.4.
87 + * Delete the legacy strings translations.
88 + */
106 89 register_post_type( 'polylang_mo', array( 'rewrite' => false, 'query_var' => false ) );
107 90 $ids = get_posts(
108 91 array(
109 92 'post_type' => 'polylang_mo',
@@ -120,9 +103,9 @@
120 103 // Delete all what is related to languages and translations
121 104 $term_ids = array();
122 105 $tt_ids = array();
123 106
124 - foreach ( get_terms( $pll_taxonomies, array( 'hide_empty' => false ) ) as $term ) {
107 + foreach ( get_terms( array( 'taxonomy' => $pll_taxonomies, 'hide_empty' => false ) ) as $term ) {
125 108 $term_ids[] = (int) $term->term_id;
126 109 $tt_ids[] = (int) $term->term_taxonomy_id;
127 110 }
128 111
@@ -129,8 +112,9 @@
129 112 if ( ! empty( $term_ids ) ) {
130 113 $term_ids = array_unique( $term_ids );
131 114 $wpdb->query( "DELETE FROM {$wpdb->terms} WHERE term_id IN ( " . implode( ',', $term_ids ) . ' )' ); // PHPCS:ignore WordPress.DB.PreparedSQL.NotPrepared
132 115 $wpdb->query( "DELETE FROM {$wpdb->term_taxonomy} WHERE term_id IN ( " . implode( ',', $term_ids ) . ' )' ); // PHPCS:ignore WordPress.DB.PreparedSQL.NotPrepared
116 + $wpdb->query( "DELETE FROM {$wpdb->termmeta} WHERE term_id IN ( " . implode( ',', $term_ids ) . " ) AND meta_key='_pll_strings_translations'" ); // PHPCS:ignore WordPress.DB.PreparedSQL.NotPrepared
133 117 }
134 118
135 119 if ( ! empty( $tt_ids ) ) {
136 120 $tt_ids = array_unique( $tt_ids );
@@ -145,9 +129,8 @@
145 129 delete_option( 'pll_dismissed_notices' );
146 130
147 131 // Delete transients
148 132 delete_transient( 'pll_languages_list' );
149 - delete_transient( 'pll_upgrade_1_4' );
150 133 }
151 134 }
152 135
153 136 new PLL_Uninstall();