PluginProbe
Polylang / 3.7.7
Polylang v3.7.7
3.8.9 3.8.8 3.8.7 3.8.6 3.8.5 3.8.4 3.8.3 2.7 2.7.0.1 2.7.1 2.7.2 2.7.3 2.7.4 2.8 2.8.1 2.8.2 2.8.3 2.8.4 2.9 2.9.1 2.9.2 3.0 3.0.1 3.0.2 3.0.3 All 233 releases
← All changes | install/install-base.php +26 -32 2.8.2 → 3.7.7 View file →
@@ -3,13 +3,18 @@
3 3 * @package Polylang
4 4 */
5 5
6 6 /**
7 - * A generic activation / de-activation class compatble with multisite
7 + * A generic activation / de-activation class compatible with multisite
8 8 *
9 9 * @since 1.7
10 10 */
11 11 class PLL_Install_Base {
12 + /**
13 + * The plugin basename.
14 + *
15 + * @var string
16 + */
12 17 protected $plugin_basename;
13 18
14 19 /**
15 20 * Constructor
@@ -24,15 +29,10 @@
24 29 // Manages plugin activation and deactivation
25 30 register_activation_hook( $plugin_basename, array( $this, 'activate' ) );
26 31 register_deactivation_hook( $plugin_basename, array( $this, 'deactivate' ) );
27 32
28 - // Blog creation on multisite.
29 - if ( version_compare( $GLOBALS['wp_version'], '5.1', '<' ) ) {
30 - // FIXME: Backward compatibility with WP < 5.1.
31 - add_action( 'wpmu_new_blog', array( $this, 'wpmu_new_blog' ), 5 ); // Before WP attempts to send mails which can break on some PHP versions
32 - } else {
33 - add_action( 'wp_insert_site', array( $this, 'new_site' ) );
34 - }
33 + // Site creation on multisite.
34 + add_action( 'wp_initialize_site', array( $this, 'new_site' ), 50 ); // After WP (prio 10).
35 35 }
36 36
37 37 /**
38 38 * Allows to detect plugin deactivation
@@ -38,9 +38,9 @@
38 38 * Allows to detect plugin deactivation
39 39 *
40 40 * @since 1.7
41 41 *
42 - * @return bool true if the plugin is currently beeing deactivated
42 + * @return bool true if the plugin is currently being deactivated
43 43 */
44 44 public function is_deactivation() {
45 45 return isset( $_GET['action'], $_GET['plugin'] ) && 'deactivate' === $_GET['action'] && $this->plugin_basename === $_GET['plugin']; // phpcs:ignore WordPress.Security.NonceVerification
46 46 }
@@ -45,14 +45,15 @@
45 45 return isset( $_GET['action'], $_GET['plugin'] ) && 'deactivate' === $_GET['action'] && $this->plugin_basename === $_GET['plugin']; // phpcs:ignore WordPress.Security.NonceVerification
46 46 }
47 47
48 48 /**
49 - * Activation or deactivation for all blogs
49 + * Activation or deactivation for all blogs.
50 50 *
51 51 * @since 1.2
52 52 *
53 - * @param string $what Either 'activate' or 'deactivate'
54 - * @param bool $networkwide
53 + * @param string $what Either 'activate' or 'deactivate'.
54 + * @param bool $networkwide Whether the plugin is (de)activated for all sites in the network or just the current site.
55 + * @return void
55 56 */
56 57 protected function do_for_all_blogs( $what, $networkwide ) {
57 58 // Network
58 59 if ( is_multisite() && $networkwide ) {
@@ -71,13 +72,14 @@
71 72 }
72 73 }
73 74
74 75 /**
75 - * Plugin activation for multisite
76 + * Plugin activation for multisite.
76 77 *
77 78 * @since 1.7
78 79 *
79 - * @param bool $networkwide
80 + * @param bool $networkwide Whether the plugin is activated for all sites in the network or just the current site.
81 + * @return void
80 82 */
81 83 public function activate( $networkwide ) {
82 84 $this->do_for_all_blogs( 'activate', $networkwide );
83 85 }
@@ -85,19 +87,22 @@
85 87 /**
86 88 * Plugin activation
87 89 *
88 90 * @since 0.5
91 + *
92 + * @return void
89 93 */
90 94 protected function _activate() {
91 - // Can be overriden in child class
95 + // Can be overridden in child class
92 96 }
93 97
94 98 /**
95 - * Plugin deactivation for multisite
99 + * Plugin deactivation for multisite.
96 100 *
97 101 * @since 0.1
98 102 *
99 - * @param bool $networkwide
103 + * @param bool $networkwide Whether the plugin is deactivated for all sites in the network or just the current site.
104 + * @return void
100 105 */
101 106 public function deactivate( $networkwide ) {
102 107 $this->do_for_all_blogs( 'deactivate', $networkwide );
103 108 }
@@ -105,11 +110,13 @@
105 110 /**
106 111 * Plugin deactivation
107 112 *
108 113 * @since 0.5
114 + *
115 + * @return void
109 116 */
110 117 protected function _deactivate() {
111 - // Can be overriden in child class
118 + // Can be overridden in child class
112 119 }
113 120
114 121 /**
115 122 * Site creation on multisite ( to set default options )
@@ -116,25 +123,12 @@
116 123 *
117 124 * @since 2.6.8
118 125 *
119 126 * @param WP_Site $new_site New site object.
127 + * @return void
120 128 */
121 129 public function new_site( $new_site ) {
122 130 switch_to_blog( $new_site->id );
123 - $this->_activate();
124 - restore_current_blog();
125 - }
126 -
127 - /**
128 - * Blog creation on multisite ( to set default options )
129 - * Backward compatibility with WP < 5.1
130 - *
131 - * @since 0.9.4
132 - *
133 - * @param int $blog_id
134 - */
135 - public function wpmu_new_blog( $blog_id ) {
136 - switch_to_blog( $blog_id );
137 131 $this->_activate();
138 132 restore_current_blog();
139 133 }
140 134 }