@@ -124,6 +124,7 @@ discard block |
||
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
127 | + * @param string $plugin |
|
127 | 128 | * @return bool |
128 | 129 | */ |
129 | 130 | public function hasDependency( $plugin ) |
@@ -384,6 +385,7 @@ discard block |
||
384 | 385 | } |
385 | 386 | |
386 | 387 | /** |
388 | + * @param string $key |
|
387 | 389 | * @return array|string |
388 | 390 | */ |
389 | 391 | 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 | /** |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | $plugin = filter_input( INPUT_GET, 'plugin' ); |
70 | 70 | check_admin_referer( 'activate-plugin_' . $plugin ); |
71 | 71 | $result = activate_plugin( $plugin, null, is_network_admin(), true ); |
72 | - if( is_wp_error( $result )) { |
|
72 | + if( is_wp_error( $result ) ) { |
|
73 | 73 | wp_die( $result->get_error_message() ); |
74 | 74 | } |
75 | 75 | wp_safe_redirect( wp_get_referer() ); |
@@ -83,19 +83,19 @@ discard block |
||
83 | 83 | { |
84 | 84 | check_ajax_referer( 'updates' ); |
85 | 85 | $plugin = filter_input( INPUT_POST, 'plugin' ); |
86 | - if( !$this->isPluginDependency( $plugin )) { |
|
86 | + if( !$this->isPluginDependency( $plugin ) ) { |
|
87 | 87 | wp_send_json_error(); |
88 | 88 | } |
89 | - $activateUrl = add_query_arg([ |
|
90 | - '_wpnonce' => wp_create_nonce( sprintf( 'activate-plugin_%s', $plugin )), |
|
89 | + $activateUrl = add_query_arg( [ |
|
90 | + '_wpnonce' => wp_create_nonce( sprintf( 'activate-plugin_%s', $plugin ) ), |
|
91 | 91 | 'action' => 'activate', |
92 | 92 | 'page' => $this->app->id, |
93 | 93 | 'plugin' => $plugin, |
94 | - ], self_admin_url( 'options-general.php' )); |
|
95 | - wp_send_json_success([ |
|
94 | + ], self_admin_url( 'options-general.php' ) ); |
|
95 | + wp_send_json_success( [ |
|
96 | 96 | 'activate_url' => $activateUrl, |
97 | 97 | filter_input( INPUT_POST, 'type' ) => $plugin, |
98 | - ]); |
|
98 | + ] ); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | */ |
129 | 129 | public function hasDependency( $plugin ) |
130 | 130 | { |
131 | - if( !$this->isPluginDependency( $plugin )) { |
|
131 | + if( !$this->isPluginDependency( $plugin ) ) { |
|
132 | 132 | return true; |
133 | 133 | } |
134 | 134 | return $this->isPluginInstalled( $plugin ) && $this->isPluginValid( $plugin ); |
@@ -192,17 +192,17 @@ discard block |
||
192 | 192 | */ |
193 | 193 | public function isPluginVersionValid( $plugin ) |
194 | 194 | { |
195 | - if( !$this->isPluginDependency( $plugin )) { |
|
195 | + if( !$this->isPluginDependency( $plugin ) ) { |
|
196 | 196 | return true; |
197 | 197 | } |
198 | - if( !$this->isPluginInstalled( $plugin )) { |
|
198 | + if( !$this->isPluginInstalled( $plugin ) ) { |
|
199 | 199 | return false; |
200 | 200 | } |
201 | 201 | return $this->catchError( $plugin, 'wrong_version', version_compare( |
202 | 202 | $this->getPluginRequirements( $plugin, 'version' ), |
203 | - $this->getAllPlugins()[$plugin]['Version'], |
|
203 | + $this->getAllPlugins()[ $plugin ][ 'Version' ], |
|
204 | 204 | '<=' |
205 | - )); |
|
205 | + ) ); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | /** |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | public function hasPendingDependencies() |
222 | 222 | { |
223 | 223 | foreach( static::DEPENDENCIES as $plugin => $data ) { |
224 | - if( !$this->isPluginDependency( $plugin ))continue; |
|
224 | + if( !$this->isPluginDependency( $plugin ) )continue; |
|
225 | 225 | $this->isPluginActive( $plugin ); |
226 | 226 | $this->isPluginVersionValid( $plugin ); |
227 | 227 | } |
@@ -243,20 +243,20 @@ discard block |
||
243 | 243 | |
244 | 244 | foreach( $this->errors as $plugin => $errors ) { |
245 | 245 | $plugins .= $this->getPluginLink( $plugin ); |
246 | - if( in_array( 'not_found', $errors ) && current_user_can( 'install_plugins' )) { |
|
247 | - $actions .= $this->notice->installButton( $this->getPluginRequirements( $plugin )); |
|
246 | + if( in_array( 'not_found', $errors ) && current_user_can( 'install_plugins' ) ) { |
|
247 | + $actions .= $this->notice->installButton( $this->getPluginRequirements( $plugin ) ); |
|
248 | 248 | } |
249 | - else if( in_array( 'wrong_version', $errors ) && current_user_can( 'update_plugins' )) { |
|
250 | - $actions .= $this->notice->updateButton( $this->getPluginInformation( $plugin )); |
|
249 | + else if( in_array( 'wrong_version', $errors ) && current_user_can( 'update_plugins' ) ) { |
|
250 | + $actions .= $this->notice->updateButton( $this->getPluginInformation( $plugin ) ); |
|
251 | 251 | } |
252 | - else if( in_array( 'inactive', $errors ) && current_user_can( 'activate_plugins' )) { |
|
253 | - $actions .= $this->notice->activateButton( $this->getPluginInformation( $plugin )); |
|
252 | + else if( in_array( 'inactive', $errors ) && current_user_can( 'activate_plugins' ) ) { |
|
253 | + $actions .= $this->notice->activateButton( $this->getPluginInformation( $plugin ) ); |
|
254 | 254 | } |
255 | 255 | } |
256 | - $this->notice->addWarning([ |
|
256 | + $this->notice->addWarning( [ |
|
257 | 257 | sprintf( '<strong>%s</strong> %s', __( 'Pollux requires the latest version of the following plugins:', 'pollux' ), $plugins ), |
258 | 258 | $actions, |
259 | - ]); |
|
259 | + ] ); |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | /** |
@@ -264,11 +264,11 @@ discard block |
||
264 | 264 | */ |
265 | 265 | protected function addInvalidPHPVersionNotice() |
266 | 266 | { |
267 | - $this->notice->addError([ |
|
268 | - $this->notice->title( __( 'The Pollux plugin was deactivated.', 'pollux' )), |
|
267 | + $this->notice->addError( [ |
|
268 | + $this->notice->title( __( 'The Pollux plugin was deactivated.', 'pollux' ) ), |
|
269 | 269 | 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 ), |
270 | 270 | __( 'Please contact your hosting provider or server administrator to upgrade the version of PHP running on your server, or find an alternate plugin.', 'pollux' ), |
271 | - ]); |
|
271 | + ] ); |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | /** |
@@ -276,11 +276,11 @@ discard block |
||
276 | 276 | */ |
277 | 277 | protected function addInvalidWPVersionNotice() |
278 | 278 | { |
279 | - $this->notice->addError([ |
|
280 | - $this->notice->title( __( 'The Pollux plugin was deactivated.', 'pollux' )), |
|
279 | + $this->notice->addError( [ |
|
280 | + $this->notice->title( __( 'The Pollux plugin was deactivated.', 'pollux' ) ), |
|
281 | 281 | sprintf( __( 'Sorry, Pollux requires WordPress %s or greater in order to work properly.', 'pollux' ), self::MIN_WORDPRESS_VERSION ), |
282 | - $this->notice->button( __( 'Update WordPress', 'pollux' ), self_admin_url( 'update-core.php' )), |
|
283 | - ]); |
|
282 | + $this->notice->button( __( 'Update WordPress', 'pollux' ), self_admin_url( 'update-core.php' ) ), |
|
283 | + ] ); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | /** |
@@ -292,12 +292,12 @@ discard block |
||
292 | 292 | protected function catchError( $plugin, $error, $isValid ) |
293 | 293 | { |
294 | 294 | if( !$isValid ) { |
295 | - if( !isset( $this->errors[$plugin] )) { |
|
296 | - $this->errors[$plugin] = []; |
|
295 | + if( !isset( $this->errors[ $plugin ] ) ) { |
|
296 | + $this->errors[ $plugin ] = [ ]; |
|
297 | 297 | } |
298 | - $this->errors[$plugin] = array_keys( array_flip( |
|
299 | - array_merge( $this->errors[$plugin], [$error] ) |
|
300 | - )); |
|
298 | + $this->errors[ $plugin ] = array_keys( array_flip( |
|
299 | + array_merge( $this->errors[ $plugin ], [ $error ] ) |
|
300 | + ) ); |
|
301 | 301 | } |
302 | 302 | return $isValid; |
303 | 303 | } |
@@ -317,10 +317,10 @@ discard block |
||
317 | 317 | protected function getMustUsePlugins() |
318 | 318 | { |
319 | 319 | $plugins = get_mu_plugins(); |
320 | - if( in_array( 'Bedrock Autoloader', array_column( $plugins, 'Name' ))) { |
|
320 | + if( in_array( 'Bedrock Autoloader', array_column( $plugins, 'Name' ) ) ) { |
|
321 | 321 | $autoloadedPlugins = get_site_option( 'bedrock_autoloader' ); |
322 | - if( !empty( $autoloadedPlugins['plugins'] )) { |
|
323 | - return array_merge( $plugins, $autoloadedPlugins['plugins'] ); |
|
322 | + if( !empty( $autoloadedPlugins[ 'plugins' ] ) ) { |
|
323 | + return array_merge( $plugins, $autoloadedPlugins[ 'plugins' ] ); |
|
324 | 324 | } |
325 | 325 | } |
326 | 326 | return $plugins; |
@@ -331,8 +331,8 @@ discard block |
||
331 | 331 | */ |
332 | 332 | protected function getPlugin( $plugin ) |
333 | 333 | { |
334 | - if( $this->isPluginInstalled( $plugin )) { |
|
335 | - return $this->getAllPlugins()[$plugin]; |
|
334 | + if( $this->isPluginInstalled( $plugin ) ) { |
|
335 | + return $this->getAllPlugins()[ $plugin ]; |
|
336 | 336 | } |
337 | 337 | return false; |
338 | 338 | } |
@@ -342,18 +342,18 @@ discard block |
||
342 | 342 | */ |
343 | 343 | protected function getPluginData( $plugin, $data, $key = null ) |
344 | 344 | { |
345 | - if( !is_array( $data )) { |
|
346 | - throw new Exception( sprintf( 'Plugin information not found for: %s', $plugin )); |
|
345 | + if( !is_array( $data ) ) { |
|
346 | + throw new Exception( sprintf( 'Plugin information not found for: %s', $plugin ) ); |
|
347 | 347 | } |
348 | - $data['plugin'] = $plugin; |
|
349 | - $data['slug'] = $this->getPluginSlug( $plugin ); |
|
348 | + $data[ 'plugin' ] = $plugin; |
|
349 | + $data[ 'slug' ] = $this->getPluginSlug( $plugin ); |
|
350 | 350 | $data = array_change_key_case( $data ); |
351 | - if( is_null( $key )) { |
|
351 | + if( is_null( $key ) ) { |
|
352 | 352 | return $data; |
353 | 353 | } |
354 | 354 | $key = strtolower( $key ); |
355 | - return isset( $data[$key] ) |
|
356 | - ? $data[$key] |
|
355 | + return isset( $data[ $key ] ) |
|
356 | + ? $data[ $key ] |
|
357 | 357 | : ''; |
358 | 358 | } |
359 | 359 | |
@@ -377,9 +377,9 @@ discard block |
||
377 | 377 | $data = $this->getPluginRequirements( $plugin ); |
378 | 378 | } |
379 | 379 | return sprintf( '<span class="plugin-%s"><a href="%s">%s</a></span>', |
380 | - $data['slug'], |
|
381 | - $data['pluginuri'], |
|
382 | - $data['name'] |
|
380 | + $data[ 'slug' ], |
|
381 | + $data[ 'pluginuri' ], |
|
382 | + $data[ 'name' ] |
|
383 | 383 | ); |
384 | 384 | } |
385 | 385 | |
@@ -388,9 +388,9 @@ discard block |
||
388 | 388 | */ |
389 | 389 | protected function getPluginRequirements( $plugin, $key = null ) |
390 | 390 | { |
391 | - $keys = ['Name', 'Version', 'PluginURI']; |
|
391 | + $keys = [ 'Name', 'Version', 'PluginURI' ]; |
|
392 | 392 | $requirements = $this->isPluginDependency( $plugin ) |
393 | - ? array_pad( explode( '|', static::DEPENDENCIES[$plugin] ), 3, '' ) |
|
393 | + ? array_pad( explode( '|', static::DEPENDENCIES[ $plugin ] ), 3, '' ) |
|
394 | 394 | : array_fill( 0, 3, '' ); |
395 | 395 | return $this->getPluginData( $plugin, array_combine( $keys, $requirements ), $key ); |
396 | 396 | } |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | */ |
401 | 401 | protected function getPluginSlug( $plugin ) |
402 | 402 | { |
403 | - return substr( $plugin, 0, strrpos( $plugin, '/' )); |
|
403 | + return substr( $plugin, 0, strrpos( $plugin, '/' ) ); |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | /** |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | filter_input( INPUT_GET, 'plugin_status' ), |
413 | 413 | filter_input( INPUT_GET, 'paged' ), |
414 | 414 | filter_input( INPUT_GET, 's' ) |
415 | - ))); |
|
415 | + ) ) ); |
|
416 | 416 | exit; |
417 | 417 | } |
418 | 418 | } |
@@ -65,7 +65,9 @@ discard block |
||
65 | 65 | { |
66 | 66 | if( get_current_screen()->id != sprintf( 'settings_page_%s', $this->app->id ) |
67 | 67 | || filter_input( INPUT_GET, 'action' ) != 'activate' |
68 | - )return; |
|
68 | + ) { |
|
69 | + return; |
|
70 | + } |
|
69 | 71 | $plugin = filter_input( INPUT_GET, 'plugin' ); |
70 | 72 | check_admin_referer( 'activate-plugin_' . $plugin ); |
71 | 73 | $result = activate_plugin( $plugin, null, is_network_admin(), true ); |
@@ -221,7 +223,9 @@ discard block |
||
221 | 223 | public function hasPendingDependencies() |
222 | 224 | { |
223 | 225 | foreach( static::DEPENDENCIES as $plugin => $data ) { |
224 | - if( !$this->isPluginDependency( $plugin ))continue; |
|
226 | + if( !$this->isPluginDependency( $plugin )) { |
|
227 | + continue; |
|
228 | + } |
|
225 | 229 | $this->isPluginActive( $plugin ); |
226 | 230 | $this->isPluginVersionValid( $plugin ); |
227 | 231 | } |
@@ -236,7 +240,9 @@ discard block |
||
236 | 240 | if( get_current_screen()->id != 'settings_page_pollux' |
237 | 241 | || $this->app->config->disable_config |
238 | 242 | || !$this->hasPendingDependencies() |
239 | - )return; |
|
243 | + ) { |
|
244 | + return; |
|
245 | + } |
|
240 | 246 | |
241 | 247 | $plugins = ''; |
242 | 248 | $actions = ''; |
@@ -29,10 +29,10 @@ discard block |
||
29 | 29 | { |
30 | 30 | $method = strtolower( $name ); |
31 | 31 | $status = substr( $method, 3 ); |
32 | - if( 'add' == substr( $method, 0, 3 ) && in_array( $status, ['error', 'info', 'success', 'warning'] )) { |
|
33 | - return call_user_func_array( [$this, 'addNotice'], array_merge( [$status], $args )); |
|
32 | + if( 'add' == substr( $method, 0, 3 ) && in_array( $status, [ 'error', 'info', 'success', 'warning' ] ) ) { |
|
33 | + return call_user_func_array( [ $this, 'addNotice' ], array_merge( [ $status ], $args ) ); |
|
34 | 34 | } |
35 | - throw new BadMethodCallException( sprintf( 'Not a valid method: %s', $name )); |
|
35 | + throw new BadMethodCallException( sprintf( 'Not a valid method: %s', $name ) ); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | public function __get( $property ) |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | if( $property == 'all' ) { |
41 | 41 | return $this->app->notices; |
42 | 42 | } |
43 | - throw new Exception( sprintf( 'Not a valid property: %s', $property )); |
|
43 | + throw new Exception( sprintf( 'Not a valid property: %s', $property ) ); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
@@ -48,28 +48,28 @@ discard block |
||
48 | 48 | */ |
49 | 49 | public function activateButton( array $plugin ) |
50 | 50 | { |
51 | - $actionUrl = self_admin_url( sprintf( 'options-general.php?page=%s&action=activate&plugin=%s', $this->app->id, $plugin['plugin'] )); |
|
52 | - return $this->button( sprintf( '%s %s', __( 'Activate', 'pollux' ), $plugin['name'] ), [ |
|
53 | - 'data-name' => $plugin['name'], |
|
54 | - 'data-plugin' => $plugin['plugin'], |
|
55 | - 'data-slug' => $plugin['slug'], |
|
56 | - 'href' => wp_nonce_url( $actionUrl, sprintf( 'activate-plugin_%s', $plugin['plugin'] )), |
|
57 | - ]); |
|
51 | + $actionUrl = self_admin_url( sprintf( 'options-general.php?page=%s&action=activate&plugin=%s', $this->app->id, $plugin[ 'plugin' ] ) ); |
|
52 | + return $this->button( sprintf( '%s %s', __( 'Activate', 'pollux' ), $plugin[ 'name' ] ), [ |
|
53 | + 'data-name' => $plugin[ 'name' ], |
|
54 | + 'data-plugin' => $plugin[ 'plugin' ], |
|
55 | + 'data-slug' => $plugin[ 'slug' ], |
|
56 | + 'href' => wp_nonce_url( $actionUrl, sprintf( 'activate-plugin_%s', $plugin[ 'plugin' ] ) ), |
|
57 | + ] ); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
61 | 61 | * @param string $title |
62 | 62 | * @return string |
63 | 63 | */ |
64 | - public function button( $title, array $atts = [] ) |
|
64 | + public function button( $title, array $atts = [ ] ) |
|
65 | 65 | { |
66 | 66 | $atts = wp_parse_args( $atts, [ |
67 | 67 | 'class' => '', |
68 | 68 | 'href' => '', |
69 | - ]); |
|
70 | - $atts['class'] = trim( $atts['class'] . ' button button-small' ); |
|
69 | + ] ); |
|
70 | + $atts[ 'class' ] = trim( $atts[ 'class' ] . ' button button-small' ); |
|
71 | 71 | $attributes = array_reduce( array_keys( $atts ), function( $carry, $key ) use( $atts ) { |
72 | - return $carry . sprintf( ' %s="%s"', $key, $atts[$key] ); |
|
72 | + return $carry . sprintf( ' %s="%s"', $key, $atts[ $key ] ); |
|
73 | 73 | }); |
74 | 74 | return sprintf( '<a%s>%s</a>', $attributes, $title ); |
75 | 75 | } |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | if( $unset ) { |
83 | 83 | $index = array_search( $notice, $this->app->notices ); |
84 | 84 | if( $index !== false ) { |
85 | - unset( $this->app->notices[$index] ); |
|
85 | + unset( $this->app->notices[ $index ] ); |
|
86 | 86 | } |
87 | 87 | } |
88 | 88 | return $this->buildNotice( $notice ); |
@@ -93,13 +93,13 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public function installButton( array $plugin ) |
95 | 95 | { |
96 | - $actionUrl = self_admin_url( sprintf( 'update.php?action=install-plugin&plugin=%s', $plugin['slug'] )); |
|
97 | - return $this->button( sprintf( '%s %s', __( 'Install', 'pollux' ), $plugin['name'] ), [ |
|
98 | - 'data-name' => $plugin['name'], |
|
99 | - 'data-plugin' => $plugin['plugin'], |
|
100 | - 'data-slug' => $plugin['slug'], |
|
101 | - 'href' => wp_nonce_url( $actionUrl, sprintf( 'install-plugin_%s', $plugin['slug'] )), |
|
102 | - ]); |
|
96 | + $actionUrl = self_admin_url( sprintf( 'update.php?action=install-plugin&plugin=%s', $plugin[ 'slug' ] ) ); |
|
97 | + return $this->button( sprintf( '%s %s', __( 'Install', 'pollux' ), $plugin[ 'name' ] ), [ |
|
98 | + 'data-name' => $plugin[ 'name' ], |
|
99 | + 'data-plugin' => $plugin[ 'plugin' ], |
|
100 | + 'data-slug' => $plugin[ 'slug' ], |
|
101 | + 'href' => wp_nonce_url( $actionUrl, sprintf( 'install-plugin_%s', $plugin[ 'slug' ] ) ), |
|
102 | + ] ); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | /** |
@@ -107,13 +107,13 @@ discard block |
||
107 | 107 | */ |
108 | 108 | public function updateButton( array $plugin ) |
109 | 109 | { |
110 | - $actionUrl = self_admin_url( sprintf( 'update.php?action=upgrade-plugin&plugin=%s', $plugin['plugin'] )); |
|
111 | - return $this->button( sprintf( '%s %s', __( 'Update', 'pollux' ), $plugin['name'] ), [ |
|
112 | - 'data-name' => $plugin['name'], |
|
113 | - 'data-plugin' => $plugin['plugin'], |
|
114 | - 'data-slug' => $plugin['slug'], |
|
115 | - 'href' => wp_nonce_url( $actionUrl, sprintf( 'upgrade-plugin_%s', $plugin['plugin'] )), |
|
116 | - ]); |
|
110 | + $actionUrl = self_admin_url( sprintf( 'update.php?action=upgrade-plugin&plugin=%s', $plugin[ 'plugin' ] ) ); |
|
111 | + return $this->button( sprintf( '%s %s', __( 'Update', 'pollux' ), $plugin[ 'name' ] ), [ |
|
112 | + 'data-name' => $plugin[ 'name' ], |
|
113 | + 'data-plugin' => $plugin[ 'plugin' ], |
|
114 | + 'data-slug' => $plugin[ 'slug' ], |
|
115 | + 'href' => wp_nonce_url( $actionUrl, sprintf( 'upgrade-plugin_%s', $plugin[ 'plugin' ] ) ), |
|
116 | + ] ); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -133,9 +133,9 @@ discard block |
||
133 | 133 | */ |
134 | 134 | protected function addNotice( $type, $messages, $dismissible = true ) |
135 | 135 | { |
136 | - $this->app->notices[] = [ |
|
136 | + $this->app->notices[ ] = [ |
|
137 | 137 | 'dismissible' => $dismissible, |
138 | - 'message' => $this->buildMessage( array_filter( (array) $messages )), |
|
138 | + 'message' => $this->buildMessage( array_filter( (array) $messages ) ), |
|
139 | 139 | 'type' => $type, |
140 | 140 | ]; |
141 | 141 | $this->app->notices = array_unique( $this->app->notices, SORT_REGULAR ); |
@@ -147,10 +147,10 @@ discard block |
||
147 | 147 | protected function buildMessage( array $messages ) |
148 | 148 | { |
149 | 149 | foreach( $messages as $key => &$message ) { |
150 | - if( !is_wp_error( $message ))continue; |
|
150 | + if( !is_wp_error( $message ) )continue; |
|
151 | 151 | $message = $message->get_error_message(); |
152 | 152 | } |
153 | - return wpautop( implode( PHP_EOL . PHP_EOL, $messages )); |
|
153 | + return wpautop( implode( PHP_EOL . PHP_EOL, $messages ) ); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | /** |
@@ -158,10 +158,10 @@ discard block |
||
158 | 158 | */ |
159 | 159 | protected function buildNotice( array $notice ) |
160 | 160 | { |
161 | - $class = sprintf( 'notice notice-%s', $notice['type'] ); |
|
162 | - if( $notice['dismissible'] ) { |
|
161 | + $class = sprintf( 'notice notice-%s', $notice[ 'type' ] ); |
|
162 | + if( $notice[ 'dismissible' ] ) { |
|
163 | 163 | $class .= ' is-dismissible'; |
164 | 164 | } |
165 | - return sprintf( '<div class="pollux-notice %s">%s</div>', $class, $notice['message'] ); |
|
165 | + return sprintf( '<div class="pollux-notice %s">%s</div>', $class, $notice[ 'message' ] ); |
|
166 | 166 | } |
167 | 167 | } |