PluginProbe ʕ •ᴥ•ʔ
SEOPress – AI SEO Plugin & On-site SEO / 9.9.2
SEOPress – AI SEO Plugin & On-site SEO v9.9.2
9.9.2 9.9.1 9.9 9.8.5 9.8.4 9.8.3 9.8.2 9.8.1 trunk 7.0 7.0.1 7.0.2 7.0.3 7.1 7.1.1 7.1.2 7.2 7.3 7.3.1 7.3.2 7.4 7.5 7.5.0.1 7.5.0.2 7.5.0.3 7.5.1 7.5.2 7.5.2.1 7.6 7.6.1 7.7 7.7.1 7.7.2 7.8 7.9 7.9.1 7.9.2 8.0 8.0.1 8.1 8.1.1 8.2 8.3 8.3.1 8.4 8.4.1 8.5 8.5.0.2 8.5.1 8.5.1.1 8.6 8.6.1 8.7 8.7.0.1 8.7.0.2 8.8 8.8.1 8.9 8.9.0.1 8.9.0.2 9.0 9.0.1 9.1 9.2 9.3 9.3.0.1 9.3.0.2 9.3.0.3 9.3.0.4 9.4 9.4.1 9.5 9.6 9.7 9.7.1 9.7.2 9.7.3 9.7.4 9.8
wp-seopress / uninstall.php
wp-seopress Last commit date
assets 1 day ago inc 1 day ago languages 1 day ago public 1 day ago src 1 day ago templates 1 day ago vendor 1 day ago contributors.txt 6 months ago readme.txt 1 day ago seopress-autoload.php 7 months ago seopress-functions.php 1 day ago seopress.php 1 day ago uninstall.php 7 months ago wpml-config.xml 1 day ago
uninstall.php
140 lines
1 <?php
2 /**
3 * Uninstall SEOPress
4 *
5 * @package Uninstall
6 */
7
8 defined( 'ABSPATH' ) || exit( 'Please don&rsquo;t call the plugin directly. Thanks :)' );
9
10 /**
11 * Uninstall SEOPress
12 *
13 * @since 6.2
14 *
15 * @author Benjamin, inspired by Polylang
16 */
17
18 if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { // If uninstall not called from WordPress exit.
19 exit;
20 }
21
22 /**
23 * SEOPRESS_Uninstall
24 */
25 class SEOPRESS_Uninstall {
26
27 /**
28 * Constructor: manages uninstall for multisite
29 *
30 * @since 6.2
31 */
32 public function __construct() {
33 global $wpdb;
34
35 // Don't do anything except if the constant SEOPRESS_UNINSTALL is explicitely defined and true.
36 if ( ! defined( 'SEOPRESS_UNINSTALL' ) || ! SEOPRESS_UNINSTALL ) {
37 return;
38 }
39
40 // Check if it is a multisite uninstall - if so, run the uninstall function for each blog id.
41 if ( is_multisite() ) {
42 foreach ( $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" ) as $blog_id ) {
43 switch_to_blog( $blog_id );
44 $this->uninstall();
45 }
46 restore_current_blog();
47 } else {
48 $this->uninstall();
49 }
50 }
51
52 /**
53 * Delete all entries in the DB related to SEOPress Free AND PRO:
54 * Transients, post meta, options, custom tables
55 *
56 * @since 6.2
57 * @updated 7.4
58 */
59 public function uninstall() {
60 global $wpdb;
61
62 do_action( 'seopress_uninstall' );
63
64 // Delete post meta.
65 //phpcs:ignore
66 $wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_key LIKE '_seopress_%'" );
67
68 // Delete redirections / 404 errors.
69 $sql = 'DELETE `posts`, `pm`
70 FROM `' . $wpdb->prefix . 'posts` AS `posts`
71 LEFT JOIN `' . $wpdb->prefix . 'postmeta` AS `pm` ON `pm`.`post_id` = `posts`.`ID`
72 WHERE `posts`.`post_type` = \'seopress_404\'';
73
74 //phpcs:ignore
75 $sql = $wpdb->prepare( $sql );
76 //phpcs:ignore
77 $wpdb->query( $sql );
78
79 // Delete schemas.
80 $sql = 'DELETE `posts`, `pm`
81 FROM `' . $wpdb->prefix . 'posts` AS `posts`
82 LEFT JOIN `' . $wpdb->prefix . 'postmeta` AS `pm` ON `pm`.`post_id` = `posts`.`ID`
83 WHERE `posts`.`post_type` = \'seopress_schemas\'';
84
85 //phpcs:ignore
86 $sql = $wpdb->prepare( $sql );
87 //phpcs:ignore
88 $wpdb->query( $sql );
89
90 // Delete broken links.
91 $sql = 'DELETE `posts`, `pm`
92 FROM `' . $wpdb->prefix . 'posts` AS `posts`
93 LEFT JOIN `' . $wpdb->prefix . 'postmeta` AS `pm` ON `pm`.`post_id` = `posts`.`ID`
94 WHERE `posts`.`post_type` = \'seopress_bot\'';
95
96 //phpcs:ignore
97 $sql = $wpdb->prepare( $sql );
98 //phpcs:ignore
99 $wpdb->query( $sql );
100
101 // Delete global settings.
102 //phpcs:ignore
103 $options = $wpdb->get_col( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE 'seopress_%'" );
104 array_map( 'delete_option', $options );
105
106 // Delete widget options.
107 //phpcs:ignore
108 $options = $wpdb->get_col( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE 'widget_seopress_%'" );
109 array_map( 'delete_option', $options );
110
111 // Delete transients.
112 delete_transient( '_seopress_sitemap_ids_video' );
113 delete_transient( 'seopress_results_page_speed' );
114 delete_transient( 'seopress_results_page_speed_desktop' );
115 delete_transient( 'seopress_results_google_analytics' );
116 delete_transient( 'seopress_results_matomo' );
117 delete_transient( 'seopress_prevent_title_redirection_already_exist' );
118
119 // Delete custom tables.
120 //phpcs:ignore
121 $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}seopress_significant_keywords" );
122 //phpcs:ignore
123 $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}seopress_content_analysis" );
124 //phpcs:ignore
125 $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}seopress_seo_issues" );
126
127 // Clear CRON.
128 wp_clear_scheduled_hook( 'seopress_xml_sitemaps_ping_cron' );
129 wp_clear_scheduled_hook( 'seopress_404_cron_cleaning' );
130 wp_clear_scheduled_hook( 'seopress_google_analytics_cron' );
131 wp_clear_scheduled_hook( 'seopress_page_speed_insights_cron' );
132 wp_clear_scheduled_hook( 'seopress_404_email_alerts_cron' );
133 wp_clear_scheduled_hook( 'seopress_insights_gsc_cron' );
134 wp_clear_scheduled_hook( 'seopress_matomo_analytics_cron' );
135 wp_clear_scheduled_hook( 'seopress_alerts_cron' );
136 }
137 }
138
139 new SEOPRESS_Uninstall();
140