PluginProbe ʕ •ᴥ•ʔ
Reviews Feed – Add Testimonials and Customer Reviews From Google Reviews, Yelp, TripAdvisor, and More / 2.11.0
Reviews Feed – Add Testimonials and Customer Reviews From Google Reviews, Yelp, TripAdvisor, and More v2.11.0
2.11.0 2.10.0 2.9.0 2.8.0 2.7.0 2.6.7 2.6.8 2.6.5 2.6.4 2.6.3 2.6.2 2.6.0 2.5.5 2.5.4 2.5.3 2.5.2 trunk 1.0 1.0.1 1.0.2 1.0.3 1.1 1.1.1 1.1.2 1.2.0 2.0 2.1.0 2.1.1 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.5.0 2.5.1
reviews-feed / uninstall.php
reviews-feed Last commit date
assets 6 days ago class 6 days ago config 6 days ago languages 6 days ago public 6 days ago templates 6 days ago tests 6 days ago vendor 6 days ago bootstrap.php 6 days ago crowdin.yml 6 days ago gpl-2.0.txt 6 days ago readme.txt 6 days ago sb-reviews.php 6 days ago uninstall.php 6 days ago
uninstall.php
94 lines
1 <?php
2
3 if (!defined('ABSPATH')) {
4 exit; // Exit if accessed directly
5 }
6 if (! defined('WP_UNINSTALL_PLUGIN')) {
7 exit();
8 }
9
10
11 $settings = get_option('sbr_settings', array());
12 if (! is_array($settings)) {
13 $settings = array();
14 }
15
16 $preserve_settings = ! empty($settings['preserve_settings']) && $settings['preserve_settings'];
17
18 // Cron events are cleared unconditionally: they are runtime state, not
19 // settings, and leaving them scheduled after deletion fires handler-less
20 // events weekly forever.
21 $cron_keys = array(
22 'sbr_cron_additional_batch',
23 'sbr_feed_update',
24 'sbr_usage_tracking_cron',
25 'sbr_smash_usage_tracking_cron',
26 );
27 foreach ($cron_keys as $key) {
28 wp_clear_scheduled_hook($key);
29 }
30
31 if (! $preserve_settings) {
32 // wp_options
33 $wp_options_keys = array(
34 'sbr_apikeys',
35 'sbr_apikeys_limit',
36 'sbr_business_cache',
37 'sbr_db_version',
38 'sbr_settings',
39 'sbr_statuses',
40 'sbr_usage_tracking_config',
41 'sbr_smash_usage_tracking',
42 'sbr_smash_usage_tracking_site_token',
43 'sbr_smash_usage_tracking_schedule',
44 'sbr_smash_usage_events',
45 'sbr_smash_usage_active_dates',
46 'sbr_smash_usage_session_durations',
47 );
48 foreach ($wp_options_keys as $key) {
49 delete_option($key);
50 }
51
52 // user roles
53 global $wp_roles;
54 $wp_roles->remove_cap('administrator', 'manage_reviews_feed_options');
55
56 // custom tables
57 global $wpdb;
58
59 $table_keys = array(
60 'sbr_feeds',
61 'sbr_feed_caches',
62 'sbr_feed_locator',
63 'sbr_posts',
64 'sbr_reviews_posts',
65 'sbr_sources',
66 );
67 foreach ($table_keys as $key) {
68 $table_name = $wpdb->prefix . $key;
69 // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Table name is safely constructed from $wpdb->prefix
70 $wpdb->query("DROP TABLE IF EXISTS $table_name");
71 }
72
73 // custom image files
74 $upload = wp_upload_dir();
75 $folder = trailingslashit($upload['basedir']) . trailingslashit('sbr-feed-images');
76 $image_files = glob($folder . '*'); // get all file names
77 foreach ((array) $image_files as $file) { // iterate files (glob can return false)
78 if (is_file($file)) {
79 unlink($file);
80 }
81 }
82
83 // $wp_filesystem is not initialised during plugin deletion — calling
84 // ->delete() on null fatals and aborts the uninstall midway.
85 global $wp_filesystem;
86 if (! $wp_filesystem && function_exists('WP_Filesystem')) {
87 require_once ABSPATH . 'wp-admin/includes/file.php';
88 WP_Filesystem();
89 }
90 if ($wp_filesystem) {
91 $wp_filesystem->delete($folder, true);
92 }
93 }
94