PluginProbe ʕ •ᴥ•ʔ
WP Popular Posts / 6.3.2
WP Popular Posts v6.3.2
4.0.8 4.0.9 4.1.0 4.1.1 4.1.2 4.2.0 4.2.1 4.2.2 5.0.0 5.0.1 5.0.2 5.1.0 5.2.0 5.2.1 5.2.2 5.2.3 5.2.4 5.3.0 5.3.1 5.3.2 5.3.3 5.3.4 5.3.5 5.3.6 5.4.0 5.4.1 5.4.2 5.5.0 5.5.1 6.0.0 6.0.1 6.0.2 6.0.3 6.0.4 6.0.5 6.1.0 6.1.1 6.1.2 6.1.3 6.1.4 6.2.0 6.2.1 6.3.0 6.3.1 6.3.2 6.3.3 6.3.4 6.4.0 6.4.1 6.4.2 7.0.0 7.0.1 7.1.0 7.2.0 7.3.0 7.3.1 7.3.2 7.3.3 7.3.4 7.3.5 7.3.6 7.3.7 7.3.8 7.4.0 trunk 2.3.7 3.0.0 3.0.1 3.0.2 3.0.3 3.1.0 3.1.1 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 4.0.0 4.0.1 4.0.10 4.0.11 4.0.12 4.0.13 4.0.2 4.0.3 4.0.5 4.0.6
wordpress-popular-posts / uninstall.php
wordpress-popular-posts Last commit date
assets 2 years ago i18n 2 years ago src 2 years ago vendor 2 years ago LICENSE 2 years ago index.php 2 years ago readme.txt 2 years ago uninstall.php 2 years ago wordpress-popular-posts.php 2 years ago
uninstall.php
85 lines
1 <?php
2 /**
3 * Fired when the plugin is uninstalled.
4 *
5 * @package WordpressPopularPosts
6 * @author Hector Cabrera <me@cabrerahector.com>
7 * @license GPL-2.0+
8 * @link https://cabrerahector.com
9 * @copyright 2008-2022 Hector Cabrera
10 */
11
12 // If uninstall is not called from WordPress, exit
13 if ( ! defined('WP_UNINSTALL_PLUGIN') ) {
14 exit;
15 }
16
17 // Run uninstall for each blog in the network
18 if (
19 function_exists('is_multisite')
20 && is_multisite()
21 ) {
22 global $wpdb;
23
24 $original_blog_id = get_current_blog_id();
25 $blogs_ids = $wpdb->get_col("SELECT blog_id FROM {$wpdb->blogs}");
26
27 foreach( $blogs_ids as $b_id ) {
28 switch_to_blog($b_id);
29 // delete tables and options
30 wordpress_popular_posts_uninstall();
31 // delete thumbnails cache and its directory
32 wordpress_popular_posts_delete_thumb_cache();
33 }
34
35 // Switch back to current blog
36 switch_to_blog($original_blog_id);
37 } else {
38 // delete tables and options
39 wordpress_popular_posts_uninstall();
40 // delete thumbnails cache and its directory
41 wordpress_popular_posts_delete_thumb_cache();
42 }
43
44 function wordpress_popular_posts_delete_thumb_cache() {
45 $wp_upload_dir = wp_get_upload_dir();
46
47 if ( is_dir($wp_upload_dir['basedir'] . '/wordpress-popular-posts') ) {
48 $files = glob($wp_upload_dir['basedir'] . '/wordpress-popular-posts/*'); // get all file names
49
50 if ( is_array($files) && ! empty($files) ) {
51 foreach( $files as $file ){ // iterate files
52 if ( is_file($file) ) {
53 @unlink($file); // delete file
54 }
55 }
56 }
57
58 // Finally, delete WPP's upload directory
59 @rmdir($wp_upload_dir['basedir'] . '/wordpress-popular-posts');
60 }
61 }
62
63 function wordpress_popular_posts_uninstall() {
64 global $wpdb;
65
66 // Delete plugin's options
67 delete_option('wpp_ver');
68 delete_option('wpp_update');
69 delete_option('wpp_settings_config');
70 delete_option('wpp_rand');
71 delete_option('wpp_transients');
72 delete_option('wpp_performance_nag');
73
74 // Delete WPP's DB tables
75 $prefix = $wpdb->prefix . 'popularposts';
76 //phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared
77 $wpdb->query("DROP TABLE IF EXISTS {$prefix}data;");
78 $wpdb->query("DROP TABLE IF EXISTS {$prefix}datacache;");
79 $wpdb->query("DROP TABLE IF EXISTS {$prefix}datacache_backup;");
80 $wpdb->query("DROP TABLE IF EXISTS {$prefix}log;");
81 $wpdb->query("DROP TABLE IF EXISTS {$prefix}summary;");
82 $wpdb->query("DROP TABLE IF EXISTS {$prefix}transients;");
83 //phpcs:enable
84 }
85