PluginProbe
Polylang / 0.4.4
Polylang v0.4.4
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
polylang / uninstall.php

uninstall.php in Polylang 0.4.4, at uninstall.php

40 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 global $wpdb;
4 $wpdb->termmeta = $wpdb->prefix . 'termmeta'; // registers the termmeta table in wpdb
5 register_taxonomy('language', get_post_types(array('show_ui' => true)), array('label' => false, 'query_var'=>'lang')); // temporarily register the language taxonomy
6
7 $languages = get_terms('language', array('hide_empty'=>false));
8
9 foreach ($languages as $lang) {
10 // delete references to this language in all posts
11 $args = array('numberposts'=> -1, 'post_type'=>'any', 'post_status'=>'any');
12 $posts = get_posts($args);
13 foreach ($posts as $post) {
14 delete_post_meta($post->ID, '_lang-'.$lang->slug);
15 }
16 // delete references to this language in categories & post tags
17 $terms = get_terms(get_taxonomies(array('show_ui'=>true)), 'get=all');
18 foreach ($terms as $term) {
19 delete_metadata('term', $term->term_id, '_language');
20 delete_metadata('term', $term->term_id, '_lang-'.$lang->slug);
21 }
22 // finally delete the language itself
23 wp_delete_term($lang->term_id, 'language');
24 }
25
26 // delete the termmeta table only if it is empty as other plugins may use it
27 $table = $wpdb->termmeta;
28 $count = $wpdb->get_var("SELECT COUNT(*) FROM $table;");
29 if (!$count) {
30 $wpdb->query("DROP TABLE $table;");
31 unset($wpdb->termmeta);
32 }
33
34 // delete options
35 delete_option('polylang');
36 delete_option('polylang_nav_menus');
37 delete_option('polylang_widgets');
38 delete_option('widget_polylang_widget'); // automatically created by WP
39 ?>
40