30
30
* @subpackage Project
31
31
* @since Unknown
32
32
*/
33
- class WDS_Required_Plugins {
33
+ final class WDS_Required_Plugins {
34
34
35
35
/**
36
36
* Instance of this class.
@@ -45,7 +45,7 @@ class WDS_Required_Plugins {
45
45
/**
46
46
* Whether text-domain has been registered.
47
47
*
48
- * @var boolean
48
+ * @var bool
49
49
*
50
50
* @author Justin Sternberg
51
51
* @since Unknown
@@ -83,7 +83,7 @@ class WDS_Required_Plugins {
83
83
*
84
84
* @var array
85
85
*/
86
- public $ incompatibilities = array () ;
86
+ public $ incompatibilities = [] ;
87
87
88
88
/**
89
89
* Creates or returns an instance of this class.
@@ -107,27 +107,26 @@ public static function init() {
107
107
* @since 0.1.0
108
108
* @author Unknown
109
109
*
110
- * @return void
111
110
*/
112
111
private function __construct () {
113
112
if ( $ this ->incompatible () ) {
114
113
return ;
115
114
}
116
115
117
116
// Attempt activation + load text domain in the admin.
118
- add_action ( 'admin_init ' , array ( $ this , 'activate_if_not ' ) );
119
- add_action ( 'admin_init ' , array ( $ this , 'required_text_markup ' ) );
120
- add_filter ( 'extra_plugin_headers ' , array ( $ this , 'add_required_plugin_header ' ) );
117
+ add_action ( 'admin_init ' , [ $ this , 'activate_if_not ' ] );
118
+ add_action ( 'admin_init ' , [ $ this , 'required_text_markup ' ] );
119
+ add_filter ( 'extra_plugin_headers ' , [ $ this , 'add_required_plugin_header ' ] );
121
120
122
121
// Filter plugin links to remove deactivate option.
123
- add_filter ( 'plugin_action_links ' , array ( $ this , 'filter_plugin_links ' ) , 10 , 2 );
124
- add_filter ( 'network_admin_plugin_action_links ' , array ( $ this , 'filter_plugin_links ' ) , 10 , 2 );
122
+ add_filter ( 'plugin_action_links ' , [ $ this , 'filter_plugin_links ' ] , 10 , 2 );
123
+ add_filter ( 'network_admin_plugin_action_links ' , [ $ this , 'filter_plugin_links ' ] , 10 , 2 );
125
124
126
125
// Remove plugins from the plugins.
127
- add_filter ( 'all_plugins ' , array ( $ this , 'maybe_remove_plugins_from_list ' ) );
126
+ add_filter ( 'all_plugins ' , [ $ this , 'maybe_remove_plugins_from_list ' ] );
128
127
129
128
// Load text domain.
130
- add_action ( 'plugins_loaded ' , array ( $ this , 'l10n ' ) );
129
+ add_action ( 'plugins_loaded ' , [ $ this , 'l10n ' ] );
131
130
}
132
131
133
132
/**
@@ -136,18 +135,18 @@ private function __construct() {
136
135
* @author Aubrey Portwood
137
136
* @since 1.0.0
138
137
*
139
- * @return boolean True if we are incompatible with something, false if not.
138
+ * @return bool True if we are incompatible with something, false if not.
140
139
*/
141
140
public function incompatible () {
142
141
143
142
// Our tests.
144
- $ this ->incompatibilities = array (
143
+ $ this ->incompatibilities = [
145
144
146
145
/*
147
146
* WP Migrate DB Pro is performing an AJAX migration.
148
147
*/
149
148
(bool ) $ this ->is_wpmdb (),
150
- ) ;
149
+ ] ;
151
150
152
151
/**
153
152
* Add or filter your incompatibility tests here.
@@ -177,7 +176,7 @@ public function incompatible() {
177
176
* @author Aubrey Portwood
178
177
* @since 1.0.0
179
178
*
180
- * @return boolean True if we find wpmdb set as the action.
179
+ * @return bool True if we find wpmdb set as the action.
181
180
*/
182
181
public function is_wpmdb () {
183
182
@@ -190,7 +189,6 @@ public function is_wpmdb() {
190
189
*
191
190
* @since 0.1.1
192
191
* @author Unknown
193
- * @return void Early bails when we don't need to activate it.
194
192
*/
195
193
public function activate_if_not () {
196
194
@@ -225,10 +223,8 @@ public function activate_if_not() {
225
223
* @author Aubrey Portwood <aubrey@webdevstudios.com>
226
224
* @since 1.0.1 Added Exception if plugin not found.
227
225
*
228
- * @param string $plugin The plugin to activate.
229
- * @param boolean $network Whether we are activating a network-required plugin.
230
- *
231
- * @return void
226
+ * @param string $plugin The plugin to activate.
227
+ * @param bool $network Whether we are activating a network-required plugin.
232
228
*
233
229
* @throws Exception If we can't activate a required plugin.
234
230
*/
@@ -243,9 +239,9 @@ public function maybe_activate_plugin( $plugin, $network = false ) {
243
239
* @author Justin Sternberg
244
240
* @since Unknown
245
241
*
246
- * @param boolean $auto_activate Should we auto-activate the plugin, true by default.
247
- * @param string $plugin The plugin being activated.
248
- * @param string $network On what network?
242
+ * @param bool $auto_activate Should we auto-activate the plugin, true by default.
243
+ * @param string $plugin The plugin being activated.
244
+ * @param string $network On what network?
249
245
*/
250
246
$ auto_activate = apply_filters ( 'wds_required_plugin_auto_activate ' , true , $ plugin , $ network );
251
247
if ( ! $ auto_activate ) {
@@ -260,9 +256,9 @@ public function maybe_activate_plugin( $plugin, $network = false ) {
260
256
* @author Justin Sternberg
261
257
* @since Unknown
262
258
*
263
- * @param boolean $is_multisite The value of is_multisite().
264
- * @param string $plugin The plugin being activated.
265
- * @param string $network The network.
259
+ * @param bool $is_multisite The value of is_multisite().
260
+ * @param string $plugin The plugin being activated.
261
+ * @param string $network The network.
266
262
*/
267
263
$ is_multisite = apply_filters ( 'wds_required_plugin_network_activate ' , is_multisite (), $ plugin , $ network );
268
264
@@ -306,10 +302,10 @@ public function maybe_activate_plugin( $plugin, $network = false ) {
306
302
* @author Justin Sternberg
307
303
* @since Unknown
308
304
*
309
- * @param boolean $log_not_found Whether the plugin is indeed found or not,
310
- * default to true in the normal case. Set to false
311
- * if you would like to override that and not log it,
312
- * for instance, if it's intentional.
305
+ * @param bool $log_not_found Whether the plugin is indeed found or not,
306
+ * default to true in the normal case. Set to false
307
+ * if you would like to override that and not log it,
308
+ * for instance, if it's intentional.
313
309
*/
314
310
$ log_not_found = apply_filters ( 'wds_required_plugin_log_if_not_found ' , true , $ plugin , $ result , $ network );
315
311
@@ -335,7 +331,7 @@ public function maybe_activate_plugin( $plugin, $network = false ) {
335
331
* @since 1.1.0
336
332
* @author Aubrey Portwood <aubrey@webdevstudios.com>
337
333
*
338
- * @param boolean $stop_not_found Set to false to not halt execution if a plugin is not found.
334
+ * @param bool $stop_not_found Set to false to not halt execution if a plugin is not found.
339
335
*/
340
336
$ stop_not_found = apply_filters ( 'wds_required_plugin_stop_if_not_found ' , false , $ plugin , $ result , $ network );
341
337
@@ -383,25 +379,25 @@ public function required_text_markup() {
383
379
*
384
380
* @since 0.1.0
385
381
*
386
- * @param array $actions Array of actions avaible.
387
- * @param string $plugin Slug of plugin.
382
+ * @param array $actions Array of actions avaible.
383
+ * @param string $plugin Slug of plugin.
388
384
*
389
385
* @author Justin Sternberg
390
386
* @author Brad Parbs
391
387
* @author Aubrey Portwood Added documentation for filters.
392
388
*
393
389
* @return array
394
390
*/
395
- public function filter_plugin_links ( $ actions = array () , $ plugin ) {
391
+ public function filter_plugin_links ( $ actions = [] , $ plugin ) {
396
392
397
393
// Get our required plugins for network + normal.
398
394
$ required_plugins = array_unique ( array_merge ( $ this ->get_required_plugins (), $ this ->get_network_required_plugins () ) );
399
395
400
396
// Replace these action keys with what we have set for required text.
401
- $ action_keys = array (
397
+ $ action_keys = [
402
398
'deactivate ' ,
403
399
'network_active ' ,
404
- ) ;
400
+ ] ;
405
401
406
402
foreach ( $ action_keys as $ key ) {
407
403
@@ -414,8 +410,8 @@ public function filter_plugin_links( $actions = array(), $plugin ) {
414
410
* @author Brad Parbs
415
411
* @since Unknown
416
412
*
417
- * @param boolean $remove Should we remove it? Default to true.
418
- * @param string $plugin What plugin we're talking about.
413
+ * @param bool $remove Should we remove it? Default to true.
414
+ * @param string $plugin What plugin we're talking about.
419
415
*/
420
416
$ wds_required_plugin_network_activate = apply_filters ( 'wds_required_plugin_network_activate ' , true , $ plugin );
421
417
@@ -440,8 +436,8 @@ public function filter_plugin_links( $actions = array(), $plugin ) {
440
436
* @author Brad Parbs
441
437
* @author Aubrey Portwood Made it so mu-plugins are also unseen.
442
438
*
443
- * @param array $plugins Array of plugins.
444
- * @return array Array of plugins.
439
+ * @param array $plugins Array of plugins.
440
+ * @return array Array of plugins.
445
441
*/
446
442
public function maybe_remove_plugins_from_list ( $ plugins ) {
447
443
@@ -512,11 +508,11 @@ public function get_required_plugins() {
512
508
*
513
509
* @var array
514
510
*/
515
- $ required_plugins = apply_filters ( 'wds_required_plugins ' , array () );
511
+ $ required_plugins = apply_filters ( 'wds_required_plugins ' , [] );
516
512
if ( ! is_array ( $ required_plugins ) ) {
517
513
518
514
// The person who filtered this broke it.
519
- return array () ;
515
+ return [] ;
520
516
}
521
517
522
518
$ required_plugins = array_merge ( $ required_plugins , $ this ->get_header_required_plugins () );
@@ -559,11 +555,11 @@ public function get_network_required_plugins() {
559
555
*
560
556
* @var array
561
557
*/
562
- $ required_plugins = apply_filters ( 'wds_network_required_plugins ' , array () );
558
+ $ required_plugins = apply_filters ( 'wds_network_required_plugins ' , [] );
563
559
if ( ! is_array ( $ required_plugins ) ) {
564
560
565
561
// The person who filtered this broke it.
566
- return array () ;
562
+ return [] ;
567
563
}
568
564
569
565
return $ required_plugins ;
@@ -576,7 +572,6 @@ public function get_network_required_plugins() {
576
572
* @author Brad Parbs
577
573
* @since 0.1.1
578
574
*
579
- * @return void Early bails when it's un-necessary.
580
575
*/
581
576
public function l10n () {
582
577
@@ -620,7 +615,7 @@ public function l10n() {
620
615
621
616
// If we still didn't load, assume our text domain is right where we are.
622
617
$ locale = apply_filters ( 'plugin_locale ' , get_locale (), 'wds-required-plugins ' );
623
- $ mofile = dirname ( __FILE__ ) . '/languages/wds-required-plugins- ' . $ locale . '.mo ' ;
618
+ $ mofile = __DIR__ . '/languages/wds-required-plugins- ' . $ locale . '.mo ' ;
624
619
load_textdomain ( 'wds-required-plugins ' , $ mofile );
625
620
self ::$ l10n_done = true ;
626
621
}
@@ -631,7 +626,7 @@ public function l10n() {
631
626
* @since 1.2.0
632
627
* @author Zach Owen
633
628
*
634
- * @param array $extra_headers Extra headers filtered in WP core.
629
+ * @param array $extra_headers Extra headers filtered in WP core.
635
630
* @return array
636
631
*/
637
632
public function add_required_plugin_header ( $ extra_headers ) {
0 commit comments