|
1
|
|
|
<?php |
|
|
|
|
|
|
2
|
|
|
/** |
|
|
|
|
|
|
3
|
|
|
* @author Podlove <[email protected]> |
|
4
|
|
|
* @copyright Copyright (c) 2014-2018, Podlove |
|
5
|
|
|
* @license https://github.com/podlove/podlove-subscribe-button-wp-plugin/blob/master/LICENSE MIT |
|
6
|
|
|
* @package Podlove\PodloveSubscribeButton |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace PodloveSubscribeButton; |
|
10
|
|
|
|
|
11
|
|
|
class Setup { |
|
|
|
|
|
|
12
|
|
|
|
|
13
|
|
|
public static function activation( $network_wide ) { |
|
|
|
|
|
|
14
|
|
|
if ( is_multisite() ) { |
|
15
|
|
|
self::activate_for_network( $network_wide ); |
|
16
|
|
|
} else { |
|
17
|
|
|
self::activate_for_current_blog(); |
|
18
|
|
|
} |
|
19
|
|
|
} |
|
|
|
|
|
|
20
|
|
|
|
|
21
|
|
|
public static function activate_for_current_blog() { |
|
|
|
|
|
|
22
|
|
|
|
|
23
|
|
|
// Build Databases |
|
|
|
|
|
|
24
|
|
|
Model\Button::build(); |
|
25
|
|
|
|
|
26
|
|
|
$default_values = Defaults::options(); |
|
27
|
|
|
|
|
28
|
|
|
add_option( 'podlove_psb_defaults', $default_values ); |
|
29
|
|
|
|
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
public static function activate_for_network( $network_wide ) { |
|
|
|
|
|
|
33
|
|
|
|
|
34
|
|
|
Model\NetworkButton::build(); |
|
35
|
|
|
|
|
36
|
|
|
$default_values = Defaults::options_install(); |
|
37
|
|
|
|
|
38
|
|
|
add_site_option( 'podlove_psb_defaults', $default_values ); |
|
39
|
|
|
|
|
40
|
|
|
if ( $network_wide ) { |
|
41
|
|
|
global $wpdb; |
|
42
|
|
|
|
|
43
|
|
|
set_time_limit( 0 ); // may take a while, depending on network size |
|
|
|
|
|
|
44
|
|
|
$blogids = $wpdb->get_col( "SELECT blog_id FROM " . $wpdb->blogs ); |
|
|
|
|
|
|
45
|
|
|
foreach ( $blogids as $blog_id ) { |
|
46
|
|
|
switch_to_blog( $blog_id ); |
|
47
|
|
|
self::activate_for_current_blog(); |
|
48
|
|
|
} |
|
49
|
|
|
} else { |
|
50
|
|
|
self::activate_for_current_blog(); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public static function uninstall() { |
|
|
|
|
|
|
56
|
|
|
if ( is_multisite() ) { |
|
57
|
|
|
self::uninstall_for_network(); |
|
58
|
|
|
} else { |
|
59
|
|
|
self::uninstall_for_current_blog(); |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
|
|
|
|
|
62
|
|
|
|
|
63
|
|
|
public static function uninstall_for_network() { |
|
|
|
|
|
|
64
|
|
|
|
|
65
|
|
|
global $wpdb; |
|
66
|
|
|
|
|
67
|
|
|
Model\NetworkButton::destroy(); |
|
68
|
|
|
|
|
69
|
|
|
$current_blog = $wpdb->blogid; |
|
70
|
|
|
$blogids = $wpdb->get_col( "SELECT blog_id FROM " . $wpdb->blogs ); |
|
|
|
|
|
|
71
|
|
|
|
|
72
|
|
|
foreach ( $blogids as $blog_id ) { |
|
73
|
|
|
switch_to_blog( $blog_id ); |
|
74
|
|
|
self::uninstall_for_current_blog(); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
switch_to_blog( $current_blog ); |
|
78
|
|
|
|
|
79
|
|
|
$options = array( |
|
80
|
|
|
/** 1.4+ */ |
|
81
|
|
|
'podlove_psb_defaults', |
|
82
|
|
|
); |
|
83
|
|
|
|
|
84
|
|
|
foreach ( $options as $option ) { |
|
85
|
|
|
delete_site_option( $option ); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
public static function uninstall_for_current_blog() { |
|
|
|
|
|
|
91
|
|
|
|
|
92
|
|
|
// remove DB tables |
|
|
|
|
|
|
93
|
|
|
Model\Button::destroy(); |
|
94
|
|
|
|
|
95
|
|
|
$options = array( |
|
96
|
|
|
/** 1.4+ */ |
|
97
|
|
|
'podlove_psb_defaults', |
|
98
|
|
|
/** 1.3.x */ |
|
99
|
|
|
'podlove_subscribe_button_default_size', |
|
100
|
|
|
'podlove_subscribe_button_default_autowidth', |
|
101
|
|
|
'podlove_subscribe_button_default_color', |
|
102
|
|
|
'podlove_subscribe_button_default_style', |
|
103
|
|
|
'podlove_subscribe_button_default_format', |
|
104
|
|
|
'podlove_subscribe_button_default_language', |
|
105
|
|
|
'podlove_subscribe_button_plugin_database_version', |
|
106
|
|
|
'widget_podlove_subscribe_button_wp_plugin_widget', |
|
107
|
|
|
); |
|
108
|
|
|
|
|
109
|
|
|
foreach ( $options as $option ) { |
|
110
|
|
|
delete_option( $option ); |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
} // END class |
|
116
|
|
|
|