PluginProbe
WebberZone Top 10 — Popular Posts / 4.5.1
WebberZone Top 10 — Popular Posts v4.5.1
4.5.1 4.5.0 4.4.3 4.4.2 4.4.1 4.4.0 4.3.4 4.3.3 4.3.2 4.3.1 4.3.0 trunk 1.0 1.0.1 1.1 1.2 1.3 1.4 1.4.1 1.5 1.5.1 1.5.2 1.5.3 1.6 1.6.1 All 117 releases
top-10 / uninstaller.php

uninstaller.php in WebberZone Top 10 — Popular Posts 4.5.1, at uninstaller.php

87 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Update counts to database.
4 *
5 * @package Top_Ten
6 */
7
8 defined( 'ABSPATH' ) || exit;
9
10 if ( ! ( defined( 'WP_UNINSTALL_PLUGIN' ) || defined( 'WP_FS__UNINSTALL_MODE' ) ) ) {
11 exit;
12 }
13
14 if ( is_plugin_active( 'top-10-pro/top-10.php' ) ) {
15 return;
16 }
17
18 global $wpdb;
19
20 $tptn_settings = get_option( 'tptn_settings' );
21
22 wp_clear_scheduled_hook( 'tptn_aggregation_cron_hook' );
23
24 if ( ! empty( $tptn_settings['uninstall_clean_tables'] ) ) {
25
26 $table_names = array(
27 $wpdb->base_prefix . 'top_ten',
28 $wpdb->base_prefix . 'top_ten_daily',
29 $wpdb->base_prefix . 'top_ten_visits_log',
30 $wpdb->base_prefix . 'top_ten_visits_funnel',
31 );
32
33 foreach ( $table_names as $table_name ) {
34 // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.DirectQuery
35 $wpdb->query( "DROP TABLE $table_name" );
36 }
37 delete_site_option( 'tptn_db_version' );
38 }
39
40 // Delete data across multisite or single site.
41 if ( is_multisite() ) {
42
43 $sites = get_sites(
44 array(
45 'archived' => 0,
46 'spam' => 0,
47 'deleted' => 0,
48 )
49 );
50
51 foreach ( $sites as $site ) {
52 switch_to_blog( (int) $site->blog_id );
53 tptn_delete_data();
54 restore_current_blog();
55 }
56 } else {
57 tptn_delete_data();
58 }
59
60 /**
61 * Function to delete data when the plugin is uninstalled.
62 *
63 * @since 4.0.0
64 */
65 function tptn_delete_data() {
66 global $wpdb;
67
68 $settings = get_option( 'tptn_settings' );
69
70 if ( $settings['uninstall_clean_options'] ) {
71
72 if ( wp_next_scheduled( 'tptn_cron_hook' ) ) {
73 wp_clear_scheduled_hook( 'tptn_cron_hook' );
74 }
75 delete_option( 'ald_tptn_settings' );
76 delete_option( 'tptn_settings' );
77
78 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.SchemaChange
79 $wpdb->query(
80 "
81 DELETE FROM {$wpdb->options}
82 WHERE option_name LIKE '%tptn%'
83 "
84 );
85 }
86 }
87