PluginProbe
Polylang / 2.7.3
Polylang v2.7.3
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 +32 -5 3.02.7.3 View file →
@@ -1,8 +1,5 @@
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 4 exit;
8 5 }
@@ -49,10 +46,33 @@
49 46 */
50 47 public function uninstall() {
51 48 global $wpdb;
52 49
53 - do_action( 'pll_uninstall' );
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 + }
60 + }
61 + closedir();
54 62
63 + // Suppress data of the old model < 1.2
64 + // FIXME: to remove when support for v1.1.6 will be dropped
65 + $wpdb->termmeta = $wpdb->prefix . 'termmeta'; // registers the termmeta table in wpdb
66 +
67 + // Do nothing if the termmeta table does not exists
68 + if ( count( $wpdb->get_results( "SHOW TABLES LIKE '$wpdb->termmeta'" ) ) ) {
69 + $wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_key = '_translations'" );
70 + $wpdb->query( "DELETE FROM $wpdb->termmeta WHERE meta_key = '_language'" );
71 + $wpdb->query( "DELETE FROM $wpdb->termmeta WHERE meta_key = '_rtl'" );
72 + $wpdb->query( "DELETE FROM $wpdb->termmeta WHERE meta_key = '_translations'" );
73 + }
74 +
55 75 // Need to register the taxonomies
56 76 $pll_taxonomies = array( 'language', 'term_language', 'post_translations', 'term_translations' );
57 77 foreach ( $pll_taxonomies as $taxonomy ) {
58 78 register_taxonomy( $taxonomy, null, array( 'label' => false, 'public' => false, 'query_var' => false, 'rewrite' => false ) );
@@ -83,9 +103,15 @@
83 103 foreach ( $ids as $id ) {
84 104 wp_delete_post( $id, true );
85 105 }
86 106
87 - // Delete the strings translations.
107 + // Delete the strings translations ( <1.2 )
108 + // FIXME: to remove when support for v1.1.6 will be dropped
109 + foreach ( $languages as $lang ) {
110 + delete_option( 'polylang_mo' . $lang->term_id );
111 + }
112 +
113 + // Delete the strings translations 1.2+
88 114 register_post_type( 'polylang_mo', array( 'rewrite' => false, 'query_var' => false ) );
89 115 $ids = get_posts(
90 116 array(
91 117 'post_type' => 'polylang_mo',
@@ -127,8 +153,9 @@
127 153 delete_option( 'pll_dismissed_notices' );
128 154
129 155 // Delete transients
130 156 delete_transient( 'pll_languages_list' );
157 + delete_transient( 'pll_upgrade_1_4' );
131 158 }
132 159 }
133 160
134 161 new PLL_Uninstall();