-
Notifications
You must be signed in to change notification settings - Fork 9
/
uninstall.php
87 lines (77 loc) · 1.86 KB
/
uninstall.php
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
if ( !defined( 'WP_UNINSTALL_PLUGIN' ) ) {
exit;
}
new Structuring_Markup_Uninstall();
/**
* Schema.org Plugin Uninstall
*
* @author Kazuya Takami
* @version 4.5.0
* @since 1.0.0
*/
class Structuring_Markup_Uninstall {
/**
* Variable definition.
*
* @version 4.5.0
* @since 2.1.0
*/
private $text_domain = 'wp-structuring-markup';
private $custom_type_event = 'schema_event_post';
private $custom_type_video = 'schema_video_post';
/**
* Constructor Define.
*
* @version 4.5.0
* @since 1.0.0
*/
public function __construct () {
$this->drop_table( 'structuring_markup' );
$this->delete_custom_post( $this->custom_type_event );
$this->delete_post_meta( $this->custom_type_event );
$this->delete_custom_post( $this->custom_type_video );
$this->delete_post_meta( $this->custom_type_video );
delete_option( $this->text_domain );
}
/**
* Drop Table.
*
* @version 2.1.0
* @since 1.0.0
* @param string $table_name
*/
private function drop_table ( $table_name = null ) {
global $wpdb;
$table_name = $wpdb->prefix . $table_name;
$wpdb->query( "DROP TABLE IF EXISTS " . $table_name );
}
/**
* Delete custom post.
*
* @version 2.1.0
* @since 2.1.0
* @param string $custom_type
*/
private function delete_custom_post ( $custom_type = null ) {
global $wpdb;
$table_name = $wpdb->prefix . "posts";
$key = array( 'post_type' => $custom_type );
$key_prepared = array( '%s' );
$wpdb->delete( $table_name, $key, $key_prepared );
}
/**
* Delete post meta.
*
* @version 2.1.0
* @since 2.1.0
* @param string $custom_type
*/
private function delete_post_meta ( $custom_type = null ) {
global $wpdb;
$table_name = $wpdb->prefix . "postmeta";
$key = array( 'meta_key' => $custom_type );
$key_prepared = array( '%s' );
$wpdb->delete( $table_name, $key, $key_prepared );
}
}