@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | const MIN_PHP_VERSION = '5.6.0'; |
18 | 18 | const MIN_WORDPRESS_VERSION = '4.7'; |
19 | 19 | |
20 | - public $errors = []; |
|
20 | + public $errors = [ ]; |
|
21 | 21 | |
22 | 22 | /** |
23 | 23 | * @var Application |
@@ -39,11 +39,11 @@ discard block |
||
39 | 39 | $this->plugin = $plugin; |
40 | 40 | |
41 | 41 | if( $this->canActivate() ) { |
42 | - add_action( 'admin_init', array( $this, 'init' )); |
|
42 | + add_action( 'admin_init', array( $this, 'init' ) ); |
|
43 | 43 | } |
44 | 44 | else { |
45 | - add_action( 'activated_plugin', array( $this, 'deactivate' )); |
|
46 | - add_action( 'admin_notices', array( $this, 'deactivate' )); |
|
45 | + add_action( 'activated_plugin', array( $this, 'deactivate' ) ); |
|
46 | + add_action( 'admin_notices', array( $this, 'deactivate' ) ); |
|
47 | 47 | } |
48 | 48 | } |
49 | 49 | |
@@ -52,10 +52,10 @@ discard block |
||
52 | 52 | $this->app = pollux_app(); |
53 | 53 | $this->notice = pollux_app()->make( 'Notice' ); |
54 | 54 | |
55 | - add_action( 'current_screen', array( $this, 'activatePlugin' )); |
|
56 | - add_action( 'wp_ajax_pollux/dependency/activate_url', array( $this, 'ajaxActivatePluginLink' )); |
|
57 | - add_action( 'admin_notices', array( $this, 'printNotices' )); |
|
58 | - add_action( 'current_screen', array( $this, 'setDependencyNotice' )); |
|
55 | + add_action( 'current_screen', array( $this, 'activatePlugin' ) ); |
|
56 | + add_action( 'wp_ajax_pollux/dependency/activate_url', array( $this, 'ajaxActivatePluginLink' ) ); |
|
57 | + add_action( 'admin_notices', array( $this, 'printNotices' ) ); |
|
58 | + add_action( 'current_screen', array( $this, 'setDependencyNotice' ) ); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | $plugin = filter_input( INPUT_GET, 'plugin' ); |
72 | 72 | check_admin_referer( 'activate-plugin_' . $plugin ); |
73 | 73 | $result = activate_plugin( $plugin, null, is_network_admin(), true ); |
74 | - if( is_wp_error( $result )) { |
|
74 | + if( is_wp_error( $result ) ) { |
|
75 | 75 | wp_die( $result->get_error_message() ); |
76 | 76 | } |
77 | 77 | wp_safe_redirect( wp_get_referer() ); |
@@ -85,19 +85,19 @@ discard block |
||
85 | 85 | { |
86 | 86 | check_ajax_referer( 'updates' ); |
87 | 87 | $plugin = filter_input( INPUT_POST, 'plugin' ); |
88 | - if( !$this->isPluginDependency( $plugin )) { |
|
88 | + if( !$this->isPluginDependency( $plugin ) ) { |
|
89 | 89 | wp_send_json_error(); |
90 | 90 | } |
91 | - $activateUrl = add_query_arg([ |
|
92 | - '_wpnonce' => wp_create_nonce( sprintf( 'activate-plugin_%s', $plugin )), |
|
91 | + $activateUrl = add_query_arg( [ |
|
92 | + '_wpnonce' => wp_create_nonce( sprintf( 'activate-plugin_%s', $plugin ) ), |
|
93 | 93 | 'action' => 'activate', |
94 | 94 | 'page' => $this->app->id, |
95 | 95 | 'plugin' => $plugin, |
96 | - ], self_admin_url( 'options-general.php' )); |
|
97 | - wp_send_json_success([ |
|
96 | + ], self_admin_url( 'options-general.php' ) ); |
|
97 | + wp_send_json_success( [ |
|
98 | 98 | 'activate_url' => $activateUrl, |
99 | 99 | filter_input( INPUT_POST, 'type' ) => $plugin, |
100 | - ]); |
|
100 | + ] ); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -141,8 +141,8 @@ discard block |
||
141 | 141 | else if( $action == 'install' ) { |
142 | 142 | $this->installPlugin( $plugin ); |
143 | 143 | } |
144 | - else if( filter_input( INPUT_GET, '_error_nonce' )) { |
|
145 | - wp_safe_redirect( remove_query_arg( '_error_nonce' )); |
|
144 | + else if( filter_input( INPUT_GET, '_error_nonce' ) ) { |
|
145 | + wp_safe_redirect( remove_query_arg( '_error_nonce' ) ); |
|
146 | 146 | exit; |
147 | 147 | } |
148 | 148 | } |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | */ |
153 | 153 | public function hasDependency( $plugin ) |
154 | 154 | { |
155 | - if( !$this->isPluginDependency( $plugin )) { |
|
155 | + if( !$this->isPluginDependency( $plugin ) ) { |
|
156 | 156 | return true; |
157 | 157 | } |
158 | 158 | return $this->isPluginInstalled( $plugin ) && $this->isPluginValid( $plugin ); |
@@ -216,17 +216,17 @@ discard block |
||
216 | 216 | */ |
217 | 217 | public function isPluginVersionValid( $plugin ) |
218 | 218 | { |
219 | - if( !$this->isPluginDependency( $plugin )) { |
|
219 | + if( !$this->isPluginDependency( $plugin ) ) { |
|
220 | 220 | return true; |
221 | 221 | } |
222 | - if( !$this->isPluginInstalled( $plugin )) { |
|
222 | + if( !$this->isPluginInstalled( $plugin ) ) { |
|
223 | 223 | return false; |
224 | 224 | } |
225 | 225 | return $this->catchError( $plugin, 'wrong_version', version_compare( |
226 | 226 | $this->getPluginRequirements( $plugin, 'version' ), |
227 | - $this->getAllPlugins()[$plugin]['Version'], |
|
227 | + $this->getAllPlugins()[ $plugin ][ 'Version' ], |
|
228 | 228 | '<=' |
229 | - )); |
|
229 | + ) ); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | public function hasPendingDependencies() |
246 | 246 | { |
247 | 247 | foreach( static::DEPENDENCIES as $plugin => $data ) { |
248 | - if( !$this->isPluginDependency( $plugin ))continue; |
|
248 | + if( !$this->isPluginDependency( $plugin ) )continue; |
|
249 | 249 | $this->isPluginActive( $plugin ); |
250 | 250 | $this->isPluginVersionValid( $plugin ); |
251 | 251 | } |
@@ -267,20 +267,20 @@ discard block |
||
267 | 267 | |
268 | 268 | foreach( $this->errors as $plugin => $errors ) { |
269 | 269 | $plugins .= $this->getPluginLink( $plugin ); |
270 | - if( in_array( 'not_found', $errors ) && current_user_can( 'install_plugins' )) { |
|
271 | - $actions .= $this->notice->installButton( $this->getPluginRequirements( $plugin )); |
|
270 | + if( in_array( 'not_found', $errors ) && current_user_can( 'install_plugins' ) ) { |
|
271 | + $actions .= $this->notice->installButton( $this->getPluginRequirements( $plugin ) ); |
|
272 | 272 | } |
273 | - else if( in_array( 'wrong_version', $errors ) && current_user_can( 'update_plugins' )) { |
|
274 | - $actions .= $this->notice->updateButton( $this->getPluginInformation( $plugin )); |
|
273 | + else if( in_array( 'wrong_version', $errors ) && current_user_can( 'update_plugins' ) ) { |
|
274 | + $actions .= $this->notice->updateButton( $this->getPluginInformation( $plugin ) ); |
|
275 | 275 | } |
276 | - else if( in_array( 'inactive', $errors ) && current_user_can( 'activate_plugins' )) { |
|
277 | - $actions .= $this->notice->activateButton( $this->getPluginInformation( $plugin )); |
|
276 | + else if( in_array( 'inactive', $errors ) && current_user_can( 'activate_plugins' ) ) { |
|
277 | + $actions .= $this->notice->activateButton( $this->getPluginInformation( $plugin ) ); |
|
278 | 278 | } |
279 | 279 | } |
280 | - $this->notice->addWarning([ |
|
280 | + $this->notice->addWarning( [ |
|
281 | 281 | sprintf( '<strong>%s</strong> %s', __( 'Pollux requires the latest version of the following plugins:', 'pollux' ), $plugins ), |
282 | 282 | $actions, |
283 | - ]); |
|
283 | + ] ); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | /** |
@@ -288,11 +288,11 @@ discard block |
||
288 | 288 | */ |
289 | 289 | protected function addInvalidPHPVersionNotice() |
290 | 290 | { |
291 | - $this->notice->addError([ |
|
292 | - $this->notice->title( __( 'The Pollux plugin was deactivated.', 'pollux' )), |
|
291 | + $this->notice->addError( [ |
|
292 | + $this->notice->title( __( 'The Pollux plugin was deactivated.', 'pollux' ) ), |
|
293 | 293 | sprintf( __( 'Sorry, Pollux requires PHP %s or greater in order to work properly (your server is running PHP %s).', 'pollux' ), self::MIN_PHP_VERSION, PHP_VERSION ), |
294 | 294 | __( 'Please contact your hosting provider or server administrator to upgrade the version of PHP running on your server, or find an alternate plugin.', 'pollux' ), |
295 | - ]); |
|
295 | + ] ); |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | /** |
@@ -300,11 +300,11 @@ discard block |
||
300 | 300 | */ |
301 | 301 | protected function addInvalidWPVersionNotice() |
302 | 302 | { |
303 | - $this->notice->addError([ |
|
304 | - $this->notice->title( __( 'The Pollux plugin was deactivated.', 'pollux' )), |
|
303 | + $this->notice->addError( [ |
|
304 | + $this->notice->title( __( 'The Pollux plugin was deactivated.', 'pollux' ) ), |
|
305 | 305 | sprintf( __( 'Sorry, Pollux requires WordPress %s or greater in order to work properly.', 'pollux' ), self::MIN_WORDPRESS_VERSION ), |
306 | - $this->notice->button( __( 'Update WordPress', 'pollux' ), self_admin_url( 'update-core.php' )), |
|
307 | - ]); |
|
306 | + $this->notice->button( __( 'Update WordPress', 'pollux' ), self_admin_url( 'update-core.php' ) ), |
|
307 | + ] ); |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | /** |
@@ -315,12 +315,12 @@ discard block |
||
315 | 315 | protected function catchError( $plugin, $error, $isValid ) |
316 | 316 | { |
317 | 317 | if( !$isValid ) { |
318 | - if( !isset( $this->errors[$plugin] )) { |
|
319 | - $this->errors[$plugin] = []; |
|
318 | + if( !isset( $this->errors[ $plugin ] ) ) { |
|
319 | + $this->errors[ $plugin ] = [ ]; |
|
320 | 320 | } |
321 | - $this->errors[$plugin] = array_keys( array_flip( |
|
322 | - array_merge( $this->errors[$plugin], [$error] ) |
|
323 | - )); |
|
321 | + $this->errors[ $plugin ] = array_keys( array_flip( |
|
322 | + array_merge( $this->errors[ $plugin ], [ $error ] ) |
|
323 | + ) ); |
|
324 | 324 | } |
325 | 325 | return $isValid; |
326 | 326 | } |
@@ -340,10 +340,10 @@ discard block |
||
340 | 340 | protected function getMustUsePlugins() |
341 | 341 | { |
342 | 342 | $plugins = get_mu_plugins(); |
343 | - if( in_array( 'Bedrock Autoloader', array_column( $plugins, 'Name' ))) { |
|
343 | + if( in_array( 'Bedrock Autoloader', array_column( $plugins, 'Name' ) ) ) { |
|
344 | 344 | $autoloadedPlugins = get_site_option( 'bedrock_autoloader' ); |
345 | - if( !empty( $autoloadedPlugins['plugins'] )) { |
|
346 | - return array_merge( $plugins, $autoloadedPlugins['plugins'] ); |
|
345 | + if( !empty( $autoloadedPlugins[ 'plugins' ] ) ) { |
|
346 | + return array_merge( $plugins, $autoloadedPlugins[ 'plugins' ] ); |
|
347 | 347 | } |
348 | 348 | } |
349 | 349 | return $plugins; |
@@ -354,8 +354,8 @@ discard block |
||
354 | 354 | */ |
355 | 355 | protected function getPlugin( $plugin ) |
356 | 356 | { |
357 | - if( $this->isPluginInstalled( $plugin )) { |
|
358 | - return $this->getAllPlugins()[$plugin]; |
|
357 | + if( $this->isPluginInstalled( $plugin ) ) { |
|
358 | + return $this->getAllPlugins()[ $plugin ]; |
|
359 | 359 | } |
360 | 360 | return false; |
361 | 361 | } |
@@ -365,15 +365,15 @@ discard block |
||
365 | 365 | */ |
366 | 366 | protected function getPluginData( $plugin, array $data, $key = null ) |
367 | 367 | { |
368 | - $data['plugin'] = $plugin; |
|
369 | - $data['slug'] = $this->getPluginSlug( $plugin ); |
|
368 | + $data[ 'plugin' ] = $plugin; |
|
369 | + $data[ 'slug' ] = $this->getPluginSlug( $plugin ); |
|
370 | 370 | $data = array_change_key_case( $data ); |
371 | - if( is_null( $key )) { |
|
371 | + if( is_null( $key ) ) { |
|
372 | 372 | return $data; |
373 | 373 | } |
374 | 374 | $key = strtolower( $key ); |
375 | - return isset( $data[$key] ) |
|
376 | - ? $data[$key] |
|
375 | + return isset( $data[ $key ] ) |
|
376 | + ? $data[ $key ] |
|
377 | 377 | : ''; |
378 | 378 | } |
379 | 379 | |
@@ -383,10 +383,10 @@ discard block |
||
383 | 383 | protected function getPluginInformation( $plugin, $key = null ) |
384 | 384 | { |
385 | 385 | $data = $this->getPlugin( $plugin ); |
386 | - if( is_array( $data )) { |
|
386 | + if( is_array( $data ) ) { |
|
387 | 387 | return $this->getPluginData( $plugin, $data, $key ); |
388 | 388 | } |
389 | - throw new Exception( sprintf( 'Plugin information not found for: %s', $plugin )); |
|
389 | + throw new Exception( sprintf( 'Plugin information not found for: %s', $plugin ) ); |
|
390 | 390 | } |
391 | 391 | |
392 | 392 | /** |
@@ -401,9 +401,9 @@ discard block |
||
401 | 401 | $data = $this->getPluginRequirements( $plugin ); |
402 | 402 | } |
403 | 403 | return sprintf( '<span class="plugin-%s"><a href="%s">%s</a></span>', |
404 | - $data['slug'], |
|
405 | - $data['pluginuri'], |
|
406 | - $data['name'] |
|
404 | + $data[ 'slug' ], |
|
405 | + $data[ 'pluginuri' ], |
|
406 | + $data[ 'name' ] |
|
407 | 407 | ); |
408 | 408 | } |
409 | 409 | |
@@ -412,10 +412,10 @@ discard block |
||
412 | 412 | */ |
413 | 413 | protected function getPluginRequirements( $plugin, $key = null ) |
414 | 414 | { |
415 | - $keys = ['Name', 'Version', 'PluginURI']; |
|
415 | + $keys = [ 'Name', 'Version', 'PluginURI' ]; |
|
416 | 416 | $index = array_search( $key, $keys, true ); |
417 | 417 | $requirements = $this->isPluginDependency( $plugin ) |
418 | - ? array_pad( explode( '|', static::DEPENDENCIES[$plugin] ), 3, '' ) |
|
418 | + ? array_pad( explode( '|', static::DEPENDENCIES[ $plugin ] ), 3, '' ) |
|
419 | 419 | : array_fill( 0, 3, '' ); |
420 | 420 | return $this->getPluginData( $plugin, array_combine( $keys, $requirements ), $key ); |
421 | 421 | } |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | */ |
426 | 426 | protected function getPluginSlug( $plugin ) |
427 | 427 | { |
428 | - return substr( $plugin, 0, strrpos( $plugin, '/' )); |
|
428 | + return substr( $plugin, 0, strrpos( $plugin, '/' ) ); |
|
429 | 429 | } |
430 | 430 | |
431 | 431 | /** |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | filter_input( INPUT_GET, 'plugin_status' ), |
438 | 438 | filter_input( INPUT_GET, 'paged' ), |
439 | 439 | filter_input( INPUT_GET, 's' ) |
440 | - ))); |
|
440 | + ) ) ); |
|
441 | 441 | exit; |
442 | 442 | } |
443 | 443 | } |
@@ -67,7 +67,9 @@ discard block |
||
67 | 67 | if( $screen->id != sprintf( 'settings_page_%s', $this->app->id ) |
68 | 68 | || $screen->pagenow != 'options-general.php' |
69 | 69 | || filter_input( INPUT_GET, 'action' ) != 'activate' |
70 | - )return; |
|
70 | + ) { |
|
71 | + return; |
|
72 | + } |
|
71 | 73 | $plugin = filter_input( INPUT_GET, 'plugin' ); |
72 | 74 | check_admin_referer( 'activate-plugin_' . $plugin ); |
73 | 75 | $result = activate_plugin( $plugin, null, is_network_admin(), true ); |
@@ -130,7 +132,9 @@ discard block |
||
130 | 132 | */ |
131 | 133 | public function getDependencyAction() |
132 | 134 | { |
133 | - if( get_current_screen()->id != 'settings_page_pollux' )return; |
|
135 | + if( get_current_screen()->id != 'settings_page_pollux' ) { |
|
136 | + return; |
|
137 | + } |
|
134 | 138 | |
135 | 139 | $action = filter_input( INPUT_GET, 'action' ); |
136 | 140 | $plugin = filter_input( INPUT_GET, 'plugin' ); |
@@ -245,7 +249,9 @@ discard block |
||
245 | 249 | public function hasPendingDependencies() |
246 | 250 | { |
247 | 251 | foreach( static::DEPENDENCIES as $plugin => $data ) { |
248 | - if( !$this->isPluginDependency( $plugin ))continue; |
|
252 | + if( !$this->isPluginDependency( $plugin )) { |
|
253 | + continue; |
|
254 | + } |
|
249 | 255 | $this->isPluginActive( $plugin ); |
250 | 256 | $this->isPluginVersionValid( $plugin ); |
251 | 257 | } |
@@ -260,7 +266,9 @@ discard block |
||
260 | 266 | if( get_current_screen()->id != 'settings_page_pollux' |
261 | 267 | || $this->app->config->disable_config |
262 | 268 | || !$this->hasPendingDependencies() |
263 | - )return; |
|
269 | + ) { |
|
270 | + return; |
|
271 | + } |
|
264 | 272 | |
265 | 273 | $plugins = ''; |
266 | 274 | $actions = ''; |