-
Notifications
You must be signed in to change notification settings - Fork 5
/
uninstall.php
131 lines (106 loc) · 3.34 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<?php
/**
* Uninstall Arabic Webfonts
*
* This file runs when the plugin in uninstalled (deleted).
* This will not run when the plugin is deactivated.
*
* @since 1.0
*
* @package Arabic_Webfonts
*/
// If plugin is not being uninstalled, exit (do nothing)
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
exit;
}
// Do actions here if plugin is being uninstalled.
/**
* The uninstalling process.
*
* @since 1.0
*/
function awf_uninstall_arabic_webfonts_plugin() {
if ( function_exists( 'is_multisite' ) && is_multisite() ) {
// check permission
if ( false == is_super_admin() ) {
return;
}
// get all sites in network
$sites = wp_get_sites();
foreach ( $sites as $site ) {
switch_to_blog( $site[ 'blog_id' ] );
// delete custom post type
awf_delete_custom_post_type();
// remove all theme mods
awf_remove_all_theme_mods();
// delete transients
delete_transient( 'awf-get-fonts' );
restore_current_blog();
}
} else {
if ( ! current_user_can( 'activate_plugins' ) ) {
return;
}
// delete custom post type
awf_delete_custom_post_type();
// remove all theme mods
awf_remove_all_theme_mods();
// delete transients
delete_transient( 'awf-get-fonts' );
}
}
// Run the uninstalling process
awf_uninstall_arabic_webfonts_plugin();
/**
* Delete custom post type [ awf_font_control ].
*
* @since 1.0
*/
function awf_delete_custom_post_type() {
$args = array ( 'post_type' => 'awf_font_control', 'nopaging' => true );
$query = new WP_Query ($args);
while ($query->have_posts ()) {
$query->the_post ();
$id = get_the_ID ();
wp_delete_post ($id, true);
}
wp_reset_postdata ();
}
/**
* Remove all theme mods.
*
* @since 1.0
*/
function awf_remove_all_theme_mods() {
remove_theme_mod('awf_body_font_family');
remove_theme_mod('awf_body_font_size');
remove_theme_mod('awf_body_line_height');
remove_theme_mod('awf_paragraphs_font_family');
remove_theme_mod('awf_paragraphs_font_size');
remove_theme_mod('awf_paragraphs_line_height');
remove_theme_mod('awf_paragraphs_text_decoration');
remove_theme_mod('awf_h1_font_family');
remove_theme_mod('awf_h1_font_size');
remove_theme_mod('awf_h1_line_height');
remove_theme_mod('awf_h1_text_decoration');
remove_theme_mod('awf_h2_font_family');
remove_theme_mod('awf_h2_font_size');
remove_theme_mod('awf_h2_line_height');
remove_theme_mod('awf_h2_text_decoration');
remove_theme_mod('awf_h3_font_family');
remove_theme_mod('awf_h3_font_size');
remove_theme_mod('awf_h3_line_height');
remove_theme_mod('awf_h3_text_decoration');
remove_theme_mod('awf_h4_font_family');
remove_theme_mod('awf_h4_font_size');
remove_theme_mod('awf_h4_line_height');
remove_theme_mod('awf_h4_text_decoration');
remove_theme_mod('awf_h5_font_family');
remove_theme_mod('awf_h5_font_size');
remove_theme_mod('awf_h5_line_height');
remove_theme_mod('awf_h5_text_decoration');
remove_theme_mod('awf_h6_font_family');
remove_theme_mod('awf_h6_font_size');
remove_theme_mod('awf_h6_line_height');
remove_theme_mod('awf_h6_text_decoration');
}