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