@@ -1,19 +1,19 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Plugin installation and activation for WordPress themes. |
|
| 4 | - * |
|
| 5 | - * Please note that this is a drop-in library for a theme or plugin. |
|
| 6 | - * The authors of this library (Thomas, Gary and Juliette) are NOT responsible |
|
| 7 | - * for the support of your plugin or theme. Please contact the plugin |
|
| 8 | - * or theme author for support. |
|
| 9 | - * |
|
| 10 | - * @package TGM-Plugin-Activation |
|
| 11 | - * @version 2.5.2 |
|
| 12 | - * @link http://tgmpluginactivation.com/ |
|
| 13 | - * @author Thomas Griffin, Gary Jones, Juliette Reinders Folmer |
|
| 14 | - * @copyright Copyright (c) 2011, Thomas Griffin |
|
| 15 | - * @license GPL-2.0+ |
|
| 16 | - */ |
|
| 3 | + * Plugin installation and activation for WordPress themes. |
|
| 4 | + * |
|
| 5 | + * Please note that this is a drop-in library for a theme or plugin. |
|
| 6 | + * The authors of this library (Thomas, Gary and Juliette) are NOT responsible |
|
| 7 | + * for the support of your plugin or theme. Please contact the plugin |
|
| 8 | + * or theme author for support. |
|
| 9 | + * |
|
| 10 | + * @package TGM-Plugin-Activation |
|
| 11 | + * @version 2.5.2 |
|
| 12 | + * @link http://tgmpluginactivation.com/ |
|
| 13 | + * @author Thomas Griffin, Gary Jones, Juliette Reinders Folmer |
|
| 14 | + * @copyright Copyright (c) 2011, Thomas Griffin |
|
| 15 | + * @license GPL-2.0+ |
|
| 16 | + */ |
|
| 17 | 17 | |
| 18 | 18 | /* |
| 19 | 19 | Copyright 2011 Thomas Griffin (thomasgriffinmedia.com) |
@@ -1342,13 +1342,13 @@ discard block |
||
| 1342 | 1342 | $key = preg_replace( '`[^A-Za-z0-9_-]`', '', $key ); |
| 1343 | 1343 | |
| 1344 | 1344 | /** |
| 1345 | - * Filter a sanitized key string. |
|
| 1346 | - * |
|
| 1347 | - * @since 3.0.0 |
|
| 1348 | - * |
|
| 1349 | - * @param string $key Sanitized key. |
|
| 1350 | - * @param string $raw_key The key prior to sanitization. |
|
| 1351 | - */ |
|
| 1345 | + * Filter a sanitized key string. |
|
| 1346 | + * |
|
| 1347 | + * @since 3.0.0 |
|
| 1348 | + * |
|
| 1349 | + * @param string $key Sanitized key. |
|
| 1350 | + * @param string $raw_key The key prior to sanitization. |
|
| 1351 | + */ |
|
| 1352 | 1352 | return apply_filters( 'tgmpa_sanitize_key', $key, $raw_key ); |
| 1353 | 1353 | } |
| 1354 | 1354 | |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | */ |
| 256 | 256 | public function __construct() { |
| 257 | 257 | // Set the current WordPress version. |
| 258 | - $this->wp_version = $GLOBALS['wp_version']; |
|
| 258 | + $this->wp_version = $GLOBALS[ 'wp_version' ]; |
|
| 259 | 259 | |
| 260 | 260 | // Announce that the class is ready, and pass the object (for advanced use). |
| 261 | 261 | do_action_ref_array( 'tgmpa_init', array( $this ) ); |
@@ -441,15 +441,15 @@ discard block |
||
| 441 | 441 | public function add_plugin_action_link_filters() { |
| 442 | 442 | foreach ( $this->plugins as $slug => $plugin ) { |
| 443 | 443 | if ( false === $this->can_plugin_activate( $slug ) ) { |
| 444 | - add_filter( 'plugin_action_links_' . $plugin['file_path'], array( $this, 'filter_plugin_action_links_activate' ), 20 ); |
|
| 444 | + add_filter( 'plugin_action_links_'.$plugin[ 'file_path' ], array( $this, 'filter_plugin_action_links_activate' ), 20 ); |
|
| 445 | 445 | } |
| 446 | 446 | |
| 447 | - if ( true === $plugin['force_activation'] ) { |
|
| 448 | - add_filter( 'plugin_action_links_' . $plugin['file_path'], array( $this, 'filter_plugin_action_links_deactivate' ), 20 ); |
|
| 447 | + if ( true === $plugin[ 'force_activation' ] ) { |
|
| 448 | + add_filter( 'plugin_action_links_'.$plugin[ 'file_path' ], array( $this, 'filter_plugin_action_links_deactivate' ), 20 ); |
|
| 449 | 449 | } |
| 450 | 450 | |
| 451 | 451 | if ( false !== $this->does_plugin_require_update( $slug ) ) { |
| 452 | - add_filter( 'plugin_action_links_' . $plugin['file_path'], array( $this, 'filter_plugin_action_links_update' ), 20 ); |
|
| 452 | + add_filter( 'plugin_action_links_'.$plugin[ 'file_path' ], array( $this, 'filter_plugin_action_links_update' ), 20 ); |
|
| 453 | 453 | } |
| 454 | 454 | } |
| 455 | 455 | } |
@@ -464,7 +464,7 @@ discard block |
||
| 464 | 464 | * @return array |
| 465 | 465 | */ |
| 466 | 466 | public function filter_plugin_action_links_activate( $actions ) { |
| 467 | - unset( $actions['activate'] ); |
|
| 467 | + unset( $actions[ 'activate' ] ); |
|
| 468 | 468 | |
| 469 | 469 | return $actions; |
| 470 | 470 | } |
@@ -478,7 +478,7 @@ discard block |
||
| 478 | 478 | * @return array |
| 479 | 479 | */ |
| 480 | 480 | public function filter_plugin_action_links_deactivate( $actions ) { |
| 481 | - unset( $actions['deactivate'] ); |
|
| 481 | + unset( $actions[ 'deactivate' ] ); |
|
| 482 | 482 | |
| 483 | 483 | return $actions; |
| 484 | 484 | } |
@@ -493,7 +493,7 @@ discard block |
||
| 493 | 493 | * @return array |
| 494 | 494 | */ |
| 495 | 495 | public function filter_plugin_action_links_update( $actions ) { |
| 496 | - $actions['update'] = sprintf( |
|
| 496 | + $actions[ 'update' ] = sprintf( |
|
| 497 | 497 | '<a href="%1$s" title="%2$s" class="edit">%3$s</a>', |
| 498 | 498 | esc_url( $this->get_tgmpa_status_url( 'update' ) ), |
| 499 | 499 | esc_attr__( 'This plugin needs to be updated to be compatible with your theme.', 'tgmpa' ), |
@@ -531,9 +531,9 @@ discard block |
||
| 531 | 531 | return; |
| 532 | 532 | } |
| 533 | 533 | |
| 534 | - if ( isset( $_REQUEST['tab'] ) && 'plugin-information' === $_REQUEST['tab'] ) { |
|
| 534 | + if ( isset( $_REQUEST[ 'tab' ] ) && 'plugin-information' === $_REQUEST[ 'tab' ] ) { |
|
| 535 | 535 | // Needed for install_plugin_information(). |
| 536 | - require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; |
|
| 536 | + require_once ABSPATH.'wp-admin/includes/plugin-install.php'; |
|
| 537 | 537 | |
| 538 | 538 | wp_enqueue_style( 'plugin-install' ); |
| 539 | 539 | |
@@ -561,7 +561,7 @@ discard block |
||
| 561 | 561 | * @since 2.1.0 |
| 562 | 562 | */ |
| 563 | 563 | public function thickbox() { |
| 564 | - if ( ! get_user_meta( get_current_user_id(), 'tgmpa_dismissed_notice_' . $this->id, true ) ) { |
|
| 564 | + if ( ! get_user_meta( get_current_user_id(), 'tgmpa_dismissed_notice_'.$this->id, true ) ) { |
|
| 565 | 565 | add_thickbox(); |
| 566 | 566 | } |
| 567 | 567 | } |
@@ -590,11 +590,11 @@ discard block |
||
| 590 | 590 | $args = apply_filters( |
| 591 | 591 | 'tgmpa_admin_menu_args', |
| 592 | 592 | array( |
| 593 | - 'parent_slug' => $this->parent_slug, // Parent Menu slug. |
|
| 594 | - 'page_title' => $this->strings['page_title'], // Page title. |
|
| 595 | - 'menu_title' => $this->strings['menu_title'], // Menu title. |
|
| 596 | - 'capability' => $this->capability, // Capability. |
|
| 597 | - 'menu_slug' => $this->menu, // Menu slug. |
|
| 593 | + 'parent_slug' => $this->parent_slug, // Parent Menu slug. |
|
| 594 | + 'page_title' => $this->strings[ 'page_title' ], // Page title. |
|
| 595 | + 'menu_title' => $this->strings[ 'menu_title' ], // Menu title. |
|
| 596 | + 'capability' => $this->capability, // Capability. |
|
| 597 | + 'menu_slug' => $this->menu, // Menu slug. |
|
| 598 | 598 | 'function' => array( $this, 'install_plugins_page' ), // Callback. |
| 599 | 599 | ) |
| 600 | 600 | ); |
@@ -615,10 +615,10 @@ discard block |
||
| 615 | 615 | } |
| 616 | 616 | |
| 617 | 617 | if ( 'themes.php' === $this->parent_slug ) { |
| 618 | - $this->page_hook = call_user_func( 'add_theme_page', $args['page_title'], $args['menu_title'], $args['capability'], $args['menu_slug'], $args['function'] ); |
|
| 618 | + $this->page_hook = call_user_func( 'add_theme_page', $args[ 'page_title' ], $args[ 'menu_title' ], $args[ 'capability' ], $args[ 'menu_slug' ], $args[ 'function' ] ); |
|
| 619 | 619 | } else { |
| 620 | 620 | $type = 'submenu'; |
| 621 | - $this->page_hook = call_user_func( "add_{$type}_page", $args['parent_slug'], $args['page_title'], $args['menu_title'], $args['capability'], $args['menu_slug'], $args['function'] ); |
|
| 621 | + $this->page_hook = call_user_func( "add_{$type}_page", $args[ 'parent_slug' ], $args[ 'page_title' ], $args[ 'menu_title' ], $args[ 'capability' ], $args[ 'menu_slug' ], $args[ 'function' ] ); |
|
| 622 | 622 | } |
| 623 | 623 | } |
| 624 | 624 | |
@@ -687,37 +687,37 @@ discard block |
||
| 687 | 687 | * @return boolean True on success, false on failure. |
| 688 | 688 | */ |
| 689 | 689 | protected function do_plugin_install() { |
| 690 | - if ( empty( $_GET['plugin'] ) ) { |
|
| 690 | + if ( empty( $_GET[ 'plugin' ] ) ) { |
|
| 691 | 691 | return false; |
| 692 | 692 | } |
| 693 | 693 | |
| 694 | 694 | // All plugin information will be stored in an array for processing. |
| 695 | - $slug = $this->sanitize_key( urldecode( $_GET['plugin'] ) ); |
|
| 695 | + $slug = $this->sanitize_key( urldecode( $_GET[ 'plugin' ] ) ); |
|
| 696 | 696 | |
| 697 | 697 | if ( ! isset( $this->plugins[ $slug ] ) ) { |
| 698 | 698 | return false; |
| 699 | 699 | } |
| 700 | 700 | |
| 701 | 701 | // Was an install or upgrade action link clicked? |
| 702 | - if ( ( isset( $_GET['tgmpa-install'] ) && 'install-plugin' === $_GET['tgmpa-install'] ) || ( isset( $_GET['tgmpa-update'] ) && 'update-plugin' === $_GET['tgmpa-update'] ) ) { |
|
| 702 | + if ( ( isset( $_GET[ 'tgmpa-install' ] ) && 'install-plugin' === $_GET[ 'tgmpa-install' ] ) || ( isset( $_GET[ 'tgmpa-update' ] ) && 'update-plugin' === $_GET[ 'tgmpa-update' ] ) ) { |
|
| 703 | 703 | |
| 704 | 704 | $install_type = 'install'; |
| 705 | - if ( isset( $_GET['tgmpa-update'] ) && 'update-plugin' === $_GET['tgmpa-update'] ) { |
|
| 705 | + if ( isset( $_GET[ 'tgmpa-update' ] ) && 'update-plugin' === $_GET[ 'tgmpa-update' ] ) { |
|
| 706 | 706 | $install_type = 'update'; |
| 707 | 707 | } |
| 708 | 708 | |
| 709 | - check_admin_referer( 'tgmpa-' . $install_type, 'tgmpa-nonce' ); |
|
| 709 | + check_admin_referer( 'tgmpa-'.$install_type, 'tgmpa-nonce' ); |
|
| 710 | 710 | |
| 711 | 711 | // Pass necessary information via URL if WP_Filesystem is needed. |
| 712 | 712 | $url = wp_nonce_url( |
| 713 | 713 | add_query_arg( |
| 714 | 714 | array( |
| 715 | 715 | 'plugin' => urlencode( $slug ), |
| 716 | - 'tgmpa-' . $install_type => $install_type . '-plugin', |
|
| 716 | + 'tgmpa-'.$install_type => $install_type.'-plugin', |
|
| 717 | 717 | ), |
| 718 | 718 | $this->get_tgmpa_url() |
| 719 | 719 | ), |
| 720 | - 'tgmpa-' . $install_type, |
|
| 720 | + 'tgmpa-'.$install_type, |
|
| 721 | 721 | 'tgmpa-nonce' |
| 722 | 722 | ); |
| 723 | 723 | |
@@ -736,35 +736,35 @@ discard block |
||
| 736 | 736 | |
| 737 | 737 | // Prep variables for Plugin_Installer_Skin class. |
| 738 | 738 | $extra = array(); |
| 739 | - $extra['slug'] = $slug; // Needed for potentially renaming of directory name. |
|
| 739 | + $extra[ 'slug' ] = $slug; // Needed for potentially renaming of directory name. |
|
| 740 | 740 | $source = $this->get_download_url( $slug ); |
| 741 | - $api = ( 'repo' === $this->plugins[ $slug ]['source_type'] ) ? $this->get_plugins_api( $slug ) : null; |
|
| 741 | + $api = ( 'repo' === $this->plugins[ $slug ][ 'source_type' ] ) ? $this->get_plugins_api( $slug ) : null; |
|
| 742 | 742 | $api = ( false !== $api ) ? $api : null; |
| 743 | 743 | |
| 744 | 744 | $url = add_query_arg( |
| 745 | 745 | array( |
| 746 | - 'action' => $install_type . '-plugin', |
|
| 746 | + 'action' => $install_type.'-plugin', |
|
| 747 | 747 | 'plugin' => urlencode( $slug ), |
| 748 | 748 | ), |
| 749 | 749 | 'update.php' |
| 750 | 750 | ); |
| 751 | 751 | |
| 752 | 752 | if ( ! class_exists( 'Plugin_Upgrader', false ) ) { |
| 753 | - require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
|
| 753 | + require_once ABSPATH.'wp-admin/includes/class-wp-upgrader.php'; |
|
| 754 | 754 | } |
| 755 | 755 | |
| 756 | 756 | $skin_args = array( |
| 757 | - 'type' => ( 'bundled' !== $this->plugins[ $slug ]['source_type'] ) ? 'web' : 'upload', |
|
| 758 | - 'title' => sprintf( $this->strings['installing'], $this->plugins[ $slug ]['name'] ), |
|
| 757 | + 'type' => ( 'bundled' !== $this->plugins[ $slug ][ 'source_type' ] ) ? 'web' : 'upload', |
|
| 758 | + 'title' => sprintf( $this->strings[ 'installing' ], $this->plugins[ $slug ][ 'name' ] ), |
|
| 759 | 759 | 'url' => esc_url_raw( $url ), |
| 760 | - 'nonce' => $install_type . '-plugin_' . $slug, |
|
| 760 | + 'nonce' => $install_type.'-plugin_'.$slug, |
|
| 761 | 761 | 'plugin' => '', |
| 762 | 762 | 'api' => $api, |
| 763 | 763 | 'extra' => $extra, |
| 764 | 764 | ); |
| 765 | 765 | |
| 766 | 766 | if ( 'update' === $install_type ) { |
| 767 | - $skin_args['plugin'] = $this->plugins[ $slug ]['file_path']; |
|
| 767 | + $skin_args[ 'plugin' ] = $this->plugins[ $slug ][ 'file_path' ]; |
|
| 768 | 768 | $skin = new Plugin_Upgrader_Skin( $skin_args ); |
| 769 | 769 | } else { |
| 770 | 770 | $skin = new Plugin_Installer_Skin( $skin_args ); |
@@ -779,10 +779,10 @@ discard block |
||
| 779 | 779 | if ( 'update' === $install_type ) { |
| 780 | 780 | // Inject our info into the update transient. |
| 781 | 781 | $to_inject = array( $slug => $this->plugins[ $slug ] ); |
| 782 | - $to_inject[ $slug ]['source'] = $source; |
|
| 782 | + $to_inject[ $slug ][ 'source' ] = $source; |
|
| 783 | 783 | $this->inject_update_info( $to_inject ); |
| 784 | 784 | |
| 785 | - $upgrader->upgrade( $this->plugins[ $slug ]['file_path'] ); |
|
| 785 | + $upgrader->upgrade( $this->plugins[ $slug ][ 'file_path' ] ); |
|
| 786 | 786 | } else { |
| 787 | 787 | $upgrader->install( $source ); |
| 788 | 788 | } |
@@ -805,18 +805,18 @@ discard block |
||
| 805 | 805 | |
| 806 | 806 | // Display message based on if all plugins are now active or not. |
| 807 | 807 | if ( $this->is_tgmpa_complete() ) { |
| 808 | - echo '<p>', sprintf( esc_html( $this->strings['complete'] ), '<a href="' . esc_url( self_admin_url() ) . '">' . esc_html__( 'Return to the Dashboard', 'tgmpa' ) . '</a>' ), '</p>'; |
|
| 808 | + echo '<p>', sprintf( esc_html( $this->strings[ 'complete' ] ), '<a href="'.esc_url( self_admin_url() ).'">'.esc_html__( 'Return to the Dashboard', 'tgmpa' ).'</a>' ), '</p>'; |
|
| 809 | 809 | echo '<style type="text/css">#adminmenu .wp-submenu li.current { display: none !important; }</style>'; |
| 810 | 810 | } else { |
| 811 | - echo '<p><a href="', esc_url( $this->get_tgmpa_url() ), '" target="_parent">', esc_html( $this->strings['return'] ), '</a></p>'; |
|
| 811 | + echo '<p><a href="', esc_url( $this->get_tgmpa_url() ), '" target="_parent">', esc_html( $this->strings[ 'return' ] ), '</a></p>'; |
|
| 812 | 812 | } |
| 813 | 813 | |
| 814 | 814 | return true; |
| 815 | - } elseif ( isset( $this->plugins[ $slug ]['file_path'], $_GET['tgmpa-activate'] ) && 'activate-plugin' === $_GET['tgmpa-activate'] ) { |
|
| 815 | + } elseif ( isset( $this->plugins[ $slug ][ 'file_path' ], $_GET[ 'tgmpa-activate' ] ) && 'activate-plugin' === $_GET[ 'tgmpa-activate' ] ) { |
|
| 816 | 816 | // Activate action link was clicked. |
| 817 | 817 | check_admin_referer( 'tgmpa-activate', 'tgmpa-nonce' ); |
| 818 | 818 | |
| 819 | - if ( false === $this->activate_single_plugin( $this->plugins[ $slug ]['file_path'], $slug ) ) { |
|
| 819 | + if ( false === $this->activate_single_plugin( $this->plugins[ $slug ][ 'file_path' ], $slug ) ) { |
|
| 820 | 820 | return true; // Finish execution of the function early as we encountered an error. |
| 821 | 821 | } |
| 822 | 822 | } |
@@ -839,7 +839,7 @@ discard block |
||
| 839 | 839 | } |
| 840 | 840 | |
| 841 | 841 | foreach ( $plugins as $slug => $plugin ) { |
| 842 | - $file_path = $plugin['file_path']; |
|
| 842 | + $file_path = $plugin[ 'file_path' ]; |
|
| 843 | 843 | |
| 844 | 844 | if ( empty( $repo_updates->response[ $file_path ] ) ) { |
| 845 | 845 | $repo_updates->response[ $file_path ] = new stdClass; |
@@ -848,10 +848,10 @@ discard block |
||
| 848 | 848 | // We only really need to set package, but let's do all we can in case WP changes something. |
| 849 | 849 | $repo_updates->response[ $file_path ]->slug = $slug; |
| 850 | 850 | $repo_updates->response[ $file_path ]->plugin = $file_path; |
| 851 | - $repo_updates->response[ $file_path ]->new_version = $plugin['version']; |
|
| 852 | - $repo_updates->response[ $file_path ]->package = $plugin['source']; |
|
| 853 | - if ( empty( $repo_updates->response[ $file_path ]->url ) && ! empty( $plugin['external_url'] ) ) { |
|
| 854 | - $repo_updates->response[ $file_path ]->url = $plugin['external_url']; |
|
| 851 | + $repo_updates->response[ $file_path ]->new_version = $plugin[ 'version' ]; |
|
| 852 | + $repo_updates->response[ $file_path ]->package = $plugin[ 'source' ]; |
|
| 853 | + if ( empty( $repo_updates->response[ $file_path ]->url ) && ! empty( $plugin[ 'external_url' ] ) ) { |
|
| 854 | + $repo_updates->response[ $file_path ]->url = $plugin[ 'external_url' ]; |
|
| 855 | 855 | } |
| 856 | 856 | } |
| 857 | 857 | |
@@ -875,13 +875,13 @@ discard block |
||
| 875 | 875 | * @return string $source |
| 876 | 876 | */ |
| 877 | 877 | public function maybe_adjust_source_dir( $source, $remote_source, $upgrader ) { |
| 878 | - if ( ! $this->is_tgmpa_page() || ! is_object( $GLOBALS['wp_filesystem'] ) ) { |
|
| 878 | + if ( ! $this->is_tgmpa_page() || ! is_object( $GLOBALS[ 'wp_filesystem' ] ) ) { |
|
| 879 | 879 | return $source; |
| 880 | 880 | } |
| 881 | 881 | |
| 882 | 882 | // Check for single file plugins. |
| 883 | - $source_files = array_keys( $GLOBALS['wp_filesystem']->dirlist( $remote_source ) ); |
|
| 884 | - if ( 1 === count( $source_files ) && false === $GLOBALS['wp_filesystem']->is_dir( $source ) ) { |
|
| 883 | + $source_files = array_keys( $GLOBALS[ 'wp_filesystem' ]->dirlist( $remote_source ) ); |
|
| 884 | + if ( 1 === count( $source_files ) && false === $GLOBALS[ 'wp_filesystem' ]->is_dir( $source ) ) { |
|
| 885 | 885 | return $source; |
| 886 | 886 | } |
| 887 | 887 | |
@@ -889,12 +889,12 @@ discard block |
||
| 889 | 889 | $desired_slug = ''; |
| 890 | 890 | |
| 891 | 891 | // Figure out what the slug is supposed to be. |
| 892 | - if ( false === $upgrader->bulk && ! empty( $upgrader->skin->options['extra']['slug'] ) ) { |
|
| 893 | - $desired_slug = $upgrader->skin->options['extra']['slug']; |
|
| 892 | + if ( false === $upgrader->bulk && ! empty( $upgrader->skin->options[ 'extra' ][ 'slug' ] ) ) { |
|
| 893 | + $desired_slug = $upgrader->skin->options[ 'extra' ][ 'slug' ]; |
|
| 894 | 894 | } else { |
| 895 | 895 | // Bulk installer contains less info, so fall back on the info registered here. |
| 896 | 896 | foreach ( $this->plugins as $slug => $plugin ) { |
| 897 | - if ( ! empty( $upgrader->skin->plugin_names[ $upgrader->skin->i ] ) && $plugin['name'] === $upgrader->skin->plugin_names[ $upgrader->skin->i ] ) { |
|
| 897 | + if ( ! empty( $upgrader->skin->plugin_names[ $upgrader->skin->i ] ) && $plugin[ 'name' ] === $upgrader->skin->plugin_names[ $upgrader->skin->i ] ) { |
|
| 898 | 898 | $desired_slug = $slug; |
| 899 | 899 | break; |
| 900 | 900 | } |
@@ -907,15 +907,15 @@ discard block |
||
| 907 | 907 | |
| 908 | 908 | if ( ! empty( $subdir_name ) && $subdir_name !== $desired_slug ) { |
| 909 | 909 | $from = untrailingslashit( $source ); |
| 910 | - $to = trailingslashit( $remote_source ) . $desired_slug; |
|
| 910 | + $to = trailingslashit( $remote_source ).$desired_slug; |
|
| 911 | 911 | |
| 912 | - if ( true === $GLOBALS['wp_filesystem']->move( $from, $to ) ) { |
|
| 912 | + if ( true === $GLOBALS[ 'wp_filesystem' ]->move( $from, $to ) ) { |
|
| 913 | 913 | return trailingslashit( $to ); |
| 914 | 914 | } else { |
| 915 | - 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 ) ); |
|
| 915 | + 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 ) ); |
|
| 916 | 916 | } |
| 917 | 917 | } elseif ( empty( $subdir_name ) ) { |
| 918 | - 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 ) ); |
|
| 918 | + 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 ) ); |
|
| 919 | 919 | } |
| 920 | 920 | } |
| 921 | 921 | |
@@ -939,19 +939,19 @@ discard block |
||
| 939 | 939 | |
| 940 | 940 | if ( is_wp_error( $activate ) ) { |
| 941 | 941 | echo '<div id="message" class="error"><p>', wp_kses_post( $activate->get_error_message() ), '</p></div>', |
| 942 | - '<p><a href="', esc_url( $this->get_tgmpa_url() ), '" target="_parent">', esc_html( $this->strings['return'] ), '</a></p>'; |
|
| 942 | + '<p><a href="', esc_url( $this->get_tgmpa_url() ), '" target="_parent">', esc_html( $this->strings[ 'return' ] ), '</a></p>'; |
|
| 943 | 943 | |
| 944 | 944 | return false; // End it here if there is an error with activation. |
| 945 | 945 | } else { |
| 946 | 946 | if ( ! $automatic ) { |
| 947 | 947 | // Make sure message doesn't display again if bulk activation is performed |
| 948 | 948 | // immediately after a single activation. |
| 949 | - if ( ! isset( $_POST['action'] ) ) { // WPCS: CSRF OK. |
|
| 950 | - echo '<div id="message" class="updated"><p>', esc_html( $this->strings['activated_successfully'] ), ' <strong>', esc_html( $this->plugins[ $slug ]['name'] ), '.</strong></p></div>'; |
|
| 949 | + if ( ! isset( $_POST[ 'action' ] ) ) { // WPCS: CSRF OK. |
|
| 950 | + echo '<div id="message" class="updated"><p>', esc_html( $this->strings[ 'activated_successfully' ] ), ' <strong>', esc_html( $this->plugins[ $slug ][ 'name' ] ), '.</strong></p></div>'; |
|
| 951 | 951 | } |
| 952 | 952 | } else { |
| 953 | 953 | // Simpler message layout for use on the plugin install page. |
| 954 | - echo '<p>', esc_html( $this->strings['plugin_activated'] ), '</p>'; |
|
| 954 | + echo '<p>', esc_html( $this->strings[ 'plugin_activated' ] ), '</p>'; |
|
| 955 | 955 | } |
| 956 | 956 | } |
| 957 | 957 | } elseif ( $this->is_plugin_active( $slug ) ) { |
@@ -959,25 +959,25 @@ discard block |
||
| 959 | 959 | // on the plugin install page. |
| 960 | 960 | echo '<div id="message" class="error"><p>', |
| 961 | 961 | sprintf( |
| 962 | - esc_html( $this->strings['plugin_already_active'] ), |
|
| 963 | - '<strong>' . esc_html( $this->plugins[ $slug ]['name'] ) . '</strong>' |
|
| 962 | + esc_html( $this->strings[ 'plugin_already_active' ] ), |
|
| 963 | + '<strong>'.esc_html( $this->plugins[ $slug ][ 'name' ] ).'</strong>' |
|
| 964 | 964 | ), |
| 965 | 965 | '</p></div>'; |
| 966 | 966 | } elseif ( $this->does_plugin_require_update( $slug ) ) { |
| 967 | 967 | if ( ! $automatic ) { |
| 968 | 968 | // Make sure message doesn't display again if bulk activation is performed |
| 969 | 969 | // immediately after a single activation. |
| 970 | - if ( ! isset( $_POST['action'] ) ) { // WPCS: CSRF OK. |
|
| 970 | + if ( ! isset( $_POST[ 'action' ] ) ) { // WPCS: CSRF OK. |
|
| 971 | 971 | echo '<div id="message" class="error"><p>', |
| 972 | 972 | sprintf( |
| 973 | - esc_html( $this->strings['plugin_needs_higher_version'] ), |
|
| 974 | - '<strong>' . esc_html( $this->plugins[ $slug ]['name'] ) . '</strong>' |
|
| 973 | + esc_html( $this->strings[ 'plugin_needs_higher_version' ] ), |
|
| 974 | + '<strong>'.esc_html( $this->plugins[ $slug ][ 'name' ] ).'</strong>' |
|
| 975 | 975 | ), |
| 976 | 976 | '</p></div>'; |
| 977 | 977 | } |
| 978 | 978 | } else { |
| 979 | 979 | // Simpler message layout for use on the plugin install page. |
| 980 | - echo '<p>', sprintf( esc_html( $this->strings['plugin_needs_higher_version'] ), esc_html( $this->plugins[ $slug ]['name'] ) ), '</p>'; |
|
| 980 | + echo '<p>', sprintf( esc_html( $this->strings[ 'plugin_needs_higher_version' ] ), esc_html( $this->plugins[ $slug ][ 'name' ] ) ), '</p>'; |
|
| 981 | 981 | } |
| 982 | 982 | } |
| 983 | 983 | |
@@ -1001,7 +1001,7 @@ discard block |
||
| 1001 | 1001 | */ |
| 1002 | 1002 | public function notices() { |
| 1003 | 1003 | // Remove nag on the install page / Return early if the nag message has been dismissed or user < author. |
| 1004 | - if ( ( $this->is_tgmpa_page() || $this->is_core_update_page() ) || get_user_meta( get_current_user_id(), 'tgmpa_dismissed_notice_' . $this->id, true ) || ! current_user_can( apply_filters( 'tgmpa_show_admin_notice_capability', 'publish_posts' ) ) ) { |
|
| 1004 | + if ( ( $this->is_tgmpa_page() || $this->is_core_update_page() ) || get_user_meta( get_current_user_id(), 'tgmpa_dismissed_notice_'.$this->id, true ) || ! current_user_can( apply_filters( 'tgmpa_show_admin_notice_capability', 'publish_posts' ) ) ) { |
|
| 1005 | 1005 | return; |
| 1006 | 1006 | } |
| 1007 | 1007 | |
@@ -1023,13 +1023,13 @@ discard block |
||
| 1023 | 1023 | if ( current_user_can( 'install_plugins' ) ) { |
| 1024 | 1024 | $install_link_count++; |
| 1025 | 1025 | |
| 1026 | - if ( true === $plugin['required'] ) { |
|
| 1027 | - $message['notice_can_install_required'][] = $slug; |
|
| 1026 | + if ( true === $plugin[ 'required' ] ) { |
|
| 1027 | + $message[ 'notice_can_install_required' ][ ] = $slug; |
|
| 1028 | 1028 | } else { |
| 1029 | - $message['notice_can_install_recommended'][] = $slug; |
|
| 1029 | + $message[ 'notice_can_install_recommended' ][ ] = $slug; |
|
| 1030 | 1030 | } |
| 1031 | 1031 | } |
| 1032 | - if ( true === $plugin['required'] ) { |
|
| 1032 | + if ( true === $plugin[ 'required' ] ) { |
|
| 1033 | 1033 | $total_required_action_count++; |
| 1034 | 1034 | } |
| 1035 | 1035 | } else { |
@@ -1037,13 +1037,13 @@ discard block |
||
| 1037 | 1037 | if ( current_user_can( 'activate_plugins' ) ) { |
| 1038 | 1038 | $activate_link_count++; |
| 1039 | 1039 | |
| 1040 | - if ( true === $plugin['required'] ) { |
|
| 1041 | - $message['notice_can_activate_required'][] = $slug; |
|
| 1040 | + if ( true === $plugin[ 'required' ] ) { |
|
| 1041 | + $message[ 'notice_can_activate_required' ][ ] = $slug; |
|
| 1042 | 1042 | } else { |
| 1043 | - $message['notice_can_activate_recommended'][] = $slug; |
|
| 1043 | + $message[ 'notice_can_activate_recommended' ][ ] = $slug; |
|
| 1044 | 1044 | } |
| 1045 | 1045 | } |
| 1046 | - if ( true === $plugin['required'] ) { |
|
| 1046 | + if ( true === $plugin[ 'required' ] ) { |
|
| 1047 | 1047 | $total_required_action_count++; |
| 1048 | 1048 | } |
| 1049 | 1049 | } |
@@ -1054,12 +1054,12 @@ discard block |
||
| 1054 | 1054 | $update_link_count++; |
| 1055 | 1055 | |
| 1056 | 1056 | if ( $this->does_plugin_require_update( $slug ) ) { |
| 1057 | - $message['notice_ask_to_update'][] = $slug; |
|
| 1057 | + $message[ 'notice_ask_to_update' ][ ] = $slug; |
|
| 1058 | 1058 | } elseif ( false !== $this->does_plugin_have_update( $slug ) ) { |
| 1059 | - $message['notice_ask_to_update_maybe'][] = $slug; |
|
| 1059 | + $message[ 'notice_ask_to_update_maybe' ][ ] = $slug; |
|
| 1060 | 1060 | } |
| 1061 | 1061 | } |
| 1062 | - if ( true === $plugin['required'] ) { |
|
| 1062 | + if ( true === $plugin[ 'required' ] ) { |
|
| 1063 | 1063 | $total_required_action_count++; |
| 1064 | 1064 | } |
| 1065 | 1065 | } |
@@ -1074,10 +1074,10 @@ discard block |
||
| 1074 | 1074 | |
| 1075 | 1075 | // As add_settings_error() wraps the final message in a <p> and as the final message can't be |
| 1076 | 1076 | // filtered, using <p>'s in our html would render invalid html output. |
| 1077 | - $line_template = '<span style="display: block; margin: 0.5em 0.5em 0 0; clear: both;">%s</span>' . "\n"; |
|
| 1077 | + $line_template = '<span style="display: block; margin: 0.5em 0.5em 0 0; clear: both;">%s</span>'."\n"; |
|
| 1078 | 1078 | |
| 1079 | 1079 | if ( ! current_user_can( 'activate_plugins' ) && ! current_user_can( 'install_plugins' ) && ! current_user_can( 'update_plugins' ) ) { |
| 1080 | - $rendered = esc_html__( $this->strings['notice_cannot_install_activate'] . ' ' . $this->strings['contact_admin'] ); |
|
| 1080 | + $rendered = esc_html__( $this->strings[ 'notice_cannot_install_activate' ].' '.$this->strings[ 'contact_admin' ] ); |
|
| 1081 | 1081 | $rendered .= $this->create_user_action_links_for_notice( 0, 0, 0, $line_template ); |
| 1082 | 1082 | } else { |
| 1083 | 1083 | |
@@ -1092,14 +1092,14 @@ discard block |
||
| 1092 | 1092 | |
| 1093 | 1093 | // Get the external info link for a plugin if one is available. |
| 1094 | 1094 | foreach ( $plugin_group as $plugin_slug ) { |
| 1095 | - $linked_plugins[] = $this->get_info_link( $plugin_slug ); |
|
| 1095 | + $linked_plugins[ ] = $this->get_info_link( $plugin_slug ); |
|
| 1096 | 1096 | } |
| 1097 | 1097 | unset( $plugin_slug ); |
| 1098 | 1098 | |
| 1099 | 1099 | $count = count( $plugin_group ); |
| 1100 | 1100 | $linked_plugins = array_map( array( 'TGMPA_Utils', 'wrap_in_em' ), $linked_plugins ); |
| 1101 | 1101 | $last_plugin = array_pop( $linked_plugins ); // Pop off last name to prep for readability. |
| 1102 | - $imploded = empty( $linked_plugins ) ? $last_plugin : ( implode( ', ', $linked_plugins ) . ' ' . esc_html_x( 'and', 'plugin A *and* plugin B', 'tgmpa' ) . ' ' . $last_plugin ); |
|
| 1102 | + $imploded = empty( $linked_plugins ) ? $last_plugin : ( implode( ', ', $linked_plugins ).' '.esc_html_x( 'and', 'plugin A *and* plugin B', 'tgmpa' ).' '.$last_plugin ); |
|
| 1103 | 1103 | |
| 1104 | 1104 | $rendered .= sprintf( |
| 1105 | 1105 | $line_template, |
@@ -1121,7 +1121,7 @@ discard block |
||
| 1121 | 1121 | } |
| 1122 | 1122 | |
| 1123 | 1123 | // Admin options pages already output settings_errors, so this is to avoid duplication. |
| 1124 | - if ( 'options-general' !== $GLOBALS['current_screen']->parent_base ) { |
|
| 1124 | + if ( 'options-general' !== $GLOBALS[ 'current_screen' ]->parent_base ) { |
|
| 1125 | 1125 | $this->display_settings_errors(); |
| 1126 | 1126 | } |
| 1127 | 1127 | } |
@@ -1143,32 +1143,32 @@ discard block |
||
| 1143 | 1143 | 'install' => '', |
| 1144 | 1144 | 'update' => '', |
| 1145 | 1145 | 'activate' => '', |
| 1146 | - 'dismiss' => $this->dismissable ? '<a href="' . esc_url( wp_nonce_url( add_query_arg( 'tgmpa-dismiss', 'dismiss_admin_notices' ), 'tgmpa-dismiss-' . get_current_user_id() ) ) . '" class="dismiss-notice" target="_parent">' . esc_html( $this->strings['dismiss'] ) . '</a>' : '', |
|
| 1146 | + 'dismiss' => $this->dismissable ? '<a href="'.esc_url( wp_nonce_url( add_query_arg( 'tgmpa-dismiss', 'dismiss_admin_notices' ), 'tgmpa-dismiss-'.get_current_user_id() ) ).'" class="dismiss-notice" target="_parent">'.esc_html( $this->strings[ 'dismiss' ] ).'</a>' : '', |
|
| 1147 | 1147 | ); |
| 1148 | 1148 | |
| 1149 | 1149 | $link_template = '<a href="%2$s">%1$s</a>'; |
| 1150 | 1150 | |
| 1151 | 1151 | if ( current_user_can( 'install_plugins' ) ) { |
| 1152 | 1152 | if ( $install_link_count > 0 ) { |
| 1153 | - $action_links['install'] = sprintf( |
|
| 1153 | + $action_links[ 'install' ] = sprintf( |
|
| 1154 | 1154 | $link_template, |
| 1155 | - translate_nooped_plural( $this->strings['install_link'], $install_link_count, 'tgmpa' ), |
|
| 1155 | + translate_nooped_plural( $this->strings[ 'install_link' ], $install_link_count, 'tgmpa' ), |
|
| 1156 | 1156 | esc_url( $this->get_tgmpa_status_url( 'install' ) ) |
| 1157 | 1157 | ); |
| 1158 | 1158 | } |
| 1159 | 1159 | if ( $update_link_count > 0 ) { |
| 1160 | - $action_links['update'] = sprintf( |
|
| 1160 | + $action_links[ 'update' ] = sprintf( |
|
| 1161 | 1161 | $link_template, |
| 1162 | - translate_nooped_plural( $this->strings['update_link'], $update_link_count, 'tgmpa' ), |
|
| 1162 | + translate_nooped_plural( $this->strings[ 'update_link' ], $update_link_count, 'tgmpa' ), |
|
| 1163 | 1163 | esc_url( $this->get_tgmpa_status_url( 'update' ) ) |
| 1164 | 1164 | ); |
| 1165 | 1165 | } |
| 1166 | 1166 | } |
| 1167 | 1167 | |
| 1168 | 1168 | if ( current_user_can( 'activate_plugins' ) && $activate_link_count > 0 ) { |
| 1169 | - $action_links['activate'] = sprintf( |
|
| 1169 | + $action_links[ 'activate' ] = sprintf( |
|
| 1170 | 1170 | $link_template, |
| 1171 | - translate_nooped_plural( $this->strings['activate_link'], $activate_link_count, 'tgmpa' ), |
|
| 1171 | + translate_nooped_plural( $this->strings[ 'activate_link' ], $activate_link_count, 'tgmpa' ), |
|
| 1172 | 1172 | esc_url( $this->get_tgmpa_status_url( 'activate' ) ) |
| 1173 | 1173 | ); |
| 1174 | 1174 | } |
@@ -1196,8 +1196,8 @@ discard block |
||
| 1196 | 1196 | * @return string |
| 1197 | 1197 | */ |
| 1198 | 1198 | protected function get_admin_notice_class() { |
| 1199 | - if ( ! empty( $this->strings['nag_type'] ) ) { |
|
| 1200 | - return sanitize_html_class( strtolower( $this->strings['nag_type'] ) ); |
|
| 1199 | + if ( ! empty( $this->strings[ 'nag_type' ] ) ) { |
|
| 1200 | + return sanitize_html_class( strtolower( $this->strings[ 'nag_type' ] ) ); |
|
| 1201 | 1201 | } else { |
| 1202 | 1202 | if ( version_compare( $this->wp_version, '4.2', '>=' ) ) { |
| 1203 | 1203 | return 'notice-warning'; |
@@ -1220,7 +1220,7 @@ discard block |
||
| 1220 | 1220 | settings_errors( 'tgmpa' ); |
| 1221 | 1221 | |
| 1222 | 1222 | foreach ( (array) $wp_settings_errors as $key => $details ) { |
| 1223 | - if ( 'tgmpa' === $details['setting'] ) { |
|
| 1223 | + if ( 'tgmpa' === $details[ 'setting' ] ) { |
|
| 1224 | 1224 | unset( $wp_settings_errors[ $key ] ); |
| 1225 | 1225 | break; |
| 1226 | 1226 | } |
@@ -1235,8 +1235,8 @@ discard block |
||
| 1235 | 1235 | * @since 2.1.0 |
| 1236 | 1236 | */ |
| 1237 | 1237 | public function dismiss() { |
| 1238 | - if ( isset( $_GET['tgmpa-dismiss'] ) && check_admin_referer( 'tgmpa-dismis-' . get_current_user_id() ) ) { |
|
| 1239 | - update_user_meta( get_current_user_id(), 'tgmpa_dismissed_notice_' . $this->id, 1 ); |
|
| 1238 | + if ( isset( $_GET[ 'tgmpa-dismiss' ] ) && check_admin_referer( 'tgmpa-dismis-'.get_current_user_id() ) ) { |
|
| 1239 | + update_user_meta( get_current_user_id(), 'tgmpa_dismissed_notice_'.$this->id, 1 ); |
|
| 1240 | 1240 | } |
| 1241 | 1241 | } |
| 1242 | 1242 | |
@@ -1252,54 +1252,54 @@ discard block |
||
| 1252 | 1252 | * @return null Return early if incorrect argument. |
| 1253 | 1253 | */ |
| 1254 | 1254 | public function register( $plugin ) { |
| 1255 | - if ( empty( $plugin['slug'] ) || empty( $plugin['name'] ) ) { |
|
| 1255 | + if ( empty( $plugin[ 'slug' ] ) || empty( $plugin[ 'name' ] ) ) { |
|
| 1256 | 1256 | return; |
| 1257 | 1257 | } |
| 1258 | 1258 | |
| 1259 | - if ( empty( $plugin['slug'] ) || ! is_string( $plugin['slug'] ) || isset( $this->plugins[ $plugin['slug'] ] ) ) { |
|
| 1259 | + if ( empty( $plugin[ 'slug' ] ) || ! is_string( $plugin[ 'slug' ] ) || isset( $this->plugins[ $plugin[ 'slug' ] ] ) ) { |
|
| 1260 | 1260 | return; |
| 1261 | 1261 | } |
| 1262 | 1262 | |
| 1263 | 1263 | $defaults = array( |
| 1264 | - 'name' => '', // String |
|
| 1265 | - 'slug' => '', // String |
|
| 1266 | - 'source' => 'repo', // String |
|
| 1267 | - 'required' => false, // Boolean |
|
| 1268 | - 'version' => '', // String |
|
| 1269 | - 'force_activation' => false, // Boolean |
|
| 1270 | - 'force_deactivation' => false, // Boolean |
|
| 1271 | - 'external_url' => '', // String |
|
| 1272 | - 'is_callable' => '', // String|Array. |
|
| 1264 | + 'name' => '', // String |
|
| 1265 | + 'slug' => '', // String |
|
| 1266 | + 'source' => 'repo', // String |
|
| 1267 | + 'required' => false, // Boolean |
|
| 1268 | + 'version' => '', // String |
|
| 1269 | + 'force_activation' => false, // Boolean |
|
| 1270 | + 'force_deactivation' => false, // Boolean |
|
| 1271 | + 'external_url' => '', // String |
|
| 1272 | + 'is_callable' => '', // String|Array. |
|
| 1273 | 1273 | ); |
| 1274 | 1274 | |
| 1275 | 1275 | // Prepare the received data. |
| 1276 | 1276 | $plugin = wp_parse_args( $plugin, $defaults ); |
| 1277 | 1277 | |
| 1278 | 1278 | // Standardize the received slug. |
| 1279 | - $plugin['slug'] = $this->sanitize_key( $plugin['slug'] ); |
|
| 1279 | + $plugin[ 'slug' ] = $this->sanitize_key( $plugin[ 'slug' ] ); |
|
| 1280 | 1280 | |
| 1281 | 1281 | // Forgive users for using string versions of booleans or floats for version number. |
| 1282 | - $plugin['version'] = (string) $plugin['version']; |
|
| 1283 | - $plugin['source'] = empty( $plugin['source'] ) ? 'repo' : $plugin['source']; |
|
| 1284 | - $plugin['required'] = TGMPA_Utils::validate_bool( $plugin['required'] ); |
|
| 1285 | - $plugin['force_activation'] = TGMPA_Utils::validate_bool( $plugin['force_activation'] ); |
|
| 1286 | - $plugin['force_deactivation'] = TGMPA_Utils::validate_bool( $plugin['force_deactivation'] ); |
|
| 1282 | + $plugin[ 'version' ] = (string) $plugin[ 'version' ]; |
|
| 1283 | + $plugin[ 'source' ] = empty( $plugin[ 'source' ] ) ? 'repo' : $plugin[ 'source' ]; |
|
| 1284 | + $plugin[ 'required' ] = TGMPA_Utils::validate_bool( $plugin[ 'required' ] ); |
|
| 1285 | + $plugin[ 'force_activation' ] = TGMPA_Utils::validate_bool( $plugin[ 'force_activation' ] ); |
|
| 1286 | + $plugin[ 'force_deactivation' ] = TGMPA_Utils::validate_bool( $plugin[ 'force_deactivation' ] ); |
|
| 1287 | 1287 | |
| 1288 | 1288 | // Enrich the received data. |
| 1289 | - $plugin['file_path'] = $this->_get_plugin_basename_from_slug( $plugin['slug'] ); |
|
| 1290 | - $plugin['source_type'] = $this->get_plugin_source_type( $plugin['source'] ); |
|
| 1289 | + $plugin[ 'file_path' ] = $this->_get_plugin_basename_from_slug( $plugin[ 'slug' ] ); |
|
| 1290 | + $plugin[ 'source_type' ] = $this->get_plugin_source_type( $plugin[ 'source' ] ); |
|
| 1291 | 1291 | |
| 1292 | 1292 | // Set the class properties. |
| 1293 | - $this->plugins[ $plugin['slug'] ] = $plugin; |
|
| 1294 | - $this->sort_order[ $plugin['slug'] ] = $plugin['name']; |
|
| 1293 | + $this->plugins[ $plugin[ 'slug' ] ] = $plugin; |
|
| 1294 | + $this->sort_order[ $plugin[ 'slug' ] ] = $plugin[ 'name' ]; |
|
| 1295 | 1295 | |
| 1296 | 1296 | // Should we add the force activation hook ? |
| 1297 | - if ( true === $plugin['force_activation'] ) { |
|
| 1297 | + if ( true === $plugin[ 'force_activation' ] ) { |
|
| 1298 | 1298 | $this->has_forced_activation = true; |
| 1299 | 1299 | } |
| 1300 | 1300 | |
| 1301 | 1301 | // Should we add the force deactivation hook ? |
| 1302 | - if ( true === $plugin['force_deactivation'] ) { |
|
| 1302 | + if ( true === $plugin[ 'force_deactivation' ] ) { |
|
| 1303 | 1303 | $this->has_forced_deactivation = true; |
| 1304 | 1304 | } |
| 1305 | 1305 | } |
@@ -1425,11 +1425,11 @@ discard block |
||
| 1425 | 1425 | */ |
| 1426 | 1426 | public function populate_file_path( $plugin_slug = '' ) { |
| 1427 | 1427 | if ( ! empty( $plugin_slug ) && is_string( $plugin_slug ) && isset( $this->plugins[ $plugin_slug ] ) ) { |
| 1428 | - $this->plugins[ $plugin_slug ]['file_path'] = $this->_get_plugin_basename_from_slug( $plugin_slug ); |
|
| 1428 | + $this->plugins[ $plugin_slug ][ 'file_path' ] = $this->_get_plugin_basename_from_slug( $plugin_slug ); |
|
| 1429 | 1429 | } else { |
| 1430 | 1430 | // Add file_path key for all plugins. |
| 1431 | 1431 | foreach ( $this->plugins as $slug => $values ) { |
| 1432 | - $this->plugins[ $slug ]['file_path'] = $this->_get_plugin_basename_from_slug( $slug ); |
|
| 1432 | + $this->plugins[ $slug ][ 'file_path' ] = $this->_get_plugin_basename_from_slug( $slug ); |
|
| 1433 | 1433 | } |
| 1434 | 1434 | } |
| 1435 | 1435 | } |
@@ -1447,7 +1447,7 @@ discard block |
||
| 1447 | 1447 | $keys = array_keys( $this->get_plugins() ); |
| 1448 | 1448 | |
| 1449 | 1449 | foreach ( $keys as $key ) { |
| 1450 | - if ( preg_match( '|^' . $slug . '/|', $key ) ) { |
|
| 1450 | + if ( preg_match( '|^'.$slug.'/|', $key ) ) { |
|
| 1451 | 1451 | return $key; |
| 1452 | 1452 | } |
| 1453 | 1453 | } |
@@ -1469,7 +1469,7 @@ discard block |
||
| 1469 | 1469 | */ |
| 1470 | 1470 | public function _get_plugin_data_from_name( $name, $data = 'slug' ) { |
| 1471 | 1471 | foreach ( $this->plugins as $values ) { |
| 1472 | - if ( $name === $values['name'] && isset( $values[ $data ] ) ) { |
|
| 1472 | + if ( $name === $values[ 'name' ] && isset( $values[ $data ] ) ) { |
|
| 1473 | 1473 | return $values[ $data ]; |
| 1474 | 1474 | } |
| 1475 | 1475 | } |
@@ -1488,13 +1488,13 @@ discard block |
||
| 1488 | 1488 | public function get_download_url( $slug ) { |
| 1489 | 1489 | $dl_source = ''; |
| 1490 | 1490 | |
| 1491 | - switch ( $this->plugins[ $slug ]['source_type'] ) { |
|
| 1491 | + switch ( $this->plugins[ $slug ][ 'source_type' ] ) { |
|
| 1492 | 1492 | case 'repo': |
| 1493 | 1493 | return $this->get_wp_repo_download_url( $slug ); |
| 1494 | 1494 | case 'external': |
| 1495 | - return $this->plugins[ $slug ]['source']; |
|
| 1495 | + return $this->plugins[ $slug ][ 'source' ]; |
|
| 1496 | 1496 | case 'bundled': |
| 1497 | - return $this->default_path . $this->plugins[ $slug ]['source']; |
|
| 1497 | + return $this->default_path.$this->plugins[ $slug ][ 'source' ]; |
|
| 1498 | 1498 | } |
| 1499 | 1499 | |
| 1500 | 1500 | return $dl_source; // Should never happen. |
@@ -1532,7 +1532,7 @@ discard block |
||
| 1532 | 1532 | |
| 1533 | 1533 | if ( ! isset( $api[ $slug ] ) ) { |
| 1534 | 1534 | if ( ! function_exists( 'plugins_api' ) ) { |
| 1535 | - require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; |
|
| 1535 | + require_once ABSPATH.'wp-admin/includes/plugin-install.php'; |
|
| 1536 | 1536 | } |
| 1537 | 1537 | |
| 1538 | 1538 | $response = plugins_api( 'plugin_information', array( 'slug' => $slug, 'fields' => array( 'sections' => false ) ) ); |
@@ -1540,7 +1540,7 @@ discard block |
||
| 1540 | 1540 | $api[ $slug ] = false; |
| 1541 | 1541 | |
| 1542 | 1542 | if ( is_wp_error( $response ) ) { |
| 1543 | - wp_die( esc_html( $this->strings['oops'] ) ); |
|
| 1543 | + wp_die( esc_html( $this->strings[ 'oops' ] ) ); |
|
| 1544 | 1544 | } else { |
| 1545 | 1545 | $api[ $slug ] = $response; |
| 1546 | 1546 | } |
@@ -1559,13 +1559,13 @@ discard block |
||
| 1559 | 1559 | * or the plugin name if not. |
| 1560 | 1560 | */ |
| 1561 | 1561 | public function get_info_link( $slug ) { |
| 1562 | - if ( ! empty( $this->plugins[ $slug ]['external_url'] ) && preg_match( self::IS_URL_REGEX, $this->plugins[ $slug ]['external_url'] ) ) { |
|
| 1562 | + if ( ! empty( $this->plugins[ $slug ][ 'external_url' ] ) && preg_match( self::IS_URL_REGEX, $this->plugins[ $slug ][ 'external_url' ] ) ) { |
|
| 1563 | 1563 | $link = sprintf( |
| 1564 | 1564 | '<a href="%1$s" target="_blank">%2$s</a>', |
| 1565 | - esc_url( $this->plugins[ $slug ]['external_url'] ), |
|
| 1566 | - esc_html( $this->plugins[ $slug ]['name'] ) |
|
| 1565 | + esc_url( $this->plugins[ $slug ][ 'external_url' ] ), |
|
| 1566 | + esc_html( $this->plugins[ $slug ][ 'name' ] ) |
|
| 1567 | 1567 | ); |
| 1568 | - } elseif ( 'repo' === $this->plugins[ $slug ]['source_type'] ) { |
|
| 1568 | + } elseif ( 'repo' === $this->plugins[ $slug ][ 'source_type' ] ) { |
|
| 1569 | 1569 | $url = add_query_arg( |
| 1570 | 1570 | array( |
| 1571 | 1571 | 'tab' => 'plugin-information', |
@@ -1580,10 +1580,10 @@ discard block |
||
| 1580 | 1580 | $link = sprintf( |
| 1581 | 1581 | '<a href="%1$s" class="thickbox">%2$s</a>', |
| 1582 | 1582 | esc_url( $url ), |
| 1583 | - esc_html( $this->plugins[ $slug ]['name'] ) |
|
| 1583 | + esc_html( $this->plugins[ $slug ][ 'name' ] ) |
|
| 1584 | 1584 | ); |
| 1585 | 1585 | } else { |
| 1586 | - $link = esc_html( $this->plugins[ $slug ]['name'] ); // No hyperlink. |
|
| 1586 | + $link = esc_html( $this->plugins[ $slug ][ 'name' ] ); // No hyperlink. |
|
| 1587 | 1587 | } |
| 1588 | 1588 | |
| 1589 | 1589 | return $link; |
@@ -1597,7 +1597,7 @@ discard block |
||
| 1597 | 1597 | * @return boolean True when on the TGMPA page, false otherwise. |
| 1598 | 1598 | */ |
| 1599 | 1599 | protected function is_tgmpa_page() { |
| 1600 | - return isset( $_GET['page'] ) && $this->menu === $_GET['page']; |
|
| 1600 | + return isset( $_GET[ 'page' ] ) && $this->menu === $_GET[ 'page' ]; |
|
| 1601 | 1601 | } |
| 1602 | 1602 | |
| 1603 | 1603 | /** |
@@ -1616,10 +1616,10 @@ discard block |
||
| 1616 | 1616 | if ( 'update-core' === $screen->base ) { |
| 1617 | 1617 | // Core update screen. |
| 1618 | 1618 | return true; |
| 1619 | - } elseif ( 'plugins' === $screen->base && isset( $POST['action'] ) ) { |
|
| 1619 | + } elseif ( 'plugins' === $screen->base && isset( $POST[ 'action' ] ) ) { |
|
| 1620 | 1620 | // Plugins bulk update screen. |
| 1621 | 1621 | return true; |
| 1622 | - } elseif ( 'update' === $screen->base && isset( $POST['action'] ) ) { |
|
| 1622 | + } elseif ( 'update' === $screen->base && isset( $POST[ 'action' ] ) ) { |
|
| 1623 | 1623 | // Individual updates (ajax call). |
| 1624 | 1624 | return true; |
| 1625 | 1625 | } |
@@ -1706,7 +1706,7 @@ discard block |
||
| 1706 | 1706 | public function is_plugin_installed( $slug ) { |
| 1707 | 1707 | $installed_plugins = $this->get_plugins(); // Retrieve a list of all installed plugins (WP cached). |
| 1708 | 1708 | |
| 1709 | - return ( ! empty( $installed_plugins[ $this->plugins[ $slug ]['file_path'] ] ) ); |
|
| 1709 | + return ( ! empty( $installed_plugins[ $this->plugins[ $slug ][ 'file_path' ] ] ) ); |
|
| 1710 | 1710 | } |
| 1711 | 1711 | |
| 1712 | 1712 | /** |
@@ -1718,7 +1718,7 @@ discard block |
||
| 1718 | 1718 | * @return bool True if active, false otherwise. |
| 1719 | 1719 | */ |
| 1720 | 1720 | public function is_plugin_active( $slug ) { |
| 1721 | - return ( ( ! empty( $this->plugins[ $slug ]['is_callable'] ) && is_callable( $this->plugins[ $slug ]['is_callable'] ) ) || is_plugin_active( $this->plugins[ $slug ]['file_path'] ) ); |
|
| 1721 | + return ( ( ! empty( $this->plugins[ $slug ][ 'is_callable' ] ) && is_callable( $this->plugins[ $slug ][ 'is_callable' ] ) ) || is_plugin_active( $this->plugins[ $slug ][ 'file_path' ] ) ); |
|
| 1722 | 1722 | } |
| 1723 | 1723 | |
| 1724 | 1724 | /** |
@@ -1732,14 +1732,14 @@ discard block |
||
| 1732 | 1732 | */ |
| 1733 | 1733 | public function can_plugin_update( $slug ) { |
| 1734 | 1734 | // We currently can't get reliable info on non-WP-repo plugins - issue #380. |
| 1735 | - if ( 'repo' !== $this->plugins[ $slug ]['source_type'] ) { |
|
| 1735 | + if ( 'repo' !== $this->plugins[ $slug ][ 'source_type' ] ) { |
|
| 1736 | 1736 | return true; |
| 1737 | 1737 | } |
| 1738 | 1738 | |
| 1739 | 1739 | $api = $this->get_plugins_api( $slug ); |
| 1740 | 1740 | |
| 1741 | 1741 | if ( false !== $api && isset( $api->requires ) ) { |
| 1742 | - return version_compare( $GLOBALS['wp_version'], $api->requires, '>=' ); |
|
| 1742 | + return version_compare( $GLOBALS[ 'wp_version' ], $api->requires, '>=' ); |
|
| 1743 | 1743 | } |
| 1744 | 1744 | |
| 1745 | 1745 | // No usable info received from the plugins API, presume we can update. |
@@ -1788,8 +1788,8 @@ discard block |
||
| 1788 | 1788 | public function get_installed_version( $slug ) { |
| 1789 | 1789 | $installed_plugins = $this->get_plugins(); // Retrieve a list of all installed plugins (WP cached). |
| 1790 | 1790 | |
| 1791 | - if ( ! empty( $installed_plugins[ $this->plugins[ $slug ]['file_path'] ]['Version'] ) ) { |
|
| 1792 | - return $installed_plugins[ $this->plugins[ $slug ]['file_path'] ]['Version']; |
|
| 1791 | + if ( ! empty( $installed_plugins[ $this->plugins[ $slug ][ 'file_path' ] ][ 'Version' ] ) ) { |
|
| 1792 | + return $installed_plugins[ $this->plugins[ $slug ][ 'file_path' ] ][ 'Version' ]; |
|
| 1793 | 1793 | } |
| 1794 | 1794 | |
| 1795 | 1795 | return ''; |
@@ -1805,7 +1805,7 @@ discard block |
||
| 1805 | 1805 | */ |
| 1806 | 1806 | public function does_plugin_require_update( $slug ) { |
| 1807 | 1807 | $installed_version = $this->get_installed_version( $slug ); |
| 1808 | - $minimum_version = $this->plugins[ $slug ]['version']; |
|
| 1808 | + $minimum_version = $this->plugins[ $slug ][ 'version' ]; |
|
| 1809 | 1809 | |
| 1810 | 1810 | return version_compare( $minimum_version, $installed_version, '>' ); |
| 1811 | 1811 | } |
@@ -1820,9 +1820,9 @@ discard block |
||
| 1820 | 1820 | */ |
| 1821 | 1821 | public function does_plugin_have_update( $slug ) { |
| 1822 | 1822 | // Presume bundled and external plugins will point to a package which meets the minimum required version. |
| 1823 | - if ( 'repo' !== $this->plugins[ $slug ]['source_type'] ) { |
|
| 1823 | + if ( 'repo' !== $this->plugins[ $slug ][ 'source_type' ] ) { |
|
| 1824 | 1824 | if ( $this->does_plugin_require_update( $slug ) ) { |
| 1825 | - return $this->plugins[ $slug ]['version']; |
|
| 1825 | + return $this->plugins[ $slug ][ 'version' ]; |
|
| 1826 | 1826 | } |
| 1827 | 1827 | |
| 1828 | 1828 | return false; |
@@ -1830,8 +1830,8 @@ discard block |
||
| 1830 | 1830 | |
| 1831 | 1831 | $repo_updates = get_site_transient( 'update_plugins' ); |
| 1832 | 1832 | |
| 1833 | - if ( isset( $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->new_version ) ) { |
|
| 1834 | - return $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->new_version; |
|
| 1833 | + if ( isset( $repo_updates->response[ $this->plugins[ $slug ][ 'file_path' ] ]->new_version ) ) { |
|
| 1834 | + return $repo_updates->response[ $this->plugins[ $slug ][ 'file_path' ] ]->new_version; |
|
| 1835 | 1835 | } |
| 1836 | 1836 | |
| 1837 | 1837 | return false; |
@@ -1847,14 +1847,14 @@ discard block |
||
| 1847 | 1847 | */ |
| 1848 | 1848 | public function get_upgrade_notice( $slug ) { |
| 1849 | 1849 | // We currently can't get reliable info on non-WP-repo plugins - issue #380. |
| 1850 | - if ( 'repo' !== $this->plugins[ $slug ]['source_type'] ) { |
|
| 1850 | + if ( 'repo' !== $this->plugins[ $slug ][ 'source_type' ] ) { |
|
| 1851 | 1851 | return ''; |
| 1852 | 1852 | } |
| 1853 | 1853 | |
| 1854 | 1854 | $repo_updates = get_site_transient( 'update_plugins' ); |
| 1855 | 1855 | |
| 1856 | - if ( ! empty( $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->upgrade_notice ) ) { |
|
| 1857 | - return $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->upgrade_notice; |
|
| 1856 | + if ( ! empty( $repo_updates->response[ $this->plugins[ $slug ][ 'file_path' ] ]->upgrade_notice ) ) { |
|
| 1857 | + return $repo_updates->response[ $this->plugins[ $slug ][ 'file_path' ] ]->upgrade_notice; |
|
| 1858 | 1858 | } |
| 1859 | 1859 | |
| 1860 | 1860 | return ''; |
@@ -1870,7 +1870,7 @@ discard block |
||
| 1870 | 1870 | */ |
| 1871 | 1871 | public function get_plugins( $plugin_folder = '' ) { |
| 1872 | 1872 | if ( ! function_exists( 'get_plugins' ) ) { |
| 1873 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
| 1873 | + require_once ABSPATH.'wp-admin/includes/plugin.php'; |
|
| 1874 | 1874 | } |
| 1875 | 1875 | |
| 1876 | 1876 | return get_plugins( $plugin_folder ); |
@@ -1885,7 +1885,7 @@ discard block |
||
| 1885 | 1885 | * @since 2.1.1 |
| 1886 | 1886 | */ |
| 1887 | 1887 | public function update_dismiss() { |
| 1888 | - delete_metadata( 'user', null, 'tgmpa_dismissed_notice_' . $this->id, null, true ); |
|
| 1888 | + delete_metadata( 'user', null, 'tgmpa_dismissed_notice_'.$this->id, null, true ); |
|
| 1889 | 1889 | } |
| 1890 | 1890 | |
| 1891 | 1891 | /** |
@@ -1904,13 +1904,13 @@ discard block |
||
| 1904 | 1904 | */ |
| 1905 | 1905 | public function force_activation() { |
| 1906 | 1906 | foreach ( $this->plugins as $slug => $plugin ) { |
| 1907 | - if ( true === $plugin['force_activation'] ) { |
|
| 1907 | + if ( true === $plugin[ 'force_activation' ] ) { |
|
| 1908 | 1908 | if ( ! $this->is_plugin_installed( $slug ) ) { |
| 1909 | 1909 | // Oops, plugin isn't there so iterate to next condition. |
| 1910 | 1910 | continue; |
| 1911 | 1911 | } elseif ( $this->can_plugin_activate( $slug ) ) { |
| 1912 | 1912 | // There we go, activate the plugin. |
| 1913 | - activate_plugin( $plugin['file_path'] ); |
|
| 1913 | + activate_plugin( $plugin[ 'file_path' ] ); |
|
| 1914 | 1914 | } |
| 1915 | 1915 | } |
| 1916 | 1916 | } |
@@ -1931,8 +1931,8 @@ discard block |
||
| 1931 | 1931 | public function force_deactivation() { |
| 1932 | 1932 | foreach ( $this->plugins as $slug => $plugin ) { |
| 1933 | 1933 | // Only proceed forward if the parameter is set to true and plugin is active. |
| 1934 | - if ( true === $plugin['force_deactivation'] && $this->is_plugin_active( $slug ) ) { |
|
| 1935 | - deactivate_plugins( $plugin['file_path'] ); |
|
| 1934 | + if ( true === $plugin[ 'force_deactivation' ] && $this->is_plugin_active( $slug ) ) { |
|
| 1935 | + deactivate_plugins( $plugin[ 'file_path' ] ); |
|
| 1936 | 1936 | } |
| 1937 | 1937 | } |
| 1938 | 1938 | } |
@@ -1967,7 +1967,7 @@ discard block |
||
| 1967 | 1967 | * Ensure only one instance of the class is ever invoked. |
| 1968 | 1968 | */ |
| 1969 | 1969 | function load_tgm_plugin_activation() { |
| 1970 | - $GLOBALS['tgmpa'] = TGM_Plugin_Activation::get_instance(); |
|
| 1970 | + $GLOBALS[ 'tgmpa' ] = TGM_Plugin_Activation::get_instance(); |
|
| 1971 | 1971 | } |
| 1972 | 1972 | } |
| 1973 | 1973 | |
@@ -1989,7 +1989,7 @@ discard block |
||
| 1989 | 1989 | * @param array $config Optional. An array of configuration values. |
| 1990 | 1990 | */ |
| 1991 | 1991 | function tgmpa( $plugins, $config = array() ) { |
| 1992 | - $instance = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) ); |
|
| 1992 | + $instance = call_user_func( array( get_class( $GLOBALS[ 'tgmpa' ] ), 'get_instance' ) ); |
|
| 1993 | 1993 | |
| 1994 | 1994 | foreach ( $plugins as $plugin ) { |
| 1995 | 1995 | call_user_func( array( $instance, 'register' ), $plugin ); |
@@ -1997,17 +1997,17 @@ discard block |
||
| 1997 | 1997 | |
| 1998 | 1998 | if ( ! empty( $config ) && is_array( $config ) ) { |
| 1999 | 1999 | // Send out notices for deprecated arguments passed. |
| 2000 | - if ( isset( $config['notices'] ) ) { |
|
| 2000 | + if ( isset( $config[ 'notices' ] ) ) { |
|
| 2001 | 2001 | _deprecated_argument( __FUNCTION__, '2.2.0', 'The `notices` config parameter was renamed to `has_notices` in TGMPA 2.2.0. Please adjust your configuration.' ); |
| 2002 | - if ( ! isset( $config['has_notices'] ) ) { |
|
| 2003 | - $config['has_notices'] = $config['notices']; |
|
| 2002 | + if ( ! isset( $config[ 'has_notices' ] ) ) { |
|
| 2003 | + $config[ 'has_notices' ] = $config[ 'notices' ]; |
|
| 2004 | 2004 | } |
| 2005 | 2005 | } |
| 2006 | 2006 | |
| 2007 | - if ( isset( $config['parent_menu_slug'] ) ) { |
|
| 2007 | + if ( isset( $config[ 'parent_menu_slug' ] ) ) { |
|
| 2008 | 2008 | _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.' ); |
| 2009 | 2009 | } |
| 2010 | - if ( isset( $config['parent_url_slug'] ) ) { |
|
| 2010 | + if ( isset( $config[ 'parent_url_slug' ] ) ) { |
|
| 2011 | 2011 | _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.' ); |
| 2012 | 2012 | } |
| 2013 | 2013 | |
@@ -2023,7 +2023,7 @@ discard block |
||
| 2023 | 2023 | * @since 2.2.0 |
| 2024 | 2024 | */ |
| 2025 | 2025 | if ( ! class_exists( 'WP_List_Table' ) ) { |
| 2026 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
| 2026 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
| 2027 | 2027 | } |
| 2028 | 2028 | |
| 2029 | 2029 | if ( ! class_exists( 'TGMPA_List_Table' ) ) { |
@@ -2084,7 +2084,7 @@ discard block |
||
| 2084 | 2084 | * @since 2.2.0 |
| 2085 | 2085 | */ |
| 2086 | 2086 | public function __construct() { |
| 2087 | - $this->tgmpa = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) ); |
|
| 2087 | + $this->tgmpa = call_user_func( array( get_class( $GLOBALS[ 'tgmpa' ] ), 'get_instance' ) ); |
|
| 2088 | 2088 | |
| 2089 | 2089 | parent::__construct( |
| 2090 | 2090 | array( |
@@ -2094,8 +2094,8 @@ discard block |
||
| 2094 | 2094 | ) |
| 2095 | 2095 | ); |
| 2096 | 2096 | |
| 2097 | - if ( isset( $_REQUEST['plugin_status'] ) && in_array( $_REQUEST['plugin_status'], array( 'install', 'update', 'activate' ), true ) ) { |
|
| 2098 | - $this->view_context = sanitize_key( $_REQUEST['plugin_status'] ); |
|
| 2097 | + if ( isset( $_REQUEST[ 'plugin_status' ] ) && in_array( $_REQUEST[ 'plugin_status' ], array( 'install', 'update', 'activate' ), true ) ) { |
|
| 2098 | + $this->view_context = sanitize_key( $_REQUEST[ 'plugin_status' ] ); |
|
| 2099 | 2099 | } |
| 2100 | 2100 | |
| 2101 | 2101 | add_filter( 'tgmpa_table_data_items', array( $this, 'sort_table_items' ) ); |
@@ -2142,20 +2142,20 @@ discard block |
||
| 2142 | 2142 | } |
| 2143 | 2143 | |
| 2144 | 2144 | foreach ( $plugins[ $this->view_context ] as $slug => $plugin ) { |
| 2145 | - $table_data[ $i ]['sanitized_plugin'] = $plugin['name']; |
|
| 2146 | - $table_data[ $i ]['slug'] = $slug; |
|
| 2147 | - $table_data[ $i ]['plugin'] = '<strong>' . $this->tgmpa->get_info_link( $slug ) . '</strong>'; |
|
| 2148 | - $table_data[ $i ]['source'] = $this->get_plugin_source_type_text( $plugin['source_type'] ); |
|
| 2149 | - $table_data[ $i ]['type'] = $this->get_plugin_advise_type_text( $plugin['required'] ); |
|
| 2150 | - $table_data[ $i ]['status'] = $this->get_plugin_status_text( $slug ); |
|
| 2151 | - $table_data[ $i ]['installed_version'] = $this->tgmpa->get_installed_version( $slug ); |
|
| 2152 | - $table_data[ $i ]['minimum_version'] = $plugin['version']; |
|
| 2153 | - $table_data[ $i ]['available_version'] = $this->tgmpa->does_plugin_have_update( $slug ); |
|
| 2145 | + $table_data[ $i ][ 'sanitized_plugin' ] = $plugin[ 'name' ]; |
|
| 2146 | + $table_data[ $i ][ 'slug' ] = $slug; |
|
| 2147 | + $table_data[ $i ][ 'plugin' ] = '<strong>'.$this->tgmpa->get_info_link( $slug ).'</strong>'; |
|
| 2148 | + $table_data[ $i ][ 'source' ] = $this->get_plugin_source_type_text( $plugin[ 'source_type' ] ); |
|
| 2149 | + $table_data[ $i ][ 'type' ] = $this->get_plugin_advise_type_text( $plugin[ 'required' ] ); |
|
| 2150 | + $table_data[ $i ][ 'status' ] = $this->get_plugin_status_text( $slug ); |
|
| 2151 | + $table_data[ $i ][ 'installed_version' ] = $this->tgmpa->get_installed_version( $slug ); |
|
| 2152 | + $table_data[ $i ][ 'minimum_version' ] = $plugin[ 'version' ]; |
|
| 2153 | + $table_data[ $i ][ 'available_version' ] = $this->tgmpa->does_plugin_have_update( $slug ); |
|
| 2154 | 2154 | |
| 2155 | 2155 | // Prep the upgrade notice info. |
| 2156 | 2156 | $upgrade_notice = $this->tgmpa->get_upgrade_notice( $slug ); |
| 2157 | 2157 | if ( ! empty( $upgrade_notice ) ) { |
| 2158 | - $table_data[ $i ]['upgrade_notice'] = $upgrade_notice; |
|
| 2158 | + $table_data[ $i ][ 'upgrade_notice' ] = $upgrade_notice; |
|
| 2159 | 2159 | |
| 2160 | 2160 | add_action( "tgmpa_after_plugin_row_$slug", array( $this, 'wp_plugin_update_row' ), 10, 2 ); |
| 2161 | 2161 | } |
@@ -2186,17 +2186,17 @@ discard block |
||
| 2186 | 2186 | // No need to display plugins if they are installed, up-to-date and active. |
| 2187 | 2187 | continue; |
| 2188 | 2188 | } else { |
| 2189 | - $plugins['all'][ $slug ] = $plugin; |
|
| 2189 | + $plugins[ 'all' ][ $slug ] = $plugin; |
|
| 2190 | 2190 | |
| 2191 | 2191 | if ( ! $this->tgmpa->is_plugin_installed( $slug ) ) { |
| 2192 | - $plugins['install'][ $slug ] = $plugin; |
|
| 2192 | + $plugins[ 'install' ][ $slug ] = $plugin; |
|
| 2193 | 2193 | } else { |
| 2194 | 2194 | if ( false !== $this->tgmpa->does_plugin_have_update( $slug ) ) { |
| 2195 | - $plugins['update'][ $slug ] = $plugin; |
|
| 2195 | + $plugins[ 'update' ][ $slug ] = $plugin; |
|
| 2196 | 2196 | } |
| 2197 | 2197 | |
| 2198 | 2198 | if ( $this->tgmpa->can_plugin_activate( $slug ) ) { |
| 2199 | - $plugins['activate'][ $slug ] = $plugin; |
|
| 2199 | + $plugins[ 'activate' ][ $slug ] = $plugin; |
|
| 2200 | 2200 | } |
| 2201 | 2201 | } |
| 2202 | 2202 | } |
@@ -2315,8 +2315,8 @@ discard block |
||
| 2315 | 2315 | $name = array(); |
| 2316 | 2316 | |
| 2317 | 2317 | foreach ( $items as $i => $plugin ) { |
| 2318 | - $type[ $i ] = $plugin['type']; // Required / recommended. |
|
| 2319 | - $name[ $i ] = $plugin['sanitized_plugin']; |
|
| 2318 | + $type[ $i ] = $plugin[ 'type' ]; // Required / recommended. |
|
| 2319 | + $name[ $i ] = $plugin[ 'sanitized_plugin' ]; |
|
| 2320 | 2320 | } |
| 2321 | 2321 | |
| 2322 | 2322 | array_multisort( $type, SORT_DESC, $name, SORT_ASC, $items ); |
@@ -2398,9 +2398,9 @@ discard block |
||
| 2398 | 2398 | public function column_cb( $item ) { |
| 2399 | 2399 | return sprintf( |
| 2400 | 2400 | '<input type="checkbox" name="%1$s[]" value="%2$s" id="%3$s" />', |
| 2401 | - esc_attr( $this->_args['singular'] ), |
|
| 2402 | - esc_attr( $item['slug'] ), |
|
| 2403 | - esc_attr( $item['sanitized_plugin'] ) |
|
| 2401 | + esc_attr( $this->_args[ 'singular' ] ), |
|
| 2402 | + esc_attr( $item[ 'slug' ] ), |
|
| 2403 | + esc_attr( $item[ 'sanitized_plugin' ] ) |
|
| 2404 | 2404 | ); |
| 2405 | 2405 | } |
| 2406 | 2406 | |
@@ -2415,7 +2415,7 @@ discard block |
||
| 2415 | 2415 | public function column_plugin( $item ) { |
| 2416 | 2416 | return sprintf( |
| 2417 | 2417 | '%1$s %2$s', |
| 2418 | - $item['plugin'], |
|
| 2418 | + $item[ 'plugin' ], |
|
| 2419 | 2419 | $this->row_actions( $this->get_row_actions( $item ), true ) |
| 2420 | 2420 | ); |
| 2421 | 2421 | } |
@@ -2431,38 +2431,38 @@ discard block |
||
| 2431 | 2431 | public function column_version( $item ) { |
| 2432 | 2432 | $output = array(); |
| 2433 | 2433 | |
| 2434 | - if ( $this->tgmpa->is_plugin_installed( $item['slug'] ) ) { |
|
| 2435 | - $installed = ! empty( $item['installed_version'] ) ? $item['installed_version'] : _x( 'unknown', 'as in: "version nr unknown"', 'tgmpa' ); |
|
| 2434 | + if ( $this->tgmpa->is_plugin_installed( $item[ 'slug' ] ) ) { |
|
| 2435 | + $installed = ! empty( $item[ 'installed_version' ] ) ? $item[ 'installed_version' ] : _x( 'unknown', 'as in: "version nr unknown"', 'tgmpa' ); |
|
| 2436 | 2436 | |
| 2437 | 2437 | $color = ''; |
| 2438 | - if ( ! empty( $item['minimum_version'] ) && $this->tgmpa->does_plugin_require_update( $item['slug'] ) ) { |
|
| 2438 | + if ( ! empty( $item[ 'minimum_version' ] ) && $this->tgmpa->does_plugin_require_update( $item[ 'slug' ] ) ) { |
|
| 2439 | 2439 | $color = ' color: #ff0000; font-weight: bold;'; |
| 2440 | 2440 | } |
| 2441 | 2441 | |
| 2442 | - $output[] = sprintf( |
|
| 2443 | - '<p><span style="min-width: 32px; text-align: right; float: right;%1$s">%2$s</span>' . __( 'Installed version:', 'tgmpa' ) . '</p>', |
|
| 2442 | + $output[ ] = sprintf( |
|
| 2443 | + '<p><span style="min-width: 32px; text-align: right; float: right;%1$s">%2$s</span>'.__( 'Installed version:', 'tgmpa' ).'</p>', |
|
| 2444 | 2444 | $color, |
| 2445 | 2445 | $installed |
| 2446 | 2446 | ); |
| 2447 | 2447 | } |
| 2448 | 2448 | |
| 2449 | - if ( ! empty( $item['minimum_version'] ) ) { |
|
| 2450 | - $output[] = sprintf( |
|
| 2451 | - '<p><span style="min-width: 32px; text-align: right; float: right;">%1$s</span>' . __( 'Minimum required version:', 'tgmpa' ) . '</p>', |
|
| 2452 | - $item['minimum_version'] |
|
| 2449 | + if ( ! empty( $item[ 'minimum_version' ] ) ) { |
|
| 2450 | + $output[ ] = sprintf( |
|
| 2451 | + '<p><span style="min-width: 32px; text-align: right; float: right;">%1$s</span>'.__( 'Minimum required version:', 'tgmpa' ).'</p>', |
|
| 2452 | + $item[ 'minimum_version' ] |
|
| 2453 | 2453 | ); |
| 2454 | 2454 | } |
| 2455 | 2455 | |
| 2456 | - if ( ! empty( $item['available_version'] ) ) { |
|
| 2456 | + if ( ! empty( $item[ 'available_version' ] ) ) { |
|
| 2457 | 2457 | $color = ''; |
| 2458 | - if ( ! empty( $item['minimum_version'] ) && version_compare( $item['available_version'], $item['minimum_version'], '>=' ) ) { |
|
| 2458 | + if ( ! empty( $item[ 'minimum_version' ] ) && version_compare( $item[ 'available_version' ], $item[ 'minimum_version' ], '>=' ) ) { |
|
| 2459 | 2459 | $color = ' color: #71C671; font-weight: bold;'; |
| 2460 | 2460 | } |
| 2461 | 2461 | |
| 2462 | - $output[] = sprintf( |
|
| 2463 | - '<p><span style="min-width: 32px; text-align: right; float: right;%1$s">%2$s</span>' . __( 'Available version:', 'tgmpa' ) . '</p>', |
|
| 2462 | + $output[ ] = sprintf( |
|
| 2463 | + '<p><span style="min-width: 32px; text-align: right; float: right;%1$s">%2$s</span>'.__( 'Available version:', 'tgmpa' ).'</p>', |
|
| 2464 | 2464 | $color, |
| 2465 | - $item['available_version'] |
|
| 2465 | + $item[ 'available_version' ] |
|
| 2466 | 2466 | ); |
| 2467 | 2467 | } |
| 2468 | 2468 | |
@@ -2503,8 +2503,8 @@ discard block |
||
| 2503 | 2503 | ); |
| 2504 | 2504 | |
| 2505 | 2505 | if ( 'all' === $this->view_context || 'update' === $this->view_context ) { |
| 2506 | - $columns['version'] = __( 'Version', 'tgmpa' ); |
|
| 2507 | - $columns['status'] = __( 'Status', 'tgmpa' ); |
|
| 2506 | + $columns[ 'version' ] = __( 'Version', 'tgmpa' ); |
|
| 2507 | + $columns[ 'status' ] = __( 'Status', 'tgmpa' ); |
|
| 2508 | 2508 | } |
| 2509 | 2509 | |
| 2510 | 2510 | return apply_filters( 'tgmpa_table_columns', $columns ); |
@@ -2551,17 +2551,17 @@ discard block |
||
| 2551 | 2551 | $action_links = array(); |
| 2552 | 2552 | |
| 2553 | 2553 | // Display the 'Install' action link if the plugin is not yet available. |
| 2554 | - if ( ! $this->tgmpa->is_plugin_installed( $item['slug'] ) ) { |
|
| 2555 | - $actions['install'] = _x( 'Install %2$s', '%2$s = plugin name in screen reader markup', 'tgmpa' ); |
|
| 2554 | + if ( ! $this->tgmpa->is_plugin_installed( $item[ 'slug' ] ) ) { |
|
| 2555 | + $actions[ 'install' ] = _x( 'Install %2$s', '%2$s = plugin name in screen reader markup', 'tgmpa' ); |
|
| 2556 | 2556 | } else { |
| 2557 | 2557 | // Display the 'Update' action link if an update is available and WP complies with plugin minimum. |
| 2558 | - if ( false !== $this->tgmpa->does_plugin_have_update( $item['slug'] ) && $this->tgmpa->can_plugin_update( $item['slug'] ) ) { |
|
| 2559 | - $actions['update'] = _x( 'Update %2$s', '%2$s = plugin name in screen reader markup', 'tgmpa' ); |
|
| 2558 | + if ( false !== $this->tgmpa->does_plugin_have_update( $item[ 'slug' ] ) && $this->tgmpa->can_plugin_update( $item[ 'slug' ] ) ) { |
|
| 2559 | + $actions[ 'update' ] = _x( 'Update %2$s', '%2$s = plugin name in screen reader markup', 'tgmpa' ); |
|
| 2560 | 2560 | } |
| 2561 | 2561 | |
| 2562 | 2562 | // Display the 'Activate' action link, but only if the plugin meets the minimum version. |
| 2563 | - if ( $this->tgmpa->can_plugin_activate( $item['slug'] ) ) { |
|
| 2564 | - $actions['activate'] = _x( 'Activate %2$s', '%2$s = plugin name in screen reader markup', 'tgmpa' ); |
|
| 2563 | + if ( $this->tgmpa->can_plugin_activate( $item[ 'slug' ] ) ) { |
|
| 2564 | + $actions[ 'activate' ] = _x( 'Activate %2$s', '%2$s = plugin name in screen reader markup', 'tgmpa' ); |
|
| 2565 | 2565 | } |
| 2566 | 2566 | } |
| 2567 | 2567 | |
@@ -2570,24 +2570,24 @@ discard block |
||
| 2570 | 2570 | $nonce_url = wp_nonce_url( |
| 2571 | 2571 | add_query_arg( |
| 2572 | 2572 | array( |
| 2573 | - 'plugin' => urlencode( $item['slug'] ), |
|
| 2574 | - 'tgmpa-' . $action => $action . '-plugin', |
|
| 2573 | + 'plugin' => urlencode( $item[ 'slug' ] ), |
|
| 2574 | + 'tgmpa-'.$action => $action.'-plugin', |
|
| 2575 | 2575 | ), |
| 2576 | 2576 | $this->tgmpa->get_tgmpa_url() |
| 2577 | 2577 | ), |
| 2578 | - 'tgmpa-' . $action, |
|
| 2578 | + 'tgmpa-'.$action, |
|
| 2579 | 2579 | 'tgmpa-nonce' |
| 2580 | 2580 | ); |
| 2581 | 2581 | |
| 2582 | 2582 | $action_links[ $action ] = sprintf( |
| 2583 | - '<a href="%1$s">' . esc_html( $text ) . '</a>', |
|
| 2583 | + '<a href="%1$s">'.esc_html( $text ).'</a>', |
|
| 2584 | 2584 | esc_url( $nonce_url ), |
| 2585 | - '<span class="screen-reader-text">' . esc_html( $item['sanitized_plugin'] ) . '</span>' |
|
| 2585 | + '<span class="screen-reader-text">'.esc_html( $item[ 'sanitized_plugin' ] ).'</span>' |
|
| 2586 | 2586 | ); |
| 2587 | 2587 | } |
| 2588 | 2588 | |
| 2589 | 2589 | $prefix = ( defined( 'WP_NETWORK_ADMIN' ) && WP_NETWORK_ADMIN ) ? 'network_admin_' : ''; |
| 2590 | - return apply_filters( "tgmpa_{$prefix}plugin_action_links", array_filter( $action_links ), $item['slug'], $item, $this->view_context ); |
|
| 2590 | + return apply_filters( "tgmpa_{$prefix}plugin_action_links", array_filter( $action_links ), $item[ 'slug' ], $item, $this->view_context ); |
|
| 2591 | 2591 | } |
| 2592 | 2592 | |
| 2593 | 2593 | /** |
@@ -2608,7 +2608,7 @@ discard block |
||
| 2608 | 2608 | * |
| 2609 | 2609 | * @since 2.5.0 |
| 2610 | 2610 | */ |
| 2611 | - do_action( "tgmpa_after_plugin_row_{$item['slug']}", $item['slug'], $item, $this->view_context ); |
|
| 2611 | + do_action( "tgmpa_after_plugin_row_{$item[ 'slug' ]}", $item[ 'slug' ], $item, $this->view_context ); |
|
| 2612 | 2612 | } |
| 2613 | 2613 | |
| 2614 | 2614 | /** |
@@ -2623,7 +2623,7 @@ discard block |
||
| 2623 | 2623 | * @return null Return early if upgrade notice is empty. |
| 2624 | 2624 | */ |
| 2625 | 2625 | public function wp_plugin_update_row( $slug, $item ) { |
| 2626 | - if ( empty( $item['upgrade_notice'] ) ) { |
|
| 2626 | + if ( empty( $item[ 'upgrade_notice' ] ) ) { |
|
| 2627 | 2627 | return; |
| 2628 | 2628 | } |
| 2629 | 2629 | |
@@ -2632,7 +2632,7 @@ discard block |
||
| 2632 | 2632 | <td colspan="', absint( $this->get_column_count() ), '" class="plugin-update colspanchange"> |
| 2633 | 2633 | <div class="update-message">', |
| 2634 | 2634 | esc_html__( 'Upgrade message from the plugin author:', 'tgmpa' ), |
| 2635 | - ' <strong>', wp_kses_data( $item['upgrade_notice'] ), '</strong> |
|
| 2635 | + ' <strong>', wp_kses_data( $item[ 'upgrade_notice' ] ), '</strong> |
|
| 2636 | 2636 | </div> |
| 2637 | 2637 | </td> |
| 2638 | 2638 | </tr>'; |
@@ -2664,16 +2664,16 @@ discard block |
||
| 2664 | 2664 | |
| 2665 | 2665 | if ( 'update' !== $this->view_context && 'activate' !== $this->view_context ) { |
| 2666 | 2666 | if ( current_user_can( 'install_plugins' ) ) { |
| 2667 | - $actions['tgmpa-bulk-install'] = __( 'Install', 'tgmpa' ); |
|
| 2667 | + $actions[ 'tgmpa-bulk-install' ] = __( 'Install', 'tgmpa' ); |
|
| 2668 | 2668 | } |
| 2669 | 2669 | } |
| 2670 | 2670 | |
| 2671 | 2671 | if ( 'install' !== $this->view_context ) { |
| 2672 | 2672 | if ( current_user_can( 'update_plugins' ) ) { |
| 2673 | - $actions['tgmpa-bulk-update'] = __( 'Update', 'tgmpa' ); |
|
| 2673 | + $actions[ 'tgmpa-bulk-update' ] = __( 'Update', 'tgmpa' ); |
|
| 2674 | 2674 | } |
| 2675 | 2675 | if ( current_user_can( 'activate_plugins' ) ) { |
| 2676 | - $actions['tgmpa-bulk-activate'] = __( 'Activate', 'tgmpa' ); |
|
| 2676 | + $actions[ 'tgmpa-bulk-activate' ] = __( 'Activate', 'tgmpa' ); |
|
| 2677 | 2677 | } |
| 2678 | 2678 | } |
| 2679 | 2679 | |
@@ -2692,7 +2692,7 @@ discard block |
||
| 2692 | 2692 | // Bulk installation process. |
| 2693 | 2693 | if ( 'tgmpa-bulk-install' === $this->current_action() || 'tgmpa-bulk-update' === $this->current_action() ) { |
| 2694 | 2694 | |
| 2695 | - check_admin_referer( 'bulk-' . $this->_args['plural'] ); |
|
| 2695 | + check_admin_referer( 'bulk-'.$this->_args[ 'plural' ] ); |
|
| 2696 | 2696 | |
| 2697 | 2697 | $install_type = 'install'; |
| 2698 | 2698 | if ( 'tgmpa-bulk-update' === $this->current_action() ) { |
@@ -2702,7 +2702,7 @@ discard block |
||
| 2702 | 2702 | $plugins_to_install = array(); |
| 2703 | 2703 | |
| 2704 | 2704 | // Did user actually select any plugins to install/update ? |
| 2705 | - if ( empty( $_POST['plugin'] ) ) { |
|
| 2705 | + if ( empty( $_POST[ 'plugin' ] ) ) { |
|
| 2706 | 2706 | if ( 'install' === $install_type ) { |
| 2707 | 2707 | $message = __( 'No plugins were selected to be installed. No action taken.', 'tgmpa' ); |
| 2708 | 2708 | } else { |
@@ -2714,11 +2714,11 @@ discard block |
||
| 2714 | 2714 | return false; |
| 2715 | 2715 | } |
| 2716 | 2716 | |
| 2717 | - if ( is_array( $_POST['plugin'] ) ) { |
|
| 2718 | - $plugins_to_install = (array) $_POST['plugin']; |
|
| 2719 | - } elseif ( is_string( $_POST['plugin'] ) ) { |
|
| 2717 | + if ( is_array( $_POST[ 'plugin' ] ) ) { |
|
| 2718 | + $plugins_to_install = (array) $_POST[ 'plugin' ]; |
|
| 2719 | + } elseif ( is_string( $_POST[ 'plugin' ] ) ) { |
|
| 2720 | 2720 | // Received via Filesystem page - un-flatten array (WP bug #19643). |
| 2721 | - $plugins_to_install = explode( ',', $_POST['plugin'] ); |
|
| 2721 | + $plugins_to_install = explode( ',', $_POST[ 'plugin' ] ); |
|
| 2722 | 2722 | } |
| 2723 | 2723 | |
| 2724 | 2724 | // Sanitize the received input. |
@@ -2760,11 +2760,11 @@ discard block |
||
| 2760 | 2760 | // Pass all necessary information if WP_Filesystem is needed. |
| 2761 | 2761 | $url = wp_nonce_url( |
| 2762 | 2762 | $this->tgmpa->get_tgmpa_url(), |
| 2763 | - 'bulk-' . $this->_args['plural'] |
|
| 2763 | + 'bulk-'.$this->_args[ 'plural' ] |
|
| 2764 | 2764 | ); |
| 2765 | 2765 | |
| 2766 | 2766 | // Give validated data back to $_POST which is the only place the filesystem looks for extra fields. |
| 2767 | - $_POST['plugin'] = implode( ',', $plugins_to_install ); // Work around for WP bug #19643. |
|
| 2767 | + $_POST[ 'plugin' ] = implode( ',', $plugins_to_install ); // Work around for WP bug #19643. |
|
| 2768 | 2768 | |
| 2769 | 2769 | $method = ''; // Leave blank so WP_Filesystem can populate it as necessary. |
| 2770 | 2770 | $fields = array_keys( $_POST ); // Extra fields to pass to WP_Filesystem. |
@@ -2791,22 +2791,22 @@ discard block |
||
| 2791 | 2791 | |
| 2792 | 2792 | // Prepare the data for validated plugins for the install/upgrade. |
| 2793 | 2793 | foreach ( $plugins_to_install as $slug ) { |
| 2794 | - $name = $this->tgmpa->plugins[ $slug ]['name']; |
|
| 2794 | + $name = $this->tgmpa->plugins[ $slug ][ 'name' ]; |
|
| 2795 | 2795 | $source = $this->tgmpa->get_download_url( $slug ); |
| 2796 | 2796 | |
| 2797 | 2797 | if ( ! empty( $name ) && ! empty( $source ) ) { |
| 2798 | - $names[] = $name; |
|
| 2798 | + $names[ ] = $name; |
|
| 2799 | 2799 | |
| 2800 | 2800 | switch ( $install_type ) { |
| 2801 | 2801 | |
| 2802 | 2802 | case 'install': |
| 2803 | - $sources[] = $source; |
|
| 2803 | + $sources[ ] = $source; |
|
| 2804 | 2804 | break; |
| 2805 | 2805 | |
| 2806 | 2806 | case 'update': |
| 2807 | - $file_paths[] = $this->tgmpa->plugins[ $slug ]['file_path']; |
|
| 2807 | + $file_paths[ ] = $this->tgmpa->plugins[ $slug ][ 'file_path' ]; |
|
| 2808 | 2808 | $to_inject[ $slug ] = $this->tgmpa->plugins[ $slug ]; |
| 2809 | - $to_inject[ $slug ]['source'] = $source; |
|
| 2809 | + $to_inject[ $slug ][ 'source' ] = $source; |
|
| 2810 | 2810 | break; |
| 2811 | 2811 | } |
| 2812 | 2812 | } |
@@ -2818,7 +2818,7 @@ discard block |
||
| 2818 | 2818 | new TGMPA_Bulk_Installer_Skin( |
| 2819 | 2819 | array( |
| 2820 | 2820 | 'url' => esc_url_raw( $this->tgmpa->get_tgmpa_url() ), |
| 2821 | - 'nonce' => 'bulk-' . $this->_args['plural'], |
|
| 2821 | + 'nonce' => 'bulk-'.$this->_args[ 'plural' ], |
|
| 2822 | 2822 | 'names' => $names, |
| 2823 | 2823 | 'install_type' => $install_type, |
| 2824 | 2824 | ) |
@@ -2850,10 +2850,10 @@ discard block |
||
| 2850 | 2850 | |
| 2851 | 2851 | // Bulk activation process. |
| 2852 | 2852 | if ( 'tgmpa-bulk-activate' === $this->current_action() ) { |
| 2853 | - check_admin_referer( 'bulk-' . $this->_args['plural'] ); |
|
| 2853 | + check_admin_referer( 'bulk-'.$this->_args[ 'plural' ] ); |
|
| 2854 | 2854 | |
| 2855 | 2855 | // Did user actually select any plugins to activate ? |
| 2856 | - if ( empty( $_POST['plugin'] ) ) { |
|
| 2856 | + if ( empty( $_POST[ 'plugin' ] ) ) { |
|
| 2857 | 2857 | echo '<div id="message" class="error"><p>', esc_html__( 'No plugins were selected to be activated. No action taken.', 'tgmpa' ), '</p></div>'; |
| 2858 | 2858 | |
| 2859 | 2859 | return false; |
@@ -2861,8 +2861,8 @@ discard block |
||
| 2861 | 2861 | |
| 2862 | 2862 | // Grab plugin data from $_POST. |
| 2863 | 2863 | $plugins = array(); |
| 2864 | - if ( isset( $_POST['plugin'] ) ) { |
|
| 2865 | - $plugins = array_map( 'urldecode', (array) $_POST['plugin'] ); |
|
| 2864 | + if ( isset( $_POST[ 'plugin' ] ) ) { |
|
| 2865 | + $plugins = array_map( 'urldecode', (array) $_POST[ 'plugin' ] ); |
|
| 2866 | 2866 | $plugins = array_map( array( $this->tgmpa, 'sanitize_key' ), $plugins ); |
| 2867 | 2867 | } |
| 2868 | 2868 | |
@@ -2872,8 +2872,8 @@ discard block |
||
| 2872 | 2872 | // Grab the file paths for the selected & inactive plugins from the registration array. |
| 2873 | 2873 | foreach ( $plugins as $slug ) { |
| 2874 | 2874 | if ( $this->tgmpa->can_plugin_activate( $slug ) ) { |
| 2875 | - $plugins_to_activate[] = $this->tgmpa->plugins[ $slug ]['file_path']; |
|
| 2876 | - $plugin_names[] = $this->tgmpa->plugins[ $slug ]['name']; |
|
| 2875 | + $plugins_to_activate[ ] = $this->tgmpa->plugins[ $slug ][ 'file_path' ]; |
|
| 2876 | + $plugin_names[ ] = $this->tgmpa->plugins[ $slug ][ 'name' ]; |
|
| 2877 | 2877 | } |
| 2878 | 2878 | } |
| 2879 | 2879 | unset( $slug ); |
@@ -2894,7 +2894,7 @@ discard block |
||
| 2894 | 2894 | $count = count( $plugin_names ); // Count so we can use _n function. |
| 2895 | 2895 | $plugin_names = array_map( array( 'TGMPA_Utils', 'wrap_in_strong' ), $plugin_names ); |
| 2896 | 2896 | $last_plugin = array_pop( $plugin_names ); // Pop off last name to prep for readability. |
| 2897 | - $imploded = empty( $plugin_names ) ? $last_plugin : ( implode( ', ', $plugin_names ) . ' ' . esc_html_x( 'and', 'plugin A *and* plugin B', 'tgmpa' ) . ' ' . $last_plugin ); |
|
| 2897 | + $imploded = empty( $plugin_names ) ? $last_plugin : ( implode( ', ', $plugin_names ).' '.esc_html_x( 'and', 'plugin A *and* plugin B', 'tgmpa' ).' '.$last_plugin ); |
|
| 2898 | 2898 | |
| 2899 | 2899 | printf( // WPCS: xss ok. |
| 2900 | 2900 | '<div id="message" class="updated"><p>%1$s %2$s.</p></div>', |
@@ -2997,16 +2997,16 @@ discard block |
||
| 2997 | 2997 | */ |
| 2998 | 2998 | function tgmpa_load_bulk_installer() { |
| 2999 | 2999 | // Silently fail if 2.5+ is loaded *after* an older version. |
| 3000 | - if ( ! isset( $GLOBALS['tgmpa'] ) ) { |
|
| 3000 | + if ( ! isset( $GLOBALS[ 'tgmpa' ] ) ) { |
|
| 3001 | 3001 | return; |
| 3002 | 3002 | } |
| 3003 | 3003 | |
| 3004 | 3004 | // Get TGMPA class instance. |
| 3005 | - $tgmpa_instance = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) ); |
|
| 3005 | + $tgmpa_instance = call_user_func( array( get_class( $GLOBALS[ 'tgmpa' ] ), 'get_instance' ) ); |
|
| 3006 | 3006 | |
| 3007 | - if ( isset( $_GET['page'] ) && $tgmpa_instance->menu === $_GET['page'] ) { |
|
| 3007 | + if ( isset( $_GET[ 'page' ] ) && $tgmpa_instance->menu === $_GET[ 'page' ] ) { |
|
| 3008 | 3008 | if ( ! class_exists( 'Plugin_Upgrader', false ) ) { |
| 3009 | - require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
|
| 3009 | + require_once ABSPATH.'wp-admin/includes/class-wp-upgrader.php'; |
|
| 3010 | 3010 | } |
| 3011 | 3011 | |
| 3012 | 3012 | if ( ! class_exists( 'TGMPA_Bulk_Installer' ) ) { |
@@ -3073,11 +3073,11 @@ discard block |
||
| 3073 | 3073 | */ |
| 3074 | 3074 | public function __construct( $skin = null ) { |
| 3075 | 3075 | // Get TGMPA class instance. |
| 3076 | - $this->tgmpa = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) ); |
|
| 3076 | + $this->tgmpa = call_user_func( array( get_class( $GLOBALS[ 'tgmpa' ] ), 'get_instance' ) ); |
|
| 3077 | 3077 | |
| 3078 | 3078 | parent::__construct( $skin ); |
| 3079 | 3079 | |
| 3080 | - if ( isset( $this->skin->options['install_type'] ) && 'update' === $this->skin->options['install_type'] ) { |
|
| 3080 | + if ( isset( $this->skin->options[ 'install_type' ] ) && 'update' === $this->skin->options[ 'install_type' ] ) { |
|
| 3081 | 3081 | $this->clear_destination = true; |
| 3082 | 3082 | } |
| 3083 | 3083 | |
@@ -3094,8 +3094,8 @@ discard block |
||
| 3094 | 3094 | * @since 2.2.0 |
| 3095 | 3095 | */ |
| 3096 | 3096 | public function activate_strings() { |
| 3097 | - $this->strings['activation_failed'] = __( 'Plugin activation failed.', 'tgmpa' ); |
|
| 3098 | - $this->strings['activation_success'] = __( 'Plugin activated successfully.', 'tgmpa' ); |
|
| 3097 | + $this->strings[ 'activation_failed' ] = __( 'Plugin activation failed.', 'tgmpa' ); |
|
| 3098 | + $this->strings[ 'activation_success' ] = __( 'Plugin activated successfully.', 'tgmpa' ); |
|
| 3099 | 3099 | } |
| 3100 | 3100 | |
| 3101 | 3101 | /** |
@@ -3113,7 +3113,7 @@ discard block |
||
| 3113 | 3113 | |
| 3114 | 3114 | // Reset the strings in case we changed one during automatic activation. |
| 3115 | 3115 | if ( $this->tgmpa->is_automatic ) { |
| 3116 | - if ( 'update' === $this->skin->options['install_type'] ) { |
|
| 3116 | + if ( 'update' === $this->skin->options[ 'install_type' ] ) { |
|
| 3117 | 3117 | $this->upgrade_strings(); |
| 3118 | 3118 | } else { |
| 3119 | 3119 | $this->install_strings(); |
@@ -3268,7 +3268,7 @@ discard block |
||
| 3268 | 3268 | remove_filter( 'upgrader_post_install', array( $this, 'auto_activate' ), 10 ); |
| 3269 | 3269 | |
| 3270 | 3270 | // Force refresh of plugin update information. |
| 3271 | - wp_clean_plugins_cache( $parsed_args['clear_update_cache'] ); |
|
| 3271 | + wp_clean_plugins_cache( $parsed_args[ 'clear_update_cache' ] ); |
|
| 3272 | 3272 | |
| 3273 | 3273 | return $results; |
| 3274 | 3274 | } |
@@ -3319,13 +3319,13 @@ discard block |
||
| 3319 | 3319 | $activate = activate_plugin( $plugin_info ); |
| 3320 | 3320 | |
| 3321 | 3321 | // Adjust the success string based on the activation result. |
| 3322 | - $this->strings['process_success'] = $this->strings['process_success'] . "<br />\n"; |
|
| 3322 | + $this->strings[ 'process_success' ] = $this->strings[ 'process_success' ]."<br />\n"; |
|
| 3323 | 3323 | |
| 3324 | 3324 | if ( is_wp_error( $activate ) ) { |
| 3325 | 3325 | $this->skin->error( $activate ); |
| 3326 | - $this->strings['process_success'] .= $this->strings['activation_failed']; |
|
| 3326 | + $this->strings[ 'process_success' ] .= $this->strings[ 'activation_failed' ]; |
|
| 3327 | 3327 | } else { |
| 3328 | - $this->strings['process_success'] .= $this->strings['activation_success']; |
|
| 3328 | + $this->strings[ 'process_success' ] .= $this->strings[ 'activation_success' ]; |
|
| 3329 | 3329 | } |
| 3330 | 3330 | } |
| 3331 | 3331 | } |
@@ -3401,7 +3401,7 @@ discard block |
||
| 3401 | 3401 | */ |
| 3402 | 3402 | public function __construct( $args = array() ) { |
| 3403 | 3403 | // Get TGMPA class instance. |
| 3404 | - $this->tgmpa = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) ); |
|
| 3404 | + $this->tgmpa = call_user_func( array( get_class( $GLOBALS[ 'tgmpa' ] ), 'get_instance' ) ); |
|
| 3405 | 3405 | |
| 3406 | 3406 | // Parse default and new args. |
| 3407 | 3407 | $defaults = array( |
@@ -3410,10 +3410,10 @@ discard block |
||
| 3410 | 3410 | 'names' => array(), |
| 3411 | 3411 | 'install_type' => 'install', |
| 3412 | 3412 | ); |
| 3413 | - $args = wp_parse_args( $args, $defaults ); |
|
| 3413 | + $args = wp_parse_args( $args, $defaults ); |
|
| 3414 | 3414 | |
| 3415 | 3415 | // Set plugin names to $this->plugin_names property. |
| 3416 | - $this->plugin_names = $args['names']; |
|
| 3416 | + $this->plugin_names = $args[ 'names' ]; |
|
| 3417 | 3417 | |
| 3418 | 3418 | // Extract the new args. |
| 3419 | 3419 | parent::__construct( $args ); |
@@ -3428,25 +3428,25 @@ discard block |
||
| 3428 | 3428 | * @since 2.2.0 |
| 3429 | 3429 | */ |
| 3430 | 3430 | public function add_strings() { |
| 3431 | - if ( 'update' === $this->options['install_type'] ) { |
|
| 3431 | + if ( 'update' === $this->options[ 'install_type' ] ) { |
|
| 3432 | 3432 | parent::add_strings(); |
| 3433 | - $this->upgrader->strings['skin_before_update_header'] = __( 'Updating Plugin %1$s (%2$d/%3$d)', 'tgmpa' ); |
|
| 3433 | + $this->upgrader->strings[ 'skin_before_update_header' ] = __( 'Updating Plugin %1$s (%2$d/%3$d)', 'tgmpa' ); |
|
| 3434 | 3434 | } else { |
| 3435 | - $this->upgrader->strings['skin_update_failed_error'] = __( 'An error occurred while installing %1$s: <strong>%2$s</strong>.', 'tgmpa' ); |
|
| 3436 | - $this->upgrader->strings['skin_update_failed'] = __( 'The installation of %1$s failed.', 'tgmpa' ); |
|
| 3435 | + $this->upgrader->strings[ 'skin_update_failed_error' ] = __( 'An error occurred while installing %1$s: <strong>%2$s</strong>.', 'tgmpa' ); |
|
| 3436 | + $this->upgrader->strings[ 'skin_update_failed' ] = __( 'The installation of %1$s failed.', 'tgmpa' ); |
|
| 3437 | 3437 | |
| 3438 | 3438 | if ( $this->tgmpa->is_automatic ) { |
| 3439 | 3439 | // Automatic activation strings. |
| 3440 | - $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' ); |
|
| 3441 | - $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>'; |
|
| 3442 | - $this->upgrader->strings['skin_upgrade_end'] = __( 'All installations and activations have been completed.', 'tgmpa' ); |
|
| 3443 | - $this->upgrader->strings['skin_before_update_header'] = __( 'Installing and Activating Plugin %1$s (%2$d/%3$d)', 'tgmpa' ); |
|
| 3440 | + $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' ); |
|
| 3441 | + $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>'; |
|
| 3442 | + $this->upgrader->strings[ 'skin_upgrade_end' ] = __( 'All installations and activations have been completed.', 'tgmpa' ); |
|
| 3443 | + $this->upgrader->strings[ 'skin_before_update_header' ] = __( 'Installing and Activating Plugin %1$s (%2$d/%3$d)', 'tgmpa' ); |
|
| 3444 | 3444 | } else { |
| 3445 | 3445 | // Default installation strings. |
| 3446 | - $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' ); |
|
| 3447 | - $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>'; |
|
| 3448 | - $this->upgrader->strings['skin_upgrade_end'] = __( 'All installations have been completed.', 'tgmpa' ); |
|
| 3449 | - $this->upgrader->strings['skin_before_update_header'] = __( 'Installing Plugin %1$s (%2$d/%3$d)', 'tgmpa' ); |
|
| 3446 | + $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' ); |
|
| 3447 | + $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>'; |
|
| 3448 | + $this->upgrader->strings[ 'skin_upgrade_end' ] = __( 'All installations have been completed.', 'tgmpa' ); |
|
| 3449 | + $this->upgrader->strings[ 'skin_before_update_header' ] = __( 'Installing Plugin %1$s (%2$d/%3$d)', 'tgmpa' ); |
|
| 3450 | 3450 | } |
| 3451 | 3451 | } |
| 3452 | 3452 | } |
@@ -3504,12 +3504,12 @@ discard block |
||
| 3504 | 3504 | if ( $this->tgmpa->is_tgmpa_complete() ) { |
| 3505 | 3505 | // All plugins are active, so we display the complete string and hide the menu to protect users. |
| 3506 | 3506 | echo '<style type="text/css">#adminmenu .wp-submenu li.current { display: none !important; }</style>'; |
| 3507 | - $update_actions['dashboard'] = sprintf( |
|
| 3508 | - esc_html( $this->tgmpa->strings['complete'] ), |
|
| 3509 | - '<a href="' . esc_url( self_admin_url() ) . '">' . esc_html__( 'Return to the Dashboard', 'tgmpa' ) . '</a>' |
|
| 3507 | + $update_actions[ 'dashboard' ] = sprintf( |
|
| 3508 | + esc_html( $this->tgmpa->strings[ 'complete' ] ), |
|
| 3509 | + '<a href="'.esc_url( self_admin_url() ).'">'.esc_html__( 'Return to the Dashboard', 'tgmpa' ).'</a>' |
|
| 3510 | 3510 | ); |
| 3511 | 3511 | } else { |
| 3512 | - $update_actions['tgmpa_page'] = '<a href="' . esc_url( $this->tgmpa->get_tgmpa_url() ) . '" target="_parent">' . esc_html( $this->tgmpa->strings['return'] ) . '</a>'; |
|
| 3512 | + $update_actions[ 'tgmpa_page' ] = '<a href="'.esc_url( $this->tgmpa->get_tgmpa_url() ).'" target="_parent">'.esc_html( $this->tgmpa->strings[ 'return' ] ).'</a>'; |
|
| 3513 | 3513 | } |
| 3514 | 3514 | |
| 3515 | 3515 | /** |
@@ -3599,7 +3599,7 @@ discard block |
||
| 3599 | 3599 | * @return string |
| 3600 | 3600 | */ |
| 3601 | 3601 | public static function wrap_in_em( $string ) { |
| 3602 | - return '<em>' . wp_kses_post( $string ) . '</em>'; |
|
| 3602 | + return '<em>'.wp_kses_post( $string ).'</em>'; |
|
| 3603 | 3603 | } |
| 3604 | 3604 | |
| 3605 | 3605 | /** |
@@ -3613,7 +3613,7 @@ discard block |
||
| 3613 | 3613 | * @return string |
| 3614 | 3614 | */ |
| 3615 | 3615 | public static function wrap_in_strong( $string ) { |
| 3616 | - return '<strong>' . wp_kses_post( $string ) . '</strong>'; |
|
| 3616 | + return '<strong>'.wp_kses_post( $string ).'</strong>'; |
|
| 3617 | 3617 | } |
| 3618 | 3618 | |
| 3619 | 3619 | /** |
@@ -3650,7 +3650,7 @@ discard block |
||
| 3650 | 3650 | */ |
| 3651 | 3651 | protected static function emulate_filter_bool( $value ) { |
| 3652 | 3652 | // @codingStandardsIgnoreStart |
| 3653 | - static $true = array( |
|
| 3653 | + static $true = array( |
|
| 3654 | 3654 | '1', |
| 3655 | 3655 | 'true', 'True', 'TRUE', |
| 3656 | 3656 | 'y', 'Y', |