@@ -143,6 +143,7 @@ discard block |
||
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | /** |
| 146 | + * @param string $plugin |
|
| 146 | 147 | * @return bool |
| 147 | 148 | */ |
| 148 | 149 | public function hasDependency( $plugin ) |
@@ -304,7 +305,7 @@ discard block |
||
| 304 | 305 | |
| 305 | 306 | /** |
| 306 | 307 | * @param string $error |
| 307 | - * @param bool $bool |
|
| 308 | + * @param boolean $isValid |
|
| 308 | 309 | * @return bool |
| 309 | 310 | */ |
| 310 | 311 | protected function catchError( $plugin, $error, $isValid ) |
@@ -403,6 +404,7 @@ discard block |
||
| 403 | 404 | } |
| 404 | 405 | |
| 405 | 406 | /** |
| 407 | + * @param string $key |
|
| 406 | 408 | * @return array|string |
| 407 | 409 | */ |
| 408 | 410 | protected function getPluginRequirements( $plugin, $key = null ) |
@@ -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 | )return; |
| 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,14 +85,14 @@ 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 | - $actionUrl = self_admin_url( sprintf( 'options-general.php?page=%s&action=activate&plugin=%s', $this->app->id, $plugin )); |
|
| 92 | - wp_send_json_success([ |
|
| 93 | - 'activate_url' => wp_nonce_url( $actionUrl, sprintf( 'activate-plugin_%s', $plugin )), |
|
| 91 | + $actionUrl = self_admin_url( sprintf( 'options-general.php?page=%s&action=activate&plugin=%s', $this->app->id, $plugin ) ); |
|
| 92 | + wp_send_json_success( [ |
|
| 93 | + 'activate_url' => wp_nonce_url( $actionUrl, sprintf( 'activate-plugin_%s', $plugin ) ), |
|
| 94 | 94 | filter_input( INPUT_POST, 'type' ) => $plugin, |
| 95 | - ]); |
|
| 95 | + ] ); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
@@ -136,8 +136,8 @@ discard block |
||
| 136 | 136 | else if( $action == 'install' ) { |
| 137 | 137 | $this->installPlugin( $plugin ); |
| 138 | 138 | } |
| 139 | - else if( filter_input( INPUT_GET, '_error_nonce' )) { |
|
| 140 | - wp_safe_redirect( remove_query_arg( '_error_nonce' )); |
|
| 139 | + else if( filter_input( INPUT_GET, '_error_nonce' ) ) { |
|
| 140 | + wp_safe_redirect( remove_query_arg( '_error_nonce' ) ); |
|
| 141 | 141 | exit; |
| 142 | 142 | } |
| 143 | 143 | } |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | */ |
| 148 | 148 | public function hasDependency( $plugin ) |
| 149 | 149 | { |
| 150 | - if( !$this->isPluginDependency( $plugin )) { |
|
| 150 | + if( !$this->isPluginDependency( $plugin ) ) { |
|
| 151 | 151 | return true; |
| 152 | 152 | } |
| 153 | 153 | return $this->isPluginInstalled( $plugin ) && $this->isPluginValid( $plugin ); |
@@ -211,17 +211,17 @@ discard block |
||
| 211 | 211 | */ |
| 212 | 212 | public function isPluginVersionValid( $plugin ) |
| 213 | 213 | { |
| 214 | - if( !$this->isPluginDependency( $plugin )) { |
|
| 214 | + if( !$this->isPluginDependency( $plugin ) ) { |
|
| 215 | 215 | return true; |
| 216 | 216 | } |
| 217 | - if( !$this->isPluginInstalled( $plugin )) { |
|
| 217 | + if( !$this->isPluginInstalled( $plugin ) ) { |
|
| 218 | 218 | return false; |
| 219 | 219 | } |
| 220 | 220 | return $this->catchError( $plugin, 'wrong_version', version_compare( |
| 221 | 221 | $this->getPluginRequirements( $plugin, 'version' ), |
| 222 | - $this->getAllPlugins()[$plugin]['Version'], |
|
| 222 | + $this->getAllPlugins()[ $plugin ][ 'Version' ], |
|
| 223 | 223 | '<=' |
| 224 | - )); |
|
| 224 | + ) ); |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | /** |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | public function hasPendingDependencies() |
| 241 | 241 | { |
| 242 | 242 | foreach( static::DEPENDENCIES as $plugin => $data ) { |
| 243 | - if( !$this->isPluginDependency( $plugin ))continue; |
|
| 243 | + if( !$this->isPluginDependency( $plugin ) )continue; |
|
| 244 | 244 | $this->isPluginActive( $plugin ); |
| 245 | 245 | $this->isPluginVersionValid( $plugin ); |
| 246 | 246 | } |
@@ -262,20 +262,20 @@ discard block |
||
| 262 | 262 | |
| 263 | 263 | foreach( $this->errors as $plugin => $errors ) { |
| 264 | 264 | $plugins .= $this->getPluginLink( $plugin ); |
| 265 | - if( in_array( 'not_found', $errors ) && current_user_can( 'install_plugins' )) { |
|
| 266 | - $actions .= $this->notice->installButton( $this->getPluginRequirements( $plugin )); |
|
| 265 | + if( in_array( 'not_found', $errors ) && current_user_can( 'install_plugins' ) ) { |
|
| 266 | + $actions .= $this->notice->installButton( $this->getPluginRequirements( $plugin ) ); |
|
| 267 | 267 | } |
| 268 | - else if( in_array( 'wrong_version', $errors ) && current_user_can( 'update_plugins' )) { |
|
| 269 | - $actions .= $this->notice->updateButton( $this->getPluginInformation( $plugin )); |
|
| 268 | + else if( in_array( 'wrong_version', $errors ) && current_user_can( 'update_plugins' ) ) { |
|
| 269 | + $actions .= $this->notice->updateButton( $this->getPluginInformation( $plugin ) ); |
|
| 270 | 270 | } |
| 271 | - else if( in_array( 'inactive', $errors ) && current_user_can( 'activate_plugins' )) { |
|
| 272 | - $actions .= $this->notice->activateButton( $this->getPluginInformation( $plugin )); |
|
| 271 | + else if( in_array( 'inactive', $errors ) && current_user_can( 'activate_plugins' ) ) { |
|
| 272 | + $actions .= $this->notice->activateButton( $this->getPluginInformation( $plugin ) ); |
|
| 273 | 273 | } |
| 274 | 274 | } |
| 275 | - $this->notice->addWarning([ |
|
| 275 | + $this->notice->addWarning( [ |
|
| 276 | 276 | sprintf( '<strong>%s</strong> %s', __( 'Pollux requires the latest version of the following plugins:', 'pollux' ), $plugins ), |
| 277 | 277 | $actions, |
| 278 | - ]); |
|
| 278 | + ] ); |
|
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | /** |
@@ -283,11 +283,11 @@ discard block |
||
| 283 | 283 | */ |
| 284 | 284 | protected function addInvalidPHPVersionNotice() |
| 285 | 285 | { |
| 286 | - $this->notice->addError([ |
|
| 287 | - $this->notice->title( __( 'The Pollux plugin was deactivated.', 'pollux' )), |
|
| 286 | + $this->notice->addError( [ |
|
| 287 | + $this->notice->title( __( 'The Pollux plugin was deactivated.', 'pollux' ) ), |
|
| 288 | 288 | 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 ), |
| 289 | 289 | __( 'Please contact your hosting provider or server administrator to upgrade the version of PHP running on your server, or find an alternate plugin.', 'pollux' ), |
| 290 | - ]); |
|
| 290 | + ] ); |
|
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | /** |
@@ -295,11 +295,11 @@ discard block |
||
| 295 | 295 | */ |
| 296 | 296 | protected function addInvalidWPVersionNotice() |
| 297 | 297 | { |
| 298 | - $this->notice->addError([ |
|
| 299 | - $this->notice->title( __( 'The Pollux plugin was deactivated.', 'pollux' )), |
|
| 298 | + $this->notice->addError( [ |
|
| 299 | + $this->notice->title( __( 'The Pollux plugin was deactivated.', 'pollux' ) ), |
|
| 300 | 300 | sprintf( __( 'Sorry, Pollux requires WordPress %s or greater in order to work properly.', 'pollux' ), self::MIN_WORDPRESS_VERSION ), |
| 301 | - $this->notice->button( __( 'Update WordPress', 'pollux' ), self_admin_url( 'update-core.php' )), |
|
| 302 | - ]); |
|
| 301 | + $this->notice->button( __( 'Update WordPress', 'pollux' ), self_admin_url( 'update-core.php' ) ), |
|
| 302 | + ] ); |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | /** |
@@ -310,12 +310,12 @@ discard block |
||
| 310 | 310 | protected function catchError( $plugin, $error, $isValid ) |
| 311 | 311 | { |
| 312 | 312 | if( !$isValid ) { |
| 313 | - if( !isset( $this->errors[$plugin] )) { |
|
| 314 | - $this->errors[$plugin] = []; |
|
| 313 | + if( !isset( $this->errors[ $plugin ] ) ) { |
|
| 314 | + $this->errors[ $plugin ] = [ ]; |
|
| 315 | 315 | } |
| 316 | - $this->errors[$plugin] = array_keys( array_flip( |
|
| 317 | - array_merge( $this->errors[$plugin], [$error] ) |
|
| 318 | - )); |
|
| 316 | + $this->errors[ $plugin ] = array_keys( array_flip( |
|
| 317 | + array_merge( $this->errors[ $plugin ], [ $error ] ) |
|
| 318 | + ) ); |
|
| 319 | 319 | } |
| 320 | 320 | return $isValid; |
| 321 | 321 | } |
@@ -335,10 +335,10 @@ discard block |
||
| 335 | 335 | protected function getMustUsePlugins() |
| 336 | 336 | { |
| 337 | 337 | $plugins = get_mu_plugins(); |
| 338 | - if( in_array( 'Bedrock Autoloader', array_column( $plugins, 'Name' ))) { |
|
| 338 | + if( in_array( 'Bedrock Autoloader', array_column( $plugins, 'Name' ) ) ) { |
|
| 339 | 339 | $autoloadedPlugins = get_site_option( 'bedrock_autoloader' ); |
| 340 | - if( !empty( $autoloadedPlugins['plugins'] )) { |
|
| 341 | - return array_merge( $plugins, $autoloadedPlugins['plugins'] ); |
|
| 340 | + if( !empty( $autoloadedPlugins[ 'plugins' ] ) ) { |
|
| 341 | + return array_merge( $plugins, $autoloadedPlugins[ 'plugins' ] ); |
|
| 342 | 342 | } |
| 343 | 343 | } |
| 344 | 344 | return $plugins; |
@@ -349,8 +349,8 @@ discard block |
||
| 349 | 349 | */ |
| 350 | 350 | protected function getPlugin( $plugin ) |
| 351 | 351 | { |
| 352 | - if( $this->isPluginInstalled( $plugin )) { |
|
| 353 | - return $this->getAllPlugins()[$plugin]; |
|
| 352 | + if( $this->isPluginInstalled( $plugin ) ) { |
|
| 353 | + return $this->getAllPlugins()[ $plugin ]; |
|
| 354 | 354 | } |
| 355 | 355 | return false; |
| 356 | 356 | } |
@@ -360,15 +360,15 @@ discard block |
||
| 360 | 360 | */ |
| 361 | 361 | protected function getPluginData( $plugin, array $data, $key = null ) |
| 362 | 362 | { |
| 363 | - $data['plugin'] = $plugin; |
|
| 364 | - $data['slug'] = $this->getPluginSlug( $plugin ); |
|
| 363 | + $data[ 'plugin' ] = $plugin; |
|
| 364 | + $data[ 'slug' ] = $this->getPluginSlug( $plugin ); |
|
| 365 | 365 | $data = array_change_key_case( $data ); |
| 366 | - if( is_null( $key )) { |
|
| 366 | + if( is_null( $key ) ) { |
|
| 367 | 367 | return $data; |
| 368 | 368 | } |
| 369 | 369 | $key = strtolower( $key ); |
| 370 | - return isset( $data[$key] ) |
|
| 371 | - ? $data[$key] |
|
| 370 | + return isset( $data[ $key ] ) |
|
| 371 | + ? $data[ $key ] |
|
| 372 | 372 | : ''; |
| 373 | 373 | } |
| 374 | 374 | |
@@ -378,10 +378,10 @@ discard block |
||
| 378 | 378 | protected function getPluginInformation( $plugin, $key = null ) |
| 379 | 379 | { |
| 380 | 380 | $data = $this->getPlugin( $plugin ); |
| 381 | - if( is_array( $data )) { |
|
| 381 | + if( is_array( $data ) ) { |
|
| 382 | 382 | return $this->getPluginData( $plugin, $data, $key ); |
| 383 | 383 | } |
| 384 | - throw new Exception( sprintf( 'Plugin information not found for: %s', $plugin )); |
|
| 384 | + throw new Exception( sprintf( 'Plugin information not found for: %s', $plugin ) ); |
|
| 385 | 385 | } |
| 386 | 386 | |
| 387 | 387 | /** |
@@ -396,9 +396,9 @@ discard block |
||
| 396 | 396 | $data = $this->getPluginRequirements( $plugin ); |
| 397 | 397 | } |
| 398 | 398 | return sprintf( '<span class="plugin-%s"><a href="%s">%s</a></span>', |
| 399 | - $data['slug'], |
|
| 400 | - $data['pluginuri'], |
|
| 401 | - $data['name'] |
|
| 399 | + $data[ 'slug' ], |
|
| 400 | + $data[ 'pluginuri' ], |
|
| 401 | + $data[ 'name' ] |
|
| 402 | 402 | ); |
| 403 | 403 | } |
| 404 | 404 | |
@@ -407,10 +407,10 @@ discard block |
||
| 407 | 407 | */ |
| 408 | 408 | protected function getPluginRequirements( $plugin, $key = null ) |
| 409 | 409 | { |
| 410 | - $keys = ['Name', 'Version', 'PluginURI']; |
|
| 410 | + $keys = [ 'Name', 'Version', 'PluginURI' ]; |
|
| 411 | 411 | $index = array_search( $key, $keys, true ); |
| 412 | 412 | $requirements = $this->isPluginDependency( $plugin ) |
| 413 | - ? array_pad( explode( '|', static::DEPENDENCIES[$plugin] ), 3, '' ) |
|
| 413 | + ? array_pad( explode( '|', static::DEPENDENCIES[ $plugin ] ), 3, '' ) |
|
| 414 | 414 | : array_fill( 0, 3, '' ); |
| 415 | 415 | return $this->getPluginData( $plugin, array_combine( $keys, $requirements ), $key ); |
| 416 | 416 | } |
@@ -420,7 +420,7 @@ discard block |
||
| 420 | 420 | */ |
| 421 | 421 | protected function getPluginSlug( $plugin ) |
| 422 | 422 | { |
| 423 | - return substr( $plugin, 0, strrpos( $plugin, '/' )); |
|
| 423 | + return substr( $plugin, 0, strrpos( $plugin, '/' ) ); |
|
| 424 | 424 | } |
| 425 | 425 | |
| 426 | 426 | /** |
@@ -432,7 +432,7 @@ discard block |
||
| 432 | 432 | filter_input( INPUT_GET, 'plugin_status' ), |
| 433 | 433 | filter_input( INPUT_GET, 'paged' ), |
| 434 | 434 | filter_input( INPUT_GET, 's' ) |
| 435 | - ))); |
|
| 435 | + ) ) ); |
|
| 436 | 436 | exit; |
| 437 | 437 | } |
| 438 | 438 | } |
@@ -68,7 +68,9 @@ discard block |
||
| 68 | 68 | if( $screen->id != 'settings_page_pollux' |
| 69 | 69 | || $screen->pagenow != 'options-general.php' |
| 70 | 70 | || filter_input( INPUT_GET, 'action' ) != 'activate' |
| 71 | - )return; |
|
| 71 | + ) { |
|
| 72 | + return; |
|
| 73 | + } |
|
| 72 | 74 | check_admin_referer( 'activate-plugin_' . $plugin ); |
| 73 | 75 | $result = activate_plugin( $plugin, null, is_network_admin(), true ); |
| 74 | 76 | if( is_wp_error( $result )) { |
@@ -125,7 +127,9 @@ discard block |
||
| 125 | 127 | */ |
| 126 | 128 | public function getDependencyAction() |
| 127 | 129 | { |
| 128 | - if( get_current_screen()->id != 'settings_page_pollux' )return; |
|
| 130 | + if( get_current_screen()->id != 'settings_page_pollux' ) { |
|
| 131 | + return; |
|
| 132 | + } |
|
| 129 | 133 | |
| 130 | 134 | $action = filter_input( INPUT_GET, 'action' ); |
| 131 | 135 | $plugin = filter_input( INPUT_GET, 'plugin' ); |
@@ -240,7 +244,9 @@ discard block |
||
| 240 | 244 | public function hasPendingDependencies() |
| 241 | 245 | { |
| 242 | 246 | foreach( static::DEPENDENCIES as $plugin => $data ) { |
| 243 | - if( !$this->isPluginDependency( $plugin ))continue; |
|
| 247 | + if( !$this->isPluginDependency( $plugin )) { |
|
| 248 | + continue; |
|
| 249 | + } |
|
| 244 | 250 | $this->isPluginActive( $plugin ); |
| 245 | 251 | $this->isPluginVersionValid( $plugin ); |
| 246 | 252 | } |
@@ -255,7 +261,9 @@ discard block |
||
| 255 | 261 | if( get_current_screen()->id != 'settings_page_pollux' |
| 256 | 262 | || $this->app->config->disable_config |
| 257 | 263 | || !$this->hasPendingDependencies() |
| 258 | - )return; |
|
| 264 | + ) { |
|
| 265 | + return; |
|
| 266 | + } |
|
| 259 | 267 | |
| 260 | 268 | $plugins = ''; |
| 261 | 269 | $actions = ''; |
@@ -28,10 +28,10 @@ discard block |
||
| 28 | 28 | { |
| 29 | 29 | $method = strtolower( $name ); |
| 30 | 30 | $status = substr( $method, 3 ); |
| 31 | - if( 'add' == substr( $method, 0, 3 ) && in_array( $status, ['error', 'info', 'success', 'warning'] )) { |
|
| 32 | - return call_user_func_array( [$this, 'addNotice'], array_merge( [$status], $args )); |
|
| 31 | + if( 'add' == substr( $method, 0, 3 ) && in_array( $status, [ 'error', 'info', 'success', 'warning' ] ) ) { |
|
| 32 | + return call_user_func_array( [ $this, 'addNotice' ], array_merge( [ $status ], $args ) ); |
|
| 33 | 33 | } |
| 34 | - throw new BadMethodCallException( sprintf( 'Not a valid method: %s', $name )); |
|
| 34 | + throw new BadMethodCallException( sprintf( 'Not a valid method: %s', $name ) ); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | /** |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | if( $property == 'all' ) { |
| 43 | 43 | return $this->app->notices; |
| 44 | 44 | } |
| 45 | - throw new Exception( sprintf( 'Not a valid property: %s', $property )); |
|
| 45 | + throw new Exception( sprintf( 'Not a valid property: %s', $property ) ); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -50,13 +50,13 @@ discard block |
||
| 50 | 50 | */ |
| 51 | 51 | public function activateButton( array $plugin ) |
| 52 | 52 | { |
| 53 | - $actionUrl = self_admin_url( sprintf( 'options-general.php?page=%s&action=activate&plugin=%s', $this->app->id, $plugin['plugin'] )); |
|
| 54 | - return $this->button( sprintf( '%s %s', __( 'Activate', 'pollux' ), $plugin['name'] ), [ |
|
| 55 | - 'data-name' => $plugin['name'], |
|
| 56 | - 'data-plugin' => $plugin['plugin'], |
|
| 57 | - 'data-slug' => $plugin['slug'], |
|
| 58 | - 'href' => wp_nonce_url( $actionUrl, sprintf( 'activate-plugin_%s', $plugin['plugin'] )), |
|
| 59 | - ]); |
|
| 53 | + $actionUrl = self_admin_url( sprintf( 'options-general.php?page=%s&action=activate&plugin=%s', $this->app->id, $plugin[ 'plugin' ] ) ); |
|
| 54 | + return $this->button( sprintf( '%s %s', __( 'Activate', 'pollux' ), $plugin[ 'name' ] ), [ |
|
| 55 | + 'data-name' => $plugin[ 'name' ], |
|
| 56 | + 'data-plugin' => $plugin[ 'plugin' ], |
|
| 57 | + 'data-slug' => $plugin[ 'slug' ], |
|
| 58 | + 'href' => wp_nonce_url( $actionUrl, sprintf( 'activate-plugin_%s', $plugin[ 'plugin' ] ) ), |
|
| 59 | + ] ); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** |
@@ -65,15 +65,15 @@ discard block |
||
| 65 | 65 | * @param string $attributes |
| 66 | 66 | * @return string |
| 67 | 67 | */ |
| 68 | - public function button( $title, array $atts = [] ) |
|
| 68 | + public function button( $title, array $atts = [ ] ) |
|
| 69 | 69 | { |
| 70 | 70 | $atts = wp_parse_args( $atts, [ |
| 71 | 71 | 'class' => '', |
| 72 | 72 | 'href' => '', |
| 73 | - ]); |
|
| 74 | - $atts['class'] = trim( $atts['class'] . ' button button-small' ); |
|
| 73 | + ] ); |
|
| 74 | + $atts[ 'class' ] = trim( $atts[ 'class' ] . ' button button-small' ); |
|
| 75 | 75 | $attributes = array_reduce( array_keys( $atts ), function( $carry, $key ) use( $atts ) { |
| 76 | - return $carry . sprintf( ' %s="%s"', $key, $atts[$key] ); |
|
| 76 | + return $carry . sprintf( ' %s="%s"', $key, $atts[ $key ] ); |
|
| 77 | 77 | }); |
| 78 | 78 | return sprintf( '<a%s>%s</a>', $attributes, $title ); |
| 79 | 79 | } |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | if( $unset ) { |
| 87 | 87 | $index = array_search( $notice, $this->app->notices ); |
| 88 | 88 | if( $index !== false ) { |
| 89 | - unset( $this->app->notices[$index] ); |
|
| 89 | + unset( $this->app->notices[ $index ] ); |
|
| 90 | 90 | } |
| 91 | 91 | } |
| 92 | 92 | return $this->buildNotice( $notice ); |
@@ -97,13 +97,13 @@ discard block |
||
| 97 | 97 | */ |
| 98 | 98 | public function installButton( array $plugin ) |
| 99 | 99 | { |
| 100 | - $actionUrl = self_admin_url( sprintf( 'update.php?action=install-plugin&plugin=%s', $plugin['slug'] )); |
|
| 101 | - return $this->button( sprintf( '%s %s', __( 'Install', 'pollux' ), $plugin['name'] ), [ |
|
| 102 | - 'data-name' => $plugin['name'], |
|
| 103 | - 'data-plugin' => $plugin['plugin'], |
|
| 104 | - 'data-slug' => $plugin['slug'], |
|
| 105 | - 'href' => wp_nonce_url( $actionUrl, sprintf( 'install-plugin_%s', $plugin['slug'] )), |
|
| 106 | - ]); |
|
| 100 | + $actionUrl = self_admin_url( sprintf( 'update.php?action=install-plugin&plugin=%s', $plugin[ 'slug' ] ) ); |
|
| 101 | + return $this->button( sprintf( '%s %s', __( 'Install', 'pollux' ), $plugin[ 'name' ] ), [ |
|
| 102 | + 'data-name' => $plugin[ 'name' ], |
|
| 103 | + 'data-plugin' => $plugin[ 'plugin' ], |
|
| 104 | + 'data-slug' => $plugin[ 'slug' ], |
|
| 105 | + 'href' => wp_nonce_url( $actionUrl, sprintf( 'install-plugin_%s', $plugin[ 'slug' ] ) ), |
|
| 106 | + ] ); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | /** |
@@ -111,13 +111,13 @@ discard block |
||
| 111 | 111 | */ |
| 112 | 112 | public function updateButton( array $plugin ) |
| 113 | 113 | { |
| 114 | - $actionUrl = self_admin_url( sprintf( 'update.php?action=upgrade-plugin&plugin=%s', $plugin['plugin'] )); |
|
| 115 | - return $this->button( sprintf( '%s %s', __( 'Update', 'pollux' ), $plugin['name'] ), [ |
|
| 116 | - 'data-name' => $plugin['name'], |
|
| 117 | - 'data-plugin' => $plugin['plugin'], |
|
| 118 | - 'data-slug' => $plugin['slug'], |
|
| 119 | - 'href' => wp_nonce_url( $actionUrl, sprintf( 'upgrade-plugin_%s', $plugin['plugin'] )), |
|
| 120 | - ]); |
|
| 114 | + $actionUrl = self_admin_url( sprintf( 'update.php?action=upgrade-plugin&plugin=%s', $plugin[ 'plugin' ] ) ); |
|
| 115 | + return $this->button( sprintf( '%s %s', __( 'Update', 'pollux' ), $plugin[ 'name' ] ), [ |
|
| 116 | + 'data-name' => $plugin[ 'name' ], |
|
| 117 | + 'data-plugin' => $plugin[ 'plugin' ], |
|
| 118 | + 'data-slug' => $plugin[ 'slug' ], |
|
| 119 | + 'href' => wp_nonce_url( $actionUrl, sprintf( 'upgrade-plugin_%s', $plugin[ 'plugin' ] ) ), |
|
| 120 | + ] ); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | /** |
@@ -137,9 +137,9 @@ discard block |
||
| 137 | 137 | */ |
| 138 | 138 | protected function addNotice( $type, $messages, $dismissible = true ) |
| 139 | 139 | { |
| 140 | - $this->app->notices[] = [ |
|
| 140 | + $this->app->notices[ ] = [ |
|
| 141 | 141 | 'dismissible' => $dismissible, |
| 142 | - 'message' => $this->buildMessage( array_filter( (array) $messages )), |
|
| 142 | + 'message' => $this->buildMessage( array_filter( (array) $messages ) ), |
|
| 143 | 143 | 'type' => $type, |
| 144 | 144 | ]; |
| 145 | 145 | $this->app->notices = array_unique( $this->app->notices, SORT_REGULAR ); |
@@ -151,10 +151,10 @@ discard block |
||
| 151 | 151 | protected function buildMessage( array $messages ) |
| 152 | 152 | { |
| 153 | 153 | foreach( $messages as $key => &$message ) { |
| 154 | - if( !is_wp_error( $message ))continue; |
|
| 154 | + if( !is_wp_error( $message ) )continue; |
|
| 155 | 155 | $message = $message->get_error_message(); |
| 156 | 156 | } |
| 157 | - return wpautop( implode( PHP_EOL . PHP_EOL, $messages )); |
|
| 157 | + return wpautop( implode( PHP_EOL . PHP_EOL, $messages ) ); |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | /** |
@@ -162,10 +162,10 @@ discard block |
||
| 162 | 162 | */ |
| 163 | 163 | protected function buildNotice( array $notice ) |
| 164 | 164 | { |
| 165 | - $class = sprintf( 'notice notice-%s', $notice['type'] ); |
|
| 166 | - if( $notice['dismissible'] ) { |
|
| 165 | + $class = sprintf( 'notice notice-%s', $notice[ 'type' ] ); |
|
| 166 | + if( $notice[ 'dismissible' ] ) { |
|
| 167 | 167 | $class .= ' is-dismissible'; |
| 168 | 168 | } |
| 169 | - return sprintf( '<div class="pollux-notice %s">%s</div>', $class, $notice['message'] ); |
|
| 169 | + return sprintf( '<div class="pollux-notice %s">%s</div>', $class, $notice[ 'message' ] ); |
|
| 170 | 170 | } |
| 171 | 171 | } |