@@ -29,9 +29,9 @@ discard block |
||
29 | 29 | * @param object $callback_instance Callback class. |
30 | 30 | * @param string $action The name of the action we are processing for. |
31 | 31 | */ |
32 | - public function __construct( $callback_instance, $action ) { |
|
33 | - if ( is_object( $callback_instance ) ) { |
|
34 | - $this->get_data( $callback_instance, $action ); |
|
32 | + public function __construct($callback_instance, $action) { |
|
33 | + if (is_object($callback_instance)) { |
|
34 | + $this->get_data($callback_instance, $action); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | } |
@@ -49,9 +49,9 @@ discard block |
||
49 | 49 | * @param object $callback_instance Callback class. |
50 | 50 | * @param string $action The name of the action we are processing for. |
51 | 51 | */ |
52 | - protected function get_data( $callback_instance, $action ) { |
|
52 | + protected function get_data($callback_instance, $action) { |
|
53 | 53 | $data = array(); |
54 | - if ( is_array( $_POST ) ) { |
|
54 | + if (is_array($_POST)) { |
|
55 | 55 | $params = $callback_instance::params(); |
56 | 56 | |
57 | 57 | /** |
@@ -61,20 +61,20 @@ discard block |
||
61 | 61 | * |
62 | 62 | * @param array $params Array of params in form of $params[ 'action_name' ][ 'POST_field' ] = 'callback_function_for_sanatizing' ] |
63 | 63 | */ |
64 | - $params = apply_filters( 'lasso_api_params', $params ); |
|
65 | - if ( is_array( $params ) && isset( $params[ $action ] ) && is_array( $params[ $action ] ) ) { |
|
66 | - $params = $params[ $action ]; |
|
67 | - foreach( $params as $key => $callback ) { |
|
64 | + $params = apply_filters('lasso_api_params', $params); |
|
65 | + if (is_array($params) && isset($params[$action]) && is_array($params[$action])) { |
|
66 | + $params = $params[$action]; |
|
67 | + foreach ($params as $key => $callback) { |
|
68 | 68 | $_data = null; |
69 | - if ( is_array( $callback ) ) { |
|
70 | - foreach( $callback as $cb ) { |
|
71 | - $_data = $this->sanitize( $key, $cb ); |
|
69 | + if (is_array($callback)) { |
|
70 | + foreach ($callback as $cb) { |
|
71 | + $_data = $this->sanitize($key, $cb); |
|
72 | 72 | } |
73 | - }else{ |
|
74 | - $_data = $this->sanitize( $key, $callback ); |
|
73 | + } else { |
|
74 | + $_data = $this->sanitize($key, $callback); |
|
75 | 75 | } |
76 | 76 | |
77 | - $data[ $key ] = $_data; |
|
77 | + $data[$key] = $_data; |
|
78 | 78 | |
79 | 79 | } |
80 | 80 | |
@@ -98,11 +98,11 @@ discard block |
||
98 | 98 | * |
99 | 99 | * @return string|null Sanitized data or null. |
100 | 100 | */ |
101 | - protected function sanitize( $key, $cb ) { |
|
101 | + protected function sanitize($key, $cb) { |
|
102 | 102 | $_data = null; |
103 | - if ( isset( $_POST[ $key ] ) ) { |
|
104 | - if ( function_exists( $cb ) ) { |
|
105 | - $_data = call_user_func( $cb, $_POST[ $key ] ); |
|
103 | + if (isset($_POST[$key])) { |
|
104 | + if (function_exists($cb)) { |
|
105 | + $_data = call_user_func($cb, $_POST[$key]); |
|
106 | 106 | |
107 | 107 | return $_data; |
108 | 108 |
@@ -10,7 +10,7 @@ |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // If uninstall not called from WordPress, then exit |
13 | -if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
|
13 | +if (!defined('WP_UNINSTALL_PLUGIN')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
44 | 44 | */ |
45 | 45 | |
46 | -if ( ! class_exists( 'TGM_Plugin_Activation' ) ) { |
|
46 | +if (!class_exists('TGM_Plugin_Activation')) { |
|
47 | 47 | |
48 | 48 | /** |
49 | 49 | * Automatic plugin installation and activation library. |
@@ -269,10 +269,10 @@ discard block |
||
269 | 269 | $this->wp_version = $GLOBALS['wp_version']; |
270 | 270 | |
271 | 271 | // Announce that the class is ready, and pass the object (for advanced use). |
272 | - do_action_ref_array( 'tgmpa_init', array( $this ) ); |
|
272 | + do_action_ref_array('tgmpa_init', array($this)); |
|
273 | 273 | |
274 | 274 | // When the rest of WP has loaded, kick-start the rest of the class. |
275 | - add_action( 'init', array( $this, 'init' ) ); |
|
275 | + add_action('init', array($this, 'init')); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | /** |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | * @return void Silently fail to set the property when this is tried from outside of this class context. |
290 | 290 | * (Inside this class context, the __set() method if not used as there is direct access.) |
291 | 291 | */ |
292 | - public function __set( $name, $value ) { |
|
292 | + public function __set($name, $value) { |
|
293 | 293 | return; |
294 | 294 | } |
295 | 295 | |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | * @param string $name Name of an inaccessible property. |
300 | 300 | * @return mixed The property value. |
301 | 301 | */ |
302 | - public function __get( $name ) { |
|
302 | + public function __get($name) { |
|
303 | 303 | return $this->{$name}; |
304 | 304 | } |
305 | 305 | |
@@ -324,16 +324,16 @@ discard block |
||
324 | 324 | * @param bool $load Whether or not TGMPA should load. |
325 | 325 | * Defaults to the return of `is_admin() && ! defined( 'DOING_AJAX' )`. |
326 | 326 | */ |
327 | - if ( true !== apply_filters( 'tgmpa_load', ( is_admin() && ! defined( 'DOING_AJAX' ) ) ) ) { |
|
327 | + if (true !== apply_filters('tgmpa_load', (is_admin() && !defined('DOING_AJAX')))) { |
|
328 | 328 | return; |
329 | 329 | } |
330 | 330 | |
331 | 331 | // Load class strings. |
332 | 332 | $this->strings = array( |
333 | - 'page_title' => __( 'Install Required Plugins', 'tgmpa' ), |
|
334 | - 'menu_title' => __( 'Install Plugins', 'tgmpa' ), |
|
335 | - 'installing' => __( 'Installing Plugin: %s', 'tgmpa' ), |
|
336 | - 'oops' => __( 'Something went wrong with the plugin API.', 'tgmpa' ), |
|
333 | + 'page_title' => __('Install Required Plugins', 'tgmpa'), |
|
334 | + 'menu_title' => __('Install Plugins', 'tgmpa'), |
|
335 | + 'installing' => __('Installing Plugin: %s', 'tgmpa'), |
|
336 | + 'oops' => __('Something went wrong with the plugin API.', 'tgmpa'), |
|
337 | 337 | 'notice_can_install_required' => _n_noop( |
338 | 338 | 'This theme requires the following plugin: %1$s.', |
339 | 339 | 'This theme requires the following plugins: %1$s.', |
@@ -394,62 +394,62 @@ discard block |
||
394 | 394 | 'Begin activating plugins', |
395 | 395 | 'tgmpa' |
396 | 396 | ), |
397 | - 'return' => __( 'Return to Required Plugins Installer', 'tgmpa' ), |
|
398 | - 'dashboard' => __( 'Return to the dashboard', 'tgmpa' ), |
|
399 | - 'plugin_activated' => __( 'Plugin activated successfully.', 'tgmpa' ), |
|
400 | - 'activated_successfully' => __( 'The following plugin was activated successfully:', 'tgmpa' ), |
|
401 | - 'plugin_already_active' => __( 'No action taken. Plugin %1$s was already active.', 'tgmpa' ), |
|
402 | - 'plugin_needs_higher_version' => __( 'Plugin not activated. A higher version of %s is needed for this theme. Please update the plugin.', 'tgmpa' ), |
|
403 | - 'complete' => __( 'All plugins installed and activated successfully. %1$s', 'tgmpa' ), |
|
404 | - 'dismiss' => __( 'Dismiss this notice', 'tgmpa' ), |
|
405 | - 'contact_admin' => __( 'Please contact the administrator of this site for help.', 'tgmpa' ), |
|
397 | + 'return' => __('Return to Required Plugins Installer', 'tgmpa'), |
|
398 | + 'dashboard' => __('Return to the dashboard', 'tgmpa'), |
|
399 | + 'plugin_activated' => __('Plugin activated successfully.', 'tgmpa'), |
|
400 | + 'activated_successfully' => __('The following plugin was activated successfully:', 'tgmpa'), |
|
401 | + 'plugin_already_active' => __('No action taken. Plugin %1$s was already active.', 'tgmpa'), |
|
402 | + 'plugin_needs_higher_version' => __('Plugin not activated. A higher version of %s is needed for this theme. Please update the plugin.', 'tgmpa'), |
|
403 | + 'complete' => __('All plugins installed and activated successfully. %1$s', 'tgmpa'), |
|
404 | + 'dismiss' => __('Dismiss this notice', 'tgmpa'), |
|
405 | + 'contact_admin' => __('Please contact the administrator of this site for help.', 'tgmpa'), |
|
406 | 406 | ); |
407 | 407 | |
408 | - do_action( 'tgmpa_register' ); |
|
408 | + do_action('tgmpa_register'); |
|
409 | 409 | |
410 | 410 | /* After this point, the plugins should be registered and the configuration set. */ |
411 | 411 | |
412 | 412 | // Proceed only if we have plugins to handle. |
413 | - if ( empty( $this->plugins ) || ! is_array( $this->plugins ) ) { |
|
413 | + if (empty($this->plugins) || !is_array($this->plugins)) { |
|
414 | 414 | return; |
415 | 415 | } |
416 | 416 | |
417 | 417 | // Set up the menu and notices if we still have outstanding actions. |
418 | - if ( true !== $this->is_tgmpa_complete() ) { |
|
418 | + if (true !== $this->is_tgmpa_complete()) { |
|
419 | 419 | // Sort the plugins. |
420 | - array_multisort( $this->sort_order, SORT_ASC, $this->plugins ); |
|
420 | + array_multisort($this->sort_order, SORT_ASC, $this->plugins); |
|
421 | 421 | |
422 | - add_action( 'admin_menu', array( $this, 'admin_menu' ) ); |
|
423 | - add_action( 'admin_head', array( $this, 'dismiss' ) ); |
|
422 | + add_action('admin_menu', array($this, 'admin_menu')); |
|
423 | + add_action('admin_head', array($this, 'dismiss')); |
|
424 | 424 | |
425 | 425 | // Prevent the normal links from showing underneath a single install/update page. |
426 | - add_filter( 'install_plugin_complete_actions', array( $this, 'actions' ) ); |
|
427 | - add_filter( 'update_plugin_complete_actions', array( $this, 'actions' ) ); |
|
426 | + add_filter('install_plugin_complete_actions', array($this, 'actions')); |
|
427 | + add_filter('update_plugin_complete_actions', array($this, 'actions')); |
|
428 | 428 | |
429 | - if ( $this->has_notices ) { |
|
430 | - add_action( 'admin_notices', array( $this, 'notices' ) ); |
|
431 | - add_action( 'admin_init', array( $this, 'admin_init' ), 1 ); |
|
432 | - add_action( 'admin_enqueue_scripts', array( $this, 'thickbox' ) ); |
|
429 | + if ($this->has_notices) { |
|
430 | + add_action('admin_notices', array($this, 'notices')); |
|
431 | + add_action('admin_init', array($this, 'admin_init'), 1); |
|
432 | + add_action('admin_enqueue_scripts', array($this, 'thickbox')); |
|
433 | 433 | } |
434 | 434 | |
435 | - add_action( 'load-plugins.php', array( $this, 'add_plugin_action_link_filters' ), 1 ); |
|
435 | + add_action('load-plugins.php', array($this, 'add_plugin_action_link_filters'), 1); |
|
436 | 436 | } |
437 | 437 | |
438 | 438 | // Make sure things get reset on switch theme. |
439 | - add_action( 'switch_theme', array( $this, 'flush_plugins_cache' ) ); |
|
439 | + add_action('switch_theme', array($this, 'flush_plugins_cache')); |
|
440 | 440 | |
441 | - if ( $this->has_notices ) { |
|
442 | - add_action( 'switch_theme', array( $this, 'update_dismiss' ) ); |
|
441 | + if ($this->has_notices) { |
|
442 | + add_action('switch_theme', array($this, 'update_dismiss')); |
|
443 | 443 | } |
444 | 444 | |
445 | 445 | // Setup the force activation hook. |
446 | - if ( true === $this->has_forced_activation ) { |
|
447 | - add_action( 'admin_init', array( $this, 'force_activation' ) ); |
|
446 | + if (true === $this->has_forced_activation) { |
|
447 | + add_action('admin_init', array($this, 'force_activation')); |
|
448 | 448 | } |
449 | 449 | |
450 | 450 | // Setup the force deactivation hook. |
451 | - if ( true === $this->has_forced_deactivation ) { |
|
452 | - add_action( 'switch_theme', array( $this, 'force_deactivation' ) ); |
|
451 | + if (true === $this->has_forced_deactivation) { |
|
452 | + add_action('switch_theme', array($this, 'force_deactivation')); |
|
453 | 453 | } |
454 | 454 | } |
455 | 455 | |
@@ -460,17 +460,17 @@ discard block |
||
460 | 460 | * @since 2.5.0 |
461 | 461 | */ |
462 | 462 | public function add_plugin_action_link_filters() { |
463 | - foreach ( $this->plugins as $slug => $plugin ) { |
|
464 | - if ( false === $this->can_plugin_activate( $slug ) ) { |
|
465 | - add_filter( 'plugin_action_links_' . $plugin['file_path'], array( $this, 'filter_plugin_action_links_activate' ), 20 ); |
|
463 | + foreach ($this->plugins as $slug => $plugin) { |
|
464 | + if (false === $this->can_plugin_activate($slug)) { |
|
465 | + add_filter('plugin_action_links_'.$plugin['file_path'], array($this, 'filter_plugin_action_links_activate'), 20); |
|
466 | 466 | } |
467 | 467 | |
468 | - if ( true === $plugin['force_activation'] ) { |
|
469 | - add_filter( 'plugin_action_links_' . $plugin['file_path'], array( $this, 'filter_plugin_action_links_deactivate' ), 20 ); |
|
468 | + if (true === $plugin['force_activation']) { |
|
469 | + add_filter('plugin_action_links_'.$plugin['file_path'], array($this, 'filter_plugin_action_links_deactivate'), 20); |
|
470 | 470 | } |
471 | 471 | |
472 | - if ( false !== $this->does_plugin_require_update( $slug ) ) { |
|
473 | - add_filter( 'plugin_action_links_' . $plugin['file_path'], array( $this, 'filter_plugin_action_links_update' ), 20 ); |
|
472 | + if (false !== $this->does_plugin_require_update($slug)) { |
|
473 | + add_filter('plugin_action_links_'.$plugin['file_path'], array($this, 'filter_plugin_action_links_update'), 20); |
|
474 | 474 | } |
475 | 475 | } |
476 | 476 | } |
@@ -484,8 +484,8 @@ discard block |
||
484 | 484 | * @param array $actions Action links. |
485 | 485 | * @return array |
486 | 486 | */ |
487 | - public function filter_plugin_action_links_activate( $actions ) { |
|
488 | - unset( $actions['activate'] ); |
|
487 | + public function filter_plugin_action_links_activate($actions) { |
|
488 | + unset($actions['activate']); |
|
489 | 489 | |
490 | 490 | return $actions; |
491 | 491 | } |
@@ -498,8 +498,8 @@ discard block |
||
498 | 498 | * @param array $actions Action links. |
499 | 499 | * @return array |
500 | 500 | */ |
501 | - public function filter_plugin_action_links_deactivate( $actions ) { |
|
502 | - unset( $actions['deactivate'] ); |
|
501 | + public function filter_plugin_action_links_deactivate($actions) { |
|
502 | + unset($actions['deactivate']); |
|
503 | 503 | |
504 | 504 | return $actions; |
505 | 505 | } |
@@ -513,12 +513,12 @@ discard block |
||
513 | 513 | * @param array $actions Action links. |
514 | 514 | * @return array |
515 | 515 | */ |
516 | - public function filter_plugin_action_links_update( $actions ) { |
|
516 | + public function filter_plugin_action_links_update($actions) { |
|
517 | 517 | $actions['update'] = sprintf( |
518 | 518 | '<a href="%1$s" title="%2$s" class="edit">%3$s</a>', |
519 | - esc_url( $this->get_tgmpa_status_url( 'update' ) ), |
|
520 | - esc_attr__( 'This plugin needs to be updated to be compatible with your theme.', 'tgmpa' ), |
|
521 | - esc_html__( 'Update Required', 'tgmpa' ) |
|
519 | + esc_url($this->get_tgmpa_status_url('update')), |
|
520 | + esc_attr__('This plugin needs to be updated to be compatible with your theme.', 'tgmpa'), |
|
521 | + esc_html__('Update Required', 'tgmpa') |
|
522 | 522 | ); |
523 | 523 | |
524 | 524 | return $actions; |
@@ -548,15 +548,15 @@ discard block |
||
548 | 548 | * @return null Returns early if not the TGMPA page. |
549 | 549 | */ |
550 | 550 | public function admin_init() { |
551 | - if ( ! $this->is_tgmpa_page() ) { |
|
551 | + if (!$this->is_tgmpa_page()) { |
|
552 | 552 | return; |
553 | 553 | } |
554 | 554 | |
555 | - if ( isset( $_REQUEST['tab'] ) && 'plugin-information' === $_REQUEST['tab'] ) { |
|
555 | + if (isset($_REQUEST['tab']) && 'plugin-information' === $_REQUEST['tab']) { |
|
556 | 556 | // Needed for install_plugin_information(). |
557 | - require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; |
|
557 | + require_once ABSPATH.'wp-admin/includes/plugin-install.php'; |
|
558 | 558 | |
559 | - wp_enqueue_style( 'plugin-install' ); |
|
559 | + wp_enqueue_style('plugin-install'); |
|
560 | 560 | |
561 | 561 | global $tab, $body_id; |
562 | 562 | $body_id = 'plugin-information'; |
@@ -582,7 +582,7 @@ discard block |
||
582 | 582 | * @since 2.1.0 |
583 | 583 | */ |
584 | 584 | public function thickbox() { |
585 | - if ( ! get_user_meta( get_current_user_id(), 'tgmpa_dismissed_notice_' . $this->id, true ) ) { |
|
585 | + if (!get_user_meta(get_current_user_id(), 'tgmpa_dismissed_notice_'.$this->id, true)) { |
|
586 | 586 | add_thickbox(); |
587 | 587 | } |
588 | 588 | } |
@@ -604,23 +604,23 @@ discard block |
||
604 | 604 | */ |
605 | 605 | public function admin_menu() { |
606 | 606 | // Make sure privileges are correct to see the page. |
607 | - if ( ! current_user_can( 'install_plugins' ) ) { |
|
607 | + if (!current_user_can('install_plugins')) { |
|
608 | 608 | return; |
609 | 609 | } |
610 | 610 | |
611 | 611 | $args = apply_filters( |
612 | 612 | 'tgmpa_admin_menu_args', |
613 | 613 | array( |
614 | - 'parent_slug' => $this->parent_slug, // Parent Menu slug. |
|
615 | - 'page_title' => $this->strings['page_title'], // Page title. |
|
616 | - 'menu_title' => $this->strings['menu_title'], // Menu title. |
|
617 | - 'capability' => $this->capability, // Capability. |
|
618 | - 'menu_slug' => $this->menu, // Menu slug. |
|
619 | - 'function' => array( $this, 'install_plugins_page' ), // Callback. |
|
614 | + 'parent_slug' => $this->parent_slug, // Parent Menu slug. |
|
615 | + 'page_title' => $this->strings['page_title'], // Page title. |
|
616 | + 'menu_title' => $this->strings['menu_title'], // Menu title. |
|
617 | + 'capability' => $this->capability, // Capability. |
|
618 | + 'menu_slug' => $this->menu, // Menu slug. |
|
619 | + 'function' => array($this, 'install_plugins_page'), // Callback. |
|
620 | 620 | ) |
621 | 621 | ); |
622 | 622 | |
623 | - $this->add_admin_menu( $args ); |
|
623 | + $this->add_admin_menu($args); |
|
624 | 624 | } |
625 | 625 | |
626 | 626 | /** |
@@ -630,15 +630,15 @@ discard block |
||
630 | 630 | * |
631 | 631 | * @param array $args Menu item configuration. |
632 | 632 | */ |
633 | - protected function add_admin_menu( array $args ) { |
|
634 | - if ( has_filter( 'tgmpa_admin_menu_use_add_theme_page' ) ) { |
|
635 | - _deprecated_function( 'The "tgmpa_admin_menu_use_add_theme_page" filter', '2.5.0', esc_html__( 'Set the parent_slug config variable instead.', 'tgmpa' ) ); |
|
633 | + protected function add_admin_menu(array $args) { |
|
634 | + if (has_filter('tgmpa_admin_menu_use_add_theme_page')) { |
|
635 | + _deprecated_function('The "tgmpa_admin_menu_use_add_theme_page" filter', '2.5.0', esc_html__('Set the parent_slug config variable instead.', 'tgmpa')); |
|
636 | 636 | } |
637 | 637 | |
638 | - if ( 'themes.php' === $this->parent_slug ) { |
|
639 | - $this->page_hook = call_user_func( 'add_theme_page', $args['page_title'], $args['menu_title'], $args['capability'], $args['menu_slug'], $args['function'] ); |
|
638 | + if ('themes.php' === $this->parent_slug) { |
|
639 | + $this->page_hook = call_user_func('add_theme_page', $args['page_title'], $args['menu_title'], $args['capability'], $args['menu_slug'], $args['function']); |
|
640 | 640 | } else { |
641 | - $this->page_hook = call_user_func( 'add_submenu_page', $args['parent_slug'], $args['page_title'], $args['menu_title'], $args['capability'], $args['menu_slug'], $args['function'] ); |
|
641 | + $this->page_hook = call_user_func('add_submenu_page', $args['parent_slug'], $args['page_title'], $args['menu_title'], $args['capability'], $args['menu_slug'], $args['function']); |
|
642 | 642 | } |
643 | 643 | } |
644 | 644 | |
@@ -658,28 +658,28 @@ discard block |
||
658 | 658 | $plugin_table = new TGMPA_List_Table; |
659 | 659 | |
660 | 660 | // Return early if processing a plugin installation action. |
661 | - if ( ( ( 'tgmpa-bulk-install' === $plugin_table->current_action() || 'tgmpa-bulk-update' === $plugin_table->current_action() ) && $plugin_table->process_bulk_actions() ) || $this->do_plugin_install() ) { |
|
661 | + if ((('tgmpa-bulk-install' === $plugin_table->current_action() || 'tgmpa-bulk-update' === $plugin_table->current_action()) && $plugin_table->process_bulk_actions()) || $this->do_plugin_install()) { |
|
662 | 662 | return; |
663 | 663 | } |
664 | 664 | |
665 | 665 | // Force refresh of available plugin information so we'll know about manual updates/deletes. |
666 | - wp_clean_plugins_cache( false ); |
|
666 | + wp_clean_plugins_cache(false); |
|
667 | 667 | |
668 | 668 | ?> |
669 | 669 | <div class="tgmpa wrap"> |
670 | - <h2><?php echo esc_html( get_admin_page_title() ); ?></h2> |
|
670 | + <h2><?php echo esc_html(get_admin_page_title()); ?></h2> |
|
671 | 671 | <?php $plugin_table->prepare_items(); ?> |
672 | 672 | |
673 | 673 | <?php |
674 | - if ( ! empty( $this->message ) && is_string( $this->message ) ) { |
|
675 | - echo wp_kses_post( $this->message ); |
|
674 | + if (!empty($this->message) && is_string($this->message)) { |
|
675 | + echo wp_kses_post($this->message); |
|
676 | 676 | } |
677 | 677 | ?> |
678 | 678 | <?php $plugin_table->views(); ?> |
679 | 679 | |
680 | 680 | <form id="tgmpa-plugins" action="" method="post"> |
681 | - <input type="hidden" name="tgmpa-page" value="<?php echo esc_attr( $this->menu ); ?>" /> |
|
682 | - <input type="hidden" name="plugin_status" value="<?php echo esc_attr( $plugin_table->view_context ); ?>" /> |
|
681 | + <input type="hidden" name="tgmpa-page" value="<?php echo esc_attr($this->menu); ?>" /> |
|
682 | + <input type="hidden" name="plugin_status" value="<?php echo esc_attr($plugin_table->view_context); ?>" /> |
|
683 | 683 | <?php $plugin_table->display(); ?> |
684 | 684 | </form> |
685 | 685 | </div> |
@@ -707,48 +707,48 @@ discard block |
||
707 | 707 | * @return boolean True on success, false on failure. |
708 | 708 | */ |
709 | 709 | protected function do_plugin_install() { |
710 | - if ( empty( $_GET['plugin'] ) ) { |
|
710 | + if (empty($_GET['plugin'])) { |
|
711 | 711 | return false; |
712 | 712 | } |
713 | 713 | |
714 | 714 | // All plugin information will be stored in an array for processing. |
715 | - $slug = $this->sanitize_key( urldecode( $_GET['plugin'] ) ); |
|
715 | + $slug = $this->sanitize_key(urldecode($_GET['plugin'])); |
|
716 | 716 | |
717 | - if ( ! isset( $this->plugins[ $slug ] ) ) { |
|
717 | + if (!isset($this->plugins[$slug])) { |
|
718 | 718 | return false; |
719 | 719 | } |
720 | 720 | |
721 | 721 | // Was an install or upgrade action link clicked? |
722 | - if ( ( isset( $_GET['tgmpa-install'] ) && 'install-plugin' === $_GET['tgmpa-install'] ) || ( isset( $_GET['tgmpa-update'] ) && 'update-plugin' === $_GET['tgmpa-update'] ) ) { |
|
722 | + if ((isset($_GET['tgmpa-install']) && 'install-plugin' === $_GET['tgmpa-install']) || (isset($_GET['tgmpa-update']) && 'update-plugin' === $_GET['tgmpa-update'])) { |
|
723 | 723 | |
724 | 724 | $install_type = 'install'; |
725 | - if ( isset( $_GET['tgmpa-update'] ) && 'update-plugin' === $_GET['tgmpa-update'] ) { |
|
725 | + if (isset($_GET['tgmpa-update']) && 'update-plugin' === $_GET['tgmpa-update']) { |
|
726 | 726 | $install_type = 'update'; |
727 | 727 | } |
728 | 728 | |
729 | - check_admin_referer( 'tgmpa-' . $install_type, 'tgmpa-nonce' ); |
|
729 | + check_admin_referer('tgmpa-'.$install_type, 'tgmpa-nonce'); |
|
730 | 730 | |
731 | 731 | // Pass necessary information via URL if WP_Filesystem is needed. |
732 | 732 | $url = wp_nonce_url( |
733 | 733 | add_query_arg( |
734 | 734 | array( |
735 | - 'plugin' => urlencode( $slug ), |
|
736 | - 'tgmpa-' . $install_type => $install_type . '-plugin', |
|
735 | + 'plugin' => urlencode($slug), |
|
736 | + 'tgmpa-'.$install_type => $install_type.'-plugin', |
|
737 | 737 | ), |
738 | 738 | $this->get_tgmpa_url() |
739 | 739 | ), |
740 | - 'tgmpa-' . $install_type, |
|
740 | + 'tgmpa-'.$install_type, |
|
741 | 741 | 'tgmpa-nonce' |
742 | 742 | ); |
743 | 743 | |
744 | 744 | $method = ''; // Leave blank so WP_Filesystem can populate it as necessary. |
745 | 745 | |
746 | - if ( false === ( $creds = request_filesystem_credentials( esc_url_raw( $url ), $method, false, false, array() ) ) ) { |
|
746 | + if (false === ($creds = request_filesystem_credentials(esc_url_raw($url), $method, false, false, array()))) { |
|
747 | 747 | return true; |
748 | 748 | } |
749 | 749 | |
750 | - if ( ! WP_Filesystem( $creds ) ) { |
|
751 | - request_filesystem_credentials( esc_url_raw( $url ), $method, true, false, array() ); // Setup WP_Filesystem. |
|
750 | + if (!WP_Filesystem($creds)) { |
|
751 | + request_filesystem_credentials(esc_url_raw($url), $method, true, false, array()); // Setup WP_Filesystem. |
|
752 | 752 | return true; |
753 | 753 | } |
754 | 754 | |
@@ -757,66 +757,66 @@ discard block |
||
757 | 757 | // Prep variables for Plugin_Installer_Skin class. |
758 | 758 | $extra = array(); |
759 | 759 | $extra['slug'] = $slug; // Needed for potentially renaming of directory name. |
760 | - $source = $this->get_download_url( $slug ); |
|
761 | - $api = ( 'repo' === $this->plugins[ $slug ]['source_type'] ) ? $this->get_plugins_api( $slug ) : null; |
|
762 | - $api = ( false !== $api ) ? $api : null; |
|
760 | + $source = $this->get_download_url($slug); |
|
761 | + $api = ('repo' === $this->plugins[$slug]['source_type']) ? $this->get_plugins_api($slug) : null; |
|
762 | + $api = (false !== $api) ? $api : null; |
|
763 | 763 | |
764 | 764 | $url = add_query_arg( |
765 | 765 | array( |
766 | - 'action' => $install_type . '-plugin', |
|
767 | - 'plugin' => urlencode( $slug ), |
|
766 | + 'action' => $install_type.'-plugin', |
|
767 | + 'plugin' => urlencode($slug), |
|
768 | 768 | ), |
769 | 769 | 'update.php' |
770 | 770 | ); |
771 | 771 | |
772 | - if ( ! class_exists( 'Plugin_Upgrader', false ) ) { |
|
773 | - require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
|
772 | + if (!class_exists('Plugin_Upgrader', false)) { |
|
773 | + require_once ABSPATH.'wp-admin/includes/class-wp-upgrader.php'; |
|
774 | 774 | } |
775 | 775 | |
776 | 776 | $skin_args = array( |
777 | - 'type' => ( 'bundled' !== $this->plugins[ $slug ]['source_type'] ) ? 'web' : 'upload', |
|
778 | - 'title' => sprintf( $this->strings['installing'], $this->plugins[ $slug ]['name'] ), |
|
779 | - 'url' => esc_url_raw( $url ), |
|
780 | - 'nonce' => $install_type . '-plugin_' . $slug, |
|
777 | + 'type' => ('bundled' !== $this->plugins[$slug]['source_type']) ? 'web' : 'upload', |
|
778 | + 'title' => sprintf($this->strings['installing'], $this->plugins[$slug]['name']), |
|
779 | + 'url' => esc_url_raw($url), |
|
780 | + 'nonce' => $install_type.'-plugin_'.$slug, |
|
781 | 781 | 'plugin' => '', |
782 | 782 | 'api' => $api, |
783 | 783 | 'extra' => $extra, |
784 | 784 | ); |
785 | 785 | |
786 | - if ( 'update' === $install_type ) { |
|
787 | - $skin_args['plugin'] = $this->plugins[ $slug ]['file_path']; |
|
788 | - $skin = new Plugin_Upgrader_Skin( $skin_args ); |
|
786 | + if ('update' === $install_type) { |
|
787 | + $skin_args['plugin'] = $this->plugins[$slug]['file_path']; |
|
788 | + $skin = new Plugin_Upgrader_Skin($skin_args); |
|
789 | 789 | } else { |
790 | - $skin = new Plugin_Installer_Skin( $skin_args ); |
|
790 | + $skin = new Plugin_Installer_Skin($skin_args); |
|
791 | 791 | } |
792 | 792 | |
793 | 793 | // Create a new instance of Plugin_Upgrader. |
794 | - $upgrader = new Plugin_Upgrader( $skin ); |
|
794 | + $upgrader = new Plugin_Upgrader($skin); |
|
795 | 795 | |
796 | 796 | // Perform the action and install the plugin from the $source urldecode(). |
797 | - add_filter( 'upgrader_source_selection', array( $this, 'maybe_adjust_source_dir' ), 1, 3 ); |
|
797 | + add_filter('upgrader_source_selection', array($this, 'maybe_adjust_source_dir'), 1, 3); |
|
798 | 798 | |
799 | - if ( 'update' === $install_type ) { |
|
799 | + if ('update' === $install_type) { |
|
800 | 800 | // Inject our info into the update transient. |
801 | - $to_inject = array( $slug => $this->plugins[ $slug ] ); |
|
802 | - $to_inject[ $slug ]['source'] = $source; |
|
803 | - $this->inject_update_info( $to_inject ); |
|
801 | + $to_inject = array($slug => $this->plugins[$slug]); |
|
802 | + $to_inject[$slug]['source'] = $source; |
|
803 | + $this->inject_update_info($to_inject); |
|
804 | 804 | |
805 | - $upgrader->upgrade( $this->plugins[ $slug ]['file_path'] ); |
|
805 | + $upgrader->upgrade($this->plugins[$slug]['file_path']); |
|
806 | 806 | } else { |
807 | - $upgrader->install( $source ); |
|
807 | + $upgrader->install($source); |
|
808 | 808 | } |
809 | 809 | |
810 | - remove_filter( 'upgrader_source_selection', array( $this, 'maybe_adjust_source_dir' ), 1, 3 ); |
|
810 | + remove_filter('upgrader_source_selection', array($this, 'maybe_adjust_source_dir'), 1, 3); |
|
811 | 811 | |
812 | 812 | // Make sure we have the correct file path now the plugin is installed/updated. |
813 | - $this->populate_file_path( $slug ); |
|
813 | + $this->populate_file_path($slug); |
|
814 | 814 | |
815 | 815 | // Only activate plugins if the config option is set to true and the plugin isn't |
816 | 816 | // already active (upgrade). |
817 | - if ( $this->is_automatic && ! $this->is_plugin_active( $slug ) ) { |
|
817 | + if ($this->is_automatic && !$this->is_plugin_active($slug)) { |
|
818 | 818 | $plugin_activate = $upgrader->plugin_info(); // Grab the plugin info from the Plugin_Upgrader method. |
819 | - if ( false === $this->activate_single_plugin( $plugin_activate, $slug, true ) ) { |
|
819 | + if (false === $this->activate_single_plugin($plugin_activate, $slug, true)) { |
|
820 | 820 | return true; // Finish execution of the function early as we encountered an error. |
821 | 821 | } |
822 | 822 | } |
@@ -824,19 +824,19 @@ discard block |
||
824 | 824 | $this->show_tgmpa_version(); |
825 | 825 | |
826 | 826 | // Display message based on if all plugins are now active or not. |
827 | - if ( $this->is_tgmpa_complete() ) { |
|
828 | - echo '<p>', sprintf( esc_html( $this->strings['complete'] ), '<a href="' . esc_url( self_admin_url() ) . '">' . esc_html__( 'Return to the Dashboard', 'tgmpa' ) . '</a>' ), '</p>'; |
|
827 | + if ($this->is_tgmpa_complete()) { |
|
828 | + echo '<p>', sprintf(esc_html($this->strings['complete']), '<a href="'.esc_url(self_admin_url()).'">'.esc_html__('Return to the Dashboard', 'tgmpa').'</a>'), '</p>'; |
|
829 | 829 | echo '<style type="text/css">#adminmenu .wp-submenu li.current { display: none !important; }</style>'; |
830 | 830 | } else { |
831 | - echo '<p><a href="', esc_url( $this->get_tgmpa_url() ), '" target="_parent">', esc_html( $this->strings['return'] ), '</a></p>'; |
|
831 | + echo '<p><a href="', esc_url($this->get_tgmpa_url()), '" target="_parent">', esc_html($this->strings['return']), '</a></p>'; |
|
832 | 832 | } |
833 | 833 | |
834 | 834 | return true; |
835 | - } elseif ( isset( $this->plugins[ $slug ]['file_path'], $_GET['tgmpa-activate'] ) && 'activate-plugin' === $_GET['tgmpa-activate'] ) { |
|
835 | + } elseif (isset($this->plugins[$slug]['file_path'], $_GET['tgmpa-activate']) && 'activate-plugin' === $_GET['tgmpa-activate']) { |
|
836 | 836 | // Activate action link was clicked. |
837 | - check_admin_referer( 'tgmpa-activate', 'tgmpa-nonce' ); |
|
837 | + check_admin_referer('tgmpa-activate', 'tgmpa-nonce'); |
|
838 | 838 | |
839 | - if ( false === $this->activate_single_plugin( $this->plugins[ $slug ]['file_path'], $slug ) ) { |
|
839 | + if (false === $this->activate_single_plugin($this->plugins[$slug]['file_path'], $slug)) { |
|
840 | 840 | return true; // Finish execution of the function early as we encountered an error. |
841 | 841 | } |
842 | 842 | } |
@@ -851,31 +851,31 @@ discard block |
||
851 | 851 | * |
852 | 852 | * @param array $plugins The plugin information for the plugins which are to be updated. |
853 | 853 | */ |
854 | - public function inject_update_info( $plugins ) { |
|
855 | - $repo_updates = get_site_transient( 'update_plugins' ); |
|
854 | + public function inject_update_info($plugins) { |
|
855 | + $repo_updates = get_site_transient('update_plugins'); |
|
856 | 856 | |
857 | - if ( ! is_object( $repo_updates ) ) { |
|
857 | + if (!is_object($repo_updates)) { |
|
858 | 858 | $repo_updates = new stdClass; |
859 | 859 | } |
860 | 860 | |
861 | - foreach ( $plugins as $slug => $plugin ) { |
|
861 | + foreach ($plugins as $slug => $plugin) { |
|
862 | 862 | $file_path = $plugin['file_path']; |
863 | 863 | |
864 | - if ( empty( $repo_updates->response[ $file_path ] ) ) { |
|
865 | - $repo_updates->response[ $file_path ] = new stdClass; |
|
864 | + if (empty($repo_updates->response[$file_path])) { |
|
865 | + $repo_updates->response[$file_path] = new stdClass; |
|
866 | 866 | } |
867 | 867 | |
868 | 868 | // We only really need to set package, but let's do all we can in case WP changes something. |
869 | - $repo_updates->response[ $file_path ]->slug = $slug; |
|
870 | - $repo_updates->response[ $file_path ]->plugin = $file_path; |
|
871 | - $repo_updates->response[ $file_path ]->new_version = $plugin['version']; |
|
872 | - $repo_updates->response[ $file_path ]->package = $plugin['source']; |
|
873 | - if ( empty( $repo_updates->response[ $file_path ]->url ) && ! empty( $plugin['external_url'] ) ) { |
|
874 | - $repo_updates->response[ $file_path ]->url = $plugin['external_url']; |
|
869 | + $repo_updates->response[$file_path]->slug = $slug; |
|
870 | + $repo_updates->response[$file_path]->plugin = $file_path; |
|
871 | + $repo_updates->response[$file_path]->new_version = $plugin['version']; |
|
872 | + $repo_updates->response[$file_path]->package = $plugin['source']; |
|
873 | + if (empty($repo_updates->response[$file_path]->url) && !empty($plugin['external_url'])) { |
|
874 | + $repo_updates->response[$file_path]->url = $plugin['external_url']; |
|
875 | 875 | } |
876 | 876 | } |
877 | 877 | |
878 | - set_site_transient( 'update_plugins', $repo_updates ); |
|
878 | + set_site_transient('update_plugins', $repo_updates); |
|
879 | 879 | } |
880 | 880 | |
881 | 881 | /** |
@@ -894,14 +894,14 @@ discard block |
||
894 | 894 | * @param \WP_Upgrader $upgrader Instance of the upgrader which installs the plugin. |
895 | 895 | * @return string $source |
896 | 896 | */ |
897 | - public function maybe_adjust_source_dir( $source, $remote_source, $upgrader ) { |
|
898 | - if ( ! $this->is_tgmpa_page() || ! is_object( $GLOBALS['wp_filesystem'] ) ) { |
|
897 | + public function maybe_adjust_source_dir($source, $remote_source, $upgrader) { |
|
898 | + if (!$this->is_tgmpa_page() || !is_object($GLOBALS['wp_filesystem'])) { |
|
899 | 899 | return $source; |
900 | 900 | } |
901 | 901 | |
902 | 902 | // Check for single file plugins. |
903 | - $source_files = array_keys( $GLOBALS['wp_filesystem']->dirlist( $remote_source ) ); |
|
904 | - if ( 1 === count( $source_files ) && false === $GLOBALS['wp_filesystem']->is_dir( $source ) ) { |
|
903 | + $source_files = array_keys($GLOBALS['wp_filesystem']->dirlist($remote_source)); |
|
904 | + if (1 === count($source_files) && false === $GLOBALS['wp_filesystem']->is_dir($source)) { |
|
905 | 905 | return $source; |
906 | 906 | } |
907 | 907 | |
@@ -909,33 +909,33 @@ discard block |
||
909 | 909 | $desired_slug = ''; |
910 | 910 | |
911 | 911 | // Figure out what the slug is supposed to be. |
912 | - if ( false === $upgrader->bulk && ! empty( $upgrader->skin->options['extra']['slug'] ) ) { |
|
912 | + if (false === $upgrader->bulk && !empty($upgrader->skin->options['extra']['slug'])) { |
|
913 | 913 | $desired_slug = $upgrader->skin->options['extra']['slug']; |
914 | 914 | } else { |
915 | 915 | // Bulk installer contains less info, so fall back on the info registered here. |
916 | - foreach ( $this->plugins as $slug => $plugin ) { |
|
917 | - if ( ! empty( $upgrader->skin->plugin_names[ $upgrader->skin->i ] ) && $plugin['name'] === $upgrader->skin->plugin_names[ $upgrader->skin->i ] ) { |
|
916 | + foreach ($this->plugins as $slug => $plugin) { |
|
917 | + if (!empty($upgrader->skin->plugin_names[$upgrader->skin->i]) && $plugin['name'] === $upgrader->skin->plugin_names[$upgrader->skin->i]) { |
|
918 | 918 | $desired_slug = $slug; |
919 | 919 | break; |
920 | 920 | } |
921 | 921 | } |
922 | - unset( $slug, $plugin ); |
|
922 | + unset($slug, $plugin); |
|
923 | 923 | } |
924 | 924 | |
925 | - if ( ! empty( $desired_slug ) ) { |
|
926 | - $subdir_name = untrailingslashit( str_replace( trailingslashit( $remote_source ), '', $source ) ); |
|
925 | + if (!empty($desired_slug)) { |
|
926 | + $subdir_name = untrailingslashit(str_replace(trailingslashit($remote_source), '', $source)); |
|
927 | 927 | |
928 | - if ( ! empty( $subdir_name ) && $subdir_name !== $desired_slug ) { |
|
929 | - $from = untrailingslashit( $source ); |
|
930 | - $to = trailingslashit( $remote_source ) . $desired_slug; |
|
928 | + if (!empty($subdir_name) && $subdir_name !== $desired_slug) { |
|
929 | + $from = untrailingslashit($source); |
|
930 | + $to = trailingslashit($remote_source).$desired_slug; |
|
931 | 931 | |
932 | - if ( true === $GLOBALS['wp_filesystem']->move( $from, $to ) ) { |
|
933 | - return trailingslashit( $to ); |
|
932 | + if (true === $GLOBALS['wp_filesystem']->move($from, $to)) { |
|
933 | + return trailingslashit($to); |
|
934 | 934 | } else { |
935 | - return new WP_Error( 'rename_failed', esc_html__( 'The remote plugin package does not contain a folder with the desired slug and renaming did not work.', 'tgmpa' ) . ' ' . esc_html__( 'Please contact the plugin provider and ask them to package their plugin according to the WordPress guidelines.', 'tgmpa' ), array( 'found' => $subdir_name, 'expected' => $desired_slug ) ); |
|
935 | + return new WP_Error('rename_failed', esc_html__('The remote plugin package does not contain a folder with the desired slug and renaming did not work.', 'tgmpa').' '.esc_html__('Please contact the plugin provider and ask them to package their plugin according to the WordPress guidelines.', 'tgmpa'), array('found' => $subdir_name, 'expected' => $desired_slug)); |
|
936 | 936 | } |
937 | - } elseif ( empty( $subdir_name ) ) { |
|
938 | - return new WP_Error( 'packaged_wrong', esc_html__( 'The remote plugin package consists of more than one file, but the files are not packaged in a folder.', 'tgmpa' ) . ' ' . esc_html__( 'Please contact the plugin provider and ask them to package their plugin according to the WordPress guidelines.', 'tgmpa' ), array( 'found' => $subdir_name, 'expected' => $desired_slug ) ); |
|
937 | + } elseif (empty($subdir_name)) { |
|
938 | + return new WP_Error('packaged_wrong', esc_html__('The remote plugin package consists of more than one file, but the files are not packaged in a folder.', 'tgmpa').' '.esc_html__('Please contact the plugin provider and ask them to package their plugin according to the WordPress guidelines.', 'tgmpa'), array('found' => $subdir_name, 'expected' => $desired_slug)); |
|
939 | 939 | } |
940 | 940 | } |
941 | 941 | |
@@ -953,51 +953,51 @@ discard block |
||
953 | 953 | * This determines the styling of the output messages. |
954 | 954 | * @return bool False if an error was encountered, true otherwise. |
955 | 955 | */ |
956 | - protected function activate_single_plugin( $file_path, $slug, $automatic = false ) { |
|
957 | - if ( $this->can_plugin_activate( $slug ) ) { |
|
958 | - $activate = activate_plugin( $file_path ); |
|
956 | + protected function activate_single_plugin($file_path, $slug, $automatic = false) { |
|
957 | + if ($this->can_plugin_activate($slug)) { |
|
958 | + $activate = activate_plugin($file_path); |
|
959 | 959 | |
960 | - if ( is_wp_error( $activate ) ) { |
|
961 | - echo '<div id="message" class="error"><p>', wp_kses_post( $activate->get_error_message() ), '</p></div>', |
|
962 | - '<p><a href="', esc_url( $this->get_tgmpa_url() ), '" target="_parent">', esc_html( $this->strings['return'] ), '</a></p>'; |
|
960 | + if (is_wp_error($activate)) { |
|
961 | + echo '<div id="message" class="error"><p>', wp_kses_post($activate->get_error_message()), '</p></div>', |
|
962 | + '<p><a href="', esc_url($this->get_tgmpa_url()), '" target="_parent">', esc_html($this->strings['return']), '</a></p>'; |
|
963 | 963 | |
964 | 964 | return false; // End it here if there is an error with activation. |
965 | 965 | } else { |
966 | - if ( ! $automatic ) { |
|
966 | + if (!$automatic) { |
|
967 | 967 | // Make sure message doesn't display again if bulk activation is performed |
968 | 968 | // immediately after a single activation. |
969 | - if ( ! isset( $_POST['action'] ) ) { // WPCS: CSRF OK. |
|
970 | - echo '<div id="message" class="updated"><p>', esc_html( $this->strings['activated_successfully'] ), ' <strong>', esc_html( $this->plugins[ $slug ]['name'] ), '.</strong></p></div>'; |
|
969 | + if (!isset($_POST['action'])) { // WPCS: CSRF OK. |
|
970 | + echo '<div id="message" class="updated"><p>', esc_html($this->strings['activated_successfully']), ' <strong>', esc_html($this->plugins[$slug]['name']), '.</strong></p></div>'; |
|
971 | 971 | } |
972 | 972 | } else { |
973 | 973 | // Simpler message layout for use on the plugin install page. |
974 | - echo '<p>', esc_html( $this->strings['plugin_activated'] ), '</p>'; |
|
974 | + echo '<p>', esc_html($this->strings['plugin_activated']), '</p>'; |
|
975 | 975 | } |
976 | 976 | } |
977 | - } elseif ( $this->is_plugin_active( $slug ) ) { |
|
977 | + } elseif ($this->is_plugin_active($slug)) { |
|
978 | 978 | // No simpler message format provided as this message should never be encountered |
979 | 979 | // on the plugin install page. |
980 | 980 | echo '<div id="message" class="error"><p>', |
981 | 981 | sprintf( |
982 | - esc_html( $this->strings['plugin_already_active'] ), |
|
983 | - '<strong>' . esc_html( $this->plugins[ $slug ]['name'] ) . '</strong>' |
|
982 | + esc_html($this->strings['plugin_already_active']), |
|
983 | + '<strong>'.esc_html($this->plugins[$slug]['name']).'</strong>' |
|
984 | 984 | ), |
985 | 985 | '</p></div>'; |
986 | - } elseif ( $this->does_plugin_require_update( $slug ) ) { |
|
987 | - if ( ! $automatic ) { |
|
986 | + } elseif ($this->does_plugin_require_update($slug)) { |
|
987 | + if (!$automatic) { |
|
988 | 988 | // Make sure message doesn't display again if bulk activation is performed |
989 | 989 | // immediately after a single activation. |
990 | - if ( ! isset( $_POST['action'] ) ) { // WPCS: CSRF OK. |
|
990 | + if (!isset($_POST['action'])) { // WPCS: CSRF OK. |
|
991 | 991 | echo '<div id="message" class="error"><p>', |
992 | 992 | sprintf( |
993 | - esc_html( $this->strings['plugin_needs_higher_version'] ), |
|
994 | - '<strong>' . esc_html( $this->plugins[ $slug ]['name'] ) . '</strong>' |
|
993 | + esc_html($this->strings['plugin_needs_higher_version']), |
|
994 | + '<strong>'.esc_html($this->plugins[$slug]['name']).'</strong>' |
|
995 | 995 | ), |
996 | 996 | '</p></div>'; |
997 | 997 | } |
998 | 998 | } else { |
999 | 999 | // Simpler message layout for use on the plugin install page. |
1000 | - echo '<p>', sprintf( esc_html( $this->strings['plugin_needs_higher_version'] ), esc_html( $this->plugins[ $slug ]['name'] ) ), '</p>'; |
|
1000 | + echo '<p>', sprintf(esc_html($this->strings['plugin_needs_higher_version']), esc_html($this->plugins[$slug]['name'])), '</p>'; |
|
1001 | 1001 | } |
1002 | 1002 | } |
1003 | 1003 | |
@@ -1021,7 +1021,7 @@ discard block |
||
1021 | 1021 | */ |
1022 | 1022 | public function notices() { |
1023 | 1023 | // Remove nag on the install page / Return early if the nag message has been dismissed. |
1024 | - if ( $this->is_tgmpa_page() || get_user_meta( get_current_user_id(), 'tgmpa_dismissed_notice_' . $this->id, true ) ) { |
|
1024 | + if ($this->is_tgmpa_page() || get_user_meta(get_current_user_id(), 'tgmpa_dismissed_notice_'.$this->id, true)) { |
|
1025 | 1025 | return; |
1026 | 1026 | } |
1027 | 1027 | |
@@ -1033,16 +1033,16 @@ discard block |
||
1033 | 1033 | $update_link_count = 0; |
1034 | 1034 | $activate_link_count = 0; |
1035 | 1035 | |
1036 | - foreach ( $this->plugins as $slug => $plugin ) { |
|
1037 | - if ( $this->is_plugin_active( $slug ) && false === $this->does_plugin_have_update( $slug ) ) { |
|
1036 | + foreach ($this->plugins as $slug => $plugin) { |
|
1037 | + if ($this->is_plugin_active($slug) && false === $this->does_plugin_have_update($slug)) { |
|
1038 | 1038 | continue; |
1039 | 1039 | } |
1040 | 1040 | |
1041 | - if ( ! $this->is_plugin_installed( $slug ) ) { |
|
1042 | - if ( current_user_can( 'install_plugins' ) ) { |
|
1041 | + if (!$this->is_plugin_installed($slug)) { |
|
1042 | + if (current_user_can('install_plugins')) { |
|
1043 | 1043 | $install_link_count++; |
1044 | 1044 | |
1045 | - if ( true === $plugin['required'] ) { |
|
1045 | + if (true === $plugin['required']) { |
|
1046 | 1046 | $message['notice_can_install_required'][] = $slug; |
1047 | 1047 | } else { |
1048 | 1048 | $message['notice_can_install_recommended'][] = $slug; |
@@ -1052,11 +1052,11 @@ discard block |
||
1052 | 1052 | $message['notice_cannot_install'][] = $slug; |
1053 | 1053 | } |
1054 | 1054 | } else { |
1055 | - if ( ! $this->is_plugin_active( $slug ) && $this->can_plugin_activate( $slug ) ) { |
|
1056 | - if ( current_user_can( 'activate_plugins' ) ) { |
|
1055 | + if (!$this->is_plugin_active($slug) && $this->can_plugin_activate($slug)) { |
|
1056 | + if (current_user_can('activate_plugins')) { |
|
1057 | 1057 | $activate_link_count++; |
1058 | 1058 | |
1059 | - if ( true === $plugin['required'] ) { |
|
1059 | + if (true === $plugin['required']) { |
|
1060 | 1060 | $message['notice_can_activate_required'][] = $slug; |
1061 | 1061 | } else { |
1062 | 1062 | $message['notice_can_activate_recommended'][] = $slug; |
@@ -1067,14 +1067,14 @@ discard block |
||
1067 | 1067 | } |
1068 | 1068 | } |
1069 | 1069 | |
1070 | - if ( $this->does_plugin_require_update( $slug ) || false !== $this->does_plugin_have_update( $slug ) ) { |
|
1070 | + if ($this->does_plugin_require_update($slug) || false !== $this->does_plugin_have_update($slug)) { |
|
1071 | 1071 | |
1072 | - if ( current_user_can( 'install_plugins' ) ) { |
|
1072 | + if (current_user_can('install_plugins')) { |
|
1073 | 1073 | $update_link_count++; |
1074 | 1074 | |
1075 | - if ( $this->does_plugin_require_update( $slug ) ) { |
|
1075 | + if ($this->does_plugin_require_update($slug)) { |
|
1076 | 1076 | $message['notice_ask_to_update'][] = $slug; |
1077 | - } elseif ( false !== $this->does_plugin_have_update( $slug ) ) { |
|
1077 | + } elseif (false !== $this->does_plugin_have_update($slug)) { |
|
1078 | 1078 | $message['notice_ask_to_update_maybe'][] = $slug; |
1079 | 1079 | } |
1080 | 1080 | } else { |
@@ -1084,107 +1084,107 @@ discard block |
||
1084 | 1084 | } |
1085 | 1085 | } |
1086 | 1086 | } |
1087 | - unset( $slug, $plugin ); |
|
1087 | + unset($slug, $plugin); |
|
1088 | 1088 | |
1089 | 1089 | // If we have notices to display, we move forward. |
1090 | - if ( ! empty( $message ) ) { |
|
1091 | - krsort( $message ); // Sort messages. |
|
1090 | + if (!empty($message)) { |
|
1091 | + krsort($message); // Sort messages. |
|
1092 | 1092 | $rendered = ''; |
1093 | 1093 | |
1094 | 1094 | // As add_settings_error() wraps the final message in a <p> and as the final message can't be |
1095 | 1095 | // filtered, using <p>'s in our html would render invalid html output. |
1096 | - $line_template = '<span style="display: block; margin: 0.5em 0.5em 0 0; clear: both;">%s</span>' . "\n"; |
|
1096 | + $line_template = '<span style="display: block; margin: 0.5em 0.5em 0 0; clear: both;">%s</span>'."\n"; |
|
1097 | 1097 | |
1098 | 1098 | // If dismissable is false and a message is set, output it now. |
1099 | - if ( ! $this->dismissable && ! empty( $this->dismiss_msg ) ) { |
|
1100 | - $rendered .= sprintf( $line_template, wp_kses_post( $this->dismiss_msg ) ); |
|
1099 | + if (!$this->dismissable && !empty($this->dismiss_msg)) { |
|
1100 | + $rendered .= sprintf($line_template, wp_kses_post($this->dismiss_msg)); |
|
1101 | 1101 | } |
1102 | 1102 | |
1103 | 1103 | // Render the individual message lines for the notice. |
1104 | - foreach ( $message as $type => $plugin_group ) { |
|
1104 | + foreach ($message as $type => $plugin_group) { |
|
1105 | 1105 | $linked_plugins = array(); |
1106 | 1106 | |
1107 | 1107 | // Get the external info link for a plugin if one is available. |
1108 | - foreach ( $plugin_group as $plugin_slug ) { |
|
1109 | - $linked_plugins[] = $this->get_info_link( $plugin_slug ); |
|
1108 | + foreach ($plugin_group as $plugin_slug) { |
|
1109 | + $linked_plugins[] = $this->get_info_link($plugin_slug); |
|
1110 | 1110 | } |
1111 | - unset( $plugin_slug ); |
|
1111 | + unset($plugin_slug); |
|
1112 | 1112 | |
1113 | - $count = count( $plugin_group ); |
|
1114 | - $linked_plugins = array_map( array( 'TGMPA_Utils', 'wrap_in_em' ), $linked_plugins ); |
|
1115 | - $last_plugin = array_pop( $linked_plugins ); // Pop off last name to prep for readability. |
|
1116 | - $imploded = empty( $linked_plugins ) ? $last_plugin : ( implode( ', ', $linked_plugins ) . ' ' . esc_html_x( 'and', 'plugin A *and* plugin B', 'tgmpa' ) . ' ' . $last_plugin ); |
|
1113 | + $count = count($plugin_group); |
|
1114 | + $linked_plugins = array_map(array('TGMPA_Utils', 'wrap_in_em'), $linked_plugins); |
|
1115 | + $last_plugin = array_pop($linked_plugins); // Pop off last name to prep for readability. |
|
1116 | + $imploded = empty($linked_plugins) ? $last_plugin : (implode(', ', $linked_plugins).' '.esc_html_x('and', 'plugin A *and* plugin B', 'tgmpa').' '.$last_plugin); |
|
1117 | 1117 | |
1118 | 1118 | $rendered .= sprintf( |
1119 | 1119 | $line_template, |
1120 | 1120 | sprintf( |
1121 | - translate_nooped_plural( $this->strings[ $type ], $count, 'tgmpa' ), |
|
1121 | + translate_nooped_plural($this->strings[$type], $count, 'tgmpa'), |
|
1122 | 1122 | $imploded, |
1123 | 1123 | $count |
1124 | 1124 | ) |
1125 | 1125 | ); |
1126 | 1126 | |
1127 | - if ( 0 === strpos( $type, 'notice_cannot' ) ) { |
|
1127 | + if (0 === strpos($type, 'notice_cannot')) { |
|
1128 | 1128 | $rendered .= $this->strings['contact_admin']; |
1129 | 1129 | } |
1130 | 1130 | } |
1131 | - unset( $type, $plugin_group, $linked_plugins, $count, $last_plugin, $imploded ); |
|
1131 | + unset($type, $plugin_group, $linked_plugins, $count, $last_plugin, $imploded); |
|
1132 | 1132 | |
1133 | 1133 | // Setup action links. |
1134 | 1134 | $action_links = array( |
1135 | 1135 | 'install' => '', |
1136 | 1136 | 'update' => '', |
1137 | 1137 | 'activate' => '', |
1138 | - 'dismiss' => $this->dismissable ? '<a href="' . esc_url( add_query_arg( 'tgmpa-dismiss', 'dismiss_admin_notices' ) ) . '" class="dismiss-notice" target="_parent">' . esc_html( $this->strings['dismiss'] ) . '</a>' : '', |
|
1138 | + 'dismiss' => $this->dismissable ? '<a href="'.esc_url(add_query_arg('tgmpa-dismiss', 'dismiss_admin_notices')).'" class="dismiss-notice" target="_parent">'.esc_html($this->strings['dismiss']).'</a>' : '', |
|
1139 | 1139 | ); |
1140 | 1140 | |
1141 | 1141 | $link_template = '<a href="%2$s">%1$s</a>'; |
1142 | 1142 | |
1143 | - if ( current_user_can( 'install_plugins' ) ) { |
|
1144 | - if ( $install_link_count > 0 ) { |
|
1143 | + if (current_user_can('install_plugins')) { |
|
1144 | + if ($install_link_count > 0) { |
|
1145 | 1145 | $action_links['install'] = sprintf( |
1146 | 1146 | $link_template, |
1147 | - translate_nooped_plural( $this->strings['install_link'], $install_link_count, 'tgmpa' ), |
|
1148 | - esc_url( $this->get_tgmpa_status_url( 'install' ) ) |
|
1147 | + translate_nooped_plural($this->strings['install_link'], $install_link_count, 'tgmpa'), |
|
1148 | + esc_url($this->get_tgmpa_status_url('install')) |
|
1149 | 1149 | ); |
1150 | 1150 | } |
1151 | - if ( $update_link_count > 0 ) { |
|
1151 | + if ($update_link_count > 0) { |
|
1152 | 1152 | $action_links['update'] = sprintf( |
1153 | 1153 | $link_template, |
1154 | - translate_nooped_plural( $this->strings['update_link'], $update_link_count, 'tgmpa' ), |
|
1155 | - esc_url( $this->get_tgmpa_status_url( 'update' ) ) |
|
1154 | + translate_nooped_plural($this->strings['update_link'], $update_link_count, 'tgmpa'), |
|
1155 | + esc_url($this->get_tgmpa_status_url('update')) |
|
1156 | 1156 | ); |
1157 | 1157 | } |
1158 | 1158 | } |
1159 | 1159 | |
1160 | - if ( current_user_can( 'activate_plugins' ) && $activate_link_count > 0 ) { |
|
1160 | + if (current_user_can('activate_plugins') && $activate_link_count > 0) { |
|
1161 | 1161 | $action_links['activate'] = sprintf( |
1162 | 1162 | $link_template, |
1163 | - translate_nooped_plural( $this->strings['activate_link'], $activate_link_count, 'tgmpa' ), |
|
1164 | - esc_url( $this->get_tgmpa_status_url( 'activate' ) ) |
|
1163 | + translate_nooped_plural($this->strings['activate_link'], $activate_link_count, 'tgmpa'), |
|
1164 | + esc_url($this->get_tgmpa_status_url('activate')) |
|
1165 | 1165 | ); |
1166 | 1166 | } |
1167 | 1167 | |
1168 | - $action_links = apply_filters( 'tgmpa_notice_action_links', $action_links ); |
|
1168 | + $action_links = apply_filters('tgmpa_notice_action_links', $action_links); |
|
1169 | 1169 | |
1170 | - $action_links = array_filter( (array) $action_links ); // Remove any empty array items. |
|
1170 | + $action_links = array_filter((array) $action_links); // Remove any empty array items. |
|
1171 | 1171 | |
1172 | - if ( ! empty( $action_links ) && is_array( $action_links ) ) { |
|
1173 | - $action_links = sprintf( $line_template, implode( ' | ', $action_links ) ); |
|
1174 | - $rendered .= apply_filters( 'tgmpa_notice_rendered_action_links', $action_links ); |
|
1172 | + if (!empty($action_links) && is_array($action_links)) { |
|
1173 | + $action_links = sprintf($line_template, implode(' | ', $action_links)); |
|
1174 | + $rendered .= apply_filters('tgmpa_notice_rendered_action_links', $action_links); |
|
1175 | 1175 | } |
1176 | 1176 | |
1177 | 1177 | // Register the nag messages and prepare them to be processed. |
1178 | - if ( ! empty( $this->strings['nag_type'] ) ) { |
|
1179 | - add_settings_error( 'tgmpa', 'tgmpa', $rendered, sanitize_html_class( strtolower( $this->strings['nag_type'] ) ) ); |
|
1178 | + if (!empty($this->strings['nag_type'])) { |
|
1179 | + add_settings_error('tgmpa', 'tgmpa', $rendered, sanitize_html_class(strtolower($this->strings['nag_type']))); |
|
1180 | 1180 | } else { |
1181 | - $nag_class = version_compare( $this->wp_version, '3.8', '<' ) ? 'updated' : 'update-nag'; |
|
1182 | - add_settings_error( 'tgmpa', 'tgmpa', $rendered, $nag_class ); |
|
1181 | + $nag_class = version_compare($this->wp_version, '3.8', '<') ? 'updated' : 'update-nag'; |
|
1182 | + add_settings_error('tgmpa', 'tgmpa', $rendered, $nag_class); |
|
1183 | 1183 | } |
1184 | 1184 | } |
1185 | 1185 | |
1186 | 1186 | // Admin options pages already output settings_errors, so this is to avoid duplication. |
1187 | - if ( 'options-general' !== $GLOBALS['current_screen']->parent_base ) { |
|
1187 | + if ('options-general' !== $GLOBALS['current_screen']->parent_base) { |
|
1188 | 1188 | $this->display_settings_errors(); |
1189 | 1189 | } |
1190 | 1190 | } |
@@ -1197,11 +1197,11 @@ discard block |
||
1197 | 1197 | protected function display_settings_errors() { |
1198 | 1198 | global $wp_settings_errors; |
1199 | 1199 | |
1200 | - settings_errors( 'tgmpa' ); |
|
1200 | + settings_errors('tgmpa'); |
|
1201 | 1201 | |
1202 | - foreach ( (array) $wp_settings_errors as $key => $details ) { |
|
1203 | - if ( 'tgmpa' === $details['setting'] ) { |
|
1204 | - unset( $wp_settings_errors[ $key ] ); |
|
1202 | + foreach ((array) $wp_settings_errors as $key => $details) { |
|
1203 | + if ('tgmpa' === $details['setting']) { |
|
1204 | + unset($wp_settings_errors[$key]); |
|
1205 | 1205 | break; |
1206 | 1206 | } |
1207 | 1207 | } |
@@ -1215,8 +1215,8 @@ discard block |
||
1215 | 1215 | * @since 2.1.0 |
1216 | 1216 | */ |
1217 | 1217 | public function dismiss() { |
1218 | - if ( isset( $_GET['tgmpa-dismiss'] ) ) { |
|
1219 | - update_user_meta( get_current_user_id(), 'tgmpa_dismissed_notice_' . $this->id, 1 ); |
|
1218 | + if (isset($_GET['tgmpa-dismiss'])) { |
|
1219 | + update_user_meta(get_current_user_id(), 'tgmpa_dismissed_notice_'.$this->id, 1); |
|
1220 | 1220 | } |
1221 | 1221 | } |
1222 | 1222 | |
@@ -1231,55 +1231,55 @@ discard block |
||
1231 | 1231 | * @param array|null $plugin Array of plugin arguments or null if invalid argument. |
1232 | 1232 | * @return null Return early if incorrect argument. |
1233 | 1233 | */ |
1234 | - public function register( $plugin ) { |
|
1235 | - if ( empty( $plugin['slug'] ) || empty( $plugin['name'] ) ) { |
|
1234 | + public function register($plugin) { |
|
1235 | + if (empty($plugin['slug']) || empty($plugin['name'])) { |
|
1236 | 1236 | return; |
1237 | 1237 | } |
1238 | 1238 | |
1239 | - if ( empty( $plugin['slug'] ) || ! is_string( $plugin['slug'] ) || isset( $this->plugins[ $plugin['slug'] ] ) ) { |
|
1239 | + if (empty($plugin['slug']) || !is_string($plugin['slug']) || isset($this->plugins[$plugin['slug']])) { |
|
1240 | 1240 | return; |
1241 | 1241 | } |
1242 | 1242 | |
1243 | 1243 | $defaults = array( |
1244 | - 'name' => '', // String |
|
1245 | - 'slug' => '', // String |
|
1246 | - 'source' => 'repo', // String |
|
1247 | - 'required' => false, // Boolean |
|
1248 | - 'version' => '', // String |
|
1249 | - 'force_activation' => false, // Boolean |
|
1250 | - 'force_deactivation' => false, // Boolean |
|
1251 | - 'external_url' => '', // String |
|
1252 | - 'is_callable' => '', // String|Array. |
|
1244 | + 'name' => '', // String |
|
1245 | + 'slug' => '', // String |
|
1246 | + 'source' => 'repo', // String |
|
1247 | + 'required' => false, // Boolean |
|
1248 | + 'version' => '', // String |
|
1249 | + 'force_activation' => false, // Boolean |
|
1250 | + 'force_deactivation' => false, // Boolean |
|
1251 | + 'external_url' => '', // String |
|
1252 | + 'is_callable' => '', // String|Array. |
|
1253 | 1253 | ); |
1254 | 1254 | |
1255 | 1255 | // Prepare the received data. |
1256 | - $plugin = wp_parse_args( $plugin, $defaults ); |
|
1256 | + $plugin = wp_parse_args($plugin, $defaults); |
|
1257 | 1257 | |
1258 | 1258 | // Standardize the received slug. |
1259 | - $plugin['slug'] = $this->sanitize_key( $plugin['slug'] ); |
|
1259 | + $plugin['slug'] = $this->sanitize_key($plugin['slug']); |
|
1260 | 1260 | |
1261 | 1261 | // Forgive users for using string versions of booleans or floats for version number. |
1262 | 1262 | $plugin['version'] = (string) $plugin['version']; |
1263 | - $plugin['source'] = empty( $plugin['source'] ) ? 'repo' : $plugin['source']; |
|
1264 | - $plugin['required'] = TGMPA_Utils::validate_bool( $plugin['required'] ); |
|
1265 | - $plugin['force_activation'] = TGMPA_Utils::validate_bool( $plugin['force_activation'] ); |
|
1266 | - $plugin['force_deactivation'] = TGMPA_Utils::validate_bool( $plugin['force_deactivation'] ); |
|
1263 | + $plugin['source'] = empty($plugin['source']) ? 'repo' : $plugin['source']; |
|
1264 | + $plugin['required'] = TGMPA_Utils::validate_bool($plugin['required']); |
|
1265 | + $plugin['force_activation'] = TGMPA_Utils::validate_bool($plugin['force_activation']); |
|
1266 | + $plugin['force_deactivation'] = TGMPA_Utils::validate_bool($plugin['force_deactivation']); |
|
1267 | 1267 | |
1268 | 1268 | // Enrich the received data. |
1269 | - $plugin['file_path'] = $this->_get_plugin_basename_from_slug( $plugin['slug'] ); |
|
1270 | - $plugin['source_type'] = $this->get_plugin_source_type( $plugin['source'] ); |
|
1269 | + $plugin['file_path'] = $this->_get_plugin_basename_from_slug($plugin['slug']); |
|
1270 | + $plugin['source_type'] = $this->get_plugin_source_type($plugin['source']); |
|
1271 | 1271 | |
1272 | 1272 | // Set the class properties. |
1273 | - $this->plugins[ $plugin['slug'] ] = $plugin; |
|
1274 | - $this->sort_order[ $plugin['slug'] ] = $plugin['name']; |
|
1273 | + $this->plugins[$plugin['slug']] = $plugin; |
|
1274 | + $this->sort_order[$plugin['slug']] = $plugin['name']; |
|
1275 | 1275 | |
1276 | 1276 | // Should we add the force activation hook ? |
1277 | - if ( true === $plugin['force_activation'] ) { |
|
1277 | + if (true === $plugin['force_activation']) { |
|
1278 | 1278 | $this->has_forced_activation = true; |
1279 | 1279 | } |
1280 | 1280 | |
1281 | 1281 | // Should we add the force deactivation hook ? |
1282 | - if ( true === $plugin['force_deactivation'] ) { |
|
1282 | + if (true === $plugin['force_deactivation']) { |
|
1283 | 1283 | $this->has_forced_deactivation = true; |
1284 | 1284 | } |
1285 | 1285 | } |
@@ -1293,10 +1293,10 @@ discard block |
||
1293 | 1293 | * (= bundled) or an external URL. |
1294 | 1294 | * @return string 'repo', 'external', or 'bundled' |
1295 | 1295 | */ |
1296 | - protected function get_plugin_source_type( $source ) { |
|
1297 | - if ( 'repo' === $source || preg_match( self::WP_REPO_REGEX, $source ) ) { |
|
1296 | + protected function get_plugin_source_type($source) { |
|
1297 | + if ('repo' === $source || preg_match(self::WP_REPO_REGEX, $source)) { |
|
1298 | 1298 | return 'repo'; |
1299 | - } elseif ( preg_match( self::IS_URL_REGEX, $source ) ) { |
|
1299 | + } elseif (preg_match(self::IS_URL_REGEX, $source)) { |
|
1300 | 1300 | return 'external'; |
1301 | 1301 | } else { |
1302 | 1302 | return 'bundled'; |
@@ -1317,9 +1317,9 @@ discard block |
||
1317 | 1317 | * @param string $key String key. |
1318 | 1318 | * @return string Sanitized key |
1319 | 1319 | */ |
1320 | - public function sanitize_key( $key ) { |
|
1320 | + public function sanitize_key($key) { |
|
1321 | 1321 | $raw_key = $key; |
1322 | - $key = preg_replace( '`[^A-Za-z0-9_-]`', '', $key ); |
|
1322 | + $key = preg_replace('`[^A-Za-z0-9_-]`', '', $key); |
|
1323 | 1323 | |
1324 | 1324 | /** |
1325 | 1325 | * Filter a sanitized key string. |
@@ -1329,7 +1329,7 @@ discard block |
||
1329 | 1329 | * @param string $key Sanitized key. |
1330 | 1330 | * @param string $raw_key The key prior to sanitization. |
1331 | 1331 | */ |
1332 | - return apply_filters( 'tgmpa_sanitize_key', $key, $raw_key ); |
|
1332 | + return apply_filters('tgmpa_sanitize_key', $key, $raw_key); |
|
1333 | 1333 | } |
1334 | 1334 | |
1335 | 1335 | /** |
@@ -1339,7 +1339,7 @@ discard block |
||
1339 | 1339 | * |
1340 | 1340 | * @param array $config Array of config options to pass as class properties. |
1341 | 1341 | */ |
1342 | - public function config( $config ) { |
|
1342 | + public function config($config) { |
|
1343 | 1343 | $keys = array( |
1344 | 1344 | 'id', |
1345 | 1345 | 'default_path', |
@@ -1354,12 +1354,12 @@ discard block |
||
1354 | 1354 | 'strings', |
1355 | 1355 | ); |
1356 | 1356 | |
1357 | - foreach ( $keys as $key ) { |
|
1358 | - if ( isset( $config[ $key ] ) ) { |
|
1359 | - if ( is_array( $config[ $key ] ) ) { |
|
1360 | - $this->$key = array_merge( $this->$key, $config[ $key ] ); |
|
1357 | + foreach ($keys as $key) { |
|
1358 | + if (isset($config[$key])) { |
|
1359 | + if (is_array($config[$key])) { |
|
1360 | + $this->$key = array_merge($this->$key, $config[$key]); |
|
1361 | 1361 | } else { |
1362 | - $this->$key = $config[ $key ]; |
|
1362 | + $this->$key = $config[$key]; |
|
1363 | 1363 | } |
1364 | 1364 | } |
1365 | 1365 | } |
@@ -1373,9 +1373,9 @@ discard block |
||
1373 | 1373 | * @param array $install_actions Existing array of actions. |
1374 | 1374 | * @return array Amended array of actions. |
1375 | 1375 | */ |
1376 | - public function actions( $install_actions ) { |
|
1376 | + public function actions($install_actions) { |
|
1377 | 1377 | // Remove action links on the TGMPA install page. |
1378 | - if ( $this->is_tgmpa_page() ) { |
|
1378 | + if ($this->is_tgmpa_page()) { |
|
1379 | 1379 | return false; |
1380 | 1380 | } |
1381 | 1381 | |
@@ -1391,8 +1391,8 @@ discard block |
||
1391 | 1391 | * @param bool $clear_update_cache Optional. Whether to clear the Plugin updates cache. |
1392 | 1392 | * Parameter added in v2.5.0. |
1393 | 1393 | */ |
1394 | - public function flush_plugins_cache( $clear_update_cache = true ) { |
|
1395 | - wp_clean_plugins_cache( $clear_update_cache ); |
|
1394 | + public function flush_plugins_cache($clear_update_cache = true) { |
|
1395 | + wp_clean_plugins_cache($clear_update_cache); |
|
1396 | 1396 | } |
1397 | 1397 | |
1398 | 1398 | /** |
@@ -1403,13 +1403,13 @@ discard block |
||
1403 | 1403 | * @param string $plugin_slug Optional. If set, only (re-)populates the file path for that specific plugin. |
1404 | 1404 | * Parameter added in v2.5.0. |
1405 | 1405 | */ |
1406 | - public function populate_file_path( $plugin_slug = '' ) { |
|
1407 | - if ( ! empty( $plugin_slug ) && is_string( $plugin_slug ) && isset( $this->plugins[ $plugin_slug ] ) ) { |
|
1408 | - $this->plugins[ $plugin_slug ]['file_path'] = $this->_get_plugin_basename_from_slug( $plugin_slug ); |
|
1406 | + public function populate_file_path($plugin_slug = '') { |
|
1407 | + if (!empty($plugin_slug) && is_string($plugin_slug) && isset($this->plugins[$plugin_slug])) { |
|
1408 | + $this->plugins[$plugin_slug]['file_path'] = $this->_get_plugin_basename_from_slug($plugin_slug); |
|
1409 | 1409 | } else { |
1410 | 1410 | // Add file_path key for all plugins. |
1411 | - foreach ( $this->plugins as $slug => $values ) { |
|
1412 | - $this->plugins[ $slug ]['file_path'] = $this->_get_plugin_basename_from_slug( $slug ); |
|
1411 | + foreach ($this->plugins as $slug => $values) { |
|
1412 | + $this->plugins[$slug]['file_path'] = $this->_get_plugin_basename_from_slug($slug); |
|
1413 | 1413 | } |
1414 | 1414 | } |
1415 | 1415 | } |
@@ -1423,11 +1423,11 @@ discard block |
||
1423 | 1423 | * @param string $slug Plugin slug (typically folder name) as provided by the developer. |
1424 | 1424 | * @return string Either file path for plugin if installed, or just the plugin slug. |
1425 | 1425 | */ |
1426 | - protected function _get_plugin_basename_from_slug( $slug ) { |
|
1427 | - $keys = array_keys( $this->get_plugins() ); |
|
1426 | + protected function _get_plugin_basename_from_slug($slug) { |
|
1427 | + $keys = array_keys($this->get_plugins()); |
|
1428 | 1428 | |
1429 | - foreach ( $keys as $key ) { |
|
1430 | - if ( preg_match( '|^' . $slug . '/|', $key ) ) { |
|
1429 | + foreach ($keys as $key) { |
|
1430 | + if (preg_match('|^'.$slug.'/|', $key)) { |
|
1431 | 1431 | return $key; |
1432 | 1432 | } |
1433 | 1433 | } |
@@ -1447,10 +1447,10 @@ discard block |
||
1447 | 1447 | * @param string $data Optional. Array key of plugin data to return. Default is slug. |
1448 | 1448 | * @return string|boolean Plugin slug if found, false otherwise. |
1449 | 1449 | */ |
1450 | - public function _get_plugin_data_from_name( $name, $data = 'slug' ) { |
|
1451 | - foreach ( $this->plugins as $values ) { |
|
1452 | - if ( $name === $values['name'] && isset( $values[ $data ] ) ) { |
|
1453 | - return $values[ $data ]; |
|
1450 | + public function _get_plugin_data_from_name($name, $data = 'slug') { |
|
1451 | + foreach ($this->plugins as $values) { |
|
1452 | + if ($name === $values['name'] && isset($values[$data])) { |
|
1453 | + return $values[$data]; |
|
1454 | 1454 | } |
1455 | 1455 | } |
1456 | 1456 | |
@@ -1465,16 +1465,16 @@ discard block |
||
1465 | 1465 | * @param string $slug Plugin slug. |
1466 | 1466 | * @return string Plugin download URL or path to local file or empty string if undetermined. |
1467 | 1467 | */ |
1468 | - public function get_download_url( $slug ) { |
|
1468 | + public function get_download_url($slug) { |
|
1469 | 1469 | $dl_source = ''; |
1470 | 1470 | |
1471 | - switch ( $this->plugins[ $slug ]['source_type'] ) { |
|
1471 | + switch ($this->plugins[$slug]['source_type']) { |
|
1472 | 1472 | case 'repo': |
1473 | - return $this->get_wp_repo_download_url( $slug ); |
|
1473 | + return $this->get_wp_repo_download_url($slug); |
|
1474 | 1474 | case 'external': |
1475 | - return $this->plugins[ $slug ]['source']; |
|
1475 | + return $this->plugins[$slug]['source']; |
|
1476 | 1476 | case 'bundled': |
1477 | - return $this->default_path . $this->plugins[ $slug ]['source']; |
|
1477 | + return $this->default_path.$this->plugins[$slug]['source']; |
|
1478 | 1478 | } |
1479 | 1479 | |
1480 | 1480 | return $dl_source; // Should never happen. |
@@ -1488,11 +1488,11 @@ discard block |
||
1488 | 1488 | * @param string $slug Plugin slug. |
1489 | 1489 | * @return string Plugin download URL. |
1490 | 1490 | */ |
1491 | - protected function get_wp_repo_download_url( $slug ) { |
|
1491 | + protected function get_wp_repo_download_url($slug) { |
|
1492 | 1492 | $source = ''; |
1493 | - $api = $this->get_plugins_api( $slug ); |
|
1493 | + $api = $this->get_plugins_api($slug); |
|
1494 | 1494 | |
1495 | - if ( false !== $api && isset( $api->download_link ) ) { |
|
1495 | + if (false !== $api && isset($api->download_link)) { |
|
1496 | 1496 | $source = $api->download_link; |
1497 | 1497 | } |
1498 | 1498 | |
@@ -1507,26 +1507,26 @@ discard block |
||
1507 | 1507 | * @param string $slug Plugin slug. |
1508 | 1508 | * @return object Plugins_api response object on success, WP_Error on failure. |
1509 | 1509 | */ |
1510 | - protected function get_plugins_api( $slug ) { |
|
1510 | + protected function get_plugins_api($slug) { |
|
1511 | 1511 | static $api = array(); // Cache received responses. |
1512 | 1512 | |
1513 | - if ( ! isset( $api[ $slug ] ) ) { |
|
1514 | - if ( ! function_exists( 'plugins_api' ) ) { |
|
1515 | - require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; |
|
1513 | + if (!isset($api[$slug])) { |
|
1514 | + if (!function_exists('plugins_api')) { |
|
1515 | + require_once ABSPATH.'wp-admin/includes/plugin-install.php'; |
|
1516 | 1516 | } |
1517 | 1517 | |
1518 | - $response = plugins_api( 'plugin_information', array( 'slug' => $slug, 'fields' => array( 'sections' => false ) ) ); |
|
1518 | + $response = plugins_api('plugin_information', array('slug' => $slug, 'fields' => array('sections' => false))); |
|
1519 | 1519 | |
1520 | - $api[ $slug ] = false; |
|
1520 | + $api[$slug] = false; |
|
1521 | 1521 | |
1522 | - if ( is_wp_error( $response ) ) { |
|
1523 | - wp_die( esc_html( $this->strings['oops'] ) ); |
|
1522 | + if (is_wp_error($response)) { |
|
1523 | + wp_die(esc_html($this->strings['oops'])); |
|
1524 | 1524 | } else { |
1525 | - $api[ $slug ] = $response; |
|
1525 | + $api[$slug] = $response; |
|
1526 | 1526 | } |
1527 | 1527 | } |
1528 | 1528 | |
1529 | - return $api[ $slug ]; |
|
1529 | + return $api[$slug]; |
|
1530 | 1530 | } |
1531 | 1531 | |
1532 | 1532 | /** |
@@ -1538,32 +1538,32 @@ discard block |
||
1538 | 1538 | * @return string Fully formed html link to a plugin information page if available |
1539 | 1539 | * or the plugin name if not. |
1540 | 1540 | */ |
1541 | - public function get_info_link( $slug ) { |
|
1542 | - if ( ! empty( $this->plugins[ $slug ]['external_url'] ) && preg_match( self::IS_URL_REGEX, $this->plugins[ $slug ]['external_url'] ) ) { |
|
1541 | + public function get_info_link($slug) { |
|
1542 | + if (!empty($this->plugins[$slug]['external_url']) && preg_match(self::IS_URL_REGEX, $this->plugins[$slug]['external_url'])) { |
|
1543 | 1543 | $link = sprintf( |
1544 | 1544 | '<a href="%1$s" target="_blank">%2$s</a>', |
1545 | - esc_url( $this->plugins[ $slug ]['external_url'] ), |
|
1546 | - esc_html( $this->plugins[ $slug ]['name'] ) |
|
1545 | + esc_url($this->plugins[$slug]['external_url']), |
|
1546 | + esc_html($this->plugins[$slug]['name']) |
|
1547 | 1547 | ); |
1548 | - } elseif ( 'repo' === $this->plugins[ $slug ]['source_type'] ) { |
|
1548 | + } elseif ('repo' === $this->plugins[$slug]['source_type']) { |
|
1549 | 1549 | $url = add_query_arg( |
1550 | 1550 | array( |
1551 | 1551 | 'tab' => 'plugin-information', |
1552 | - 'plugin' => urlencode( $slug ), |
|
1552 | + 'plugin' => urlencode($slug), |
|
1553 | 1553 | 'TB_iframe' => 'true', |
1554 | 1554 | 'width' => '640', |
1555 | 1555 | 'height' => '500', |
1556 | 1556 | ), |
1557 | - self_admin_url( 'plugin-install.php' ) |
|
1557 | + self_admin_url('plugin-install.php') |
|
1558 | 1558 | ); |
1559 | 1559 | |
1560 | 1560 | $link = sprintf( |
1561 | 1561 | '<a href="%1$s" class="thickbox">%2$s</a>', |
1562 | - esc_url( $url ), |
|
1563 | - esc_html( $this->plugins[ $slug ]['name'] ) |
|
1562 | + esc_url($url), |
|
1563 | + esc_html($this->plugins[$slug]['name']) |
|
1564 | 1564 | ); |
1565 | 1565 | } else { |
1566 | - $link = esc_html( $this->plugins[ $slug ]['name'] ); // No hyperlink. |
|
1566 | + $link = esc_html($this->plugins[$slug]['name']); // No hyperlink. |
|
1567 | 1567 | } |
1568 | 1568 | |
1569 | 1569 | return $link; |
@@ -1577,7 +1577,7 @@ discard block |
||
1577 | 1577 | * @return boolean True when on the TGMPA page, false otherwise. |
1578 | 1578 | */ |
1579 | 1579 | protected function is_tgmpa_page() { |
1580 | - return isset( $_GET['page'] ) && $this->menu === $_GET['page']; |
|
1580 | + return isset($_GET['page']) && $this->menu === $_GET['page']; |
|
1581 | 1581 | } |
1582 | 1582 | |
1583 | 1583 | /** |
@@ -1593,16 +1593,16 @@ discard block |
||
1593 | 1593 | public function get_tgmpa_url() { |
1594 | 1594 | static $url; |
1595 | 1595 | |
1596 | - if ( ! isset( $url ) ) { |
|
1596 | + if (!isset($url)) { |
|
1597 | 1597 | $parent = $this->parent_slug; |
1598 | - if ( false === strpos( $parent, '.php' ) ) { |
|
1598 | + if (false === strpos($parent, '.php')) { |
|
1599 | 1599 | $parent = 'admin.php'; |
1600 | 1600 | } |
1601 | 1601 | $url = add_query_arg( |
1602 | 1602 | array( |
1603 | - 'page' => urlencode( $this->menu ), |
|
1603 | + 'page' => urlencode($this->menu), |
|
1604 | 1604 | ), |
1605 | - self_admin_url( $parent ) |
|
1605 | + self_admin_url($parent) |
|
1606 | 1606 | ); |
1607 | 1607 | } |
1608 | 1608 | |
@@ -1620,10 +1620,10 @@ discard block |
||
1620 | 1620 | * @param string $status Plugin status - either 'install', 'update' or 'activate'. |
1621 | 1621 | * @return string Properly encoded URL (not escaped). |
1622 | 1622 | */ |
1623 | - public function get_tgmpa_status_url( $status ) { |
|
1623 | + public function get_tgmpa_status_url($status) { |
|
1624 | 1624 | return add_query_arg( |
1625 | 1625 | array( |
1626 | - 'plugin_status' => urlencode( $status ), |
|
1626 | + 'plugin_status' => urlencode($status), |
|
1627 | 1627 | ), |
1628 | 1628 | $this->get_tgmpa_url() |
1629 | 1629 | ); |
@@ -1638,8 +1638,8 @@ discard block |
||
1638 | 1638 | */ |
1639 | 1639 | public function is_tgmpa_complete() { |
1640 | 1640 | $complete = true; |
1641 | - foreach ( $this->plugins as $slug => $plugin ) { |
|
1642 | - if ( ! $this->is_plugin_active( $slug ) || false !== $this->does_plugin_have_update( $slug ) ) { |
|
1641 | + foreach ($this->plugins as $slug => $plugin) { |
|
1642 | + if (!$this->is_plugin_active($slug) || false !== $this->does_plugin_have_update($slug)) { |
|
1643 | 1643 | $complete = false; |
1644 | 1644 | break; |
1645 | 1645 | } |
@@ -1656,10 +1656,10 @@ discard block |
||
1656 | 1656 | * @param string $slug Plugin slug. |
1657 | 1657 | * @return bool True if installed, false otherwise. |
1658 | 1658 | */ |
1659 | - public function is_plugin_installed( $slug ) { |
|
1659 | + public function is_plugin_installed($slug) { |
|
1660 | 1660 | $installed_plugins = $this->get_plugins(); // Retrieve a list of all installed plugins (WP cached). |
1661 | 1661 | |
1662 | - return ( ! empty( $installed_plugins[ $this->plugins[ $slug ]['file_path'] ] ) ); |
|
1662 | + return (!empty($installed_plugins[$this->plugins[$slug]['file_path']])); |
|
1663 | 1663 | } |
1664 | 1664 | |
1665 | 1665 | /** |
@@ -1670,8 +1670,8 @@ discard block |
||
1670 | 1670 | * @param string $slug Plugin slug. |
1671 | 1671 | * @return bool True if active, false otherwise. |
1672 | 1672 | */ |
1673 | - public function is_plugin_active( $slug ) { |
|
1674 | - return ( ( ! empty( $this->plugins[ $slug ]['is_callable'] ) && is_callable( $this->plugins[ $slug ]['is_callable'] ) ) || is_plugin_active( $this->plugins[ $slug ]['file_path'] ) ); |
|
1673 | + public function is_plugin_active($slug) { |
|
1674 | + return ((!empty($this->plugins[$slug]['is_callable']) && is_callable($this->plugins[$slug]['is_callable'])) || is_plugin_active($this->plugins[$slug]['file_path'])); |
|
1675 | 1675 | } |
1676 | 1676 | |
1677 | 1677 | /** |
@@ -1683,16 +1683,16 @@ discard block |
||
1683 | 1683 | * @param string $slug Plugin slug. |
1684 | 1684 | * @return bool True if OK to update, false otherwise. |
1685 | 1685 | */ |
1686 | - public function can_plugin_update( $slug ) { |
|
1686 | + public function can_plugin_update($slug) { |
|
1687 | 1687 | // We currently can't get reliable info on non-WP-repo plugins - issue #380. |
1688 | - if ( 'repo' !== $this->plugins[ $slug ]['source_type'] ) { |
|
1688 | + if ('repo' !== $this->plugins[$slug]['source_type']) { |
|
1689 | 1689 | return true; |
1690 | 1690 | } |
1691 | 1691 | |
1692 | - $api = $this->get_plugins_api( $slug ); |
|
1692 | + $api = $this->get_plugins_api($slug); |
|
1693 | 1693 | |
1694 | - if ( false !== $api && isset( $api->requires ) ) { |
|
1695 | - return version_compare( $GLOBALS['wp_version'], $api->requires, '>=' ); |
|
1694 | + if (false !== $api && isset($api->requires)) { |
|
1695 | + return version_compare($GLOBALS['wp_version'], $api->requires, '>='); |
|
1696 | 1696 | } |
1697 | 1697 | |
1698 | 1698 | // No usable info received from the plugins API, presume we can update. |
@@ -1708,8 +1708,8 @@ discard block |
||
1708 | 1708 | * @param string $slug Plugin slug. |
1709 | 1709 | * @return bool True if OK to activate, false otherwise. |
1710 | 1710 | */ |
1711 | - public function can_plugin_activate( $slug ) { |
|
1712 | - return ( ! $this->is_plugin_active( $slug ) && ! $this->does_plugin_require_update( $slug ) ); |
|
1711 | + public function can_plugin_activate($slug) { |
|
1712 | + return (!$this->is_plugin_active($slug) && !$this->does_plugin_require_update($slug)); |
|
1713 | 1713 | } |
1714 | 1714 | |
1715 | 1715 | /** |
@@ -1721,11 +1721,11 @@ discard block |
||
1721 | 1721 | * @return string Version number as string or an empty string if the plugin is not installed |
1722 | 1722 | * or version unknown (plugins which don't comply with the plugin header standard). |
1723 | 1723 | */ |
1724 | - public function get_installed_version( $slug ) { |
|
1724 | + public function get_installed_version($slug) { |
|
1725 | 1725 | $installed_plugins = $this->get_plugins(); // Retrieve a list of all installed plugins (WP cached). |
1726 | 1726 | |
1727 | - if ( ! empty( $installed_plugins[ $this->plugins[ $slug ]['file_path'] ]['Version'] ) ) { |
|
1728 | - return $installed_plugins[ $this->plugins[ $slug ]['file_path'] ]['Version']; |
|
1727 | + if (!empty($installed_plugins[$this->plugins[$slug]['file_path']]['Version'])) { |
|
1728 | + return $installed_plugins[$this->plugins[$slug]['file_path']]['Version']; |
|
1729 | 1729 | } |
1730 | 1730 | |
1731 | 1731 | return ''; |
@@ -1739,11 +1739,11 @@ discard block |
||
1739 | 1739 | * @param string $slug Plugin slug. |
1740 | 1740 | * @return bool True when a plugin needs to be updated, otherwise false. |
1741 | 1741 | */ |
1742 | - public function does_plugin_require_update( $slug ) { |
|
1743 | - $installed_version = $this->get_installed_version( $slug ); |
|
1744 | - $minimum_version = $this->plugins[ $slug ]['version']; |
|
1742 | + public function does_plugin_require_update($slug) { |
|
1743 | + $installed_version = $this->get_installed_version($slug); |
|
1744 | + $minimum_version = $this->plugins[$slug]['version']; |
|
1745 | 1745 | |
1746 | - return version_compare( $minimum_version, $installed_version, '>' ); |
|
1746 | + return version_compare($minimum_version, $installed_version, '>'); |
|
1747 | 1747 | } |
1748 | 1748 | |
1749 | 1749 | /** |
@@ -1754,20 +1754,20 @@ discard block |
||
1754 | 1754 | * @param string $slug Plugin slug. |
1755 | 1755 | * @return false|string Version number string of the available update or false if no update available. |
1756 | 1756 | */ |
1757 | - public function does_plugin_have_update( $slug ) { |
|
1757 | + public function does_plugin_have_update($slug) { |
|
1758 | 1758 | // Presume bundled and external plugins will point to a package which meets the minimum required version. |
1759 | - if ( 'repo' !== $this->plugins[ $slug ]['source_type'] ) { |
|
1760 | - if ( $this->does_plugin_require_update( $slug ) ) { |
|
1761 | - return $this->plugins[ $slug ]['version']; |
|
1759 | + if ('repo' !== $this->plugins[$slug]['source_type']) { |
|
1760 | + if ($this->does_plugin_require_update($slug)) { |
|
1761 | + return $this->plugins[$slug]['version']; |
|
1762 | 1762 | } |
1763 | 1763 | |
1764 | 1764 | return false; |
1765 | 1765 | } |
1766 | 1766 | |
1767 | - $repo_updates = get_site_transient( 'update_plugins' ); |
|
1767 | + $repo_updates = get_site_transient('update_plugins'); |
|
1768 | 1768 | |
1769 | - if ( isset( $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->new_version ) ) { |
|
1770 | - return $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->new_version; |
|
1769 | + if (isset($repo_updates->response[$this->plugins[$slug]['file_path']]->new_version)) { |
|
1770 | + return $repo_updates->response[$this->plugins[$slug]['file_path']]->new_version; |
|
1771 | 1771 | } |
1772 | 1772 | |
1773 | 1773 | return false; |
@@ -1781,16 +1781,16 @@ discard block |
||
1781 | 1781 | * @param string $slug Plugin slug. |
1782 | 1782 | * @return string The upgrade notice or an empty string if no message was available or provided. |
1783 | 1783 | */ |
1784 | - public function get_upgrade_notice( $slug ) { |
|
1784 | + public function get_upgrade_notice($slug) { |
|
1785 | 1785 | // We currently can't get reliable info on non-WP-repo plugins - issue #380. |
1786 | - if ( 'repo' !== $this->plugins[ $slug ]['source_type'] ) { |
|
1786 | + if ('repo' !== $this->plugins[$slug]['source_type']) { |
|
1787 | 1787 | return ''; |
1788 | 1788 | } |
1789 | 1789 | |
1790 | - $repo_updates = get_site_transient( 'update_plugins' ); |
|
1790 | + $repo_updates = get_site_transient('update_plugins'); |
|
1791 | 1791 | |
1792 | - if ( ! empty( $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->upgrade_notice ) ) { |
|
1793 | - return $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->upgrade_notice; |
|
1792 | + if (!empty($repo_updates->response[$this->plugins[$slug]['file_path']]->upgrade_notice)) { |
|
1793 | + return $repo_updates->response[$this->plugins[$slug]['file_path']]->upgrade_notice; |
|
1794 | 1794 | } |
1795 | 1795 | |
1796 | 1796 | return ''; |
@@ -1804,12 +1804,12 @@ discard block |
||
1804 | 1804 | * @param string $plugin_folder Optional. Relative path to single plugin folder. |
1805 | 1805 | * @return array Array of installed plugins with plugin information. |
1806 | 1806 | */ |
1807 | - public function get_plugins( $plugin_folder = '' ) { |
|
1808 | - if ( ! function_exists( 'get_plugins' ) ) { |
|
1809 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
1807 | + public function get_plugins($plugin_folder = '') { |
|
1808 | + if (!function_exists('get_plugins')) { |
|
1809 | + require_once ABSPATH.'wp-admin/includes/plugin.php'; |
|
1810 | 1810 | } |
1811 | 1811 | |
1812 | - return get_plugins( $plugin_folder ); |
|
1812 | + return get_plugins($plugin_folder); |
|
1813 | 1813 | } |
1814 | 1814 | |
1815 | 1815 | /** |
@@ -1821,7 +1821,7 @@ discard block |
||
1821 | 1821 | * @since 2.1.1 |
1822 | 1822 | */ |
1823 | 1823 | public function update_dismiss() { |
1824 | - delete_metadata( 'user', null, 'tgmpa_dismissed_notice_' . $this->id, null, true ); |
|
1824 | + delete_metadata('user', null, 'tgmpa_dismissed_notice_'.$this->id, null, true); |
|
1825 | 1825 | } |
1826 | 1826 | |
1827 | 1827 | /** |
@@ -1839,14 +1839,14 @@ discard block |
||
1839 | 1839 | * @since 2.2.0 |
1840 | 1840 | */ |
1841 | 1841 | public function force_activation() { |
1842 | - foreach ( $this->plugins as $slug => $plugin ) { |
|
1843 | - if ( true === $plugin['force_activation'] ) { |
|
1844 | - if ( ! $this->is_plugin_installed( $slug ) ) { |
|
1842 | + foreach ($this->plugins as $slug => $plugin) { |
|
1843 | + if (true === $plugin['force_activation']) { |
|
1844 | + if (!$this->is_plugin_installed($slug)) { |
|
1845 | 1845 | // Oops, plugin isn't there so iterate to next condition. |
1846 | 1846 | continue; |
1847 | - } elseif ( $this->can_plugin_activate( $slug ) ) { |
|
1847 | + } elseif ($this->can_plugin_activate($slug)) { |
|
1848 | 1848 | // There we go, activate the plugin. |
1849 | - activate_plugin( $plugin['file_path'] ); |
|
1849 | + activate_plugin($plugin['file_path']); |
|
1850 | 1850 | } |
1851 | 1851 | } |
1852 | 1852 | } |
@@ -1865,10 +1865,10 @@ discard block |
||
1865 | 1865 | * @since 2.2.0 |
1866 | 1866 | */ |
1867 | 1867 | public function force_deactivation() { |
1868 | - foreach ( $this->plugins as $slug => $plugin ) { |
|
1868 | + foreach ($this->plugins as $slug => $plugin) { |
|
1869 | 1869 | // Only proceed forward if the parameter is set to true and plugin is active. |
1870 | - if ( true === $plugin['force_deactivation'] && $this->is_plugin_active( $slug ) ) { |
|
1871 | - deactivate_plugins( $plugin['file_path'] ); |
|
1870 | + if (true === $plugin['force_deactivation'] && $this->is_plugin_active($slug)) { |
|
1871 | + deactivate_plugins($plugin['file_path']); |
|
1872 | 1872 | } |
1873 | 1873 | } |
1874 | 1874 | } |
@@ -1878,7 +1878,7 @@ discard block |
||
1878 | 1878 | */ |
1879 | 1879 | public function show_tgmpa_version() { |
1880 | 1880 | echo '<p style="float: right; padding: 0em 1.5em 0.5em 0;"><strong><small>', |
1881 | - esc_html( sprintf( _x( 'TGMPA v%s', '%s = version number', 'tgmpa' ), self::TGMPA_VERSION ) ), |
|
1881 | + esc_html(sprintf(_x('TGMPA v%s', '%s = version number', 'tgmpa'), self::TGMPA_VERSION)), |
|
1882 | 1882 | '</small></strong></p>'; |
1883 | 1883 | } |
1884 | 1884 | |
@@ -1890,7 +1890,7 @@ discard block |
||
1890 | 1890 | * @return object The TGM_Plugin_Activation object. |
1891 | 1891 | */ |
1892 | 1892 | public static function get_instance() { |
1893 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof self ) ) { |
|
1893 | + if (!isset(self::$instance) && !(self::$instance instanceof self)) { |
|
1894 | 1894 | self::$instance = new self(); |
1895 | 1895 | } |
1896 | 1896 | |
@@ -1898,7 +1898,7 @@ discard block |
||
1898 | 1898 | } |
1899 | 1899 | } |
1900 | 1900 | |
1901 | - if ( ! function_exists( 'load_tgm_plugin_activation' ) ) { |
|
1901 | + if (!function_exists('load_tgm_plugin_activation')) { |
|
1902 | 1902 | /** |
1903 | 1903 | * Ensure only one instance of the class is ever invoked. |
1904 | 1904 | */ |
@@ -1907,14 +1907,14 @@ discard block |
||
1907 | 1907 | } |
1908 | 1908 | } |
1909 | 1909 | |
1910 | - if ( did_action( 'plugins_loaded' ) ) { |
|
1910 | + if (did_action('plugins_loaded')) { |
|
1911 | 1911 | load_tgm_plugin_activation(); |
1912 | 1912 | } else { |
1913 | - add_action( 'plugins_loaded', 'load_tgm_plugin_activation' ); |
|
1913 | + add_action('plugins_loaded', 'load_tgm_plugin_activation'); |
|
1914 | 1914 | } |
1915 | 1915 | } |
1916 | 1916 | |
1917 | -if ( ! function_exists( 'tgmpa' ) ) { |
|
1917 | +if (!function_exists('tgmpa')) { |
|
1918 | 1918 | /** |
1919 | 1919 | * Helper function to register a collection of required plugins. |
1920 | 1920 | * |
@@ -1924,30 +1924,30 @@ discard block |
||
1924 | 1924 | * @param array $plugins An array of plugin arrays. |
1925 | 1925 | * @param array $config Optional. An array of configuration values. |
1926 | 1926 | */ |
1927 | - function tgmpa( $plugins, $config = array() ) { |
|
1928 | - $instance = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) ); |
|
1927 | + function tgmpa($plugins, $config = array()) { |
|
1928 | + $instance = call_user_func(array(get_class($GLOBALS['tgmpa']), 'get_instance')); |
|
1929 | 1929 | |
1930 | - foreach ( $plugins as $plugin ) { |
|
1931 | - call_user_func( array( $instance, 'register' ), $plugin ); |
|
1930 | + foreach ($plugins as $plugin) { |
|
1931 | + call_user_func(array($instance, 'register'), $plugin); |
|
1932 | 1932 | } |
1933 | 1933 | |
1934 | - if ( ! empty( $config ) && is_array( $config ) ) { |
|
1934 | + if (!empty($config) && is_array($config)) { |
|
1935 | 1935 | // Send out notices for deprecated arguments passed. |
1936 | - if ( isset( $config['notices'] ) ) { |
|
1937 | - _deprecated_argument( __FUNCTION__, '2.2.0', 'The `notices` config parameter was renamed to `has_notices` in TGMPA 2.2.0. Please adjust your configuration.' ); |
|
1938 | - if ( ! isset( $config['has_notices'] ) ) { |
|
1936 | + if (isset($config['notices'])) { |
|
1937 | + _deprecated_argument(__FUNCTION__, '2.2.0', 'The `notices` config parameter was renamed to `has_notices` in TGMPA 2.2.0. Please adjust your configuration.'); |
|
1938 | + if (!isset($config['has_notices'])) { |
|
1939 | 1939 | $config['has_notices'] = $config['notices']; |
1940 | 1940 | } |
1941 | 1941 | } |
1942 | 1942 | |
1943 | - if ( isset( $config['parent_menu_slug'] ) ) { |
|
1944 | - _deprecated_argument( __FUNCTION__, '2.4.0', 'The `parent_menu_slug` config parameter was removed in TGMPA 2.4.0. In TGMPA 2.5.0 an alternative was (re-)introduced. Please adjust your configuration. For more information visit the website: http://tgmpluginactivation.com/configuration/#h-configuration-options.' ); |
|
1943 | + if (isset($config['parent_menu_slug'])) { |
|
1944 | + _deprecated_argument(__FUNCTION__, '2.4.0', 'The `parent_menu_slug` config parameter was removed in TGMPA 2.4.0. In TGMPA 2.5.0 an alternative was (re-)introduced. Please adjust your configuration. For more information visit the website: http://tgmpluginactivation.com/configuration/#h-configuration-options.'); |
|
1945 | 1945 | } |
1946 | - if ( isset( $config['parent_url_slug'] ) ) { |
|
1947 | - _deprecated_argument( __FUNCTION__, '2.4.0', 'The `parent_url_slug` config parameter was removed in TGMPA 2.4.0. In TGMPA 2.5.0 an alternative was (re-)introduced. Please adjust your configuration. For more information visit the website: http://tgmpluginactivation.com/configuration/#h-configuration-options.' ); |
|
1946 | + if (isset($config['parent_url_slug'])) { |
|
1947 | + _deprecated_argument(__FUNCTION__, '2.4.0', 'The `parent_url_slug` config parameter was removed in TGMPA 2.4.0. In TGMPA 2.5.0 an alternative was (re-)introduced. Please adjust your configuration. For more information visit the website: http://tgmpluginactivation.com/configuration/#h-configuration-options.'); |
|
1948 | 1948 | } |
1949 | 1949 | |
1950 | - call_user_func( array( $instance, 'config' ), $config ); |
|
1950 | + call_user_func(array($instance, 'config'), $config); |
|
1951 | 1951 | } |
1952 | 1952 | } |
1953 | 1953 | } |
@@ -1958,11 +1958,11 @@ discard block |
||
1958 | 1958 | * |
1959 | 1959 | * @since 2.2.0 |
1960 | 1960 | */ |
1961 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
1962 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
1961 | +if (!class_exists('WP_List_Table')) { |
|
1962 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
1963 | 1963 | } |
1964 | 1964 | |
1965 | -if ( ! class_exists( 'TGMPA_List_Table' ) ) { |
|
1965 | +if (!class_exists('TGMPA_List_Table')) { |
|
1966 | 1966 | |
1967 | 1967 | /** |
1968 | 1968 | * List table class for handling plugins. |
@@ -2020,7 +2020,7 @@ discard block |
||
2020 | 2020 | * @since 2.2.0 |
2021 | 2021 | */ |
2022 | 2022 | public function __construct() { |
2023 | - $this->tgmpa = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) ); |
|
2023 | + $this->tgmpa = call_user_func(array(get_class($GLOBALS['tgmpa']), 'get_instance')); |
|
2024 | 2024 | |
2025 | 2025 | parent::__construct( |
2026 | 2026 | array( |
@@ -2030,11 +2030,11 @@ discard block |
||
2030 | 2030 | ) |
2031 | 2031 | ); |
2032 | 2032 | |
2033 | - if ( isset( $_REQUEST['plugin_status'] ) && in_array( $_REQUEST['plugin_status'], array( 'install', 'update', 'activate' ), true ) ) { |
|
2034 | - $this->view_context = sanitize_key( $_REQUEST['plugin_status'] ); |
|
2033 | + if (isset($_REQUEST['plugin_status']) && in_array($_REQUEST['plugin_status'], array('install', 'update', 'activate'), true)) { |
|
2034 | + $this->view_context = sanitize_key($_REQUEST['plugin_status']); |
|
2035 | 2035 | } |
2036 | 2036 | |
2037 | - add_filter( 'tgmpa_table_data_items', array( $this, 'sort_table_items' ) ); |
|
2037 | + add_filter('tgmpa_table_data_items', array($this, 'sort_table_items')); |
|
2038 | 2038 | } |
2039 | 2039 | |
2040 | 2040 | /** |
@@ -2047,7 +2047,7 @@ discard block |
||
2047 | 2047 | * @return array CSS classnames. |
2048 | 2048 | */ |
2049 | 2049 | public function get_table_classes() { |
2050 | - return array( 'widefat', 'fixed' ); |
|
2050 | + return array('widefat', 'fixed'); |
|
2051 | 2051 | } |
2052 | 2052 | |
2053 | 2053 | /** |
@@ -2066,37 +2066,37 @@ discard block |
||
2066 | 2066 | $plugins = $this->categorize_plugins_to_views(); |
2067 | 2067 | |
2068 | 2068 | // Set the counts for the view links. |
2069 | - $this->set_view_totals( $plugins ); |
|
2069 | + $this->set_view_totals($plugins); |
|
2070 | 2070 | |
2071 | 2071 | // Prep variables for use and grab list of all installed plugins. |
2072 | 2072 | $table_data = array(); |
2073 | 2073 | $i = 0; |
2074 | 2074 | |
2075 | 2075 | // Redirect to the 'all' view if no plugins were found for the selected view context. |
2076 | - if ( empty( $plugins[ $this->view_context ] ) ) { |
|
2076 | + if (empty($plugins[$this->view_context])) { |
|
2077 | 2077 | $this->view_context = 'all'; |
2078 | 2078 | } |
2079 | 2079 | |
2080 | - foreach ( $plugins[ $this->view_context ] as $slug => $plugin ) { |
|
2081 | - $table_data[ $i ]['sanitized_plugin'] = $plugin['name']; |
|
2082 | - $table_data[ $i ]['slug'] = $slug; |
|
2083 | - $table_data[ $i ]['plugin'] = '<strong>' . $this->tgmpa->get_info_link( $slug ) . '</strong>'; |
|
2084 | - $table_data[ $i ]['source'] = $this->get_plugin_source_type_text( $plugin['source_type'] ); |
|
2085 | - $table_data[ $i ]['type'] = $this->get_plugin_advise_type_text( $plugin['required'] ); |
|
2086 | - $table_data[ $i ]['status'] = $this->get_plugin_status_text( $slug ); |
|
2087 | - $table_data[ $i ]['installed_version'] = $this->tgmpa->get_installed_version( $slug ); |
|
2088 | - $table_data[ $i ]['minimum_version'] = $plugin['version']; |
|
2089 | - $table_data[ $i ]['available_version'] = $this->tgmpa->does_plugin_have_update( $slug ); |
|
2080 | + foreach ($plugins[$this->view_context] as $slug => $plugin) { |
|
2081 | + $table_data[$i]['sanitized_plugin'] = $plugin['name']; |
|
2082 | + $table_data[$i]['slug'] = $slug; |
|
2083 | + $table_data[$i]['plugin'] = '<strong>'.$this->tgmpa->get_info_link($slug).'</strong>'; |
|
2084 | + $table_data[$i]['source'] = $this->get_plugin_source_type_text($plugin['source_type']); |
|
2085 | + $table_data[$i]['type'] = $this->get_plugin_advise_type_text($plugin['required']); |
|
2086 | + $table_data[$i]['status'] = $this->get_plugin_status_text($slug); |
|
2087 | + $table_data[$i]['installed_version'] = $this->tgmpa->get_installed_version($slug); |
|
2088 | + $table_data[$i]['minimum_version'] = $plugin['version']; |
|
2089 | + $table_data[$i]['available_version'] = $this->tgmpa->does_plugin_have_update($slug); |
|
2090 | 2090 | |
2091 | 2091 | // Prep the upgrade notice info. |
2092 | - $upgrade_notice = $this->tgmpa->get_upgrade_notice( $slug ); |
|
2093 | - if ( ! empty( $upgrade_notice ) ) { |
|
2094 | - $table_data[ $i ]['upgrade_notice'] = $upgrade_notice; |
|
2092 | + $upgrade_notice = $this->tgmpa->get_upgrade_notice($slug); |
|
2093 | + if (!empty($upgrade_notice)) { |
|
2094 | + $table_data[$i]['upgrade_notice'] = $upgrade_notice; |
|
2095 | 2095 | |
2096 | - add_action( "tgmpa_after_plugin_row_$slug", array( $this, 'wp_plugin_update_row' ), 10, 2 ); |
|
2096 | + add_action("tgmpa_after_plugin_row_$slug", array($this, 'wp_plugin_update_row'), 10, 2); |
|
2097 | 2097 | } |
2098 | 2098 | |
2099 | - $table_data[ $i ] = apply_filters( 'tgmpa_table_data_item', $table_data[ $i ], $plugin ); |
|
2099 | + $table_data[$i] = apply_filters('tgmpa_table_data_item', $table_data[$i], $plugin); |
|
2100 | 2100 | |
2101 | 2101 | $i++; |
2102 | 2102 | } |
@@ -2117,22 +2117,22 @@ discard block |
||
2117 | 2117 | 'activate' => array(), |
2118 | 2118 | ); |
2119 | 2119 | |
2120 | - foreach ( $this->tgmpa->plugins as $slug => $plugin ) { |
|
2121 | - if ( $this->tgmpa->is_plugin_active( $slug ) && false === $this->tgmpa->does_plugin_have_update( $slug ) ) { |
|
2120 | + foreach ($this->tgmpa->plugins as $slug => $plugin) { |
|
2121 | + if ($this->tgmpa->is_plugin_active($slug) && false === $this->tgmpa->does_plugin_have_update($slug)) { |
|
2122 | 2122 | // No need to display plugins if they are installed, up-to-date and active. |
2123 | 2123 | continue; |
2124 | 2124 | } else { |
2125 | - $plugins['all'][ $slug ] = $plugin; |
|
2125 | + $plugins['all'][$slug] = $plugin; |
|
2126 | 2126 | |
2127 | - if ( ! $this->tgmpa->is_plugin_installed( $slug ) ) { |
|
2128 | - $plugins['install'][ $slug ] = $plugin; |
|
2127 | + if (!$this->tgmpa->is_plugin_installed($slug)) { |
|
2128 | + $plugins['install'][$slug] = $plugin; |
|
2129 | 2129 | } else { |
2130 | - if ( false !== $this->tgmpa->does_plugin_have_update( $slug ) ) { |
|
2131 | - $plugins['update'][ $slug ] = $plugin; |
|
2130 | + if (false !== $this->tgmpa->does_plugin_have_update($slug)) { |
|
2131 | + $plugins['update'][$slug] = $plugin; |
|
2132 | 2132 | } |
2133 | 2133 | |
2134 | - if ( $this->tgmpa->can_plugin_activate( $slug ) ) { |
|
2135 | - $plugins['activate'][ $slug ] = $plugin; |
|
2134 | + if ($this->tgmpa->can_plugin_activate($slug)) { |
|
2135 | + $plugins['activate'][$slug] = $plugin; |
|
2136 | 2136 | } |
2137 | 2137 | } |
2138 | 2138 | } |
@@ -2148,9 +2148,9 @@ discard block |
||
2148 | 2148 | * |
2149 | 2149 | * @param array $plugins Plugins order by view. |
2150 | 2150 | */ |
2151 | - protected function set_view_totals( $plugins ) { |
|
2152 | - foreach ( $plugins as $type => $list ) { |
|
2153 | - $this->view_totals[ $type ] = count( $list ); |
|
2151 | + protected function set_view_totals($plugins) { |
|
2152 | + foreach ($plugins as $type => $list) { |
|
2153 | + $this->view_totals[$type] = count($list); |
|
2154 | 2154 | } |
2155 | 2155 | } |
2156 | 2156 | |
@@ -2162,12 +2162,12 @@ discard block |
||
2162 | 2162 | * @param string $required Plugin required setting. |
2163 | 2163 | * @return string |
2164 | 2164 | */ |
2165 | - protected function get_plugin_advise_type_text( $required ) { |
|
2166 | - if ( true === $required ) { |
|
2167 | - return __( 'Required', 'tgmpa' ); |
|
2165 | + protected function get_plugin_advise_type_text($required) { |
|
2166 | + if (true === $required) { |
|
2167 | + return __('Required', 'tgmpa'); |
|
2168 | 2168 | } |
2169 | 2169 | |
2170 | - return __( 'Recommended', 'tgmpa' ); |
|
2170 | + return __('Recommended', 'tgmpa'); |
|
2171 | 2171 | } |
2172 | 2172 | |
2173 | 2173 | /** |
@@ -2178,18 +2178,18 @@ discard block |
||
2178 | 2178 | * @param string $type Plugin type. |
2179 | 2179 | * @return string |
2180 | 2180 | */ |
2181 | - protected function get_plugin_source_type_text( $type ) { |
|
2181 | + protected function get_plugin_source_type_text($type) { |
|
2182 | 2182 | $string = ''; |
2183 | 2183 | |
2184 | - switch ( $type ) { |
|
2184 | + switch ($type) { |
|
2185 | 2185 | case 'repo': |
2186 | - $string = __( 'WordPress Repository', 'tgmpa' ); |
|
2186 | + $string = __('WordPress Repository', 'tgmpa'); |
|
2187 | 2187 | break; |
2188 | 2188 | case 'external': |
2189 | - $string = __( 'External Source', 'tgmpa' ); |
|
2189 | + $string = __('External Source', 'tgmpa'); |
|
2190 | 2190 | break; |
2191 | 2191 | case 'bundled': |
2192 | - $string = __( 'Pre-Packaged', 'tgmpa' ); |
|
2192 | + $string = __('Pre-Packaged', 'tgmpa'); |
|
2193 | 2193 | break; |
2194 | 2194 | } |
2195 | 2195 | |
@@ -2204,35 +2204,35 @@ discard block |
||
2204 | 2204 | * @param string $slug Plugin slug. |
2205 | 2205 | * @return string |
2206 | 2206 | */ |
2207 | - protected function get_plugin_status_text( $slug ) { |
|
2208 | - if ( ! $this->tgmpa->is_plugin_installed( $slug ) ) { |
|
2209 | - return __( 'Not Installed', 'tgmpa' ); |
|
2207 | + protected function get_plugin_status_text($slug) { |
|
2208 | + if (!$this->tgmpa->is_plugin_installed($slug)) { |
|
2209 | + return __('Not Installed', 'tgmpa'); |
|
2210 | 2210 | } |
2211 | 2211 | |
2212 | - if ( ! $this->tgmpa->is_plugin_active( $slug ) ) { |
|
2213 | - $install_status = __( 'Installed But Not Activated', 'tgmpa' ); |
|
2212 | + if (!$this->tgmpa->is_plugin_active($slug)) { |
|
2213 | + $install_status = __('Installed But Not Activated', 'tgmpa'); |
|
2214 | 2214 | } else { |
2215 | - $install_status = __( 'Active', 'tgmpa' ); |
|
2215 | + $install_status = __('Active', 'tgmpa'); |
|
2216 | 2216 | } |
2217 | 2217 | |
2218 | 2218 | $update_status = ''; |
2219 | 2219 | |
2220 | - if ( $this->tgmpa->does_plugin_require_update( $slug ) && false === $this->tgmpa->does_plugin_have_update( $slug ) ) { |
|
2221 | - $update_status = __( 'Required Update not Available', 'tgmpa' ); |
|
2220 | + if ($this->tgmpa->does_plugin_require_update($slug) && false === $this->tgmpa->does_plugin_have_update($slug)) { |
|
2221 | + $update_status = __('Required Update not Available', 'tgmpa'); |
|
2222 | 2222 | |
2223 | - } elseif ( $this->tgmpa->does_plugin_require_update( $slug ) ) { |
|
2224 | - $update_status = __( 'Requires Update', 'tgmpa' ); |
|
2223 | + } elseif ($this->tgmpa->does_plugin_require_update($slug)) { |
|
2224 | + $update_status = __('Requires Update', 'tgmpa'); |
|
2225 | 2225 | |
2226 | - } elseif ( false !== $this->tgmpa->does_plugin_have_update( $slug ) ) { |
|
2227 | - $update_status = __( 'Update recommended', 'tgmpa' ); |
|
2226 | + } elseif (false !== $this->tgmpa->does_plugin_have_update($slug)) { |
|
2227 | + $update_status = __('Update recommended', 'tgmpa'); |
|
2228 | 2228 | } |
2229 | 2229 | |
2230 | - if ( '' === $update_status ) { |
|
2230 | + if ('' === $update_status) { |
|
2231 | 2231 | return $install_status; |
2232 | 2232 | } |
2233 | 2233 | |
2234 | 2234 | return sprintf( |
2235 | - _x( '%1$s, %2$s', '%1$s = install status, %2$s = update status', 'tgmpa' ), |
|
2235 | + _x('%1$s, %2$s', '%1$s = install status, %2$s = update status', 'tgmpa'), |
|
2236 | 2236 | $install_status, |
2237 | 2237 | $update_status |
2238 | 2238 | ); |
@@ -2246,16 +2246,16 @@ discard block |
||
2246 | 2246 | * @param array $items Prepared table items. |
2247 | 2247 | * @return array Sorted table items. |
2248 | 2248 | */ |
2249 | - public function sort_table_items( $items ) { |
|
2249 | + public function sort_table_items($items) { |
|
2250 | 2250 | $type = array(); |
2251 | 2251 | $name = array(); |
2252 | 2252 | |
2253 | - foreach ( $items as $i => $plugin ) { |
|
2254 | - $type[ $i ] = $plugin['type']; // Required / recommended. |
|
2255 | - $name[ $i ] = $plugin['sanitized_plugin']; |
|
2253 | + foreach ($items as $i => $plugin) { |
|
2254 | + $type[$i] = $plugin['type']; // Required / recommended. |
|
2255 | + $name[$i] = $plugin['sanitized_plugin']; |
|
2256 | 2256 | } |
2257 | 2257 | |
2258 | - array_multisort( $type, SORT_DESC, $name, SORT_ASC, $items ); |
|
2258 | + array_multisort($type, SORT_DESC, $name, SORT_ASC, $items); |
|
2259 | 2259 | |
2260 | 2260 | return $items; |
2261 | 2261 | } |
@@ -2270,36 +2270,36 @@ discard block |
||
2270 | 2270 | public function get_views() { |
2271 | 2271 | $status_links = array(); |
2272 | 2272 | |
2273 | - foreach ( $this->view_totals as $type => $count ) { |
|
2274 | - if ( $count < 1 ) { |
|
2273 | + foreach ($this->view_totals as $type => $count) { |
|
2274 | + if ($count < 1) { |
|
2275 | 2275 | continue; |
2276 | 2276 | } |
2277 | 2277 | |
2278 | - switch ( $type ) { |
|
2278 | + switch ($type) { |
|
2279 | 2279 | case 'all': |
2280 | - $text = _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $count, 'plugins', 'tgmpa' ); |
|
2280 | + $text = _nx('All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $count, 'plugins', 'tgmpa'); |
|
2281 | 2281 | break; |
2282 | 2282 | case 'install': |
2283 | - $text = _n( 'To Install <span class="count">(%s)</span>', 'To Install <span class="count">(%s)</span>', $count, 'tgmpa' ); |
|
2283 | + $text = _n('To Install <span class="count">(%s)</span>', 'To Install <span class="count">(%s)</span>', $count, 'tgmpa'); |
|
2284 | 2284 | break; |
2285 | 2285 | case 'update': |
2286 | - $text = _n( 'Update Available <span class="count">(%s)</span>', 'Update Available <span class="count">(%s)</span>', $count, 'tgmpa' ); |
|
2286 | + $text = _n('Update Available <span class="count">(%s)</span>', 'Update Available <span class="count">(%s)</span>', $count, 'tgmpa'); |
|
2287 | 2287 | break; |
2288 | 2288 | case 'activate': |
2289 | - $text = _n( 'To Activate <span class="count">(%s)</span>', 'To Activate <span class="count">(%s)</span>', $count, 'tgmpa' ); |
|
2289 | + $text = _n('To Activate <span class="count">(%s)</span>', 'To Activate <span class="count">(%s)</span>', $count, 'tgmpa'); |
|
2290 | 2290 | break; |
2291 | 2291 | default: |
2292 | 2292 | $text = ''; |
2293 | 2293 | break; |
2294 | 2294 | } |
2295 | 2295 | |
2296 | - if ( ! empty( $text ) ) { |
|
2296 | + if (!empty($text)) { |
|
2297 | 2297 | |
2298 | - $status_links[ $type ] = sprintf( |
|
2298 | + $status_links[$type] = sprintf( |
|
2299 | 2299 | '<a href="%s"%s>%s</a>', |
2300 | - esc_url( $this->tgmpa->get_tgmpa_status_url( $type ) ), |
|
2301 | - ( $type === $this->view_context ) ? ' class="current"' : '', |
|
2302 | - sprintf( $text, number_format_i18n( $count ) ) |
|
2300 | + esc_url($this->tgmpa->get_tgmpa_status_url($type)), |
|
2301 | + ($type === $this->view_context) ? ' class="current"' : '', |
|
2302 | + sprintf($text, number_format_i18n($count)) |
|
2303 | 2303 | ); |
2304 | 2304 | } |
2305 | 2305 | } |
@@ -2317,8 +2317,8 @@ discard block |
||
2317 | 2317 | * @param string $column_name The name of the column. |
2318 | 2318 | * @return string |
2319 | 2319 | */ |
2320 | - public function column_default( $item, $column_name ) { |
|
2321 | - return $item[ $column_name ]; |
|
2320 | + public function column_default($item, $column_name) { |
|
2321 | + return $item[$column_name]; |
|
2322 | 2322 | } |
2323 | 2323 | |
2324 | 2324 | /** |
@@ -2331,12 +2331,12 @@ discard block |
||
2331 | 2331 | * @param array $item Array of item data. |
2332 | 2332 | * @return string The input checkbox with all necessary info. |
2333 | 2333 | */ |
2334 | - public function column_cb( $item ) { |
|
2334 | + public function column_cb($item) { |
|
2335 | 2335 | return sprintf( |
2336 | 2336 | '<input type="checkbox" name="%1$s[]" value="%2$s" id="%3$s" />', |
2337 | - esc_attr( $this->_args['singular'] ), |
|
2338 | - esc_attr( $item['slug'] ), |
|
2339 | - esc_attr( $item['sanitized_plugin'] ) |
|
2337 | + esc_attr($this->_args['singular']), |
|
2338 | + esc_attr($item['slug']), |
|
2339 | + esc_attr($item['sanitized_plugin']) |
|
2340 | 2340 | ); |
2341 | 2341 | } |
2342 | 2342 | |
@@ -2348,11 +2348,11 @@ discard block |
||
2348 | 2348 | * @param array $item Array of item data. |
2349 | 2349 | * @return string The plugin name and action links. |
2350 | 2350 | */ |
2351 | - public function column_plugin( $item ) { |
|
2351 | + public function column_plugin($item) { |
|
2352 | 2352 | return sprintf( |
2353 | 2353 | '%1$s %2$s', |
2354 | 2354 | $item['plugin'], |
2355 | - $this->row_actions( $this->get_row_actions( $item ), true ) |
|
2355 | + $this->row_actions($this->get_row_actions($item), true) |
|
2356 | 2356 | ); |
2357 | 2357 | } |
2358 | 2358 | |
@@ -2364,48 +2364,48 @@ discard block |
||
2364 | 2364 | * @param array $item Array of item data. |
2365 | 2365 | * @return string HTML-formatted version information. |
2366 | 2366 | */ |
2367 | - public function column_version( $item ) { |
|
2367 | + public function column_version($item) { |
|
2368 | 2368 | $output = array(); |
2369 | 2369 | |
2370 | - if ( $this->tgmpa->is_plugin_installed( $item['slug'] ) ) { |
|
2371 | - $installed = ! empty( $item['installed_version'] ) ? $item['installed_version'] : _x( 'unknown', 'as in: "version nr unknown"', 'tgmpa' ); |
|
2370 | + if ($this->tgmpa->is_plugin_installed($item['slug'])) { |
|
2371 | + $installed = !empty($item['installed_version']) ? $item['installed_version'] : _x('unknown', 'as in: "version nr unknown"', 'tgmpa'); |
|
2372 | 2372 | |
2373 | 2373 | $color = ''; |
2374 | - if ( ! empty( $item['minimum_version'] ) && $this->tgmpa->does_plugin_require_update( $item['slug'] ) ) { |
|
2374 | + if (!empty($item['minimum_version']) && $this->tgmpa->does_plugin_require_update($item['slug'])) { |
|
2375 | 2375 | $color = ' color: #ff0000; font-weight: bold;'; |
2376 | 2376 | } |
2377 | 2377 | |
2378 | 2378 | $output[] = sprintf( |
2379 | - '<p><span style="min-width: 32px; text-align: right; float: right;%1$s">%2$s</span>' . __( 'Installed version:', 'tgmpa' ) . '</p>', |
|
2379 | + '<p><span style="min-width: 32px; text-align: right; float: right;%1$s">%2$s</span>'.__('Installed version:', 'tgmpa').'</p>', |
|
2380 | 2380 | $color, |
2381 | 2381 | $installed |
2382 | 2382 | ); |
2383 | 2383 | } |
2384 | 2384 | |
2385 | - if ( ! empty( $item['minimum_version'] ) ) { |
|
2385 | + if (!empty($item['minimum_version'])) { |
|
2386 | 2386 | $output[] = sprintf( |
2387 | - '<p><span style="min-width: 32px; text-align: right; float: right;">%1$s</span>' . __( 'Minimum required version:', 'tgmpa' ) . '</p>', |
|
2387 | + '<p><span style="min-width: 32px; text-align: right; float: right;">%1$s</span>'.__('Minimum required version:', 'tgmpa').'</p>', |
|
2388 | 2388 | $item['minimum_version'] |
2389 | 2389 | ); |
2390 | 2390 | } |
2391 | 2391 | |
2392 | - if ( ! empty( $item['available_version'] ) ) { |
|
2392 | + if (!empty($item['available_version'])) { |
|
2393 | 2393 | $color = ''; |
2394 | - if ( ! empty( $item['minimum_version'] ) && version_compare( $item['available_version'], $item['minimum_version'], '>=' ) ) { |
|
2394 | + if (!empty($item['minimum_version']) && version_compare($item['available_version'], $item['minimum_version'], '>=')) { |
|
2395 | 2395 | $color = ' color: #71C671; font-weight: bold;'; |
2396 | 2396 | } |
2397 | 2397 | |
2398 | 2398 | $output[] = sprintf( |
2399 | - '<p><span style="min-width: 32px; text-align: right; float: right;%1$s">%2$s</span>' . __( 'Available version:', 'tgmpa' ) . '</p>', |
|
2399 | + '<p><span style="min-width: 32px; text-align: right; float: right;%1$s">%2$s</span>'.__('Available version:', 'tgmpa').'</p>', |
|
2400 | 2400 | $color, |
2401 | 2401 | $item['available_version'] |
2402 | 2402 | ); |
2403 | 2403 | } |
2404 | 2404 | |
2405 | - if ( empty( $output ) ) { |
|
2405 | + if (empty($output)) { |
|
2406 | 2406 | return ' '; // Let's not break the table layout. |
2407 | 2407 | } else { |
2408 | - return implode( "\n", $output ); |
|
2408 | + return implode("\n", $output); |
|
2409 | 2409 | } |
2410 | 2410 | } |
2411 | 2411 | |
@@ -2419,7 +2419,7 @@ discard block |
||
2419 | 2419 | * @since 2.2.0 |
2420 | 2420 | */ |
2421 | 2421 | public function no_items() { |
2422 | - printf( wp_kses_post( __( 'No plugins to install, update or activate. <a href="%1$s">Return to the Dashboard</a>', 'tgmpa' ) ), esc_url( self_admin_url() ) ); |
|
2422 | + printf(wp_kses_post(__('No plugins to install, update or activate. <a href="%1$s">Return to the Dashboard</a>', 'tgmpa')), esc_url(self_admin_url())); |
|
2423 | 2423 | echo '<style type="text/css">#adminmenu .wp-submenu li.current { display: none !important; }</style>'; |
2424 | 2424 | } |
2425 | 2425 | |
@@ -2433,17 +2433,17 @@ discard block |
||
2433 | 2433 | public function get_columns() { |
2434 | 2434 | $columns = array( |
2435 | 2435 | 'cb' => '<input type="checkbox" />', |
2436 | - 'plugin' => __( 'Plugin', 'tgmpa' ), |
|
2437 | - 'source' => __( 'Source', 'tgmpa' ), |
|
2438 | - 'type' => __( 'Type', 'tgmpa' ), |
|
2436 | + 'plugin' => __('Plugin', 'tgmpa'), |
|
2437 | + 'source' => __('Source', 'tgmpa'), |
|
2438 | + 'type' => __('Type', 'tgmpa'), |
|
2439 | 2439 | ); |
2440 | 2440 | |
2441 | - if ( 'all' === $this->view_context || 'update' === $this->view_context ) { |
|
2442 | - $columns['version'] = __( 'Version', 'tgmpa' ); |
|
2443 | - $columns['status'] = __( 'Status', 'tgmpa' ); |
|
2441 | + if ('all' === $this->view_context || 'update' === $this->view_context) { |
|
2442 | + $columns['version'] = __('Version', 'tgmpa'); |
|
2443 | + $columns['status'] = __('Status', 'tgmpa'); |
|
2444 | 2444 | } |
2445 | 2445 | |
2446 | - return apply_filters( 'tgmpa_table_columns', $columns ); |
|
2446 | + return apply_filters('tgmpa_table_columns', $columns); |
|
2447 | 2447 | } |
2448 | 2448 | |
2449 | 2449 | /** |
@@ -2467,7 +2467,7 @@ discard block |
||
2467 | 2467 | * @return string The name of the primary column. |
2468 | 2468 | */ |
2469 | 2469 | protected function get_primary_column_name() { |
2470 | - if ( method_exists( 'WP_List_Table', 'get_primary_column_name' ) ) { |
|
2470 | + if (method_exists('WP_List_Table', 'get_primary_column_name')) { |
|
2471 | 2471 | return parent::get_primary_column_name(); |
2472 | 2472 | } else { |
2473 | 2473 | return $this->get_default_primary_column_name(); |
@@ -2482,48 +2482,48 @@ discard block |
||
2482 | 2482 | * @param array $item Array of item data. |
2483 | 2483 | * @return array Array with relevant action links. |
2484 | 2484 | */ |
2485 | - protected function get_row_actions( $item ) { |
|
2485 | + protected function get_row_actions($item) { |
|
2486 | 2486 | $actions = array(); |
2487 | 2487 | $action_links = array(); |
2488 | 2488 | |
2489 | 2489 | // Display the 'Install' action link if the plugin is not yet available. |
2490 | - if ( ! $this->tgmpa->is_plugin_installed( $item['slug'] ) ) { |
|
2491 | - $actions['install'] = _x( 'Install %2$s', '%2$s = plugin name in screen reader markup', 'tgmpa' ); |
|
2490 | + if (!$this->tgmpa->is_plugin_installed($item['slug'])) { |
|
2491 | + $actions['install'] = _x('Install %2$s', '%2$s = plugin name in screen reader markup', 'tgmpa'); |
|
2492 | 2492 | } else { |
2493 | 2493 | // Display the 'Update' action link if an update is available and WP complies with plugin minimum. |
2494 | - if ( false !== $this->tgmpa->does_plugin_have_update( $item['slug'] ) && $this->tgmpa->can_plugin_update( $item['slug'] ) ) { |
|
2495 | - $actions['update'] = _x( 'Update %2$s', '%2$s = plugin name in screen reader markup', 'tgmpa' ); |
|
2494 | + if (false !== $this->tgmpa->does_plugin_have_update($item['slug']) && $this->tgmpa->can_plugin_update($item['slug'])) { |
|
2495 | + $actions['update'] = _x('Update %2$s', '%2$s = plugin name in screen reader markup', 'tgmpa'); |
|
2496 | 2496 | } |
2497 | 2497 | |
2498 | 2498 | // Display the 'Activate' action link, but only if the plugin meets the minimum version. |
2499 | - if ( $this->tgmpa->can_plugin_activate( $item['slug'] ) ) { |
|
2500 | - $actions['activate'] = _x( 'Activate %2$s', '%2$s = plugin name in screen reader markup', 'tgmpa' ); |
|
2499 | + if ($this->tgmpa->can_plugin_activate($item['slug'])) { |
|
2500 | + $actions['activate'] = _x('Activate %2$s', '%2$s = plugin name in screen reader markup', 'tgmpa'); |
|
2501 | 2501 | } |
2502 | 2502 | } |
2503 | 2503 | |
2504 | 2504 | // Create the actual links. |
2505 | - foreach ( $actions as $action => $text ) { |
|
2505 | + foreach ($actions as $action => $text) { |
|
2506 | 2506 | $nonce_url = wp_nonce_url( |
2507 | 2507 | add_query_arg( |
2508 | 2508 | array( |
2509 | - 'plugin' => urlencode( $item['slug'] ), |
|
2510 | - 'tgmpa-' . $action => $action . '-plugin', |
|
2509 | + 'plugin' => urlencode($item['slug']), |
|
2510 | + 'tgmpa-'.$action => $action.'-plugin', |
|
2511 | 2511 | ), |
2512 | 2512 | $this->tgmpa->get_tgmpa_url() |
2513 | 2513 | ), |
2514 | - 'tgmpa-' . $action, |
|
2514 | + 'tgmpa-'.$action, |
|
2515 | 2515 | 'tgmpa-nonce' |
2516 | 2516 | ); |
2517 | 2517 | |
2518 | - $action_links[ $action ] = sprintf( |
|
2519 | - '<a href="%1$s">' . esc_html( $text ) . '</a>', |
|
2520 | - esc_url( $nonce_url ), |
|
2521 | - '<span class="screen-reader-text">' . esc_html( $item['sanitized_plugin'] ) . '</span>' |
|
2518 | + $action_links[$action] = sprintf( |
|
2519 | + '<a href="%1$s">'.esc_html($text).'</a>', |
|
2520 | + esc_url($nonce_url), |
|
2521 | + '<span class="screen-reader-text">'.esc_html($item['sanitized_plugin']).'</span>' |
|
2522 | 2522 | ); |
2523 | 2523 | } |
2524 | 2524 | |
2525 | - $prefix = ( defined( 'WP_NETWORK_ADMIN' ) && WP_NETWORK_ADMIN ) ? 'network_admin_' : ''; |
|
2526 | - return apply_filters( "tgmpa_{$prefix}plugin_action_links", array_filter( $action_links ), $item['slug'], $item, $this->view_context ); |
|
2525 | + $prefix = (defined('WP_NETWORK_ADMIN') && WP_NETWORK_ADMIN) ? 'network_admin_' : ''; |
|
2526 | + return apply_filters("tgmpa_{$prefix}plugin_action_links", array_filter($action_links), $item['slug'], $item, $this->view_context); |
|
2527 | 2527 | } |
2528 | 2528 | |
2529 | 2529 | /** |
@@ -2533,8 +2533,8 @@ discard block |
||
2533 | 2533 | * |
2534 | 2534 | * @param object $item The current item. |
2535 | 2535 | */ |
2536 | - public function single_row( $item ) { |
|
2537 | - parent::single_row( $item ); |
|
2536 | + public function single_row($item) { |
|
2537 | + parent::single_row($item); |
|
2538 | 2538 | |
2539 | 2539 | /** |
2540 | 2540 | * Fires after each specific row in the TGMPA Plugins list table. |
@@ -2544,7 +2544,7 @@ discard block |
||
2544 | 2544 | * |
2545 | 2545 | * @since 2.5.0 |
2546 | 2546 | */ |
2547 | - do_action( "tgmpa_after_plugin_row_{$item['slug']}", $item['slug'], $item, $this->view_context ); |
|
2547 | + do_action("tgmpa_after_plugin_row_{$item['slug']}", $item['slug'], $item, $this->view_context); |
|
2548 | 2548 | } |
2549 | 2549 | |
2550 | 2550 | /** |
@@ -2558,17 +2558,17 @@ discard block |
||
2558 | 2558 | * @param array $item The information available in this table row. |
2559 | 2559 | * @return null Return early if upgrade notice is empty. |
2560 | 2560 | */ |
2561 | - public function wp_plugin_update_row( $slug, $item ) { |
|
2562 | - if ( empty( $item['upgrade_notice'] ) ) { |
|
2561 | + public function wp_plugin_update_row($slug, $item) { |
|
2562 | + if (empty($item['upgrade_notice'])) { |
|
2563 | 2563 | return; |
2564 | 2564 | } |
2565 | 2565 | |
2566 | 2566 | echo ' |
2567 | 2567 | <tr class="plugin-update-tr"> |
2568 | - <td colspan="', absint( $this->get_column_count() ), '" class="plugin-update colspanchange"> |
|
2568 | + <td colspan="', absint($this->get_column_count()), '" class="plugin-update colspanchange"> |
|
2569 | 2569 | <div class="update-message">', |
2570 | - esc_html__( 'Upgrade message from the plugin author:', 'tgmpa' ), |
|
2571 | - ' <strong>', wp_kses_data( $item['upgrade_notice'] ), '</strong> |
|
2570 | + esc_html__('Upgrade message from the plugin author:', 'tgmpa'), |
|
2571 | + ' <strong>', wp_kses_data($item['upgrade_notice']), '</strong> |
|
2572 | 2572 | </div> |
2573 | 2573 | </td> |
2574 | 2574 | </tr>'; |
@@ -2581,8 +2581,8 @@ discard block |
||
2581 | 2581 | * |
2582 | 2582 | * @param string $which 'top' or 'bottom' table navigation. |
2583 | 2583 | */ |
2584 | - public function extra_tablenav( $which ) { |
|
2585 | - if ( 'bottom' === $which ) { |
|
2584 | + public function extra_tablenav($which) { |
|
2585 | + if ('bottom' === $which) { |
|
2586 | 2586 | $this->tgmpa->show_tgmpa_version(); |
2587 | 2587 | } |
2588 | 2588 | } |
@@ -2598,18 +2598,18 @@ discard block |
||
2598 | 2598 | |
2599 | 2599 | $actions = array(); |
2600 | 2600 | |
2601 | - if ( 'update' !== $this->view_context && 'activate' !== $this->view_context ) { |
|
2602 | - if ( current_user_can( 'install_plugins' ) ) { |
|
2603 | - $actions['tgmpa-bulk-install'] = __( 'Install', 'tgmpa' ); |
|
2601 | + if ('update' !== $this->view_context && 'activate' !== $this->view_context) { |
|
2602 | + if (current_user_can('install_plugins')) { |
|
2603 | + $actions['tgmpa-bulk-install'] = __('Install', 'tgmpa'); |
|
2604 | 2604 | } |
2605 | 2605 | } |
2606 | 2606 | |
2607 | - if ( 'install' !== $this->view_context ) { |
|
2608 | - if ( current_user_can( 'update_plugins' ) ) { |
|
2609 | - $actions['tgmpa-bulk-update'] = __( 'Update', 'tgmpa' ); |
|
2607 | + if ('install' !== $this->view_context) { |
|
2608 | + if (current_user_can('update_plugins')) { |
|
2609 | + $actions['tgmpa-bulk-update'] = __('Update', 'tgmpa'); |
|
2610 | 2610 | } |
2611 | - if ( current_user_can( 'activate_plugins' ) ) { |
|
2612 | - $actions['tgmpa-bulk-activate'] = __( 'Activate', 'tgmpa' ); |
|
2611 | + if (current_user_can('activate_plugins')) { |
|
2612 | + $actions['tgmpa-bulk-activate'] = __('Activate', 'tgmpa'); |
|
2613 | 2613 | } |
2614 | 2614 | } |
2615 | 2615 | |
@@ -2626,64 +2626,64 @@ discard block |
||
2626 | 2626 | */ |
2627 | 2627 | public function process_bulk_actions() { |
2628 | 2628 | // Bulk installation process. |
2629 | - if ( 'tgmpa-bulk-install' === $this->current_action() || 'tgmpa-bulk-update' === $this->current_action() ) { |
|
2629 | + if ('tgmpa-bulk-install' === $this->current_action() || 'tgmpa-bulk-update' === $this->current_action()) { |
|
2630 | 2630 | |
2631 | - check_admin_referer( 'bulk-' . $this->_args['plural'] ); |
|
2631 | + check_admin_referer('bulk-'.$this->_args['plural']); |
|
2632 | 2632 | |
2633 | 2633 | $install_type = 'install'; |
2634 | - if ( 'tgmpa-bulk-update' === $this->current_action() ) { |
|
2634 | + if ('tgmpa-bulk-update' === $this->current_action()) { |
|
2635 | 2635 | $install_type = 'update'; |
2636 | 2636 | } |
2637 | 2637 | |
2638 | 2638 | $plugins_to_install = array(); |
2639 | 2639 | |
2640 | 2640 | // Did user actually select any plugins to install/update ? |
2641 | - if ( empty( $_POST['plugin'] ) ) { |
|
2642 | - if ( 'install' === $install_type ) { |
|
2643 | - $message = __( 'No plugins were selected to be installed. No action taken.', 'tgmpa' ); |
|
2641 | + if (empty($_POST['plugin'])) { |
|
2642 | + if ('install' === $install_type) { |
|
2643 | + $message = __('No plugins were selected to be installed. No action taken.', 'tgmpa'); |
|
2644 | 2644 | } else { |
2645 | - $message = __( 'No plugins were selected to be updated. No action taken.', 'tgmpa' ); |
|
2645 | + $message = __('No plugins were selected to be updated. No action taken.', 'tgmpa'); |
|
2646 | 2646 | } |
2647 | 2647 | |
2648 | - echo '<div id="message" class="error"><p>', esc_html( $message ), '</p></div>'; |
|
2648 | + echo '<div id="message" class="error"><p>', esc_html($message), '</p></div>'; |
|
2649 | 2649 | |
2650 | 2650 | return false; |
2651 | 2651 | } |
2652 | 2652 | |
2653 | - if ( is_array( $_POST['plugin'] ) ) { |
|
2653 | + if (is_array($_POST['plugin'])) { |
|
2654 | 2654 | $plugins_to_install = (array) $_POST['plugin']; |
2655 | - } elseif ( is_string( $_POST['plugin'] ) ) { |
|
2655 | + } elseif (is_string($_POST['plugin'])) { |
|
2656 | 2656 | // Received via Filesystem page - un-flatten array (WP bug #19643). |
2657 | - $plugins_to_install = explode( ',', $_POST['plugin'] ); |
|
2657 | + $plugins_to_install = explode(',', $_POST['plugin']); |
|
2658 | 2658 | } |
2659 | 2659 | |
2660 | 2660 | // Sanitize the received input. |
2661 | - $plugins_to_install = array_map( 'urldecode', $plugins_to_install ); |
|
2662 | - $plugins_to_install = array_map( array( $this->tgmpa, 'sanitize_key' ), $plugins_to_install ); |
|
2661 | + $plugins_to_install = array_map('urldecode', $plugins_to_install); |
|
2662 | + $plugins_to_install = array_map(array($this->tgmpa, 'sanitize_key'), $plugins_to_install); |
|
2663 | 2663 | |
2664 | 2664 | // Validate the received input. |
2665 | - foreach ( $plugins_to_install as $key => $slug ) { |
|
2665 | + foreach ($plugins_to_install as $key => $slug) { |
|
2666 | 2666 | // Check if the plugin was registered with TGMPA and remove if not. |
2667 | - if ( ! isset( $this->tgmpa->plugins[ $slug ] ) ) { |
|
2668 | - unset( $plugins_to_install[ $key ] ); |
|
2667 | + if (!isset($this->tgmpa->plugins[$slug])) { |
|
2668 | + unset($plugins_to_install[$key]); |
|
2669 | 2669 | continue; |
2670 | 2670 | } |
2671 | 2671 | |
2672 | 2672 | // For updates: make sure this is a plugin we *can* update (update available and WP version ok). |
2673 | - if ( 'update' === $install_type && ( $this->tgmpa->is_plugin_installed( $slug ) && ( false === $this->tgmpa->does_plugin_have_update( $slug ) || ! $this->tgmpa->can_plugin_update( $slug ) ) ) ) { |
|
2674 | - unset( $plugins_to_install[ $key ] ); |
|
2673 | + if ('update' === $install_type && ($this->tgmpa->is_plugin_installed($slug) && (false === $this->tgmpa->does_plugin_have_update($slug) || !$this->tgmpa->can_plugin_update($slug)))) { |
|
2674 | + unset($plugins_to_install[$key]); |
|
2675 | 2675 | } |
2676 | 2676 | } |
2677 | 2677 | |
2678 | 2678 | // No need to proceed further if we have no plugins to handle. |
2679 | - if ( empty( $plugins_to_install ) ) { |
|
2680 | - if ( 'install' === $install_type ) { |
|
2681 | - $message = __( 'No plugins are available to be installed at this time.', 'tgmpa' ); |
|
2679 | + if (empty($plugins_to_install)) { |
|
2680 | + if ('install' === $install_type) { |
|
2681 | + $message = __('No plugins are available to be installed at this time.', 'tgmpa'); |
|
2682 | 2682 | } else { |
2683 | - $message = __( 'No plugins are available to be updated at this time.', 'tgmpa' ); |
|
2683 | + $message = __('No plugins are available to be updated at this time.', 'tgmpa'); |
|
2684 | 2684 | } |
2685 | 2685 | |
2686 | - echo '<div id="message" class="error"><p>', esc_html( $message ), '</p></div>'; |
|
2686 | + echo '<div id="message" class="error"><p>', esc_html($message), '</p></div>'; |
|
2687 | 2687 | |
2688 | 2688 | return false; |
2689 | 2689 | } |
@@ -2691,23 +2691,23 @@ discard block |
||
2691 | 2691 | // Pass all necessary information if WP_Filesystem is needed. |
2692 | 2692 | $url = wp_nonce_url( |
2693 | 2693 | $this->tgmpa->get_tgmpa_url(), |
2694 | - 'bulk-' . $this->_args['plural'] |
|
2694 | + 'bulk-'.$this->_args['plural'] |
|
2695 | 2695 | ); |
2696 | 2696 | |
2697 | 2697 | // Give validated data back to $_POST which is the only place the filesystem looks for extra fields. |
2698 | - $_POST['plugin'] = implode( ',', $plugins_to_install ); // Work around for WP bug #19643. |
|
2698 | + $_POST['plugin'] = implode(',', $plugins_to_install); // Work around for WP bug #19643. |
|
2699 | 2699 | |
2700 | 2700 | $method = ''; // Leave blank so WP_Filesystem can populate it as necessary. |
2701 | - $fields = array_keys( $_POST ); // Extra fields to pass to WP_Filesystem. |
|
2701 | + $fields = array_keys($_POST); // Extra fields to pass to WP_Filesystem. |
|
2702 | 2702 | |
2703 | - if ( false === ( $creds = request_filesystem_credentials( esc_url_raw( $url ), $method, false, false, $fields ) ) ) { |
|
2703 | + if (false === ($creds = request_filesystem_credentials(esc_url_raw($url), $method, false, false, $fields))) { |
|
2704 | 2704 | return true; // Stop the normal page form from displaying, credential request form will be shown. |
2705 | 2705 | } |
2706 | 2706 | |
2707 | 2707 | // Now we have some credentials, setup WP_Filesystem. |
2708 | - if ( ! WP_Filesystem( $creds ) ) { |
|
2708 | + if (!WP_Filesystem($creds)) { |
|
2709 | 2709 | // Our credentials were no good, ask the user for them again. |
2710 | - request_filesystem_credentials( esc_url_raw( $url ), $method, true, false, $fields ); |
|
2710 | + request_filesystem_credentials(esc_url_raw($url), $method, true, false, $fields); |
|
2711 | 2711 | |
2712 | 2712 | return true; |
2713 | 2713 | } |
@@ -2721,35 +2721,35 @@ discard block |
||
2721 | 2721 | $to_inject = array(); // Information to inject into the update_plugins transient. |
2722 | 2722 | |
2723 | 2723 | // Prepare the data for validated plugins for the install/upgrade. |
2724 | - foreach ( $plugins_to_install as $slug ) { |
|
2725 | - $name = $this->tgmpa->plugins[ $slug ]['name']; |
|
2726 | - $source = $this->tgmpa->get_download_url( $slug ); |
|
2724 | + foreach ($plugins_to_install as $slug) { |
|
2725 | + $name = $this->tgmpa->plugins[$slug]['name']; |
|
2726 | + $source = $this->tgmpa->get_download_url($slug); |
|
2727 | 2727 | |
2728 | - if ( ! empty( $name ) && ! empty( $source ) ) { |
|
2728 | + if (!empty($name) && !empty($source)) { |
|
2729 | 2729 | $names[] = $name; |
2730 | 2730 | |
2731 | - switch ( $install_type ) { |
|
2731 | + switch ($install_type) { |
|
2732 | 2732 | |
2733 | 2733 | case 'install': |
2734 | 2734 | $sources[] = $source; |
2735 | 2735 | break; |
2736 | 2736 | |
2737 | 2737 | case 'update': |
2738 | - $file_paths[] = $this->tgmpa->plugins[ $slug ]['file_path']; |
|
2739 | - $to_inject[ $slug ] = $this->tgmpa->plugins[ $slug ]; |
|
2740 | - $to_inject[ $slug ]['source'] = $source; |
|
2738 | + $file_paths[] = $this->tgmpa->plugins[$slug]['file_path']; |
|
2739 | + $to_inject[$slug] = $this->tgmpa->plugins[$slug]; |
|
2740 | + $to_inject[$slug]['source'] = $source; |
|
2741 | 2741 | break; |
2742 | 2742 | } |
2743 | 2743 | } |
2744 | 2744 | } |
2745 | - unset( $slug, $name, $source ); |
|
2745 | + unset($slug, $name, $source); |
|
2746 | 2746 | |
2747 | 2747 | // Create a new instance of TGMPA_Bulk_Installer. |
2748 | 2748 | $installer = new TGMPA_Bulk_Installer( |
2749 | 2749 | new TGMPA_Bulk_Installer_Skin( |
2750 | 2750 | array( |
2751 | - 'url' => esc_url_raw( $this->tgmpa->get_tgmpa_url() ), |
|
2752 | - 'nonce' => 'bulk-' . $this->_args['plural'], |
|
2751 | + 'url' => esc_url_raw($this->tgmpa->get_tgmpa_url()), |
|
2752 | + 'nonce' => 'bulk-'.$this->_args['plural'], |
|
2753 | 2753 | 'names' => $names, |
2754 | 2754 | 'install_type' => $install_type, |
2755 | 2755 | ) |
@@ -2758,21 +2758,21 @@ discard block |
||
2758 | 2758 | |
2759 | 2759 | // Wrap the install process with the appropriate HTML. |
2760 | 2760 | echo '<div class="tgmpa wrap">', |
2761 | - '<h2>', esc_html( get_admin_page_title() ), '</h2>'; |
|
2761 | + '<h2>', esc_html(get_admin_page_title()), '</h2>'; |
|
2762 | 2762 | |
2763 | 2763 | // Process the bulk installation submissions. |
2764 | - add_filter( 'upgrader_source_selection', array( $this->tgmpa, 'maybe_adjust_source_dir' ), 1, 3 ); |
|
2764 | + add_filter('upgrader_source_selection', array($this->tgmpa, 'maybe_adjust_source_dir'), 1, 3); |
|
2765 | 2765 | |
2766 | - if ( 'tgmpa-bulk-update' === $this->current_action() ) { |
|
2766 | + if ('tgmpa-bulk-update' === $this->current_action()) { |
|
2767 | 2767 | // Inject our info into the update transient. |
2768 | - $this->tgmpa->inject_update_info( $to_inject ); |
|
2768 | + $this->tgmpa->inject_update_info($to_inject); |
|
2769 | 2769 | |
2770 | - $installer->bulk_upgrade( $file_paths ); |
|
2770 | + $installer->bulk_upgrade($file_paths); |
|
2771 | 2771 | } else { |
2772 | - $installer->bulk_install( $sources ); |
|
2772 | + $installer->bulk_install($sources); |
|
2773 | 2773 | } |
2774 | 2774 | |
2775 | - remove_filter( 'upgrader_source_selection', array( $this->tgmpa, 'maybe_adjust_source_dir' ), 1, 3 ); |
|
2775 | + remove_filter('upgrader_source_selection', array($this->tgmpa, 'maybe_adjust_source_dir'), 1, 3); |
|
2776 | 2776 | |
2777 | 2777 | echo '</div>'; |
2778 | 2778 | |
@@ -2780,70 +2780,70 @@ discard block |
||
2780 | 2780 | } |
2781 | 2781 | |
2782 | 2782 | // Bulk activation process. |
2783 | - if ( 'tgmpa-bulk-activate' === $this->current_action() ) { |
|
2784 | - check_admin_referer( 'bulk-' . $this->_args['plural'] ); |
|
2783 | + if ('tgmpa-bulk-activate' === $this->current_action()) { |
|
2784 | + check_admin_referer('bulk-'.$this->_args['plural']); |
|
2785 | 2785 | |
2786 | 2786 | // Did user actually select any plugins to activate ? |
2787 | - if ( empty( $_POST['plugin'] ) ) { |
|
2788 | - echo '<div id="message" class="error"><p>', esc_html__( 'No plugins were selected to be activated. No action taken.', 'tgmpa' ), '</p></div>'; |
|
2787 | + if (empty($_POST['plugin'])) { |
|
2788 | + echo '<div id="message" class="error"><p>', esc_html__('No plugins were selected to be activated. No action taken.', 'tgmpa'), '</p></div>'; |
|
2789 | 2789 | |
2790 | 2790 | return false; |
2791 | 2791 | } |
2792 | 2792 | |
2793 | 2793 | // Grab plugin data from $_POST. |
2794 | 2794 | $plugins = array(); |
2795 | - if ( isset( $_POST['plugin'] ) ) { |
|
2796 | - $plugins = array_map( 'urldecode', (array) $_POST['plugin'] ); |
|
2797 | - $plugins = array_map( array( $this->tgmpa, 'sanitize_key' ), $plugins ); |
|
2795 | + if (isset($_POST['plugin'])) { |
|
2796 | + $plugins = array_map('urldecode', (array) $_POST['plugin']); |
|
2797 | + $plugins = array_map(array($this->tgmpa, 'sanitize_key'), $plugins); |
|
2798 | 2798 | } |
2799 | 2799 | |
2800 | 2800 | $plugins_to_activate = array(); |
2801 | 2801 | $plugin_names = array(); |
2802 | 2802 | |
2803 | 2803 | // Grab the file paths for the selected & inactive plugins from the registration array. |
2804 | - foreach ( $plugins as $slug ) { |
|
2805 | - if ( $this->tgmpa->can_plugin_activate( $slug ) ) { |
|
2806 | - $plugins_to_activate[] = $this->tgmpa->plugins[ $slug ]['file_path']; |
|
2807 | - $plugin_names[] = $this->tgmpa->plugins[ $slug ]['name']; |
|
2804 | + foreach ($plugins as $slug) { |
|
2805 | + if ($this->tgmpa->can_plugin_activate($slug)) { |
|
2806 | + $plugins_to_activate[] = $this->tgmpa->plugins[$slug]['file_path']; |
|
2807 | + $plugin_names[] = $this->tgmpa->plugins[$slug]['name']; |
|
2808 | 2808 | } |
2809 | 2809 | } |
2810 | - unset( $slug ); |
|
2810 | + unset($slug); |
|
2811 | 2811 | |
2812 | 2812 | // Return early if there are no plugins to activate. |
2813 | - if ( empty( $plugins_to_activate ) ) { |
|
2814 | - echo '<div id="message" class="error"><p>', esc_html__( 'No plugins are available to be activated at this time.', 'tgmpa' ), '</p></div>'; |
|
2813 | + if (empty($plugins_to_activate)) { |
|
2814 | + echo '<div id="message" class="error"><p>', esc_html__('No plugins are available to be activated at this time.', 'tgmpa'), '</p></div>'; |
|
2815 | 2815 | |
2816 | 2816 | return false; |
2817 | 2817 | } |
2818 | 2818 | |
2819 | 2819 | // Now we are good to go - let's start activating plugins. |
2820 | - $activate = activate_plugins( $plugins_to_activate ); |
|
2820 | + $activate = activate_plugins($plugins_to_activate); |
|
2821 | 2821 | |
2822 | - if ( is_wp_error( $activate ) ) { |
|
2823 | - echo '<div id="message" class="error"><p>', wp_kses_post( $activate->get_error_message() ), '</p></div>'; |
|
2822 | + if (is_wp_error($activate)) { |
|
2823 | + echo '<div id="message" class="error"><p>', wp_kses_post($activate->get_error_message()), '</p></div>'; |
|
2824 | 2824 | } else { |
2825 | - $count = count( $plugin_names ); // Count so we can use _n function. |
|
2826 | - $plugin_names = array_map( array( 'TGMPA_Utils', 'wrap_in_strong' ), $plugin_names ); |
|
2827 | - $last_plugin = array_pop( $plugin_names ); // Pop off last name to prep for readability. |
|
2828 | - $imploded = empty( $plugin_names ) ? $last_plugin : ( implode( ', ', $plugin_names ) . ' ' . esc_html_x( 'and', 'plugin A *and* plugin B', 'tgmpa' ) . ' ' . $last_plugin ); |
|
2825 | + $count = count($plugin_names); // Count so we can use _n function. |
|
2826 | + $plugin_names = array_map(array('TGMPA_Utils', 'wrap_in_strong'), $plugin_names); |
|
2827 | + $last_plugin = array_pop($plugin_names); // Pop off last name to prep for readability. |
|
2828 | + $imploded = empty($plugin_names) ? $last_plugin : (implode(', ', $plugin_names).' '.esc_html_x('and', 'plugin A *and* plugin B', 'tgmpa').' '.$last_plugin); |
|
2829 | 2829 | |
2830 | 2830 | printf( // WPCS: xss ok. |
2831 | 2831 | '<div id="message" class="updated"><p>%1$s %2$s.</p></div>', |
2832 | - esc_html( _n( 'The following plugin was activated successfully:', 'The following plugins were activated successfully:', $count, 'tgmpa' ) ), |
|
2832 | + esc_html(_n('The following plugin was activated successfully:', 'The following plugins were activated successfully:', $count, 'tgmpa')), |
|
2833 | 2833 | $imploded |
2834 | 2834 | ); |
2835 | 2835 | |
2836 | 2836 | // Update recently activated plugins option. |
2837 | - $recent = (array) get_option( 'recently_activated' ); |
|
2838 | - foreach ( $plugins_to_activate as $plugin => $time ) { |
|
2839 | - if ( isset( $recent[ $plugin ] ) ) { |
|
2840 | - unset( $recent[ $plugin ] ); |
|
2837 | + $recent = (array) get_option('recently_activated'); |
|
2838 | + foreach ($plugins_to_activate as $plugin => $time) { |
|
2839 | + if (isset($recent[$plugin])) { |
|
2840 | + unset($recent[$plugin]); |
|
2841 | 2841 | } |
2842 | 2842 | } |
2843 | - update_option( 'recently_activated', $recent ); |
|
2843 | + update_option('recently_activated', $recent); |
|
2844 | 2844 | } |
2845 | 2845 | |
2846 | - unset( $_POST ); // Reset the $_POST variable in case user wants to perform one action after another. |
|
2846 | + unset($_POST); // Reset the $_POST variable in case user wants to perform one action after another. |
|
2847 | 2847 | |
2848 | 2848 | return true; |
2849 | 2849 | } |
@@ -2861,15 +2861,15 @@ discard block |
||
2861 | 2861 | $hidden = array(); // No columns to hide, but we must set as an array. |
2862 | 2862 | $sortable = array(); // No reason to make sortable columns. |
2863 | 2863 | $primary = $this->get_primary_column_name(); // Column which has the row actions. |
2864 | - $this->_column_headers = array( $columns, $hidden, $sortable, $primary ); // Get all necessary column headers. |
|
2864 | + $this->_column_headers = array($columns, $hidden, $sortable, $primary); // Get all necessary column headers. |
|
2865 | 2865 | |
2866 | 2866 | // Process our bulk activations here. |
2867 | - if ( 'tgmpa-bulk-activate' === $this->current_action() ) { |
|
2867 | + if ('tgmpa-bulk-activate' === $this->current_action()) { |
|
2868 | 2868 | $this->process_bulk_actions(); |
2869 | 2869 | } |
2870 | 2870 | |
2871 | 2871 | // Store all of our plugin data into $items array so WP_List_Table can use it. |
2872 | - $this->items = apply_filters( 'tgmpa_table_data_items', $this->_gather_plugin_data() ); |
|
2872 | + $this->items = apply_filters('tgmpa_table_data_items', $this->_gather_plugin_data()); |
|
2873 | 2873 | } |
2874 | 2874 | |
2875 | 2875 | /* *********** DEPRECATED METHODS *********** */ |
@@ -2885,16 +2885,16 @@ discard block |
||
2885 | 2885 | * @param string $data Optional. Array key of plugin data to return. Default is slug. |
2886 | 2886 | * @return string|boolean Plugin slug if found, false otherwise. |
2887 | 2887 | */ |
2888 | - protected function _get_plugin_data_from_name( $name, $data = 'slug' ) { |
|
2889 | - _deprecated_function( __FUNCTION__, 'TGMPA 2.5.0', 'TGM_Plugin_Activation::_get_plugin_data_from_name()' ); |
|
2888 | + protected function _get_plugin_data_from_name($name, $data = 'slug') { |
|
2889 | + _deprecated_function(__FUNCTION__, 'TGMPA 2.5.0', 'TGM_Plugin_Activation::_get_plugin_data_from_name()'); |
|
2890 | 2890 | |
2891 | - return $this->tgmpa->_get_plugin_data_from_name( $name, $data ); |
|
2891 | + return $this->tgmpa->_get_plugin_data_from_name($name, $data); |
|
2892 | 2892 | } |
2893 | 2893 | } |
2894 | 2894 | } |
2895 | 2895 | |
2896 | 2896 | |
2897 | -if ( ! class_exists( 'TGM_Bulk_Installer' ) ) { |
|
2897 | +if (!class_exists('TGM_Bulk_Installer')) { |
|
2898 | 2898 | |
2899 | 2899 | /** |
2900 | 2900 | * Hack: Prevent TGMPA v2.4.1- bulk installer class from being loaded if 2.4.1- is loaded after 2.5+. |
@@ -2902,7 +2902,7 @@ discard block |
||
2902 | 2902 | class TGM_Bulk_Installer { |
2903 | 2903 | } |
2904 | 2904 | } |
2905 | -if ( ! class_exists( 'TGM_Bulk_Installer_Skin' ) ) { |
|
2905 | +if (!class_exists('TGM_Bulk_Installer_Skin')) { |
|
2906 | 2906 | |
2907 | 2907 | /** |
2908 | 2908 | * Hack: Prevent TGMPA v2.4.1- bulk installer skin class from being loaded if 2.4.1- is loaded after 2.5+. |
@@ -2921,26 +2921,26 @@ discard block |
||
2921 | 2921 | * |
2922 | 2922 | * @since 2.2.0 |
2923 | 2923 | */ |
2924 | -add_action( 'admin_init', 'tgmpa_load_bulk_installer' ); |
|
2925 | -if ( ! function_exists( 'tgmpa_load_bulk_installer' ) ) { |
|
2924 | +add_action('admin_init', 'tgmpa_load_bulk_installer'); |
|
2925 | +if (!function_exists('tgmpa_load_bulk_installer')) { |
|
2926 | 2926 | /** |
2927 | 2927 | * Load bulk installer |
2928 | 2928 | */ |
2929 | 2929 | function tgmpa_load_bulk_installer() { |
2930 | 2930 | // Silently fail if 2.5+ is loaded *after* an older version. |
2931 | - if ( ! isset( $GLOBALS['tgmpa'] ) ) { |
|
2931 | + if (!isset($GLOBALS['tgmpa'])) { |
|
2932 | 2932 | return; |
2933 | 2933 | } |
2934 | 2934 | |
2935 | 2935 | // Get TGMPA class instance. |
2936 | - $tgmpa_instance = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) ); |
|
2936 | + $tgmpa_instance = call_user_func(array(get_class($GLOBALS['tgmpa']), 'get_instance')); |
|
2937 | 2937 | |
2938 | - if ( isset( $_GET['page'] ) && $tgmpa_instance->menu === $_GET['page'] ) { |
|
2939 | - if ( ! class_exists( 'Plugin_Upgrader', false ) ) { |
|
2940 | - require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
|
2938 | + if (isset($_GET['page']) && $tgmpa_instance->menu === $_GET['page']) { |
|
2939 | + if (!class_exists('Plugin_Upgrader', false)) { |
|
2940 | + require_once ABSPATH.'wp-admin/includes/class-wp-upgrader.php'; |
|
2941 | 2941 | } |
2942 | 2942 | |
2943 | - if ( ! class_exists( 'TGMPA_Bulk_Installer' ) ) { |
|
2943 | + if (!class_exists('TGMPA_Bulk_Installer')) { |
|
2944 | 2944 | |
2945 | 2945 | /** |
2946 | 2946 | * Installer class to handle bulk plugin installations. |
@@ -3002,21 +3002,21 @@ discard block |
||
3002 | 3002 | * |
3003 | 3003 | * @param \Bulk_Upgrader_Skin|null $skin Installer skin. |
3004 | 3004 | */ |
3005 | - public function __construct( $skin = null ) { |
|
3005 | + public function __construct($skin = null) { |
|
3006 | 3006 | // Get TGMPA class instance. |
3007 | - $this->tgmpa = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) ); |
|
3007 | + $this->tgmpa = call_user_func(array(get_class($GLOBALS['tgmpa']), 'get_instance')); |
|
3008 | 3008 | |
3009 | - parent::__construct( $skin ); |
|
3009 | + parent::__construct($skin); |
|
3010 | 3010 | |
3011 | - if ( isset( $this->skin->options['install_type'] ) && 'update' === $this->skin->options['install_type'] ) { |
|
3011 | + if (isset($this->skin->options['install_type']) && 'update' === $this->skin->options['install_type']) { |
|
3012 | 3012 | $this->clear_destination = true; |
3013 | 3013 | } |
3014 | 3014 | |
3015 | - if ( $this->tgmpa->is_automatic ) { |
|
3015 | + if ($this->tgmpa->is_automatic) { |
|
3016 | 3016 | $this->activate_strings(); |
3017 | 3017 | } |
3018 | 3018 | |
3019 | - add_action( 'upgrader_process_complete', array( $this->tgmpa, 'populate_file_path' ) ); |
|
3019 | + add_action('upgrader_process_complete', array($this->tgmpa, 'populate_file_path')); |
|
3020 | 3020 | } |
3021 | 3021 | |
3022 | 3022 | /** |
@@ -3025,8 +3025,8 @@ discard block |
||
3025 | 3025 | * @since 2.2.0 |
3026 | 3026 | */ |
3027 | 3027 | public function activate_strings() { |
3028 | - $this->strings['activation_failed'] = __( 'Plugin activation failed.', 'tgmpa' ); |
|
3029 | - $this->strings['activation_success'] = __( 'Plugin activated successfully.', 'tgmpa' ); |
|
3028 | + $this->strings['activation_failed'] = __('Plugin activation failed.', 'tgmpa'); |
|
3029 | + $this->strings['activation_success'] = __('Plugin activated successfully.', 'tgmpa'); |
|
3030 | 3030 | } |
3031 | 3031 | |
3032 | 3032 | /** |
@@ -3039,12 +3039,12 @@ discard block |
||
3039 | 3039 | * @param array $options The installation config options. |
3040 | 3040 | * @return null|array Return early if error, array of installation data on success. |
3041 | 3041 | */ |
3042 | - public function run( $options ) { |
|
3043 | - $result = parent::run( $options ); |
|
3042 | + public function run($options) { |
|
3043 | + $result = parent::run($options); |
|
3044 | 3044 | |
3045 | 3045 | // Reset the strings in case we changed one during automatic activation. |
3046 | - if ( $this->tgmpa->is_automatic ) { |
|
3047 | - if ( 'update' === $this->skin->options['install_type'] ) { |
|
3046 | + if ($this->tgmpa->is_automatic) { |
|
3047 | + if ('update' === $this->skin->options['install_type']) { |
|
3048 | 3048 | $this->upgrade_strings(); |
3049 | 3049 | } else { |
3050 | 3050 | $this->install_strings(); |
@@ -3071,14 +3071,14 @@ discard block |
||
3071 | 3071 | * @param array $args Arbitrary passed extra arguments. |
3072 | 3072 | * @return string|bool Install confirmation messages on success, false on failure. |
3073 | 3073 | */ |
3074 | - public function bulk_install( $plugins, $args = array() ) { |
|
3074 | + public function bulk_install($plugins, $args = array()) { |
|
3075 | 3075 | // [TGMPA + ] Hook auto-activation in. |
3076 | - add_filter( 'upgrader_post_install', array( $this, 'auto_activate' ), 10 ); |
|
3076 | + add_filter('upgrader_post_install', array($this, 'auto_activate'), 10); |
|
3077 | 3077 | |
3078 | 3078 | $defaults = array( |
3079 | 3079 | 'clear_update_cache' => true, |
3080 | 3080 | ); |
3081 | - $parsed_args = wp_parse_args( $args, $defaults ); |
|
3081 | + $parsed_args = wp_parse_args($args, $defaults); |
|
3082 | 3082 | |
3083 | 3083 | $this->init(); |
3084 | 3084 | $this->bulk = true; |
@@ -3092,8 +3092,8 @@ discard block |
||
3092 | 3092 | $this->skin->header(); |
3093 | 3093 | |
3094 | 3094 | // Connect to the Filesystem first. |
3095 | - $res = $this->fs_connect( array( WP_CONTENT_DIR, WP_PLUGIN_DIR ) ); |
|
3096 | - if ( ! $res ) { |
|
3095 | + $res = $this->fs_connect(array(WP_CONTENT_DIR, WP_PLUGIN_DIR)); |
|
3096 | + if (!$res) { |
|
3097 | 3097 | $this->skin->footer(); |
3098 | 3098 | |
3099 | 3099 | return false; |
@@ -3105,22 +3105,22 @@ discard block |
||
3105 | 3105 | // - running Multisite and there are one or more plugins specified, OR |
3106 | 3106 | // - a plugin with an update available is currently active. |
3107 | 3107 | // @TODO: For multisite, maintenance mode should only kick in for individual sites if at all possible. |
3108 | - $maintenance = ( is_multisite() && ! empty( $plugins ) ); |
|
3108 | + $maintenance = (is_multisite() && !empty($plugins)); |
|
3109 | 3109 | |
3110 | 3110 | /* |
3111 | 3111 | [TGMPA - ] |
3112 | 3112 | foreach ( $plugins as $plugin ) |
3113 | 3113 | $maintenance = $maintenance || ( is_plugin_active( $plugin ) && isset( $current->response[ $plugin] ) ); |
3114 | 3114 | */ |
3115 | - if ( $maintenance ) { |
|
3116 | - $this->maintenance_mode( true ); |
|
3115 | + if ($maintenance) { |
|
3116 | + $this->maintenance_mode(true); |
|
3117 | 3117 | } |
3118 | 3118 | |
3119 | 3119 | $results = array(); |
3120 | 3120 | |
3121 | - $this->update_count = count( $plugins ); |
|
3121 | + $this->update_count = count($plugins); |
|
3122 | 3122 | $this->update_current = 0; |
3123 | - foreach ( $plugins as $plugin ) { |
|
3123 | + foreach ($plugins as $plugin) { |
|
3124 | 3124 | $this->update_current++; |
3125 | 3125 | |
3126 | 3126 | /* |
@@ -3142,7 +3142,7 @@ discard block |
||
3142 | 3142 | $this->skin->plugin_active = is_plugin_active($plugin); |
3143 | 3143 | */ |
3144 | 3144 | |
3145 | - $result = $this->run( array( |
|
3145 | + $result = $this->run(array( |
|
3146 | 3146 | 'package' => $plugin, // [TGMPA + ] adjusted. |
3147 | 3147 | 'destination' => WP_PLUGIN_DIR, |
3148 | 3148 | 'clear_destination' => false, // [TGMPA + ] adjusted. |
@@ -3151,17 +3151,17 @@ discard block |
||
3151 | 3151 | 'hook_extra' => array( |
3152 | 3152 | 'plugin' => $plugin, |
3153 | 3153 | ), |
3154 | - ) ); |
|
3154 | + )); |
|
3155 | 3155 | |
3156 | - $results[ $plugin ] = $this->result; |
|
3156 | + $results[$plugin] = $this->result; |
|
3157 | 3157 | |
3158 | 3158 | // Prevent credentials auth screen from displaying multiple times. |
3159 | - if ( false === $result ) { |
|
3159 | + if (false === $result) { |
|
3160 | 3160 | break; |
3161 | 3161 | } |
3162 | 3162 | } //end foreach $plugins |
3163 | 3163 | |
3164 | - $this->maintenance_mode( false ); |
|
3164 | + $this->maintenance_mode(false); |
|
3165 | 3165 | |
3166 | 3166 | /** |
3167 | 3167 | * Fires when the bulk upgrader process is complete. |
@@ -3179,12 +3179,12 @@ discard block |
||
3179 | 3179 | * @type array $packages Array of plugin, theme, or core packages to update. |
3180 | 3180 | * } |
3181 | 3181 | */ |
3182 | - do_action( 'upgrader_process_complete', $this, array( |
|
3182 | + do_action('upgrader_process_complete', $this, array( |
|
3183 | 3183 | 'action' => 'install', // [TGMPA + ] adjusted. |
3184 | 3184 | 'type' => 'plugin', |
3185 | 3185 | 'bulk' => true, |
3186 | 3186 | 'plugins' => $plugins, |
3187 | - ) ); |
|
3187 | + )); |
|
3188 | 3188 | |
3189 | 3189 | $this->skin->bulk_footer(); |
3190 | 3190 | |
@@ -3194,10 +3194,10 @@ discard block |
||
3194 | 3194 | /* [TGMPA - ] remove_filter('upgrader_clear_destination', array($this, 'delete_old_plugin')); */ |
3195 | 3195 | |
3196 | 3196 | // [TGMPA + ] Remove our auto-activation hook. |
3197 | - remove_filter( 'upgrader_post_install', array( $this, 'auto_activate' ), 10 ); |
|
3197 | + remove_filter('upgrader_post_install', array($this, 'auto_activate'), 10); |
|
3198 | 3198 | |
3199 | 3199 | // Force refresh of plugin update information. |
3200 | - wp_clean_plugins_cache( $parsed_args['clear_update_cache'] ); |
|
3200 | + wp_clean_plugins_cache($parsed_args['clear_update_cache']); |
|
3201 | 3201 | |
3202 | 3202 | return $results; |
3203 | 3203 | } |
@@ -3213,13 +3213,13 @@ discard block |
||
3213 | 3213 | * @param array $args Arbitrary passed extra arguments. |
3214 | 3214 | * @return string|bool Install confirmation messages on success, false on failure. |
3215 | 3215 | */ |
3216 | - public function bulk_upgrade( $plugins, $args = array() ) { |
|
3216 | + public function bulk_upgrade($plugins, $args = array()) { |
|
3217 | 3217 | |
3218 | - add_filter( 'upgrader_post_install', array( $this, 'auto_activate' ), 10 ); |
|
3218 | + add_filter('upgrader_post_install', array($this, 'auto_activate'), 10); |
|
3219 | 3219 | |
3220 | - $result = parent::bulk_upgrade( $plugins, $args ); |
|
3220 | + $result = parent::bulk_upgrade($plugins, $args); |
|
3221 | 3221 | |
3222 | - remove_filter( 'upgrader_post_install', array( $this, 'auto_activate' ), 10 ); |
|
3222 | + remove_filter('upgrader_post_install', array($this, 'auto_activate'), 10); |
|
3223 | 3223 | |
3224 | 3224 | return $result; |
3225 | 3225 | } |
@@ -3234,9 +3234,9 @@ discard block |
||
3234 | 3234 | * @param bool $bool The value we need to give back (true). |
3235 | 3235 | * @return bool |
3236 | 3236 | */ |
3237 | - public function auto_activate( $bool ) { |
|
3237 | + public function auto_activate($bool) { |
|
3238 | 3238 | // Only process the activation of installed plugins if the automatic flag is set to true. |
3239 | - if ( $this->tgmpa->is_automatic ) { |
|
3239 | + if ($this->tgmpa->is_automatic) { |
|
3240 | 3240 | // Flush plugins cache so the headers of the newly installed plugins will be read correctly. |
3241 | 3241 | wp_clean_plugins_cache(); |
3242 | 3242 | |
@@ -3244,14 +3244,14 @@ discard block |
||
3244 | 3244 | $plugin_info = $this->plugin_info(); |
3245 | 3245 | |
3246 | 3246 | // Don't try to activate on upgrade of active plugin as WP will do this already. |
3247 | - if ( ! is_plugin_active( $plugin_info ) ) { |
|
3248 | - $activate = activate_plugin( $plugin_info ); |
|
3247 | + if (!is_plugin_active($plugin_info)) { |
|
3248 | + $activate = activate_plugin($plugin_info); |
|
3249 | 3249 | |
3250 | 3250 | // Adjust the success string based on the activation result. |
3251 | - $this->strings['process_success'] = $this->strings['process_success'] . "<br />\n"; |
|
3251 | + $this->strings['process_success'] = $this->strings['process_success']."<br />\n"; |
|
3252 | 3252 | |
3253 | - if ( is_wp_error( $activate ) ) { |
|
3254 | - $this->skin->error( $activate ); |
|
3253 | + if (is_wp_error($activate)) { |
|
3254 | + $this->skin->error($activate); |
|
3255 | 3255 | $this->strings['process_success'] .= $this->strings['activation_failed']; |
3256 | 3256 | } else { |
3257 | 3257 | $this->strings['process_success'] .= $this->strings['activation_success']; |
@@ -3264,7 +3264,7 @@ discard block |
||
3264 | 3264 | } |
3265 | 3265 | } |
3266 | 3266 | |
3267 | - if ( ! class_exists( 'TGMPA_Bulk_Installer_Skin' ) ) { |
|
3267 | + if (!class_exists('TGMPA_Bulk_Installer_Skin')) { |
|
3268 | 3268 | |
3269 | 3269 | /** |
3270 | 3270 | * Installer skin to set strings for the bulk plugin installations.. |
@@ -3328,9 +3328,9 @@ discard block |
||
3328 | 3328 | * |
3329 | 3329 | * @param array $args Arguments to pass for use within the class. |
3330 | 3330 | */ |
3331 | - public function __construct( $args = array() ) { |
|
3331 | + public function __construct($args = array()) { |
|
3332 | 3332 | // Get TGMPA class instance. |
3333 | - $this->tgmpa = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) ); |
|
3333 | + $this->tgmpa = call_user_func(array(get_class($GLOBALS['tgmpa']), 'get_instance')); |
|
3334 | 3334 | |
3335 | 3335 | // Parse default and new args. |
3336 | 3336 | $defaults = array( |
@@ -3339,13 +3339,13 @@ discard block |
||
3339 | 3339 | 'names' => array(), |
3340 | 3340 | 'install_type' => 'install', |
3341 | 3341 | ); |
3342 | - $args = wp_parse_args( $args, $defaults ); |
|
3342 | + $args = wp_parse_args($args, $defaults); |
|
3343 | 3343 | |
3344 | 3344 | // Set plugin names to $this->plugin_names property. |
3345 | 3345 | $this->plugin_names = $args['names']; |
3346 | 3346 | |
3347 | 3347 | // Extract the new args. |
3348 | - parent::__construct( $args ); |
|
3348 | + parent::__construct($args); |
|
3349 | 3349 | } |
3350 | 3350 | |
3351 | 3351 | /** |
@@ -3357,25 +3357,25 @@ discard block |
||
3357 | 3357 | * @since 2.2.0 |
3358 | 3358 | */ |
3359 | 3359 | public function add_strings() { |
3360 | - if ( 'update' === $this->options['install_type'] ) { |
|
3360 | + if ('update' === $this->options['install_type']) { |
|
3361 | 3361 | parent::add_strings(); |
3362 | - $this->upgrader->strings['skin_before_update_header'] = __( 'Updating Plugin %1$s (%2$d/%3$d)', 'tgmpa' ); |
|
3362 | + $this->upgrader->strings['skin_before_update_header'] = __('Updating Plugin %1$s (%2$d/%3$d)', 'tgmpa'); |
|
3363 | 3363 | } else { |
3364 | - $this->upgrader->strings['skin_update_failed_error'] = __( 'An error occurred while installing %1$s: <strong>%2$s</strong>.', 'tgmpa' ); |
|
3365 | - $this->upgrader->strings['skin_update_failed'] = __( 'The installation of %1$s failed.', 'tgmpa' ); |
|
3364 | + $this->upgrader->strings['skin_update_failed_error'] = __('An error occurred while installing %1$s: <strong>%2$s</strong>.', 'tgmpa'); |
|
3365 | + $this->upgrader->strings['skin_update_failed'] = __('The installation of %1$s failed.', 'tgmpa'); |
|
3366 | 3366 | |
3367 | - if ( $this->tgmpa->is_automatic ) { |
|
3367 | + if ($this->tgmpa->is_automatic) { |
|
3368 | 3368 | // Automatic activation strings. |
3369 | - $this->upgrader->strings['skin_upgrade_start'] = __( 'The installation and activation process is starting. This process may take a while on some hosts, so please be patient.', 'tgmpa' ); |
|
3370 | - $this->upgrader->strings['skin_update_successful'] = __( '%1$s installed and activated successfully.', 'tgmpa' ) . ' <a href="#" class="hide-if-no-js" onclick="%2$s"><span>' . esc_html__( 'Show Details', 'tgmpa' ) . '</span><span class="hidden">' . esc_html__( 'Hide Details', 'tgmpa' ) . '</span>.</a>'; |
|
3371 | - $this->upgrader->strings['skin_upgrade_end'] = __( 'All installations and activations have been completed.', 'tgmpa' ); |
|
3372 | - $this->upgrader->strings['skin_before_update_header'] = __( 'Installing and Activating Plugin %1$s (%2$d/%3$d)', 'tgmpa' ); |
|
3369 | + $this->upgrader->strings['skin_upgrade_start'] = __('The installation and activation process is starting. This process may take a while on some hosts, so please be patient.', 'tgmpa'); |
|
3370 | + $this->upgrader->strings['skin_update_successful'] = __('%1$s installed and activated successfully.', 'tgmpa').' <a href="#" class="hide-if-no-js" onclick="%2$s"><span>'.esc_html__('Show Details', 'tgmpa').'</span><span class="hidden">'.esc_html__('Hide Details', 'tgmpa').'</span>.</a>'; |
|
3371 | + $this->upgrader->strings['skin_upgrade_end'] = __('All installations and activations have been completed.', 'tgmpa'); |
|
3372 | + $this->upgrader->strings['skin_before_update_header'] = __('Installing and Activating Plugin %1$s (%2$d/%3$d)', 'tgmpa'); |
|
3373 | 3373 | } else { |
3374 | 3374 | // Default installation strings. |
3375 | - $this->upgrader->strings['skin_upgrade_start'] = __( 'The installation process is starting. This process may take a while on some hosts, so please be patient.', 'tgmpa' ); |
|
3376 | - $this->upgrader->strings['skin_update_successful'] = esc_html__( '%1$s installed successfully.', 'tgmpa' ) . ' <a href="#" class="hide-if-no-js" onclick="%2$s"><span>' . esc_html__( 'Show Details', 'tgmpa' ) . '</span><span class="hidden">' . esc_html__( 'Hide Details', 'tgmpa' ) . '</span>.</a>'; |
|
3377 | - $this->upgrader->strings['skin_upgrade_end'] = __( 'All installations have been completed.', 'tgmpa' ); |
|
3378 | - $this->upgrader->strings['skin_before_update_header'] = __( 'Installing Plugin %1$s (%2$d/%3$d)', 'tgmpa' ); |
|
3375 | + $this->upgrader->strings['skin_upgrade_start'] = __('The installation process is starting. This process may take a while on some hosts, so please be patient.', 'tgmpa'); |
|
3376 | + $this->upgrader->strings['skin_update_successful'] = esc_html__('%1$s installed successfully.', 'tgmpa').' <a href="#" class="hide-if-no-js" onclick="%2$s"><span>'.esc_html__('Show Details', 'tgmpa').'</span><span class="hidden">'.esc_html__('Hide Details', 'tgmpa').'</span>.</a>'; |
|
3377 | + $this->upgrader->strings['skin_upgrade_end'] = __('All installations have been completed.', 'tgmpa'); |
|
3378 | + $this->upgrader->strings['skin_before_update_header'] = __('Installing Plugin %1$s (%2$d/%3$d)', 'tgmpa'); |
|
3379 | 3379 | } |
3380 | 3380 | } |
3381 | 3381 | } |
@@ -3387,11 +3387,11 @@ discard block |
||
3387 | 3387 | * |
3388 | 3388 | * @param string $title Unused in this implementation. |
3389 | 3389 | */ |
3390 | - public function before( $title = '' ) { |
|
3391 | - if ( empty( $title ) ) { |
|
3392 | - $title = esc_html( $this->plugin_names[ $this->i ] ); |
|
3390 | + public function before($title = '') { |
|
3391 | + if (empty($title)) { |
|
3392 | + $title = esc_html($this->plugin_names[$this->i]); |
|
3393 | 3393 | } |
3394 | - parent::before( $title ); |
|
3394 | + parent::before($title); |
|
3395 | 3395 | } |
3396 | 3396 | |
3397 | 3397 | /** |
@@ -3404,11 +3404,11 @@ discard block |
||
3404 | 3404 | * |
3405 | 3405 | * @param string $title Unused in this implementation. |
3406 | 3406 | */ |
3407 | - public function after( $title = '' ) { |
|
3408 | - if ( empty( $title ) ) { |
|
3409 | - $title = esc_html( $this->plugin_names[ $this->i ] ); |
|
3407 | + public function after($title = '') { |
|
3408 | + if (empty($title)) { |
|
3409 | + $title = esc_html($this->plugin_names[$this->i]); |
|
3410 | 3410 | } |
3411 | - parent::after( $title ); |
|
3411 | + parent::after($title); |
|
3412 | 3412 | |
3413 | 3413 | $this->i++; |
3414 | 3414 | } |
@@ -3430,15 +3430,15 @@ discard block |
||
3430 | 3430 | // Display message based on if all plugins are now active or not. |
3431 | 3431 | $update_actions = array(); |
3432 | 3432 | |
3433 | - if ( $this->tgmpa->is_tgmpa_complete() ) { |
|
3433 | + if ($this->tgmpa->is_tgmpa_complete()) { |
|
3434 | 3434 | // All plugins are active, so we display the complete string and hide the menu to protect users. |
3435 | 3435 | echo '<style type="text/css">#adminmenu .wp-submenu li.current { display: none !important; }</style>'; |
3436 | 3436 | $update_actions['dashboard'] = sprintf( |
3437 | - esc_html( $this->tgmpa->strings['complete'] ), |
|
3438 | - '<a href="' . esc_url( self_admin_url() ) . '">' . esc_html__( 'Return to the Dashboard', 'tgmpa' ) . '</a>' |
|
3437 | + esc_html($this->tgmpa->strings['complete']), |
|
3438 | + '<a href="'.esc_url(self_admin_url()).'">'.esc_html__('Return to the Dashboard', 'tgmpa').'</a>' |
|
3439 | 3439 | ); |
3440 | 3440 | } else { |
3441 | - $update_actions['tgmpa_page'] = '<a href="' . esc_url( $this->tgmpa->get_tgmpa_url() ) . '" target="_parent">' . esc_html( $this->tgmpa->strings['return'] ) . '</a>'; |
|
3441 | + $update_actions['tgmpa_page'] = '<a href="'.esc_url($this->tgmpa->get_tgmpa_url()).'" target="_parent">'.esc_html($this->tgmpa->strings['return']).'</a>'; |
|
3442 | 3442 | } |
3443 | 3443 | |
3444 | 3444 | /** |
@@ -3449,10 +3449,10 @@ discard block |
||
3449 | 3449 | * @param array $update_actions Array of plugin action links. |
3450 | 3450 | * @param array $plugin_info Array of information for the last-handled plugin. |
3451 | 3451 | */ |
3452 | - $update_actions = apply_filters( 'tgmpa_update_bulk_plugins_complete_actions', $update_actions, $this->plugin_info ); |
|
3452 | + $update_actions = apply_filters('tgmpa_update_bulk_plugins_complete_actions', $update_actions, $this->plugin_info); |
|
3453 | 3453 | |
3454 | - if ( ! empty( $update_actions ) ) { |
|
3455 | - $this->feedback( implode( ' | ', (array) $update_actions ) ); |
|
3454 | + if (!empty($update_actions)) { |
|
3455 | + $this->feedback(implode(' | ', (array) $update_actions)); |
|
3456 | 3456 | } |
3457 | 3457 | } |
3458 | 3458 | |
@@ -3466,7 +3466,7 @@ discard block |
||
3466 | 3466 | * @see Bulk_Upgrader_Skin::flush_output() |
3467 | 3467 | */ |
3468 | 3468 | public function before_flush_output() { |
3469 | - _deprecated_function( __FUNCTION__, 'TGMPA 2.5.0', 'Bulk_Upgrader_Skin::flush_output()' ); |
|
3469 | + _deprecated_function(__FUNCTION__, 'TGMPA 2.5.0', 'Bulk_Upgrader_Skin::flush_output()'); |
|
3470 | 3470 | $this->flush_output(); |
3471 | 3471 | } |
3472 | 3472 | |
@@ -3479,7 +3479,7 @@ discard block |
||
3479 | 3479 | * @see Bulk_Upgrader_Skin::flush_output() |
3480 | 3480 | */ |
3481 | 3481 | public function after_flush_output() { |
3482 | - _deprecated_function( __FUNCTION__, 'TGMPA 2.5.0', 'Bulk_Upgrader_Skin::flush_output()' ); |
|
3482 | + _deprecated_function(__FUNCTION__, 'TGMPA 2.5.0', 'Bulk_Upgrader_Skin::flush_output()'); |
|
3483 | 3483 | $this->flush_output(); |
3484 | 3484 | $this->i++; |
3485 | 3485 | } |
@@ -3489,7 +3489,7 @@ discard block |
||
3489 | 3489 | } |
3490 | 3490 | } |
3491 | 3491 | |
3492 | -if ( ! class_exists( 'TGMPA_Utils' ) ) { |
|
3492 | +if (!class_exists('TGMPA_Utils')) { |
|
3493 | 3493 | |
3494 | 3494 | /** |
3495 | 3495 | * Generic utilities for TGMPA. |
@@ -3527,8 +3527,8 @@ discard block |
||
3527 | 3527 | * @param string $string Text to be wrapped. |
3528 | 3528 | * @return string |
3529 | 3529 | */ |
3530 | - public static function wrap_in_em( $string ) { |
|
3531 | - return '<em>' . wp_kses_post( $string ) . '</em>'; |
|
3530 | + public static function wrap_in_em($string) { |
|
3531 | + return '<em>'.wp_kses_post($string).'</em>'; |
|
3532 | 3532 | } |
3533 | 3533 | |
3534 | 3534 | /** |
@@ -3541,8 +3541,8 @@ discard block |
||
3541 | 3541 | * @param string $string Text to be wrapped. |
3542 | 3542 | * @return string |
3543 | 3543 | */ |
3544 | - public static function wrap_in_strong( $string ) { |
|
3545 | - return '<strong>' . wp_kses_post( $string ) . '</strong>'; |
|
3544 | + public static function wrap_in_strong($string) { |
|
3545 | + return '<strong>'.wp_kses_post($string).'</strong>'; |
|
3546 | 3546 | } |
3547 | 3547 | |
3548 | 3548 | /** |
@@ -3555,15 +3555,15 @@ discard block |
||
3555 | 3555 | * @param mixed $value Arbitrary value. |
3556 | 3556 | * @return bool |
3557 | 3557 | */ |
3558 | - public static function validate_bool( $value ) { |
|
3559 | - if ( ! isset( self::$has_filters ) ) { |
|
3560 | - self::$has_filters = extension_loaded( 'filter' ); |
|
3558 | + public static function validate_bool($value) { |
|
3559 | + if (!isset(self::$has_filters)) { |
|
3560 | + self::$has_filters = extension_loaded('filter'); |
|
3561 | 3561 | } |
3562 | 3562 | |
3563 | - if ( self::$has_filters ) { |
|
3564 | - return filter_var( $value, FILTER_VALIDATE_BOOLEAN ); |
|
3563 | + if (self::$has_filters) { |
|
3564 | + return filter_var($value, FILTER_VALIDATE_BOOLEAN); |
|
3565 | 3565 | } else { |
3566 | - return self::emulate_filter_bool( $value ); |
|
3566 | + return self::emulate_filter_bool($value); |
|
3567 | 3567 | } |
3568 | 3568 | } |
3569 | 3569 | |
@@ -3577,9 +3577,9 @@ discard block |
||
3577 | 3577 | * @param mixed $value Value to cast. |
3578 | 3578 | * @return bool |
3579 | 3579 | */ |
3580 | - protected static function emulate_filter_bool( $value ) { |
|
3580 | + protected static function emulate_filter_bool($value) { |
|
3581 | 3581 | // @codingStandardsIgnoreStart |
3582 | - static $true = array( |
|
3582 | + static $true = array( |
|
3583 | 3583 | '1', |
3584 | 3584 | 'true', 'True', 'TRUE', |
3585 | 3585 | 'y', 'Y', |
@@ -3595,17 +3595,17 @@ discard block |
||
3595 | 3595 | ); |
3596 | 3596 | // @codingStandardsIgnoreEnd |
3597 | 3597 | |
3598 | - if ( is_bool( $value ) ) { |
|
3598 | + if (is_bool($value)) { |
|
3599 | 3599 | return $value; |
3600 | - } else if ( is_int( $value ) && ( 0 === $value || 1 === $value ) ) { |
|
3600 | + } else if (is_int($value) && (0 === $value || 1 === $value)) { |
|
3601 | 3601 | return (bool) $value; |
3602 | - } else if ( ( is_float( $value ) && ! is_nan( $value ) ) && ( (float) 0 === $value || (float) 1 === $value ) ) { |
|
3602 | + } else if ((is_float($value) && !is_nan($value)) && ((float) 0 === $value || (float) 1 === $value)) { |
|
3603 | 3603 | return (bool) $value; |
3604 | - } else if ( is_string( $value ) ) { |
|
3605 | - $value = trim( $value ); |
|
3606 | - if ( in_array( $value, $true, true ) ) { |
|
3604 | + } else if (is_string($value)) { |
|
3605 | + $value = trim($value); |
|
3606 | + if (in_array($value, $true, true)) { |
|
3607 | 3607 | return true; |
3608 | - } else if ( in_array( $value, $false, true ) ) { |
|
3608 | + } else if (in_array($value, $false, true)) { |
|
3609 | 3609 | return false; |
3610 | 3610 | } else { |
3611 | 3611 | return false; |
@@ -6,28 +6,28 @@ discard block |
||
6 | 6 | |
7 | 7 | function __construct() { |
8 | 8 | |
9 | - define( 'LASSO_STORE_ITEM_NAME', 'lasso' ); |
|
10 | - define( 'LASSO_STORE_URL', 'https://edituswp.com' ); |
|
11 | - |
|
12 | - add_action( 'admin_init', array( $this, 'plugin_updater' ), 0 ); |
|
13 | - add_action( 'admin_menu', array( $this, 'license_menu' ) ); |
|
14 | - add_action( 'network_admin_menu', array( $this, 'license_menu' ) ); // CHANGED Added hook. |
|
15 | - add_action( 'admin_init', array( $this, 'register_option' ) ); |
|
16 | - add_action( 'admin_init', array( $this, 'activate_license' ) ); |
|
17 | - add_action( 'admin_init', array( $this, 'deactivate_license' ) ); |
|
9 | + define('LASSO_STORE_ITEM_NAME', 'lasso'); |
|
10 | + define('LASSO_STORE_URL', 'https://edituswp.com'); |
|
11 | + |
|
12 | + add_action('admin_init', array($this, 'plugin_updater'), 0); |
|
13 | + add_action('admin_menu', array($this, 'license_menu')); |
|
14 | + add_action('network_admin_menu', array($this, 'license_menu')); // CHANGED Added hook. |
|
15 | + add_action('admin_init', array($this, 'register_option')); |
|
16 | + add_action('admin_init', array($this, 'activate_license')); |
|
17 | + add_action('admin_init', array($this, 'deactivate_license')); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | function plugin_updater() { |
21 | 21 | |
22 | 22 | // retrieve our license key from the DB |
23 | - $license_key = trim( get_option( 'lasso_license_key' ) ); |
|
23 | + $license_key = trim(get_option('lasso_license_key')); |
|
24 | 24 | |
25 | 25 | // setup the updater |
26 | - $edd_updater = new \EDD_SL_Plugin_Updater( LASSO_STORE_URL , LASSO_FILE, array( |
|
26 | + $edd_updater = new \EDD_SL_Plugin_Updater(LASSO_STORE_URL, LASSO_FILE, array( |
|
27 | 27 | 'version' => LASSO_VERSION, |
28 | 28 | 'license' => $license_key, |
29 | 29 | 'item_name' => LASSO_STORE_ITEM_NAME, |
30 | - 'author' => __( 'Aesopinteractive LLC', 'lasso' ) |
|
30 | + 'author' => __('Aesopinteractive LLC', 'lasso') |
|
31 | 31 | ) |
32 | 32 | ); |
33 | 33 | |
@@ -35,51 +35,51 @@ discard block |
||
35 | 35 | function license_menu() { |
36 | 36 | |
37 | 37 | // CHANGED Removed condition. |
38 | - add_submenu_page( 'lasso-editor', __( 'License Key', 'lasso' ), __( 'License', 'lasso' ), 'manage_options', 'lasso-license', array( $this, 'license_page' ) ); |
|
38 | + add_submenu_page('lasso-editor', __('License Key', 'lasso'), __('License', 'lasso'), 'manage_options', 'lasso-license', array($this, 'license_page')); |
|
39 | 39 | |
40 | 40 | } |
41 | 41 | function license_page() { |
42 | - $license = get_option( 'lasso_license_key' ); |
|
43 | - $status = get_option( 'lasso_license_status' ); |
|
42 | + $license = get_option('lasso_license_key'); |
|
43 | + $status = get_option('lasso_license_status'); |
|
44 | 44 | |
45 | 45 | ?> |
46 | 46 | <div class="wrap"> |
47 | - <h2><?php _e( 'Editus License', 'lasso' ); ?></h2> |
|
48 | - <p><?php _e( 'Input the license key you recieved with your purchase to ensure your version of Editus stays updated.', 'lasso' );?></p> |
|
47 | + <h2><?php _e('Editus License', 'lasso'); ?></h2> |
|
48 | + <p><?php _e('Input the license key you recieved with your purchase to ensure your version of Editus stays updated.', 'lasso'); ?></p> |
|
49 | 49 | <form class="lasso--form-settings" method="post" action="options.php"> |
50 | 50 | |
51 | - <?php settings_fields( 'lasso_license' ); ?> |
|
51 | + <?php settings_fields('lasso_license'); ?> |
|
52 | 52 | |
53 | 53 | <table class="form-table"> |
54 | 54 | <tbody> |
55 | 55 | <tr valign="top"> |
56 | 56 | <th scope="row" valign="top"> |
57 | - <?php _e( 'License Key', 'lasso' ); ?> |
|
57 | + <?php _e('License Key', 'lasso'); ?> |
|
58 | 58 | </th> |
59 | 59 | <td> |
60 | - <input id="lasso_license_key" name="lasso_license_key" type="text" class="regular-text" value="<?php esc_attr_e( $license ); ?>" /> |
|
60 | + <input id="lasso_license_key" name="lasso_license_key" type="text" class="regular-text" value="<?php esc_attr_e($license); ?>" /> |
|
61 | 61 | </td> |
62 | 62 | </tr> |
63 | - <?php if ( false !== $license ) { ?> |
|
63 | + <?php if (false !== $license) { ?> |
|
64 | 64 | <tr valign="top"> |
65 | 65 | <th scope="row" valign="top"> |
66 | - <?php _e( 'Activate License', 'lasso' ); ?> |
|
66 | + <?php _e('Activate License', 'lasso'); ?> |
|
67 | 67 | </th> |
68 | 68 | <td> |
69 | - <?php if ( $status !== false && $status == 'valid' ) { ?> |
|
70 | - <span style="color:green;"><?php _e( 'active' ); ?></span> |
|
71 | - <?php wp_nonce_field( 'lasso_license_nonce', 'lasso_license_nonce' ); ?> |
|
72 | - <input type="submit" class="button-secondary" name="edd_license_deactivate" value="<?php esc_attr_e( 'Deactivate License', 'lasso' ); ?>"/> |
|
69 | + <?php if ($status !== false && $status == 'valid') { ?> |
|
70 | + <span style="color:green;"><?php _e('active'); ?></span> |
|
71 | + <?php wp_nonce_field('lasso_license_nonce', 'lasso_license_nonce'); ?> |
|
72 | + <input type="submit" class="button-secondary" name="edd_license_deactivate" value="<?php esc_attr_e('Deactivate License', 'lasso'); ?>"/> |
|
73 | 73 | <?php } else { |
74 | - wp_nonce_field( 'lasso_license_nonce', 'lasso_license_nonce' ); ?> |
|
75 | - <input type="submit" class="button-secondary" name="edd_license_activate" value="<?php esc_attr_e( 'Activate License', 'lasso' ); ?>"/> |
|
74 | + wp_nonce_field('lasso_license_nonce', 'lasso_license_nonce'); ?> |
|
75 | + <input type="submit" class="button-secondary" name="edd_license_activate" value="<?php esc_attr_e('Activate License', 'lasso'); ?>"/> |
|
76 | 76 | <?php } ?> |
77 | 77 | </td> |
78 | 78 | </tr> |
79 | 79 | <?php } ?> |
80 | 80 | </tbody> |
81 | 81 | </table> |
82 | - <?php submit_button( 'Save License' ); ?> |
|
82 | + <?php submit_button('Save License'); ?> |
|
83 | 83 | |
84 | 84 | </form> |
85 | 85 | <?php |
@@ -88,14 +88,14 @@ discard block |
||
88 | 88 | // register option |
89 | 89 | function register_option() { |
90 | 90 | |
91 | - register_setting( 'lasso_license', 'lasso_license_key', array( $this, 'sanitize_license' ) ); |
|
91 | + register_setting('lasso_license', 'lasso_license_key', array($this, 'sanitize_license')); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | // santize |
95 | - function sanitize_license( $new ) { |
|
96 | - $old = get_option( 'lasso_license_key' ); |
|
97 | - if ( $old && $old != $new ) { |
|
98 | - delete_option( 'lasso_license_status' ); // new license has been entered, so must reactivate |
|
95 | + function sanitize_license($new) { |
|
96 | + $old = get_option('lasso_license_key'); |
|
97 | + if ($old && $old != $new) { |
|
98 | + delete_option('lasso_license_status'); // new license has been entered, so must reactivate |
|
99 | 99 | } |
100 | 100 | return $new; |
101 | 101 | } |
@@ -104,36 +104,36 @@ discard block |
||
104 | 104 | function activate_license() { |
105 | 105 | |
106 | 106 | // listen for our activate button to be clicked |
107 | - if ( isset( $_POST['edd_license_activate'] ) ) { |
|
107 | + if (isset($_POST['edd_license_activate'])) { |
|
108 | 108 | |
109 | 109 | // run a quick security check |
110 | - if ( ! check_admin_referer( 'lasso_license_nonce', 'lasso_license_nonce' ) ) |
|
110 | + if (!check_admin_referer('lasso_license_nonce', 'lasso_license_nonce')) |
|
111 | 111 | return; // get out if we didn't click the Activate button |
112 | 112 | |
113 | 113 | // retrieve the license from the database |
114 | - $license = trim( get_option( 'lasso_license_key' ) ); |
|
114 | + $license = trim(get_option('lasso_license_key')); |
|
115 | 115 | |
116 | 116 | // data to send in our API request |
117 | 117 | $api_params = array( |
118 | 118 | 'edd_action'=> 'activate_license', |
119 | 119 | 'license' => $license, |
120 | - 'item_name' => urlencode( LASSO_STORE_ITEM_NAME ), // the name of our product in EDD |
|
120 | + 'item_name' => urlencode(LASSO_STORE_ITEM_NAME), // the name of our product in EDD |
|
121 | 121 | 'url' => home_url() |
122 | 122 | ); |
123 | 123 | |
124 | 124 | // Call the custom API. |
125 | - $response = wp_remote_post( LASSO_STORE_URL, array( 'body' => $api_params, 'timeout' => 15, 'sslverify' => false ) ); |
|
125 | + $response = wp_remote_post(LASSO_STORE_URL, array('body' => $api_params, 'timeout' => 15, 'sslverify' => false)); |
|
126 | 126 | |
127 | 127 | // make sure the response came back okay |
128 | - if ( is_wp_error( $response ) ) |
|
128 | + if (is_wp_error($response)) |
|
129 | 129 | return false; |
130 | 130 | |
131 | 131 | // decode the license data |
132 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
132 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
133 | 133 | |
134 | 134 | // $license_data->license will be either "valid" or "invalid" |
135 | 135 | |
136 | - update_option( 'lasso_license_status', $license_data->license ); |
|
136 | + update_option('lasso_license_status', $license_data->license); |
|
137 | 137 | |
138 | 138 | } |
139 | 139 | } |
@@ -141,37 +141,37 @@ discard block |
||
141 | 141 | function deactivate_license() { |
142 | 142 | |
143 | 143 | // listen for our activate button to be clicked |
144 | - if ( isset( $_POST['edd_license_deactivate'] ) ) { |
|
144 | + if (isset($_POST['edd_license_deactivate'])) { |
|
145 | 145 | |
146 | 146 | // run a quick security check |
147 | - if ( ! check_admin_referer( 'lasso_license_nonce', 'lasso_license_nonce' ) ) |
|
147 | + if (!check_admin_referer('lasso_license_nonce', 'lasso_license_nonce')) |
|
148 | 148 | return; // get out if we didn't click the Activate button |
149 | 149 | |
150 | 150 | // retrieve the license from the database |
151 | - $license = trim( get_option( 'lasso_license_key' ) ); |
|
151 | + $license = trim(get_option('lasso_license_key')); |
|
152 | 152 | |
153 | 153 | |
154 | 154 | // data to send in our API request |
155 | 155 | $api_params = array( |
156 | 156 | 'edd_action'=> 'deactivate_license', |
157 | 157 | 'license' => $license, |
158 | - 'item_name' => urlencode( LASSO_STORE_ITEM_NAME ), // the name of our product in EDD |
|
158 | + 'item_name' => urlencode(LASSO_STORE_ITEM_NAME), // the name of our product in EDD |
|
159 | 159 | 'url' => home_url() |
160 | 160 | ); |
161 | 161 | |
162 | 162 | // Call the custom API. |
163 | - $response = wp_remote_post( LASSO_STORE_URL, array( 'body' => $api_params, 'timeout' => 15, 'sslverify' => false ) ); |
|
163 | + $response = wp_remote_post(LASSO_STORE_URL, array('body' => $api_params, 'timeout' => 15, 'sslverify' => false)); |
|
164 | 164 | |
165 | 165 | // make sure the response came back okay |
166 | - if ( is_wp_error( $response ) ) |
|
166 | + if (is_wp_error($response)) |
|
167 | 167 | return false; |
168 | 168 | |
169 | 169 | // decode the license data |
170 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
170 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
171 | 171 | |
172 | 172 | // $license_data->license will be either "deactivated" or "failed" |
173 | - if ( $license_data->license == 'deactivated' ) |
|
174 | - delete_option( 'lasso_license_status' ); |
|
173 | + if ($license_data->license == 'deactivated') |
|
174 | + delete_option('lasso_license_status'); |
|
175 | 175 | |
176 | 176 | } |
177 | 177 | } |
@@ -181,24 +181,24 @@ discard block |
||
181 | 181 | |
182 | 182 | global $wp_version; |
183 | 183 | |
184 | - $license = trim( get_option( 'lasso_license_key' ) ); |
|
184 | + $license = trim(get_option('lasso_license_key')); |
|
185 | 185 | |
186 | 186 | $api_params = array( |
187 | 187 | 'edd_action' => 'check_license', |
188 | 188 | 'license' => $license, |
189 | - 'item_name' => urlencode( LASSO_STORE_ITEM_NAME ), |
|
189 | + 'item_name' => urlencode(LASSO_STORE_ITEM_NAME), |
|
190 | 190 | 'url' => home_url() |
191 | 191 | ); |
192 | 192 | |
193 | 193 | // Call the custom API. |
194 | - $response = wp_remote_post( LASSO_STORE_URL, array( 'body' => $api_params, 'timeout' => 15, 'sslverify' => false ) ); |
|
194 | + $response = wp_remote_post(LASSO_STORE_URL, array('body' => $api_params, 'timeout' => 15, 'sslverify' => false)); |
|
195 | 195 | |
196 | - if ( is_wp_error( $response ) ) |
|
196 | + if (is_wp_error($response)) |
|
197 | 197 | return false; |
198 | 198 | |
199 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
199 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
200 | 200 | |
201 | - if ( $license_data->license == 'valid' ) { |
|
201 | + if ($license_data->license == 'valid') { |
|
202 | 202 | echo 'valid'; exit; |
203 | 203 | // this license is still valid |
204 | 204 | } else { |
@@ -29,15 +29,15 @@ discard block |
||
29 | 29 | * |
30 | 30 | * @return array Key "markup" has the HTML. |
31 | 31 | */ |
32 | - public function swap( $data ) { |
|
32 | + public function swap($data) { |
|
33 | 33 | |
34 | 34 | |
35 | - $id = $data[ 'gallery_id' ]; |
|
36 | - if ( is_null( $id ) ) { |
|
35 | + $id = $data['gallery_id']; |
|
36 | + if (is_null($id)) { |
|
37 | 37 | $id = false; |
38 | 38 | } |
39 | 39 | |
40 | - $markup = sprintf( '<div contenteditable="false" class="lasso--empty-component aesop-component aesop-gallery-component" data-component-type="gallery" data-id="%s">%s</div>', $id, __( 'Save and refresh to view gallery.','lasso' ) ); |
|
40 | + $markup = sprintf('<div contenteditable="false" class="lasso--empty-component aesop-component aesop-gallery-component" data-component-type="gallery" data-id="%s">%s</div>', $id, __('Save and refresh to view gallery.', 'lasso')); |
|
41 | 41 | |
42 | 42 | return array( |
43 | 43 | 'gallery' => $markup |
@@ -54,49 +54,49 @@ discard block |
||
54 | 54 | * |
55 | 55 | * @return array|bool On success an array containing "message" or on failure false. |
56 | 56 | */ |
57 | - public function create( $data ) { |
|
57 | + public function create($data) { |
|
58 | 58 | |
59 | 59 | //@todo adapt auth callbacks to work with args. |
60 | - if ( ! lasso_user_can( 'publish_posts' ) ) { |
|
60 | + if (!lasso_user_can('publish_posts')) { |
|
61 | 61 | return false; |
62 | 62 | |
63 | 63 | } |
64 | 64 | |
65 | - $gallery_ids = isset( $data['gallery_ids'] ) ? $data['gallery_ids'] : false; |
|
65 | + $gallery_ids = isset($data['gallery_ids']) ? $data['gallery_ids'] : false; |
|
66 | 66 | |
67 | 67 | // bail if no gallery ids |
68 | - if ( empty( $gallery_ids ) ) { |
|
68 | + if (empty($gallery_ids)) { |
|
69 | 69 | return false; |
70 | 70 | } |
71 | 71 | |
72 | - $postid = isset( $data['postid'] ) ? (int) $data['postid'] : false; |
|
73 | - $type = isset( $data['gallery_type'] ) ? $data['gallery_type'] : false; |
|
74 | - $edgallerytitle = isset( $data['edgallerytitle'] ) ? $data['edgallerytitle'] : $postid.'-'.rand(); |
|
72 | + $postid = isset($data['postid']) ? (int) $data['postid'] : false; |
|
73 | + $type = isset($data['gallery_type']) ? $data['gallery_type'] : false; |
|
74 | + $edgallerytitle = isset($data['edgallerytitle']) ? $data['edgallerytitle'] : $postid.'-'.rand(); |
|
75 | 75 | |
76 | 76 | // insert a new gallery |
77 | 77 | $args = array( |
78 | - 'post_title' => $edgallerytitle , |
|
78 | + 'post_title' => $edgallerytitle, |
|
79 | 79 | 'post_status' => 'publish', |
80 | 80 | 'post_type' => 'ai_galleries' |
81 | 81 | ); |
82 | 82 | |
83 | - $postid = wp_insert_post( apply_filters( 'lasso_insert_gallery_args', $args ) ); |
|
83 | + $postid = wp_insert_post(apply_filters('lasso_insert_gallery_args', $args)); |
|
84 | 84 | |
85 | 85 | // update gallery ids |
86 | - if ( $gallery_ids ) { |
|
86 | + if ($gallery_ids) { |
|
87 | 87 | |
88 | - update_post_meta( $postid, '_ase_gallery_images', $gallery_ids ); |
|
88 | + update_post_meta($postid, '_ase_gallery_images', $gallery_ids); |
|
89 | 89 | |
90 | 90 | } |
91 | 91 | |
92 | 92 | // update the gallery type |
93 | - if ( !empty( $type ) ) { |
|
93 | + if (!empty($type)) { |
|
94 | 94 | |
95 | - update_post_meta( $postid, 'aesop_gallery_type', $type ); |
|
95 | + update_post_meta($postid, 'aesop_gallery_type', $type); |
|
96 | 96 | |
97 | 97 | } |
98 | 98 | |
99 | - do_action( 'lasso_gallery_published', $postid, $gallery_ids, get_current_user_ID() ); |
|
99 | + do_action('lasso_gallery_published', $postid, $gallery_ids, get_current_user_ID()); |
|
100 | 100 | |
101 | 101 | return array( |
102 | 102 | 'message' => 'gallery-created', |
@@ -114,20 +114,20 @@ discard block |
||
114 | 114 | * |
115 | 115 | * @return array "message" key has the message. |
116 | 116 | */ |
117 | - public function update( $data ) { |
|
118 | - |
|
119 | - $options = isset( $data['fields'] ) ? $data['fields'] : false; |
|
120 | - $postid = !empty( $options ) ? (int) $options['id'] : false; |
|
121 | - $gallery_ids = isset( $data['gallery_ids'] ) ? $data['gallery_ids'] : false; |
|
122 | - if ( ! empty( $data ) && $data[ 'gallery_type' ] ) { |
|
123 | - $type = $data[ 'gallery_type' ]; |
|
124 | - }elseif ( ! empty( $options ) && $options[ 'galleryType' ] ) { |
|
125 | - $type = $options[ 'galleryType' ]; |
|
126 | - }else{ |
|
117 | + public function update($data) { |
|
118 | + |
|
119 | + $options = isset($data['fields']) ? $data['fields'] : false; |
|
120 | + $postid = !empty($options) ? (int) $options['id'] : false; |
|
121 | + $gallery_ids = isset($data['gallery_ids']) ? $data['gallery_ids'] : false; |
|
122 | + if (!empty($data) && $data['gallery_type']) { |
|
123 | + $type = $data['gallery_type']; |
|
124 | + }elseif (!empty($options) && $options['galleryType']) { |
|
125 | + $type = $options['galleryType']; |
|
126 | + } else { |
|
127 | 127 | $type = false; |
128 | 128 | } |
129 | 129 | |
130 | - save_gallery::save_gallery_options( $postid, $gallery_ids, $options, $type ); |
|
130 | + save_gallery::save_gallery_options($postid, $gallery_ids, $options, $type); |
|
131 | 131 | |
132 | 132 | return array( |
133 | 133 | 'message' => 'gallery-updated' |
@@ -145,25 +145,25 @@ discard block |
||
145 | 145 | * |
146 | 146 | * @return bool |
147 | 147 | */ |
148 | - public function get_images( $data ) { |
|
148 | + public function get_images($data) { |
|
149 | 149 | |
150 | 150 | //check caps |
151 | - if ( !current_user_can( 'edit_posts' ) ) { |
|
151 | + if (!current_user_can('edit_posts')) { |
|
152 | 152 | return false; |
153 | 153 | } |
154 | 154 | |
155 | 155 | // bail if no id specified like on new galleries |
156 | - if ( is_null( $data['post_id'] ) || empty( $data['post_id'] ) ) { |
|
156 | + if (is_null($data['post_id']) || empty($data['post_id'])) { |
|
157 | 157 | return false; |
158 | 158 | } |
159 | 159 | |
160 | - $postid = isset( $data['post_id'] ) ? $data['post_id'] : false; |
|
160 | + $postid = isset($data['post_id']) ? $data['post_id'] : false; |
|
161 | 161 | |
162 | 162 | // fetch image ids from cache |
163 | - $image_ids = get_post_meta( $postid, '_ase_gallery_images', true ); |
|
163 | + $image_ids = get_post_meta($postid, '_ase_gallery_images', true); |
|
164 | 164 | |
165 | 165 | // send ids to return images |
166 | - return self::get_the_images( $image_ids ); |
|
166 | + return self::get_the_images($image_ids); |
|
167 | 167 | |
168 | 168 | } |
169 | 169 | |
@@ -173,32 +173,32 @@ discard block |
||
173 | 173 | * @param $image_ids array array of image ids |
174 | 174 | * @since 0.1 |
175 | 175 | */ |
176 | - private function get_the_images( $image_ids = '' ) { |
|
176 | + private function get_the_images($image_ids = '') { |
|
177 | 177 | |
178 | - if ( empty( $image_ids ) ) |
|
178 | + if (empty($image_ids)) |
|
179 | 179 | return; |
180 | 180 | |
181 | - $image_ids = array_map( 'intval', explode( ',', $image_ids ) ); |
|
181 | + $image_ids = array_map('intval', explode(',', $image_ids)); |
|
182 | 182 | |
183 | 183 | $out[] = '<ul id="ase-gallery-images">'; |
184 | 184 | |
185 | - if ( !empty( $image_ids ) ): |
|
185 | + if (!empty($image_ids)): |
|
186 | 186 | |
187 | - foreach ( $image_ids as $image_id ) { |
|
187 | + foreach ($image_ids as $image_id) { |
|
188 | 188 | |
189 | - $image = wp_get_attachment_image_src( $image_id, 'thumbnail', false ); |
|
189 | + $image = wp_get_attachment_image_src($image_id, 'thumbnail', false); |
|
190 | 190 | |
191 | - $out[] = sprintf( ' |
|
191 | + $out[] = sprintf(' |
|
192 | 192 | <li id="%1s" class="ase-gallery-image"> |
193 | 193 | <i class="dashicons dashicons-no-alt" title="%2s"></i> |
194 | 194 | <i class="dashicons dashicons-edit" title="%3s"></i> |
195 | 195 | <img src="%4s"> |
196 | 196 | </li> |
197 | 197 | ', |
198 | - absint( $image_id ), |
|
199 | - __( 'Delete From Gallery', 'lasso' ), |
|
200 | - __( 'Edit Image Caption', 'lasso' ), |
|
201 | - esc_url( $image[0] ) |
|
198 | + absint($image_id), |
|
199 | + __('Delete From Gallery', 'lasso'), |
|
200 | + __('Edit Image Caption', 'lasso'), |
|
201 | + esc_url($image[0]) |
|
202 | 202 | ); |
203 | 203 | |
204 | 204 | } |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | |
208 | 208 | $out[] = '</ul>'; |
209 | 209 | |
210 | - return array( 'html' => implode( '', $out ) ); |
|
210 | + return array('html' => implode('', $out)); |
|
211 | 211 | |
212 | 212 | } |
213 | 213 | |
@@ -219,13 +219,13 @@ discard block |
||
219 | 219 | * |
220 | 220 | * @return array Array of keys to pull from $data per action and their sanitization callback |
221 | 221 | */ |
222 | - public static function params(){ |
|
223 | - $params[ 'process_gallery_swap' ] = array( |
|
222 | + public static function params() { |
|
223 | + $params['process_gallery_swap'] = array( |
|
224 | 224 | 'gallery_id' => 'absint', |
225 | 225 | |
226 | 226 | ); |
227 | 227 | |
228 | - $params[ 'process_gallery_create' ] = array( |
|
228 | + $params['process_gallery_create'] = array( |
|
229 | 229 | 'postid' => 'absint', |
230 | 230 | 'content' => 'wp_kses_post', |
231 | 231 | 'edgallerytitle' =>'sanitize_text_field', |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | |
238 | 238 | ); |
239 | 239 | |
240 | - $params[ 'process_gallery_update' ] = array( |
|
240 | + $params['process_gallery_update'] = array( |
|
241 | 241 | 'postid' => 'absint', |
242 | 242 | 'gallery_ids' => 'lasso_sanitize_data', |
243 | 243 | 'fields' => 'lasso_sanitize_data', |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | ) |
248 | 248 | ); |
249 | 249 | |
250 | - $params[ 'process_gallery_get_images' ] = array( |
|
250 | + $params['process_gallery_get_images'] = array( |
|
251 | 251 | 'post_id' => 'absint' |
252 | 252 | ); |
253 | 253 | |
@@ -263,19 +263,19 @@ discard block |
||
263 | 263 | * @return array Array of additional functions to use to authorize action. |
264 | 264 | */ |
265 | 265 | public static function auth_callbacks() { |
266 | - $params[ 'process_gallery_swap' ] = array( |
|
266 | + $params['process_gallery_swap'] = array( |
|
267 | 267 | 'lasso_user_can' |
268 | 268 | ); |
269 | 269 | |
270 | - $params[ 'process_gallery_create' ] = array( |
|
270 | + $params['process_gallery_create'] = array( |
|
271 | 271 | 'is_user_logged_in' |
272 | 272 | ); |
273 | 273 | |
274 | - $params[ 'process_gallery_update' ] = array( |
|
274 | + $params['process_gallery_update'] = array( |
|
275 | 275 | 'lasso_user_can' |
276 | 276 | ); |
277 | 277 | |
278 | - $params[ 'process_gallery_get_images' ] = array(); |
|
278 | + $params['process_gallery_get_images'] = array(); |
|
279 | 279 | |
280 | 280 | return $params; |
281 | 281 |
@@ -12,65 +12,65 @@ |
||
12 | 12 | /** |
13 | 13 | * Update an existing galleries options |
14 | 14 | */ |
15 | - public static function save_gallery_options( $postid, $gallery_ids, $options, $type = false ) { |
|
15 | + public static function save_gallery_options($postid, $gallery_ids, $options, $type = false) { |
|
16 | 16 | |
17 | 17 | // gallery width |
18 | - $gallery_width = isset( $options['width'] ) ? $options['width'] : false; |
|
18 | + $gallery_width = isset($options['width']) ? $options['width'] : false; |
|
19 | 19 | |
20 | 20 | // gallery grid item width |
21 | - $item_width = isset( $options['itemwidth'] ) ? $options['itemwidth'] : false; |
|
21 | + $item_width = isset($options['itemwidth']) ? $options['itemwidth'] : false; |
|
22 | 22 | |
23 | 23 | // caption |
24 | - $caption = isset( $options['caption'] ) ? $options['caption'] : false; |
|
24 | + $caption = isset($options['caption']) ? $options['caption'] : false; |
|
25 | 25 | |
26 | 26 | // gallery transition |
27 | - $transition = isset( $options['transition'] ) ? $options['transition'] : false; |
|
27 | + $transition = isset($options['transition']) ? $options['transition'] : false; |
|
28 | 28 | |
29 | 29 | // gallery transition speed |
30 | - $transitionSpeed = isset( $options['speed'] ) ? $options['speed'] : false; |
|
30 | + $transitionSpeed = isset($options['speed']) ? $options['speed'] : false; |
|
31 | 31 | |
32 | 32 | // gallery hide thumbs |
33 | - $hideThumbs = isset( $options['hideThumbs'] ) ? $options['hideThumbs'] : false; |
|
33 | + $hideThumbs = isset($options['hideThumbs']) ? $options['hideThumbs'] : false; |
|
34 | 34 | |
35 | 35 | // photoset layout hardwired to on for now |
36 | - $psLayout = isset( $options['pslayout'] ) ? $options['pslayout'] : false; |
|
36 | + $psLayout = isset($options['pslayout']) ? $options['pslayout'] : false; |
|
37 | 37 | |
38 | 38 | // photoset layout |
39 | - $psLightbox = 'on';//isset( $options['pslightbox'] ) ? $options['pslightbox'] : false; |
|
39 | + $psLightbox = 'on'; //isset( $options['pslightbox'] ) ? $options['pslightbox'] : false; |
|
40 | 40 | |
41 | 41 | // hero gallery height |
42 | - $gallery_height = isset( $options['height'] ) ? $options['height'] : false; |
|
42 | + $gallery_height = isset($options['height']) ? $options['height'] : false; |
|
43 | 43 | |
44 | 44 | // update gallery ids |
45 | - if ( !empty( $gallery_ids ) ) { |
|
45 | + if (!empty($gallery_ids)) { |
|
46 | 46 | |
47 | - update_post_meta( $postid, '_ase_gallery_images', $gallery_ids ); |
|
47 | + update_post_meta($postid, '_ase_gallery_images', $gallery_ids); |
|
48 | 48 | |
49 | 49 | } |
50 | 50 | |
51 | - update_post_meta( $postid, 'aesop_gallery_type', sanitize_text_field( trim( $type ) ) ); |
|
51 | + update_post_meta($postid, 'aesop_gallery_type', sanitize_text_field(trim($type))); |
|
52 | 52 | |
53 | - update_post_meta( $postid, 'aesop_gallery_width', sanitize_text_field( trim( $gallery_width ) ) ); |
|
53 | + update_post_meta($postid, 'aesop_gallery_width', sanitize_text_field(trim($gallery_width))); |
|
54 | 54 | |
55 | - update_post_meta( $postid, 'aesop_grid_gallery_width', sanitize_text_field( trim( $item_width ) ) ); |
|
55 | + update_post_meta($postid, 'aesop_grid_gallery_width', sanitize_text_field(trim($item_width))); |
|
56 | 56 | |
57 | - update_post_meta( $postid, 'aesop_gallery_caption', sanitize_text_field( trim( $caption ) ) ); |
|
57 | + update_post_meta($postid, 'aesop_gallery_caption', sanitize_text_field(trim($caption))); |
|
58 | 58 | |
59 | - update_post_meta( $postid, 'aesop_thumb_gallery_transition', sanitize_text_field( trim( $transition ) ) ); |
|
59 | + update_post_meta($postid, 'aesop_thumb_gallery_transition', sanitize_text_field(trim($transition))); |
|
60 | 60 | |
61 | - update_post_meta( $postid, 'aesop_thumb_gallery_transition_speed', absint( trim( $transitionSpeed ) ) ); |
|
61 | + update_post_meta($postid, 'aesop_thumb_gallery_transition_speed', absint(trim($transitionSpeed))); |
|
62 | 62 | |
63 | - update_post_meta( $postid, 'aesop_thumb_gallery_hide_thumbs', sanitize_text_field( trim( $hideThumbs ) ) ); |
|
63 | + update_post_meta($postid, 'aesop_thumb_gallery_hide_thumbs', sanitize_text_field(trim($hideThumbs))); |
|
64 | 64 | |
65 | - update_post_meta( $postid, 'aesop_photoset_gallery_layout', sanitize_text_field( trim( $psLayout ) ) ); |
|
65 | + update_post_meta($postid, 'aesop_photoset_gallery_layout', sanitize_text_field(trim($psLayout))); |
|
66 | 66 | |
67 | - update_post_meta( $postid, 'aesop_photoset_gallery_lightbox', sanitize_text_field( trim( $psLightbox ) ) ); |
|
67 | + update_post_meta($postid, 'aesop_photoset_gallery_lightbox', sanitize_text_field(trim($psLightbox))); |
|
68 | 68 | |
69 | - update_post_meta( $postid, 'aesop_hero_gallery_height', sanitize_text_field( trim( $gallery_height ) ) ); |
|
69 | + update_post_meta($postid, 'aesop_hero_gallery_height', sanitize_text_field(trim($gallery_height))); |
|
70 | 70 | |
71 | 71 | //hardwired for now |
72 | 72 | |
73 | - update_post_meta( $postid, 'aesop_hero_gallery_transition_speed', 300 ); |
|
73 | + update_post_meta($postid, 'aesop_hero_gallery_transition_speed', 300); |
|
74 | 74 | |
75 | 75 | } |
76 | 76 |
@@ -19,27 +19,27 @@ discard block |
||
19 | 19 | * |
20 | 20 | * @return bool Always returns true. |
21 | 21 | */ |
22 | - public function content( $data ) { |
|
22 | + public function content($data) { |
|
23 | 23 | |
24 | 24 | $save_to_post_disabled = $this->save_to_post_disables(); |
25 | 25 | |
26 | - $postid = (int) $data[ 'post_id' ]; |
|
27 | - $content = $this->replace_rendered_shortcodes( $data[ 'content' ] ); |
|
28 | - $content = $this->remove_comments( $content ); |
|
26 | + $postid = (int) $data['post_id']; |
|
27 | + $content = $this->replace_rendered_shortcodes($data['content']); |
|
28 | + $content = $this->remove_comments($content); |
|
29 | 29 | |
30 | - if ( 'off' == $save_to_post_disabled || empty( $save_to_post_disabled ) ) { |
|
30 | + if ('off' == $save_to_post_disabled || empty($save_to_post_disabled)) { |
|
31 | 31 | |
32 | 32 | $args = array( |
33 | 33 | 'ID' => (int) $postid, |
34 | 34 | 'post_content' => $content |
35 | 35 | ); |
36 | 36 | |
37 | - wp_update_post( apply_filters( 'lasso_object_save_args', $args ) ); |
|
37 | + wp_update_post(apply_filters('lasso_object_save_args', $args)); |
|
38 | 38 | |
39 | 39 | } |
40 | 40 | |
41 | 41 | // run save action |
42 | - do_action( 'lasso_post_saved', $postid, $content, get_current_user_ID() ); |
|
42 | + do_action('lasso_post_saved', $postid, $content, get_current_user_ID()); |
|
43 | 43 | |
44 | 44 | return true; |
45 | 45 | |
@@ -54,25 +54,25 @@ discard block |
||
54 | 54 | * |
55 | 55 | * @return bool Always returns true. |
56 | 56 | */ |
57 | - public function publish_content( $data ) { |
|
57 | + public function publish_content($data) { |
|
58 | 58 | $save_to_post_disabled = $this->save_to_post_disables(); |
59 | 59 | |
60 | - $postid = (int) $data[ 'post_id' ]; |
|
61 | - $content = $this->replace_rendered_shortcodes( $data[ 'content' ] ); |
|
62 | - $content = $this->remove_comments( $content ); |
|
60 | + $postid = (int) $data['post_id']; |
|
61 | + $content = $this->replace_rendered_shortcodes($data['content']); |
|
62 | + $content = $this->remove_comments($content); |
|
63 | 63 | |
64 | - if ( 'off' == $save_to_post_disabled || empty( $save_to_post_disabled ) ) { |
|
64 | + if ('off' == $save_to_post_disabled || empty($save_to_post_disabled)) { |
|
65 | 65 | |
66 | - $args = array ( |
|
66 | + $args = array( |
|
67 | 67 | 'ID' => $postid, |
68 | 68 | 'post_content' => $content, |
69 | 69 | 'post_status' => 'publish' |
70 | 70 | ); |
71 | - wp_update_post( apply_filters( 'lasso_object_publish_args', $args ) ); |
|
71 | + wp_update_post(apply_filters('lasso_object_publish_args', $args)); |
|
72 | 72 | |
73 | 73 | } |
74 | 74 | |
75 | - do_action( 'lasso_post_published', $postid, $content, get_current_user_ID() ); |
|
75 | + do_action('lasso_post_published', $postid, $content, get_current_user_ID()); |
|
76 | 76 | |
77 | 77 | return true; |
78 | 78 | |
@@ -85,13 +85,13 @@ discard block |
||
85 | 85 | * |
86 | 86 | * @return array Array of keys to pull from $_POST per action and their sanitization callback |
87 | 87 | */ |
88 | - public static function params(){ |
|
89 | - $params[ 'process_save_content' ] = array( |
|
88 | + public static function params() { |
|
89 | + $params['process_save_content'] = array( |
|
90 | 90 | 'post_id' => 'absint', |
91 | 91 | 'content' => 'wp_kses_post' |
92 | 92 | ); |
93 | 93 | |
94 | - $params[ 'process_save_publish_content' ] = array( |
|
94 | + $params['process_save_publish_content'] = array( |
|
95 | 95 | 'post_id' => 'absint', |
96 | 96 | 'content' => 'wp_kses_post' |
97 | 97 | ); |
@@ -107,11 +107,11 @@ discard block |
||
107 | 107 | * @return array Array of additional functions to use to authorize action. |
108 | 108 | */ |
109 | 109 | public static function auth_callbacks() { |
110 | - $params[ 'process_save_content' ] = array( |
|
110 | + $params['process_save_content'] = array( |
|
111 | 111 | 'lasso_user_can' |
112 | 112 | ); |
113 | 113 | |
114 | - $params[ 'process_save_publish_content' ] = array(); |
|
114 | + $params['process_save_publish_content'] = array(); |
|
115 | 115 | |
116 | 116 | return $params; |
117 | 117 | |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | * @return bool |
128 | 128 | */ |
129 | 129 | protected function save_to_post_disables() { |
130 | - $save_to_post_disabled = lasso_editor_get_option( 'post_save_disabled', 'lasso_editor' ); |
|
130 | + $save_to_post_disabled = lasso_editor_get_option('post_save_disabled', 'lasso_editor'); |
|
131 | 131 | |
132 | 132 | return $save_to_post_disabled; |
133 | 133 | |
@@ -144,15 +144,15 @@ discard block |
||
144 | 144 | * |
145 | 145 | * @return string |
146 | 146 | */ |
147 | - protected function replace_rendered_shortcodes( $content ) { |
|
147 | + protected function replace_rendered_shortcodes($content) { |
|
148 | 148 | //debug line |
149 | 149 | //file_put_contents(WP_PLUGIN_DIR."/file1.txt", $content); |
150 | 150 | |
151 | 151 | |
152 | - if ( false === strpos( $content, '--EDITUS_OTHER_SHORTCODE_START|' ) ) { |
|
152 | + if (false === strpos($content, '--EDITUS_OTHER_SHORTCODE_START|')) { |
|
153 | 153 | return $content; |
154 | 154 | } |
155 | - $content = htmlspecialchars_decode ($content); |
|
155 | + $content = htmlspecialchars_decode($content); |
|
156 | 156 | |
157 | 157 | $content = preg_replace( |
158 | 158 | '/<!--EDITUS_OTHER_SHORTCODE_START\|\[(.*?)\]-->(.*?)<!--EDITUS_OTHER_SHORTCODE_END-->/s', |
@@ -1,28 +1,28 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if ( !function_exists( 'lasso_backbone_templates' ) ): |
|
3 | +if (!function_exists('lasso_backbone_templates')): |
|
4 | 4 | |
5 | 5 | add_action('wp_footer', 'lasso_backbone_templates'); |
6 | - function lasso_backbone_templates(){ |
|
6 | + function lasso_backbone_templates() { |
|
7 | 7 | |
8 | 8 | $can_delete = lasso_user_can('delete_posts'); |
9 | 9 | $can_delete_class = $can_delete ? false : 'no-delete'; |
10 | 10 | |
11 | 11 | |
12 | 12 | // only run on posts and pages if user is logged in |
13 | - if ( is_user_logged_in() && lasso_user_can('edit_posts') ) { |
|
14 | - if ( !class_exists( 'WP_REST_Controller' ) ) { |
|
13 | + if (is_user_logged_in() && lasso_user_can('edit_posts')) { |
|
14 | + if (!class_exists('WP_REST_Controller')) { |
|
15 | 15 | // using rest api v1 |
16 | 16 | ?> |
17 | 17 | <script type="text/html" id="lasso-tmpl--post"> |
18 | 18 | <li> |
19 | - <a href="<%= post.link %>" class="lasso--post-list__item <?php echo $can_delete_class;?> <%= post.status %>" data-postid="<%= post.ID %>" > |
|
19 | + <a href="<%= post.link %>" class="lasso--post-list__item <?php echo $can_delete_class; ?> <%= post.status %>" data-postid="<%= post.ID %>" > |
|
20 | 20 | <%= post.title %> |
21 | 21 | |
22 | 22 | <div class="lasso--post-list__controls"> |
23 | - <span title="<?php echo esc_attr_e('Edit Post','lasso');?>" id="lasso--post__edit"></span> |
|
24 | - <?php if( $can_delete ): ?> |
|
25 | - <span title="<?php echo esc_attr_e('Delete Post','lasso');?>" id="lasso--post__delete"></span> |
|
23 | + <span title="<?php echo esc_attr_e('Edit Post', 'lasso'); ?>" id="lasso--post__edit"></span> |
|
24 | + <?php if ($can_delete): ?> |
|
25 | + <span title="<?php echo esc_attr_e('Delete Post', 'lasso'); ?>" id="lasso--post__delete"></span> |
|
26 | 26 | <?php endif; ?> |
27 | 27 | </div> |
28 | 28 | </a> |
@@ -34,13 +34,13 @@ discard block |
||
34 | 34 | ?> |
35 | 35 | <script type="text/html" id="lasso-tmpl--post"> |
36 | 36 | <li> |
37 | - <a href="<%= post.link %>" class="lasso--post-list__item <?php echo $can_delete_class;?> <%= post.status %>" data-postid="<%= post.id %>" > |
|
37 | + <a href="<%= post.link %>" class="lasso--post-list__item <?php echo $can_delete_class; ?> <%= post.status %>" data-postid="<%= post.id %>" > |
|
38 | 38 | <%= post.title.rendered %> |
39 | 39 | |
40 | 40 | <div class="lasso--post-list__controls"> |
41 | - <span title="<?php echo esc_attr_e('Edit Post','lasso');?>" id="lasso--post__edit"></span> |
|
42 | - <?php if( $can_delete ): ?> |
|
43 | - <span title="<?php echo esc_attr_e('Delete Post','lasso');?>" id="lasso--post__delete"></span> |
|
41 | + <span title="<?php echo esc_attr_e('Edit Post', 'lasso'); ?>" id="lasso--post__edit"></span> |
|
42 | + <?php if ($can_delete): ?> |
|
43 | + <span title="<?php echo esc_attr_e('Delete Post', 'lasso'); ?>" id="lasso--post__delete"></span> |
|
44 | 44 | <?php endif; ?> |
45 | 45 | </div> |
46 | 46 | </a> |
@@ -6,8 +6,8 @@ discard block |
||
6 | 6 | |
7 | 7 | |
8 | 8 | |
9 | -if ( lasso_user_can( 'edit_posts' ) && ! is_admin() ) { |
|
10 | - add_filter( 'the_content', 'lasso_wrap_shortcodes', 9 ); |
|
9 | +if (lasso_user_can('edit_posts') && !is_admin()) { |
|
10 | + add_filter('the_content', 'lasso_wrap_shortcodes', 9); |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | /** |
@@ -20,33 +20,33 @@ discard block |
||
20 | 20 | * |
21 | 21 | * @return string |
22 | 22 | */ |
23 | -function lasso_wrap_shortcodes( $content ) { |
|
23 | +function lasso_wrap_shortcodes($content) { |
|
24 | 24 | global $shortcode_tags; |
25 | 25 | |
26 | - if ( false === strpos( $content, '[' ) ) { |
|
26 | + if (false === strpos($content, '[')) { |
|
27 | 27 | return $content; |
28 | 28 | } |
29 | 29 | |
30 | - if ( empty( $shortcode_tags ) || ! is_array( $shortcode_tags ) ) { |
|
30 | + if (empty($shortcode_tags) || !is_array($shortcode_tags)) { |
|
31 | 31 | return $content; |
32 | 32 | } |
33 | 33 | |
34 | - $tagnames = array_keys( $shortcode_tags ); |
|
35 | - $tagregexp = join( '|', array_map( 'preg_quote', $tagnames ) ); |
|
34 | + $tagnames = array_keys($shortcode_tags); |
|
35 | + $tagregexp = join('|', array_map('preg_quote', $tagnames)); |
|
36 | 36 | $pattern = "/\\[($tagregexp)/s"; |
37 | 37 | |
38 | - if ( 0 === preg_match( $pattern, $content ) ) { |
|
38 | + if (0 === preg_match($pattern, $content)) { |
|
39 | 39 | // Avoids parsing HTML when there are no shortcodes or embeds anyway. |
40 | 40 | return $content; |
41 | 41 | } |
42 | 42 | |
43 | - $content = do_shortcodes_in_html_tags( $content, true ,$tagnames); |
|
43 | + $content = do_shortcodes_in_html_tags($content, true, $tagnames); |
|
44 | 44 | |
45 | 45 | $pattern = get_shortcode_regex(); |
46 | - $content = preg_replace_callback( "/$pattern/s", 'lasso_wrap_shortcode_tag', $content ); |
|
46 | + $content = preg_replace_callback("/$pattern/s", 'lasso_wrap_shortcode_tag', $content); |
|
47 | 47 | |
48 | 48 | // Always restore square braces so we don't break things like <!--[if IE ]> |
49 | - $content = unescape_invalid_shortcodes( $content ); |
|
49 | + $content = unescape_invalid_shortcodes($content); |
|
50 | 50 | |
51 | 51 | return $content; |
52 | 52 | } |
@@ -60,33 +60,33 @@ discard block |
||
60 | 60 | * |
61 | 61 | * @return string |
62 | 62 | */ |
63 | -function lasso_wrap_shortcode_tag( $m ) { |
|
63 | +function lasso_wrap_shortcode_tag($m) { |
|
64 | 64 | // allow [[foo]] syntax for escaping a tag |
65 | - if ( $m[1] == '[' && $m[6] == ']' ) { |
|
66 | - return substr( $m[0], 1, - 1 ); |
|
65 | + if ($m[1] == '[' && $m[6] == ']') { |
|
66 | + return substr($m[0], 1, - 1); |
|
67 | 67 | } |
68 | - $exception_arr1 = array('aesop_gallery_pop','aesop_character_carousel'); |
|
69 | - $exception_arr2 = array('su_box', 'su_note', 'su_document', 'su_spoiler','av_textblock','av_toggle_container','av_toggle'); |
|
70 | - $exception_arr2 = apply_filters('lasso_wrap_shortcode_exceptions',$exception_arr2); |
|
68 | + $exception_arr1 = array('aesop_gallery_pop', 'aesop_character_carousel'); |
|
69 | + $exception_arr2 = array('su_box', 'su_note', 'su_document', 'su_spoiler', 'av_textblock', 'av_toggle_container', 'av_toggle'); |
|
70 | + $exception_arr2 = apply_filters('lasso_wrap_shortcode_exceptions', $exception_arr2); |
|
71 | 71 | |
72 | - if ( strpos( $m[2],'aesop_' ) === 0 ) { |
|
72 | + if (strpos($m[2], 'aesop_') === 0) { |
|
73 | 73 | // check against the exceptions |
74 | - if (strpos_arr($m[2],$exception_arr1)===false) { |
|
74 | + if (strpos_arr($m[2], $exception_arr1) === false) { |
|
75 | 75 | return $m[0]; |
76 | 76 | } |
77 | 77 | } |
78 | - if (strpos_arr($m[2],$exception_arr2)!==false) { |
|
78 | + if (strpos_arr($m[2], $exception_arr2) !== false) { |
|
79 | 79 | return $m[0]; |
80 | 80 | } |
81 | 81 | |
82 | - return '<!--EDITUS_OTHER_SHORTCODE_START|[' . $m[0] . ']-->' . $m[0] . '<!--EDITUS_OTHER_SHORTCODE_END-->'; |
|
82 | + return '<!--EDITUS_OTHER_SHORTCODE_START|['.$m[0].']-->'.$m[0].'<!--EDITUS_OTHER_SHORTCODE_END-->'; |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /* a helper function */ |
86 | 86 | function strpos_arr($haystack, $needle) { |
87 | - if(!is_array($needle)) $needle = array($needle); |
|
88 | - foreach($needle as $what) { |
|
89 | - if(($pos = strpos($haystack, $what))!==false) return $pos; |
|
87 | + if (!is_array($needle)) $needle = array($needle); |
|
88 | + foreach ($needle as $what) { |
|
89 | + if (($pos = strpos($haystack, $what)) !== false) return $pos; |
|
90 | 90 | } |
91 | 91 | return false; |
92 | 92 | } |
93 | 93 | \ No newline at end of file |