PluginProbe
Polylang / 2.0.12
Polylang v2.0.12
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 -47 2.82.0.12 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,32 +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 - // 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 - }
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
35 25 }
36 26
37 27 /**
38 - * Allows to detect plugin deactivation
28 + * allows to detect plugin deactivation
39 29 *
40 30 * @since 1.7
41 31 *
42 32 * @return bool true if the plugin is currently beeing deactivated
@@ -41,21 +31,20 @@
41 31 *
42 32 * @return bool true if the plugin is currently beeing deactivated
43 33 */
44 34 public function is_deactivation() {
45 - 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'];
46 36 }
47 37
48 38 /**
49 - * Activation or deactivation for all blogs
39 + * activation or deactivation for all blogs
50 40 *
51 41 * @since 1.2
52 42 *
53 - * @param string $what Either 'activate' or 'deactivate'
54 - * @param bool $networkwide
43 + * @param string $what either 'activate' or 'deactivate'
55 44 */
56 45 protected function do_for_all_blogs( $what, $networkwide ) {
57 - // Network
46 + // network
58 47 if ( is_multisite() && $networkwide ) {
59 48 global $wpdb;
60 49
61 50 foreach ( $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" ) as $blog_id ) {
@@ -64,9 +53,9 @@
64 53 }
65 54 restore_current_blog();
66 55 }
67 56
68 - // Single blog
57 + // single blog
69 58 else {
70 59 'activate' == $what ? $this->_activate() : $this->_deactivate();
71 60 }
72 61 }
@@ -71,13 +60,11 @@
71 60 }
72 61 }
73 62
74 63 /**
75 - * Plugin activation for multisite
64 + * plugin activation for multisite
76 65 *
77 66 * @since 1.7
78 - *
79 - * @param bool $networkwide
80 67 */
81 68 public function activate( $networkwide ) {
82 69 $this->do_for_all_blogs( 'activate', $networkwide );
83 70 }
@@ -82,22 +69,20 @@
82 69 $this->do_for_all_blogs( 'activate', $networkwide );
83 70 }
84 71
85 72 /**
86 - * Plugin activation
73 + * plugin activation
87 74 *
88 75 * @since 0.5
89 76 */
90 77 protected function _activate() {
91 - // Can be overriden in child class
78 + // can be overriden in child class
92 79 }
93 80
94 81 /**
95 - * Plugin deactivation for multisite
82 + * plugin deactivation for multisite
96 83 *
97 84 * @since 0.1
98 - *
99 - * @param bool $networkwide
100 85 */
101 86 public function deactivate( $networkwide ) {
102 87 $this->do_for_all_blogs( 'deactivate', $networkwide );
103 88 }
@@ -102,32 +87,18 @@
102 87 $this->do_for_all_blogs( 'deactivate', $networkwide );
103 88 }
104 89
105 90 /**
106 - * Plugin deactivation
91 + * plugin deactivation
107 92 *
108 93 * @since 0.5
109 94 */
110 95 protected function _deactivate() {
111 - // Can be overriden in child class
96 + // can be overriden in child class
112 97 }
113 98
114 99 /**
115 - * Site creation on multisite ( to set default options )
116 - *
117 - * @since 2.6.8
118 - *
119 - * @param WP_Site $new_site New site object.
120 - */
121 - public function new_site( $new_site ) {
122 - 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
100 + * blog creation on multisite ( to set default options )
130 101 *
131 102 * @since 0.9.4
132 103 *
133 104 * @param int $blog_id