-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuninstall.php
More file actions
52 lines (43 loc) · 2.18 KB
/
Copy pathuninstall.php
File metadata and controls
52 lines (43 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
/**
* PerryLabs SEO + AEO — Uninstall
*
* Removes all plugin data from the database on uninstall.
* Deletes plugin options and all per-post SEO meta fields.
*
* @package PerryLabs_SEO
*/
// Abort if not called by WordPress uninstall process.
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
exit;
}
/* ──────────────────────────────────────────────────────────────────────
* Delete plugin options
* ────────────────────────────────────────────────────────────────────── */
delete_option( 'perrylabs_seo_options' );
delete_transient( 'perrylabs_seo_robots_txt' );
/* ──────────────────────────────────────────────────────────────────────
* Delete all per-post SEO meta fields
* ────────────────────────────────────────────────────────────────────── */
global $wpdb;
$meta_keys = array(
'_perrylabs_seo_title',
'_perrylabs_seo_description',
'_perrylabs_seo_canonical',
'_perrylabs_seo_noindex',
'_perrylabs_seo_nofollow',
'_perrylabs_seo_social_image',
'_perrylabs_seo_schema_type',
'_perrylabs_seo_alternate_urls',
);
foreach ( $meta_keys as $key ) {
$wpdb->delete(
$wpdb->postmeta,
array( 'meta_key' => $key ),
array( '%s' )
);
}
/* ──────────────────────────────────────────────────────────────────────
* Flush rewrite rules to clean up sitemap endpoints
* ────────────────────────────────────────────────────────────────────── */
flush_rewrite_rules();