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
|
|
|
|
15
|
|
|
global $wpdb; |
16
|
|
|
|
17
|
|
|
if ( $network_wide ) { |
18
|
|
|
Model\NetworkButton::build(); |
19
|
|
|
set_time_limit(0); // may take a while, depending on network size |
|
|
|
|
20
|
|
|
$blogids = $wpdb->get_col( "SELECT blog_id FROM " . $wpdb->blogs ); |
|
|
|
|
21
|
|
|
foreach ( $blogids as $blog_id ) { |
22
|
|
|
switch_to_blog( $blog_id ); |
23
|
|
|
self::activate_for_current_blog(); |
24
|
|
|
} |
25
|
|
|
} else { |
26
|
|
|
self::activate_for_current_blog(); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
public static function activate_for_current_blog() { |
|
|
|
|
32
|
|
|
|
33
|
|
|
// Build Databases |
|
|
|
|
34
|
|
|
Model\Button::build(); |
35
|
|
|
|
36
|
|
|
$default_values = Defaults::options(); |
37
|
|
|
|
38
|
|
|
// add_option( 'podlove_psb_defaults', $default_values ); |
|
|
|
|
39
|
|
|
|
40
|
|
|
foreach ( $default_values as $option => $default_value ) { |
41
|
|
|
if ( ! get_option( 'podlove_subscribe_button_default_' . $option ) ) { |
42
|
|
|
update_option( 'podlove_subscribe_button_default_' . $option, $default_value ); |
43
|
|
|
} |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public static function deactivation( $network_wide ) { |
|
|
|
|
49
|
|
|
|
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public static function uninstall() { |
|
|
|
|
53
|
|
|
if ( is_multisite() ) { |
54
|
|
|
self::uninstall_for_network(); |
55
|
|
|
} else { |
56
|
|
|
self::uninstall_for_current_blog(); |
57
|
|
|
} |
58
|
|
|
} |
|
|
|
|
59
|
|
|
|
60
|
|
|
public static function uninstall_for_network() { |
|
|
|
|
61
|
|
|
|
62
|
|
|
global $wpdb; |
63
|
|
|
|
64
|
|
|
Model\NetworkButton::destroy(); |
65
|
|
|
|
66
|
|
|
$current_blog = $wpdb->blogid; |
67
|
|
|
$blogids = $wpdb->get_col( "SELECT blog_id FROM " . $wpdb->blogs ); |
|
|
|
|
68
|
|
|
|
69
|
|
|
foreach ( $blogids as $blog_id ) { |
70
|
|
|
switch_to_blog( $blog_id ); |
71
|
|
|
self::uninstall_for_current_blog(); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
switch_to_blog( $current_blog ); |
75
|
|
|
|
76
|
|
|
// $options = array( |
|
|
|
|
77
|
|
|
// /** 1.4+ */ |
|
|
|
|
78
|
|
|
// 'podlove_subscribe_button_defaults', |
|
|
|
|
79
|
|
|
// ); |
|
|
|
|
80
|
|
|
// |
81
|
|
|
// foreach ( $options as $option ) { |
|
|
|
|
82
|
|
|
// delete_site_option( $option ); |
|
|
|
|
83
|
|
|
// } |
|
|
|
|
84
|
|
|
|
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
public static function uninstall_for_current_blog() { |
|
|
|
|
88
|
|
|
|
89
|
|
|
// remove DB tables |
|
|
|
|
90
|
|
|
Model\Button::destroy(); |
91
|
|
|
|
92
|
|
|
$options = array( |
93
|
|
|
/** 1.4+ */ |
94
|
|
|
'podlove_subscribe_button_defaults', |
95
|
|
|
'widget_podlove_subscribe_button_wp_plugin_widget', |
96
|
|
|
/** 1.3.x */ |
97
|
|
|
'podlove_subscribe_button_default_size', |
98
|
|
|
'podlove_subscribe_button_default_autowidth', |
99
|
|
|
'podlove_subscribe_button_default_color', |
100
|
|
|
'podlove_subscribe_button_default_style', |
101
|
|
|
'podlove_subscribe_button_default_format', |
102
|
|
|
'podlove_subscribe_button_default_language', |
103
|
|
|
'podlove_subscribe_button_plugin_database_version', |
104
|
|
|
); |
105
|
|
|
|
106
|
|
|
foreach ( $options as $option ) { |
107
|
|
|
delete_option( $option ); |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
} // END class |
113
|
|
|
|