PluginProbe
Polylang / 2.0.3
Polylang v2.0.3
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 +22 -32 2.92.0.3 View file →
@@ -1,11 +1,8 @@
1 1 <?php
2 -/**
3 - * @package Polylang
4 - */
5 2
6 3 /**
7 - * A generic activation / de-activation class compatble with multisite
4 + * a generic activation / de-activation class compatble with multisite
8 5 *
9 6 * @since 1.7
10 7 */
11 8 class PLL_Install_Base {
@@ -11,27 +8,25 @@
11 8 class PLL_Install_Base {
12 9 protected $plugin_basename;
13 10
14 11 /**
15 - * Constructor
12 + * constructor
16 13 *
17 14 * @since 1.7
18 - *
19 - * @param string $plugin_basename Plugin basename
20 15 */
21 16 public function __construct( $plugin_basename ) {
22 17 $this->plugin_basename = $plugin_basename;
23 18
24 - // Manages plugin activation and deactivation
19 + // manages plugin activation and deactivation
25 20 register_activation_hook( $plugin_basename, array( $this, 'activate' ) );
26 21 register_deactivation_hook( $plugin_basename, array( $this, 'deactivate' ) );
27 22
28 - // Site creation on multisite.
29 - add_action( 'wp_insert_site', array( $this, 'new_site' ) );
23 + // blog creation on multisite
24 + add_action( 'wpmu_new_blog', array( $this, 'wpmu_new_blog' ), 5 ); // before WP attempts to send mails which can break on some PHP versions
30 25 }
31 26
32 27 /**
33 - * Allows to detect plugin deactivation
28 + * allows to detect plugin deactivation
34 29 *
35 30 * @since 1.7
36 31 *
37 32 * @return bool true if the plugin is currently beeing deactivated
@@ -36,21 +31,20 @@
36 31 *
37 32 * @return bool true if the plugin is currently beeing deactivated
38 33 */
39 34 public function is_deactivation() {
40 - return isset( $_GET['action'], $_GET['plugin'] ) && 'deactivate' === $_GET['action'] && $this->plugin_basename === $_GET['plugin']; // phpcs:ignore WordPress.Security.NonceVerification
35 + return isset( $_GET['action'], $_GET['plugin'] ) && 'deactivate' == $_GET['action'] && $this->plugin_basename == $_GET['plugin'];
41 36 }
42 37
43 38 /**
44 - * Activation or deactivation for all blogs
39 + * activation or deactivation for all blogs
45 40 *
46 41 * @since 1.2
47 42 *
48 - * @param string $what Either 'activate' or 'deactivate'
49 - * @param bool $networkwide
43 + * @param string $what either 'activate' or 'deactivate'
50 44 */
51 45 protected function do_for_all_blogs( $what, $networkwide ) {
52 - // Network
46 + // network
53 47 if ( is_multisite() && $networkwide ) {
54 48 global $wpdb;
55 49
56 50 foreach ( $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" ) as $blog_id ) {
@@ -59,9 +53,9 @@
59 53 }
60 54 restore_current_blog();
61 55 }
62 56
63 - // Single blog
57 + // single blog
64 58 else {
65 59 'activate' == $what ? $this->_activate() : $this->_deactivate();
66 60 }
67 61 }
@@ -66,13 +60,11 @@
66 60 }
67 61 }
68 62
69 63 /**
70 - * Plugin activation for multisite
64 + * plugin activation for multisite
71 65 *
72 66 * @since 1.7
73 - *
74 - * @param bool $networkwide
75 67 */
76 68 public function activate( $networkwide ) {
77 69 $this->do_for_all_blogs( 'activate', $networkwide );
78 70 }
@@ -77,22 +69,20 @@
77 69 $this->do_for_all_blogs( 'activate', $networkwide );
78 70 }
79 71
80 72 /**
81 - * Plugin activation
73 + * plugin activation
82 74 *
83 75 * @since 0.5
84 76 */
85 77 protected function _activate() {
86 - // Can be overriden in child class
78 + // can be overriden in child class
87 79 }
88 80
89 81 /**
90 - * Plugin deactivation for multisite
82 + * plugin deactivation for multisite
91 83 *
92 84 * @since 0.1
93 - *
94 - * @param bool $networkwide
95 85 */
96 86 public function deactivate( $networkwide ) {
97 87 $this->do_for_all_blogs( 'deactivate', $networkwide );
98 88 }
@@ -97,25 +87,25 @@
97 87 $this->do_for_all_blogs( 'deactivate', $networkwide );
98 88 }
99 89
100 90 /**
101 - * Plugin deactivation
91 + * plugin deactivation
102 92 *
103 93 * @since 0.5
104 94 */
105 95 protected function _deactivate() {
106 - // Can be overriden in child class
96 + // can be overriden in child class
107 97 }
108 98
109 99 /**
110 - * Site creation on multisite ( to set default options )
100 + * blog creation on multisite ( to set default options )
111 101 *
112 - * @since 2.6.8
102 + * @since 0.9.4
113 103 *
114 - * @param WP_Site $new_site New site object.
104 + * @param int $blog_id
115 105 */
116 - public function new_site( $new_site ) {
117 - switch_to_blog( $new_site->id );
106 + public function wpmu_new_blog( $blog_id ) {
107 + switch_to_blog( $blog_id );
118 108 $this->_activate();
119 109 restore_current_blog();
120 110 }
121 111 }