@@ -1892,7 +1892,7 @@ discard block |
||
1892 | 1892 | * |
1893 | 1893 | * @since 2.4.0 |
1894 | 1894 | * |
1895 | - * @return object The TGM_Plugin_Activation object. |
|
1895 | + * @return TGM_Plugin_Activation The TGM_Plugin_Activation object. |
|
1896 | 1896 | */ |
1897 | 1897 | public static function get_instance() { |
1898 | 1898 | if ( ! isset( self::$instance ) && ! ( self::$instance instanceof self ) ) { |
@@ -2049,7 +2049,7 @@ discard block |
||
2049 | 2049 | * |
2050 | 2050 | * @since 2.5.0 |
2051 | 2051 | * |
2052 | - * @return array CSS classnames. |
|
2052 | + * @return string[] CSS classnames. |
|
2053 | 2053 | */ |
2054 | 2054 | public function get_table_classes() { |
2055 | 2055 | return array( 'widefat', 'fixed' ); |
@@ -971,7 +971,8 @@ discard block |
||
971 | 971 | if ( ! $automatic ) { |
972 | 972 | // Make sure message doesn't display again if bulk activation is performed |
973 | 973 | // immediately after a single activation. |
974 | - if ( ! isset( $_POST['action'] ) ) { // WPCS: CSRF OK. |
|
974 | + if ( ! isset( $_POST['action'] ) ) { |
|
975 | +// WPCS: CSRF OK. |
|
975 | 976 | echo '<div id="message" class="updated"><p>', esc_html( $this->strings['activated_successfully'] ), ' <strong>', esc_html( $this->plugins[ $slug ]['name'] ), '.</strong></p></div>'; |
976 | 977 | } |
977 | 978 | } else { |
@@ -992,7 +993,8 @@ discard block |
||
992 | 993 | if ( ! $automatic ) { |
993 | 994 | // Make sure message doesn't display again if bulk activation is performed |
994 | 995 | // immediately after a single activation. |
995 | - if ( ! isset( $_POST['action'] ) ) { // WPCS: CSRF OK. |
|
996 | + if ( ! isset( $_POST['action'] ) ) { |
|
997 | +// WPCS: CSRF OK. |
|
996 | 998 | echo '<div id="message" class="error"><p>', |
997 | 999 | sprintf( |
998 | 1000 | esc_html( $this->strings['plugin_needs_higher_version'] ), |
@@ -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 ) ); |
@@ -455,10 +455,10 @@ discard block |
||
455 | 455 | if ( false !== strpos( __FILE__, WP_PLUGIN_DIR ) || false !== strpos( __FILE__, WPMU_PLUGIN_DIR ) ) { |
456 | 456 | // Plugin, we'll need to adjust the file name. |
457 | 457 | add_action( 'load_textdomain_mofile', array( $this, 'correct_plugin_mofile' ), 10, 2 ); |
458 | - load_theme_textdomain( 'tgmpa', dirname( __FILE__ ) . '/languages' ); |
|
458 | + load_theme_textdomain( 'tgmpa', dirname( __FILE__ ).'/languages' ); |
|
459 | 459 | remove_action( 'load_textdomain_mofile', array( $this, 'correct_plugin_mofile' ), 10 ); |
460 | 460 | } else { |
461 | - load_theme_textdomain( 'tgmpa', dirname( __FILE__ ) . '/languages' ); |
|
461 | + load_theme_textdomain( 'tgmpa', dirname( __FILE__ ).'/languages' ); |
|
462 | 462 | } |
463 | 463 | } |
464 | 464 | |
@@ -531,15 +531,15 @@ discard block |
||
531 | 531 | public function add_plugin_action_link_filters() { |
532 | 532 | foreach ( $this->plugins as $slug => $plugin ) { |
533 | 533 | if ( false === $this->can_plugin_activate( $slug ) ) { |
534 | - add_filter( 'plugin_action_links_' . $plugin['file_path'], array( $this, 'filter_plugin_action_links_activate' ), 20 ); |
|
534 | + add_filter( 'plugin_action_links_'.$plugin[ 'file_path' ], array( $this, 'filter_plugin_action_links_activate' ), 20 ); |
|
535 | 535 | } |
536 | 536 | |
537 | - if ( true === $plugin['force_activation'] ) { |
|
538 | - add_filter( 'plugin_action_links_' . $plugin['file_path'], array( $this, 'filter_plugin_action_links_deactivate' ), 20 ); |
|
537 | + if ( true === $plugin[ 'force_activation' ] ) { |
|
538 | + add_filter( 'plugin_action_links_'.$plugin[ 'file_path' ], array( $this, 'filter_plugin_action_links_deactivate' ), 20 ); |
|
539 | 539 | } |
540 | 540 | |
541 | 541 | if ( false !== $this->does_plugin_require_update( $slug ) ) { |
542 | - add_filter( 'plugin_action_links_' . $plugin['file_path'], array( $this, 'filter_plugin_action_links_update' ), 20 ); |
|
542 | + add_filter( 'plugin_action_links_'.$plugin[ 'file_path' ], array( $this, 'filter_plugin_action_links_update' ), 20 ); |
|
543 | 543 | } |
544 | 544 | } |
545 | 545 | } |
@@ -554,7 +554,7 @@ discard block |
||
554 | 554 | * @return array |
555 | 555 | */ |
556 | 556 | public function filter_plugin_action_links_activate( $actions ) { |
557 | - unset( $actions['activate'] ); |
|
557 | + unset( $actions[ 'activate' ] ); |
|
558 | 558 | |
559 | 559 | return $actions; |
560 | 560 | } |
@@ -568,7 +568,7 @@ discard block |
||
568 | 568 | * @return array |
569 | 569 | */ |
570 | 570 | public function filter_plugin_action_links_deactivate( $actions ) { |
571 | - unset( $actions['deactivate'] ); |
|
571 | + unset( $actions[ 'deactivate' ] ); |
|
572 | 572 | |
573 | 573 | return $actions; |
574 | 574 | } |
@@ -583,7 +583,7 @@ discard block |
||
583 | 583 | * @return array |
584 | 584 | */ |
585 | 585 | public function filter_plugin_action_links_update( $actions ) { |
586 | - $actions['update'] = sprintf( |
|
586 | + $actions[ 'update' ] = sprintf( |
|
587 | 587 | '<a href="%1$s" title="%2$s" class="edit">%3$s</a>', |
588 | 588 | esc_url( $this->get_tgmpa_status_url( 'update' ) ), |
589 | 589 | esc_attr__( 'This plugin needs to be updated to be compatible with your theme.', 'tgmpa' ), |
@@ -621,9 +621,9 @@ discard block |
||
621 | 621 | return; |
622 | 622 | } |
623 | 623 | |
624 | - if ( isset( $_REQUEST['tab'] ) && 'plugin-information' === $_REQUEST['tab'] ) { |
|
624 | + if ( isset( $_REQUEST[ 'tab' ] ) && 'plugin-information' === $_REQUEST[ 'tab' ] ) { |
|
625 | 625 | // Needed for install_plugin_information(). |
626 | - require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; |
|
626 | + require_once ABSPATH.'wp-admin/includes/plugin-install.php'; |
|
627 | 627 | |
628 | 628 | wp_enqueue_style( 'plugin-install' ); |
629 | 629 | |
@@ -651,7 +651,7 @@ discard block |
||
651 | 651 | * @since 2.1.0 |
652 | 652 | */ |
653 | 653 | public function thickbox() { |
654 | - if ( ! get_user_meta( get_current_user_id(), 'tgmpa_dismissed_notice_' . $this->id, true ) ) { |
|
654 | + if ( ! get_user_meta( get_current_user_id(), 'tgmpa_dismissed_notice_'.$this->id, true ) ) { |
|
655 | 655 | add_thickbox(); |
656 | 656 | } |
657 | 657 | } |
@@ -680,11 +680,11 @@ discard block |
||
680 | 680 | $args = apply_filters( |
681 | 681 | 'tgmpa_admin_menu_args', |
682 | 682 | array( |
683 | - 'parent_slug' => $this->parent_slug, // Parent Menu slug. |
|
684 | - 'page_title' => $this->strings['page_title'], // Page title. |
|
685 | - 'menu_title' => $this->strings['menu_title'], // Menu title. |
|
686 | - 'capability' => $this->capability, // Capability. |
|
687 | - 'menu_slug' => $this->menu, // Menu slug. |
|
683 | + 'parent_slug' => $this->parent_slug, // Parent Menu slug. |
|
684 | + 'page_title' => $this->strings[ 'page_title' ], // Page title. |
|
685 | + 'menu_title' => $this->strings[ 'menu_title' ], // Menu title. |
|
686 | + 'capability' => $this->capability, // Capability. |
|
687 | + 'menu_slug' => $this->menu, // Menu slug. |
|
688 | 688 | 'function' => array( $this, 'install_plugins_page' ), // Callback. |
689 | 689 | ) |
690 | 690 | ); |
@@ -705,10 +705,10 @@ discard block |
||
705 | 705 | } |
706 | 706 | |
707 | 707 | if ( 'themes.php' === $this->parent_slug ) { |
708 | - $this->page_hook = call_user_func( 'add_theme_page', $args['page_title'], $args['menu_title'], $args['capability'], $args['menu_slug'], $args['function'] ); |
|
708 | + $this->page_hook = call_user_func( 'add_theme_page', $args[ 'page_title' ], $args[ 'menu_title' ], $args[ 'capability' ], $args[ 'menu_slug' ], $args[ 'function' ] ); |
|
709 | 709 | } else { |
710 | 710 | $type = 'submenu'; |
711 | - $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'] ); |
|
711 | + $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' ] ); |
|
712 | 712 | } |
713 | 713 | } |
714 | 714 | |
@@ -777,37 +777,37 @@ discard block |
||
777 | 777 | * @return boolean True on success, false on failure. |
778 | 778 | */ |
779 | 779 | protected function do_plugin_install() { |
780 | - if ( empty( $_GET['plugin'] ) ) { |
|
780 | + if ( empty( $_GET[ 'plugin' ] ) ) { |
|
781 | 781 | return false; |
782 | 782 | } |
783 | 783 | |
784 | 784 | // All plugin information will be stored in an array for processing. |
785 | - $slug = $this->sanitize_key( urldecode( $_GET['plugin'] ) ); |
|
785 | + $slug = $this->sanitize_key( urldecode( $_GET[ 'plugin' ] ) ); |
|
786 | 786 | |
787 | 787 | if ( ! isset( $this->plugins[ $slug ] ) ) { |
788 | 788 | return false; |
789 | 789 | } |
790 | 790 | |
791 | 791 | // Was an install or upgrade action link clicked? |
792 | - if ( ( isset( $_GET['tgmpa-install'] ) && 'install-plugin' === $_GET['tgmpa-install'] ) || ( isset( $_GET['tgmpa-update'] ) && 'update-plugin' === $_GET['tgmpa-update'] ) ) { |
|
792 | + if ( ( isset( $_GET[ 'tgmpa-install' ] ) && 'install-plugin' === $_GET[ 'tgmpa-install' ] ) || ( isset( $_GET[ 'tgmpa-update' ] ) && 'update-plugin' === $_GET[ 'tgmpa-update' ] ) ) { |
|
793 | 793 | |
794 | 794 | $install_type = 'install'; |
795 | - if ( isset( $_GET['tgmpa-update'] ) && 'update-plugin' === $_GET['tgmpa-update'] ) { |
|
795 | + if ( isset( $_GET[ 'tgmpa-update' ] ) && 'update-plugin' === $_GET[ 'tgmpa-update' ] ) { |
|
796 | 796 | $install_type = 'update'; |
797 | 797 | } |
798 | 798 | |
799 | - check_admin_referer( 'tgmpa-' . $install_type, 'tgmpa-nonce' ); |
|
799 | + check_admin_referer( 'tgmpa-'.$install_type, 'tgmpa-nonce' ); |
|
800 | 800 | |
801 | 801 | // Pass necessary information via URL if WP_Filesystem is needed. |
802 | 802 | $url = wp_nonce_url( |
803 | 803 | add_query_arg( |
804 | 804 | array( |
805 | 805 | 'plugin' => urlencode( $slug ), |
806 | - 'tgmpa-' . $install_type => $install_type . '-plugin', |
|
806 | + 'tgmpa-'.$install_type => $install_type.'-plugin', |
|
807 | 807 | ), |
808 | 808 | $this->get_tgmpa_url() |
809 | 809 | ), |
810 | - 'tgmpa-' . $install_type, |
|
810 | + 'tgmpa-'.$install_type, |
|
811 | 811 | 'tgmpa-nonce' |
812 | 812 | ); |
813 | 813 | |
@@ -826,29 +826,29 @@ discard block |
||
826 | 826 | |
827 | 827 | // Prep variables for Plugin_Installer_Skin class. |
828 | 828 | $extra = array(); |
829 | - $extra['slug'] = $slug; // Needed for potentially renaming of directory name. |
|
829 | + $extra[ 'slug' ] = $slug; // Needed for potentially renaming of directory name. |
|
830 | 830 | $source = $this->get_download_url( $slug ); |
831 | - $api = ( 'repo' === $this->plugins[ $slug ]['source_type'] ) ? $this->get_plugins_api( $slug ) : null; |
|
831 | + $api = ( 'repo' === $this->plugins[ $slug ][ 'source_type' ] ) ? $this->get_plugins_api( $slug ) : null; |
|
832 | 832 | $api = ( false !== $api ) ? $api : null; |
833 | 833 | |
834 | 834 | $url = add_query_arg( |
835 | 835 | array( |
836 | - 'action' => $install_type . '-plugin', |
|
836 | + 'action' => $install_type.'-plugin', |
|
837 | 837 | 'plugin' => urlencode( $slug ), |
838 | 838 | ), |
839 | 839 | 'update.php' |
840 | 840 | ); |
841 | 841 | |
842 | 842 | if ( ! class_exists( 'Plugin_Upgrader', false ) ) { |
843 | - require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
|
843 | + require_once ABSPATH.'wp-admin/includes/class-wp-upgrader.php'; |
|
844 | 844 | } |
845 | 845 | |
846 | - $title = ( 'update' === $install_type ) ? $this->strings['updating'] : $this->strings['installing']; |
|
846 | + $title = ( 'update' === $install_type ) ? $this->strings[ 'updating' ] : $this->strings[ 'installing' ]; |
|
847 | 847 | $skin_args = array( |
848 | - 'type' => ( 'bundled' !== $this->plugins[ $slug ]['source_type'] ) ? 'web' : 'upload', |
|
849 | - 'title' => sprintf( $title, $this->plugins[ $slug ]['name'] ), |
|
848 | + 'type' => ( 'bundled' !== $this->plugins[ $slug ][ 'source_type' ] ) ? 'web' : 'upload', |
|
849 | + 'title' => sprintf( $title, $this->plugins[ $slug ][ 'name' ] ), |
|
850 | 850 | 'url' => esc_url_raw( $url ), |
851 | - 'nonce' => $install_type . '-plugin_' . $slug, |
|
851 | + 'nonce' => $install_type.'-plugin_'.$slug, |
|
852 | 852 | 'plugin' => '', |
853 | 853 | 'api' => $api, |
854 | 854 | 'extra' => $extra, |
@@ -856,7 +856,7 @@ discard block |
||
856 | 856 | unset( $title ); |
857 | 857 | |
858 | 858 | if ( 'update' === $install_type ) { |
859 | - $skin_args['plugin'] = $this->plugins[ $slug ]['file_path']; |
|
859 | + $skin_args[ 'plugin' ] = $this->plugins[ $slug ][ 'file_path' ]; |
|
860 | 860 | $skin = new Plugin_Upgrader_Skin( $skin_args ); |
861 | 861 | } else { |
862 | 862 | $skin = new Plugin_Installer_Skin( $skin_args ); |
@@ -871,10 +871,10 @@ discard block |
||
871 | 871 | if ( 'update' === $install_type ) { |
872 | 872 | // Inject our info into the update transient. |
873 | 873 | $to_inject = array( $slug => $this->plugins[ $slug ] ); |
874 | - $to_inject[ $slug ]['source'] = $source; |
|
874 | + $to_inject[ $slug ][ 'source' ] = $source; |
|
875 | 875 | $this->inject_update_info( $to_inject ); |
876 | 876 | |
877 | - $upgrader->upgrade( $this->plugins[ $slug ]['file_path'] ); |
|
877 | + $upgrader->upgrade( $this->plugins[ $slug ][ 'file_path' ] ); |
|
878 | 878 | } else { |
879 | 879 | $upgrader->install( $source ); |
880 | 880 | } |
@@ -897,18 +897,18 @@ discard block |
||
897 | 897 | |
898 | 898 | // Display message based on if all plugins are now active or not. |
899 | 899 | if ( $this->is_tgmpa_complete() ) { |
900 | - echo '<p>', sprintf( esc_html( $this->strings['complete'] ), '<a href="' . esc_url( self_admin_url() ) . '">' . esc_html__( 'Return to the Dashboard', 'tgmpa' ) . '</a>' ), '</p>'; |
|
900 | + echo '<p>', sprintf( esc_html( $this->strings[ 'complete' ] ), '<a href="'.esc_url( self_admin_url() ).'">'.esc_html__( 'Return to the Dashboard', 'tgmpa' ).'</a>' ), '</p>'; |
|
901 | 901 | echo '<style type="text/css">#adminmenu .wp-submenu li.current { display: none !important; }</style>'; |
902 | 902 | } else { |
903 | - echo '<p><a href="', esc_url( $this->get_tgmpa_url() ), '" target="_parent">', esc_html( $this->strings['return'] ), '</a></p>'; |
|
903 | + echo '<p><a href="', esc_url( $this->get_tgmpa_url() ), '" target="_parent">', esc_html( $this->strings[ 'return' ] ), '</a></p>'; |
|
904 | 904 | } |
905 | 905 | |
906 | 906 | return true; |
907 | - } elseif ( isset( $this->plugins[ $slug ]['file_path'], $_GET['tgmpa-activate'] ) && 'activate-plugin' === $_GET['tgmpa-activate'] ) { |
|
907 | + } elseif ( isset( $this->plugins[ $slug ][ 'file_path' ], $_GET[ 'tgmpa-activate' ] ) && 'activate-plugin' === $_GET[ 'tgmpa-activate' ] ) { |
|
908 | 908 | // Activate action link was clicked. |
909 | 909 | check_admin_referer( 'tgmpa-activate', 'tgmpa-nonce' ); |
910 | 910 | |
911 | - if ( false === $this->activate_single_plugin( $this->plugins[ $slug ]['file_path'], $slug ) ) { |
|
911 | + if ( false === $this->activate_single_plugin( $this->plugins[ $slug ][ 'file_path' ], $slug ) ) { |
|
912 | 912 | return true; // Finish execution of the function early as we encountered an error. |
913 | 913 | } |
914 | 914 | } |
@@ -931,7 +931,7 @@ discard block |
||
931 | 931 | } |
932 | 932 | |
933 | 933 | foreach ( $plugins as $slug => $plugin ) { |
934 | - $file_path = $plugin['file_path']; |
|
934 | + $file_path = $plugin[ 'file_path' ]; |
|
935 | 935 | |
936 | 936 | if ( empty( $repo_updates->response[ $file_path ] ) ) { |
937 | 937 | $repo_updates->response[ $file_path ] = new stdClass; |
@@ -940,10 +940,10 @@ discard block |
||
940 | 940 | // We only really need to set package, but let's do all we can in case WP changes something. |
941 | 941 | $repo_updates->response[ $file_path ]->slug = $slug; |
942 | 942 | $repo_updates->response[ $file_path ]->plugin = $file_path; |
943 | - $repo_updates->response[ $file_path ]->new_version = $plugin['version']; |
|
944 | - $repo_updates->response[ $file_path ]->package = $plugin['source']; |
|
945 | - if ( empty( $repo_updates->response[ $file_path ]->url ) && ! empty( $plugin['external_url'] ) ) { |
|
946 | - $repo_updates->response[ $file_path ]->url = $plugin['external_url']; |
|
943 | + $repo_updates->response[ $file_path ]->new_version = $plugin[ 'version' ]; |
|
944 | + $repo_updates->response[ $file_path ]->package = $plugin[ 'source' ]; |
|
945 | + if ( empty( $repo_updates->response[ $file_path ]->url ) && ! empty( $plugin[ 'external_url' ] ) ) { |
|
946 | + $repo_updates->response[ $file_path ]->url = $plugin[ 'external_url' ]; |
|
947 | 947 | } |
948 | 948 | } |
949 | 949 | |
@@ -967,13 +967,13 @@ discard block |
||
967 | 967 | * @return string $source |
968 | 968 | */ |
969 | 969 | public function maybe_adjust_source_dir( $source, $remote_source, $upgrader ) { |
970 | - if ( ! $this->is_tgmpa_page() || ! is_object( $GLOBALS['wp_filesystem'] ) ) { |
|
970 | + if ( ! $this->is_tgmpa_page() || ! is_object( $GLOBALS[ 'wp_filesystem' ] ) ) { |
|
971 | 971 | return $source; |
972 | 972 | } |
973 | 973 | |
974 | 974 | // Check for single file plugins. |
975 | - $source_files = array_keys( $GLOBALS['wp_filesystem']->dirlist( $remote_source ) ); |
|
976 | - if ( 1 === count( $source_files ) && false === $GLOBALS['wp_filesystem']->is_dir( $source ) ) { |
|
975 | + $source_files = array_keys( $GLOBALS[ 'wp_filesystem' ]->dirlist( $remote_source ) ); |
|
976 | + if ( 1 === count( $source_files ) && false === $GLOBALS[ 'wp_filesystem' ]->is_dir( $source ) ) { |
|
977 | 977 | return $source; |
978 | 978 | } |
979 | 979 | |
@@ -981,12 +981,12 @@ discard block |
||
981 | 981 | $desired_slug = ''; |
982 | 982 | |
983 | 983 | // Figure out what the slug is supposed to be. |
984 | - if ( false === $upgrader->bulk && ! empty( $upgrader->skin->options['extra']['slug'] ) ) { |
|
985 | - $desired_slug = $upgrader->skin->options['extra']['slug']; |
|
984 | + if ( false === $upgrader->bulk && ! empty( $upgrader->skin->options[ 'extra' ][ 'slug' ] ) ) { |
|
985 | + $desired_slug = $upgrader->skin->options[ 'extra' ][ 'slug' ]; |
|
986 | 986 | } else { |
987 | 987 | // Bulk installer contains less info, so fall back on the info registered here. |
988 | 988 | foreach ( $this->plugins as $slug => $plugin ) { |
989 | - if ( ! empty( $upgrader->skin->plugin_names[ $upgrader->skin->i ] ) && $plugin['name'] === $upgrader->skin->plugin_names[ $upgrader->skin->i ] ) { |
|
989 | + if ( ! empty( $upgrader->skin->plugin_names[ $upgrader->skin->i ] ) && $plugin[ 'name' ] === $upgrader->skin->plugin_names[ $upgrader->skin->i ] ) { |
|
990 | 990 | $desired_slug = $slug; |
991 | 991 | break; |
992 | 992 | } |
@@ -999,15 +999,15 @@ discard block |
||
999 | 999 | |
1000 | 1000 | if ( ! empty( $subdir_name ) && $subdir_name !== $desired_slug ) { |
1001 | 1001 | $from = untrailingslashit( $source ); |
1002 | - $to = trailingslashit( $remote_source ) . $desired_slug; |
|
1002 | + $to = trailingslashit( $remote_source ).$desired_slug; |
|
1003 | 1003 | |
1004 | - if ( true === $GLOBALS['wp_filesystem']->move( $from, $to ) ) { |
|
1004 | + if ( true === $GLOBALS[ 'wp_filesystem' ]->move( $from, $to ) ) { |
|
1005 | 1005 | return trailingslashit( $to ); |
1006 | 1006 | } else { |
1007 | - 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 ) ); |
|
1007 | + 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 ) ); |
|
1008 | 1008 | } |
1009 | 1009 | } elseif ( empty( $subdir_name ) ) { |
1010 | - 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 ) ); |
|
1010 | + 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 ) ); |
|
1011 | 1011 | } |
1012 | 1012 | } |
1013 | 1013 | |
@@ -1031,19 +1031,19 @@ discard block |
||
1031 | 1031 | |
1032 | 1032 | if ( is_wp_error( $activate ) ) { |
1033 | 1033 | echo '<div id="message" class="error"><p>', wp_kses_post( $activate->get_error_message() ), '</p></div>', |
1034 | - '<p><a href="', esc_url( $this->get_tgmpa_url() ), '" target="_parent">', esc_html( $this->strings['return'] ), '</a></p>'; |
|
1034 | + '<p><a href="', esc_url( $this->get_tgmpa_url() ), '" target="_parent">', esc_html( $this->strings[ 'return' ] ), '</a></p>'; |
|
1035 | 1035 | |
1036 | 1036 | return false; // End it here if there is an error with activation. |
1037 | 1037 | } else { |
1038 | 1038 | if ( ! $automatic ) { |
1039 | 1039 | // Make sure message doesn't display again if bulk activation is performed |
1040 | 1040 | // immediately after a single activation. |
1041 | - if ( ! isset( $_POST['action'] ) ) { // WPCS: CSRF OK. |
|
1042 | - echo '<div id="message" class="updated"><p>', esc_html( $this->strings['activated_successfully'] ), ' <strong>', esc_html( $this->plugins[ $slug ]['name'] ), '.</strong></p></div>'; |
|
1041 | + if ( ! isset( $_POST[ 'action' ] ) ) { // WPCS: CSRF OK. |
|
1042 | + echo '<div id="message" class="updated"><p>', esc_html( $this->strings[ 'activated_successfully' ] ), ' <strong>', esc_html( $this->plugins[ $slug ][ 'name' ] ), '.</strong></p></div>'; |
|
1043 | 1043 | } |
1044 | 1044 | } else { |
1045 | 1045 | // Simpler message layout for use on the plugin install page. |
1046 | - echo '<p>', esc_html( $this->strings['plugin_activated'] ), '</p>'; |
|
1046 | + echo '<p>', esc_html( $this->strings[ 'plugin_activated' ] ), '</p>'; |
|
1047 | 1047 | } |
1048 | 1048 | } |
1049 | 1049 | } elseif ( $this->is_plugin_active( $slug ) ) { |
@@ -1051,25 +1051,25 @@ discard block |
||
1051 | 1051 | // on the plugin install page. |
1052 | 1052 | echo '<div id="message" class="error"><p>', |
1053 | 1053 | sprintf( |
1054 | - esc_html( $this->strings['plugin_already_active'] ), |
|
1055 | - '<strong>' . esc_html( $this->plugins[ $slug ]['name'] ) . '</strong>' |
|
1054 | + esc_html( $this->strings[ 'plugin_already_active' ] ), |
|
1055 | + '<strong>'.esc_html( $this->plugins[ $slug ][ 'name' ] ).'</strong>' |
|
1056 | 1056 | ), |
1057 | 1057 | '</p></div>'; |
1058 | 1058 | } elseif ( $this->does_plugin_require_update( $slug ) ) { |
1059 | 1059 | if ( ! $automatic ) { |
1060 | 1060 | // Make sure message doesn't display again if bulk activation is performed |
1061 | 1061 | // immediately after a single activation. |
1062 | - if ( ! isset( $_POST['action'] ) ) { // WPCS: CSRF OK. |
|
1062 | + if ( ! isset( $_POST[ 'action' ] ) ) { // WPCS: CSRF OK. |
|
1063 | 1063 | echo '<div id="message" class="error"><p>', |
1064 | 1064 | sprintf( |
1065 | - esc_html( $this->strings['plugin_needs_higher_version'] ), |
|
1066 | - '<strong>' . esc_html( $this->plugins[ $slug ]['name'] ) . '</strong>' |
|
1065 | + esc_html( $this->strings[ 'plugin_needs_higher_version' ] ), |
|
1066 | + '<strong>'.esc_html( $this->plugins[ $slug ][ 'name' ] ).'</strong>' |
|
1067 | 1067 | ), |
1068 | 1068 | '</p></div>'; |
1069 | 1069 | } |
1070 | 1070 | } else { |
1071 | 1071 | // Simpler message layout for use on the plugin install page. |
1072 | - echo '<p>', sprintf( esc_html( $this->strings['plugin_needs_higher_version'] ), esc_html( $this->plugins[ $slug ]['name'] ) ), '</p>'; |
|
1072 | + echo '<p>', sprintf( esc_html( $this->strings[ 'plugin_needs_higher_version' ] ), esc_html( $this->plugins[ $slug ][ 'name' ] ) ), '</p>'; |
|
1073 | 1073 | } |
1074 | 1074 | } |
1075 | 1075 | |
@@ -1093,7 +1093,7 @@ discard block |
||
1093 | 1093 | */ |
1094 | 1094 | public function notices() { |
1095 | 1095 | // Remove nag on the install page / Return early if the nag message has been dismissed or user < author. |
1096 | - if ( $this->is_tgmpa_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' ) ) ) { |
|
1096 | + if ( $this->is_tgmpa_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' ) ) ) { |
|
1097 | 1097 | return; |
1098 | 1098 | } |
1099 | 1099 | |
@@ -1115,13 +1115,13 @@ discard block |
||
1115 | 1115 | if ( current_user_can( 'install_plugins' ) ) { |
1116 | 1116 | $install_link_count++; |
1117 | 1117 | |
1118 | - if ( true === $plugin['required'] ) { |
|
1119 | - $message['notice_can_install_required'][] = $slug; |
|
1118 | + if ( true === $plugin[ 'required' ] ) { |
|
1119 | + $message[ 'notice_can_install_required' ][ ] = $slug; |
|
1120 | 1120 | } else { |
1121 | - $message['notice_can_install_recommended'][] = $slug; |
|
1121 | + $message[ 'notice_can_install_recommended' ][ ] = $slug; |
|
1122 | 1122 | } |
1123 | 1123 | } |
1124 | - if ( true === $plugin['required'] ) { |
|
1124 | + if ( true === $plugin[ 'required' ] ) { |
|
1125 | 1125 | $total_required_action_count++; |
1126 | 1126 | } |
1127 | 1127 | } else { |
@@ -1129,13 +1129,13 @@ discard block |
||
1129 | 1129 | if ( current_user_can( 'activate_plugins' ) ) { |
1130 | 1130 | $activate_link_count++; |
1131 | 1131 | |
1132 | - if ( true === $plugin['required'] ) { |
|
1133 | - $message['notice_can_activate_required'][] = $slug; |
|
1132 | + if ( true === $plugin[ 'required' ] ) { |
|
1133 | + $message[ 'notice_can_activate_required' ][ ] = $slug; |
|
1134 | 1134 | } else { |
1135 | - $message['notice_can_activate_recommended'][] = $slug; |
|
1135 | + $message[ 'notice_can_activate_recommended' ][ ] = $slug; |
|
1136 | 1136 | } |
1137 | 1137 | } |
1138 | - if ( true === $plugin['required'] ) { |
|
1138 | + if ( true === $plugin[ 'required' ] ) { |
|
1139 | 1139 | $total_required_action_count++; |
1140 | 1140 | } |
1141 | 1141 | } |
@@ -1146,12 +1146,12 @@ discard block |
||
1146 | 1146 | $update_link_count++; |
1147 | 1147 | |
1148 | 1148 | if ( $this->does_plugin_require_update( $slug ) ) { |
1149 | - $message['notice_ask_to_update'][] = $slug; |
|
1149 | + $message[ 'notice_ask_to_update' ][ ] = $slug; |
|
1150 | 1150 | } elseif ( false !== $this->does_plugin_have_update( $slug ) ) { |
1151 | - $message['notice_ask_to_update_maybe'][] = $slug; |
|
1151 | + $message[ 'notice_ask_to_update_maybe' ][ ] = $slug; |
|
1152 | 1152 | } |
1153 | 1153 | } |
1154 | - if ( true === $plugin['required'] ) { |
|
1154 | + if ( true === $plugin[ 'required' ] ) { |
|
1155 | 1155 | $total_required_action_count++; |
1156 | 1156 | } |
1157 | 1157 | } |
@@ -1166,10 +1166,10 @@ discard block |
||
1166 | 1166 | |
1167 | 1167 | // As add_settings_error() wraps the final message in a <p> and as the final message can't be |
1168 | 1168 | // filtered, using <p>'s in our html would render invalid html output. |
1169 | - $line_template = '<span style="display: block; margin: 0.5em 0.5em 0 0; clear: both;">%s</span>' . "\n"; |
|
1169 | + $line_template = '<span style="display: block; margin: 0.5em 0.5em 0 0; clear: both;">%s</span>'."\n"; |
|
1170 | 1170 | |
1171 | 1171 | if ( ! current_user_can( 'activate_plugins' ) && ! current_user_can( 'install_plugins' ) && ! current_user_can( 'update_plugins' ) ) { |
1172 | - $rendered = esc_html__( $this->strings['notice_cannot_install_activate'] ) . ' ' . esc_html__( $this->strings['contact_admin'] ); |
|
1172 | + $rendered = esc_html__( $this->strings[ 'notice_cannot_install_activate' ] ).' '.esc_html__( $this->strings[ 'contact_admin' ] ); |
|
1173 | 1173 | $rendered .= $this->create_user_action_links_for_notice( 0, 0, 0, $line_template ); |
1174 | 1174 | } else { |
1175 | 1175 | |
@@ -1184,14 +1184,14 @@ discard block |
||
1184 | 1184 | |
1185 | 1185 | // Get the external info link for a plugin if one is available. |
1186 | 1186 | foreach ( $plugin_group as $plugin_slug ) { |
1187 | - $linked_plugins[] = $this->get_info_link( $plugin_slug ); |
|
1187 | + $linked_plugins[ ] = $this->get_info_link( $plugin_slug ); |
|
1188 | 1188 | } |
1189 | 1189 | unset( $plugin_slug ); |
1190 | 1190 | |
1191 | 1191 | $count = count( $plugin_group ); |
1192 | 1192 | $linked_plugins = array_map( array( 'TGMPA_Utils', 'wrap_in_em' ), $linked_plugins ); |
1193 | 1193 | $last_plugin = array_pop( $linked_plugins ); // Pop off last name to prep for readability. |
1194 | - $imploded = empty( $linked_plugins ) ? $last_plugin : ( implode( ', ', $linked_plugins ) . ' ' . esc_html_x( 'and', 'plugin A *and* plugin B', 'tgmpa' ) . ' ' . $last_plugin ); |
|
1194 | + $imploded = empty( $linked_plugins ) ? $last_plugin : ( implode( ', ', $linked_plugins ).' '.esc_html_x( 'and', 'plugin A *and* plugin B', 'tgmpa' ).' '.$last_plugin ); |
|
1195 | 1195 | |
1196 | 1196 | $rendered .= sprintf( |
1197 | 1197 | $line_template, |
@@ -1213,7 +1213,7 @@ discard block |
||
1213 | 1213 | } |
1214 | 1214 | |
1215 | 1215 | // Admin options pages already output settings_errors, so this is to avoid duplication. |
1216 | - if ( 'options-general' !== $GLOBALS['current_screen']->parent_base ) { |
|
1216 | + if ( 'options-general' !== $GLOBALS[ 'current_screen' ]->parent_base ) { |
|
1217 | 1217 | $this->display_settings_errors(); |
1218 | 1218 | } |
1219 | 1219 | } |
@@ -1235,32 +1235,32 @@ discard block |
||
1235 | 1235 | 'install' => '', |
1236 | 1236 | 'update' => '', |
1237 | 1237 | 'activate' => '', |
1238 | - '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>' : '', |
|
1238 | + '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>' : '', |
|
1239 | 1239 | ); |
1240 | 1240 | |
1241 | 1241 | $link_template = '<a href="%2$s">%1$s</a>'; |
1242 | 1242 | |
1243 | 1243 | if ( current_user_can( 'install_plugins' ) ) { |
1244 | 1244 | if ( $install_count > 0 ) { |
1245 | - $action_links['install'] = sprintf( |
|
1245 | + $action_links[ 'install' ] = sprintf( |
|
1246 | 1246 | $link_template, |
1247 | - translate_nooped_plural( $this->strings['install_link'], $install_count, 'tgmpa' ), |
|
1247 | + translate_nooped_plural( $this->strings[ 'install_link' ], $install_count, 'tgmpa' ), |
|
1248 | 1248 | esc_url( $this->get_tgmpa_status_url( 'install' ) ) |
1249 | 1249 | ); |
1250 | 1250 | } |
1251 | 1251 | if ( $update_count > 0 ) { |
1252 | - $action_links['update'] = sprintf( |
|
1252 | + $action_links[ 'update' ] = sprintf( |
|
1253 | 1253 | $link_template, |
1254 | - translate_nooped_plural( $this->strings['update_link'], $update_count, 'tgmpa' ), |
|
1254 | + translate_nooped_plural( $this->strings[ 'update_link' ], $update_count, 'tgmpa' ), |
|
1255 | 1255 | esc_url( $this->get_tgmpa_status_url( 'update' ) ) |
1256 | 1256 | ); |
1257 | 1257 | } |
1258 | 1258 | } |
1259 | 1259 | |
1260 | 1260 | if ( current_user_can( 'activate_plugins' ) && $activate_count > 0 ) { |
1261 | - $action_links['activate'] = sprintf( |
|
1261 | + $action_links[ 'activate' ] = sprintf( |
|
1262 | 1262 | $link_template, |
1263 | - translate_nooped_plural( $this->strings['activate_link'], $activate_count, 'tgmpa' ), |
|
1263 | + translate_nooped_plural( $this->strings[ 'activate_link' ], $activate_count, 'tgmpa' ), |
|
1264 | 1264 | esc_url( $this->get_tgmpa_status_url( 'activate' ) ) |
1265 | 1265 | ); |
1266 | 1266 | } |
@@ -1288,8 +1288,8 @@ discard block |
||
1288 | 1288 | * @return string |
1289 | 1289 | */ |
1290 | 1290 | protected function get_admin_notice_class() { |
1291 | - if ( ! empty( $this->strings['nag_type'] ) ) { |
|
1292 | - return sanitize_html_class( strtolower( $this->strings['nag_type'] ) ); |
|
1291 | + if ( ! empty( $this->strings[ 'nag_type' ] ) ) { |
|
1292 | + return sanitize_html_class( strtolower( $this->strings[ 'nag_type' ] ) ); |
|
1293 | 1293 | } else { |
1294 | 1294 | if ( version_compare( $this->wp_version, '4.2', '>=' ) ) { |
1295 | 1295 | return 'notice-warning'; |
@@ -1312,7 +1312,7 @@ discard block |
||
1312 | 1312 | settings_errors( 'tgmpa' ); |
1313 | 1313 | |
1314 | 1314 | foreach ( (array) $wp_settings_errors as $key => $details ) { |
1315 | - if ( 'tgmpa' === $details['setting'] ) { |
|
1315 | + if ( 'tgmpa' === $details[ 'setting' ] ) { |
|
1316 | 1316 | unset( $wp_settings_errors[ $key ] ); |
1317 | 1317 | break; |
1318 | 1318 | } |
@@ -1327,8 +1327,8 @@ discard block |
||
1327 | 1327 | * @since 2.1.0 |
1328 | 1328 | */ |
1329 | 1329 | public function dismiss() { |
1330 | - if ( isset( $_GET['tgmpa-dismiss'] ) && check_admin_referer( 'tgmpa-dismis-' . get_current_user_id() ) ) { |
|
1331 | - update_user_meta( get_current_user_id(), 'tgmpa_dismissed_notice_' . $this->id, 1 ); |
|
1330 | + if ( isset( $_GET[ 'tgmpa-dismiss' ] ) && check_admin_referer( 'tgmpa-dismis-'.get_current_user_id() ) ) { |
|
1331 | + update_user_meta( get_current_user_id(), 'tgmpa_dismissed_notice_'.$this->id, 1 ); |
|
1332 | 1332 | } |
1333 | 1333 | } |
1334 | 1334 | |
@@ -1344,54 +1344,54 @@ discard block |
||
1344 | 1344 | * @return null Return early if incorrect argument. |
1345 | 1345 | */ |
1346 | 1346 | public function register( $plugin ) { |
1347 | - if ( empty( $plugin['slug'] ) || empty( $plugin['name'] ) ) { |
|
1347 | + if ( empty( $plugin[ 'slug' ] ) || empty( $plugin[ 'name' ] ) ) { |
|
1348 | 1348 | return; |
1349 | 1349 | } |
1350 | 1350 | |
1351 | - if ( empty( $plugin['slug'] ) || ! is_string( $plugin['slug'] ) || isset( $this->plugins[ $plugin['slug'] ] ) ) { |
|
1351 | + if ( empty( $plugin[ 'slug' ] ) || ! is_string( $plugin[ 'slug' ] ) || isset( $this->plugins[ $plugin[ 'slug' ] ] ) ) { |
|
1352 | 1352 | return; |
1353 | 1353 | } |
1354 | 1354 | |
1355 | 1355 | $defaults = array( |
1356 | - 'name' => '', // String |
|
1357 | - 'slug' => '', // String |
|
1358 | - 'source' => 'repo', // String |
|
1359 | - 'required' => false, // Boolean |
|
1360 | - 'version' => '', // String |
|
1361 | - 'force_activation' => false, // Boolean |
|
1362 | - 'force_deactivation' => false, // Boolean |
|
1363 | - 'external_url' => '', // String |
|
1364 | - 'is_callable' => '', // String|Array. |
|
1356 | + 'name' => '', // String |
|
1357 | + 'slug' => '', // String |
|
1358 | + 'source' => 'repo', // String |
|
1359 | + 'required' => false, // Boolean |
|
1360 | + 'version' => '', // String |
|
1361 | + 'force_activation' => false, // Boolean |
|
1362 | + 'force_deactivation' => false, // Boolean |
|
1363 | + 'external_url' => '', // String |
|
1364 | + 'is_callable' => '', // String|Array. |
|
1365 | 1365 | ); |
1366 | 1366 | |
1367 | 1367 | // Prepare the received data. |
1368 | 1368 | $plugin = wp_parse_args( $plugin, $defaults ); |
1369 | 1369 | |
1370 | 1370 | // Standardize the received slug. |
1371 | - $plugin['slug'] = $this->sanitize_key( $plugin['slug'] ); |
|
1371 | + $plugin[ 'slug' ] = $this->sanitize_key( $plugin[ 'slug' ] ); |
|
1372 | 1372 | |
1373 | 1373 | // Forgive users for using string versions of booleans or floats for version number. |
1374 | - $plugin['version'] = (string) $plugin['version']; |
|
1375 | - $plugin['source'] = empty( $plugin['source'] ) ? 'repo' : $plugin['source']; |
|
1376 | - $plugin['required'] = TGMPA_Utils::validate_bool( $plugin['required'] ); |
|
1377 | - $plugin['force_activation'] = TGMPA_Utils::validate_bool( $plugin['force_activation'] ); |
|
1378 | - $plugin['force_deactivation'] = TGMPA_Utils::validate_bool( $plugin['force_deactivation'] ); |
|
1374 | + $plugin[ 'version' ] = (string) $plugin[ 'version' ]; |
|
1375 | + $plugin[ 'source' ] = empty( $plugin[ 'source' ] ) ? 'repo' : $plugin[ 'source' ]; |
|
1376 | + $plugin[ 'required' ] = TGMPA_Utils::validate_bool( $plugin[ 'required' ] ); |
|
1377 | + $plugin[ 'force_activation' ] = TGMPA_Utils::validate_bool( $plugin[ 'force_activation' ] ); |
|
1378 | + $plugin[ 'force_deactivation' ] = TGMPA_Utils::validate_bool( $plugin[ 'force_deactivation' ] ); |
|
1379 | 1379 | |
1380 | 1380 | // Enrich the received data. |
1381 | - $plugin['file_path'] = $this->_get_plugin_basename_from_slug( $plugin['slug'] ); |
|
1382 | - $plugin['source_type'] = $this->get_plugin_source_type( $plugin['source'] ); |
|
1381 | + $plugin[ 'file_path' ] = $this->_get_plugin_basename_from_slug( $plugin[ 'slug' ] ); |
|
1382 | + $plugin[ 'source_type' ] = $this->get_plugin_source_type( $plugin[ 'source' ] ); |
|
1383 | 1383 | |
1384 | 1384 | // Set the class properties. |
1385 | - $this->plugins[ $plugin['slug'] ] = $plugin; |
|
1386 | - $this->sort_order[ $plugin['slug'] ] = $plugin['name']; |
|
1385 | + $this->plugins[ $plugin[ 'slug' ] ] = $plugin; |
|
1386 | + $this->sort_order[ $plugin[ 'slug' ] ] = $plugin[ 'name' ]; |
|
1387 | 1387 | |
1388 | 1388 | // Should we add the force activation hook ? |
1389 | - if ( true === $plugin['force_activation'] ) { |
|
1389 | + if ( true === $plugin[ 'force_activation' ] ) { |
|
1390 | 1390 | $this->has_forced_activation = true; |
1391 | 1391 | } |
1392 | 1392 | |
1393 | 1393 | // Should we add the force deactivation hook ? |
1394 | - if ( true === $plugin['force_deactivation'] ) { |
|
1394 | + if ( true === $plugin[ 'force_deactivation' ] ) { |
|
1395 | 1395 | $this->has_forced_deactivation = true; |
1396 | 1396 | } |
1397 | 1397 | } |
@@ -1517,11 +1517,11 @@ discard block |
||
1517 | 1517 | */ |
1518 | 1518 | public function populate_file_path( $plugin_slug = '' ) { |
1519 | 1519 | if ( ! empty( $plugin_slug ) && is_string( $plugin_slug ) && isset( $this->plugins[ $plugin_slug ] ) ) { |
1520 | - $this->plugins[ $plugin_slug ]['file_path'] = $this->_get_plugin_basename_from_slug( $plugin_slug ); |
|
1520 | + $this->plugins[ $plugin_slug ][ 'file_path' ] = $this->_get_plugin_basename_from_slug( $plugin_slug ); |
|
1521 | 1521 | } else { |
1522 | 1522 | // Add file_path key for all plugins. |
1523 | 1523 | foreach ( $this->plugins as $slug => $values ) { |
1524 | - $this->plugins[ $slug ]['file_path'] = $this->_get_plugin_basename_from_slug( $slug ); |
|
1524 | + $this->plugins[ $slug ][ 'file_path' ] = $this->_get_plugin_basename_from_slug( $slug ); |
|
1525 | 1525 | } |
1526 | 1526 | } |
1527 | 1527 | } |
@@ -1539,7 +1539,7 @@ discard block |
||
1539 | 1539 | $keys = array_keys( $this->get_plugins() ); |
1540 | 1540 | |
1541 | 1541 | foreach ( $keys as $key ) { |
1542 | - if ( preg_match( '|^' . $slug . '/|', $key ) ) { |
|
1542 | + if ( preg_match( '|^'.$slug.'/|', $key ) ) { |
|
1543 | 1543 | return $key; |
1544 | 1544 | } |
1545 | 1545 | } |
@@ -1561,7 +1561,7 @@ discard block |
||
1561 | 1561 | */ |
1562 | 1562 | public function _get_plugin_data_from_name( $name, $data = 'slug' ) { |
1563 | 1563 | foreach ( $this->plugins as $values ) { |
1564 | - if ( $name === $values['name'] && isset( $values[ $data ] ) ) { |
|
1564 | + if ( $name === $values[ 'name' ] && isset( $values[ $data ] ) ) { |
|
1565 | 1565 | return $values[ $data ]; |
1566 | 1566 | } |
1567 | 1567 | } |
@@ -1580,13 +1580,13 @@ discard block |
||
1580 | 1580 | public function get_download_url( $slug ) { |
1581 | 1581 | $dl_source = ''; |
1582 | 1582 | |
1583 | - switch ( $this->plugins[ $slug ]['source_type'] ) { |
|
1583 | + switch ( $this->plugins[ $slug ][ 'source_type' ] ) { |
|
1584 | 1584 | case 'repo': |
1585 | 1585 | return $this->get_wp_repo_download_url( $slug ); |
1586 | 1586 | case 'external': |
1587 | - return $this->plugins[ $slug ]['source']; |
|
1587 | + return $this->plugins[ $slug ][ 'source' ]; |
|
1588 | 1588 | case 'bundled': |
1589 | - return $this->default_path . $this->plugins[ $slug ]['source']; |
|
1589 | + return $this->default_path.$this->plugins[ $slug ][ 'source' ]; |
|
1590 | 1590 | } |
1591 | 1591 | |
1592 | 1592 | return $dl_source; // Should never happen. |
@@ -1624,7 +1624,7 @@ discard block |
||
1624 | 1624 | |
1625 | 1625 | if ( ! isset( $api[ $slug ] ) ) { |
1626 | 1626 | if ( ! function_exists( 'plugins_api' ) ) { |
1627 | - require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; |
|
1627 | + require_once ABSPATH.'wp-admin/includes/plugin-install.php'; |
|
1628 | 1628 | } |
1629 | 1629 | |
1630 | 1630 | $response = plugins_api( 'plugin_information', array( 'slug' => $slug, 'fields' => array( 'sections' => false ) ) ); |
@@ -1632,7 +1632,7 @@ discard block |
||
1632 | 1632 | $api[ $slug ] = false; |
1633 | 1633 | |
1634 | 1634 | if ( is_wp_error( $response ) ) { |
1635 | - wp_die( esc_html( $this->strings['oops'] ) ); |
|
1635 | + wp_die( esc_html( $this->strings[ 'oops' ] ) ); |
|
1636 | 1636 | } else { |
1637 | 1637 | $api[ $slug ] = $response; |
1638 | 1638 | } |
@@ -1651,13 +1651,13 @@ discard block |
||
1651 | 1651 | * or the plugin name if not. |
1652 | 1652 | */ |
1653 | 1653 | public function get_info_link( $slug ) { |
1654 | - if ( ! empty( $this->plugins[ $slug ]['external_url'] ) && preg_match( self::IS_URL_REGEX, $this->plugins[ $slug ]['external_url'] ) ) { |
|
1654 | + if ( ! empty( $this->plugins[ $slug ][ 'external_url' ] ) && preg_match( self::IS_URL_REGEX, $this->plugins[ $slug ][ 'external_url' ] ) ) { |
|
1655 | 1655 | $link = sprintf( |
1656 | 1656 | '<a href="%1$s" target="_blank">%2$s</a>', |
1657 | - esc_url( $this->plugins[ $slug ]['external_url'] ), |
|
1658 | - esc_html( $this->plugins[ $slug ]['name'] ) |
|
1657 | + esc_url( $this->plugins[ $slug ][ 'external_url' ] ), |
|
1658 | + esc_html( $this->plugins[ $slug ][ 'name' ] ) |
|
1659 | 1659 | ); |
1660 | - } elseif ( 'repo' === $this->plugins[ $slug ]['source_type'] ) { |
|
1660 | + } elseif ( 'repo' === $this->plugins[ $slug ][ 'source_type' ] ) { |
|
1661 | 1661 | $url = add_query_arg( |
1662 | 1662 | array( |
1663 | 1663 | 'tab' => 'plugin-information', |
@@ -1672,10 +1672,10 @@ discard block |
||
1672 | 1672 | $link = sprintf( |
1673 | 1673 | '<a href="%1$s" class="thickbox">%2$s</a>', |
1674 | 1674 | esc_url( $url ), |
1675 | - esc_html( $this->plugins[ $slug ]['name'] ) |
|
1675 | + esc_html( $this->plugins[ $slug ][ 'name' ] ) |
|
1676 | 1676 | ); |
1677 | 1677 | } else { |
1678 | - $link = esc_html( $this->plugins[ $slug ]['name'] ); // No hyperlink. |
|
1678 | + $link = esc_html( $this->plugins[ $slug ][ 'name' ] ); // No hyperlink. |
|
1679 | 1679 | } |
1680 | 1680 | |
1681 | 1681 | return $link; |
@@ -1689,7 +1689,7 @@ discard block |
||
1689 | 1689 | * @return boolean True when on the TGMPA page, false otherwise. |
1690 | 1690 | */ |
1691 | 1691 | protected function is_tgmpa_page() { |
1692 | - return isset( $_GET['page'] ) && $this->menu === $_GET['page']; |
|
1692 | + return isset( $_GET[ 'page' ] ) && $this->menu === $_GET[ 'page' ]; |
|
1693 | 1693 | } |
1694 | 1694 | |
1695 | 1695 | /** |
@@ -1771,7 +1771,7 @@ discard block |
||
1771 | 1771 | public function is_plugin_installed( $slug ) { |
1772 | 1772 | $installed_plugins = $this->get_plugins(); // Retrieve a list of all installed plugins (WP cached). |
1773 | 1773 | |
1774 | - return ( ! empty( $installed_plugins[ $this->plugins[ $slug ]['file_path'] ] ) ); |
|
1774 | + return ( ! empty( $installed_plugins[ $this->plugins[ $slug ][ 'file_path' ] ] ) ); |
|
1775 | 1775 | } |
1776 | 1776 | |
1777 | 1777 | /** |
@@ -1783,7 +1783,7 @@ discard block |
||
1783 | 1783 | * @return bool True if active, false otherwise. |
1784 | 1784 | */ |
1785 | 1785 | public function is_plugin_active( $slug ) { |
1786 | - return ( ( ! empty( $this->plugins[ $slug ]['is_callable'] ) && is_callable( $this->plugins[ $slug ]['is_callable'] ) ) || is_plugin_active( $this->plugins[ $slug ]['file_path'] ) ); |
|
1786 | + return ( ( ! empty( $this->plugins[ $slug ][ 'is_callable' ] ) && is_callable( $this->plugins[ $slug ][ 'is_callable' ] ) ) || is_plugin_active( $this->plugins[ $slug ][ 'file_path' ] ) ); |
|
1787 | 1787 | } |
1788 | 1788 | |
1789 | 1789 | /** |
@@ -1797,7 +1797,7 @@ discard block |
||
1797 | 1797 | */ |
1798 | 1798 | public function can_plugin_update( $slug ) { |
1799 | 1799 | // We currently can't get reliable info on non-WP-repo plugins - issue #380. |
1800 | - if ( 'repo' !== $this->plugins[ $slug ]['source_type'] ) { |
|
1800 | + if ( 'repo' !== $this->plugins[ $slug ][ 'source_type' ] ) { |
|
1801 | 1801 | return true; |
1802 | 1802 | } |
1803 | 1803 | |
@@ -1853,8 +1853,8 @@ discard block |
||
1853 | 1853 | public function get_installed_version( $slug ) { |
1854 | 1854 | $installed_plugins = $this->get_plugins(); // Retrieve a list of all installed plugins (WP cached). |
1855 | 1855 | |
1856 | - if ( ! empty( $installed_plugins[ $this->plugins[ $slug ]['file_path'] ]['Version'] ) ) { |
|
1857 | - return $installed_plugins[ $this->plugins[ $slug ]['file_path'] ]['Version']; |
|
1856 | + if ( ! empty( $installed_plugins[ $this->plugins[ $slug ][ 'file_path' ] ][ 'Version' ] ) ) { |
|
1857 | + return $installed_plugins[ $this->plugins[ $slug ][ 'file_path' ] ][ 'Version' ]; |
|
1858 | 1858 | } |
1859 | 1859 | |
1860 | 1860 | return ''; |
@@ -1870,7 +1870,7 @@ discard block |
||
1870 | 1870 | */ |
1871 | 1871 | public function does_plugin_require_update( $slug ) { |
1872 | 1872 | $installed_version = $this->get_installed_version( $slug ); |
1873 | - $minimum_version = $this->plugins[ $slug ]['version']; |
|
1873 | + $minimum_version = $this->plugins[ $slug ][ 'version' ]; |
|
1874 | 1874 | |
1875 | 1875 | return version_compare( $minimum_version, $installed_version, '>' ); |
1876 | 1876 | } |
@@ -1885,9 +1885,9 @@ discard block |
||
1885 | 1885 | */ |
1886 | 1886 | public function does_plugin_have_update( $slug ) { |
1887 | 1887 | // Presume bundled and external plugins will point to a package which meets the minimum required version. |
1888 | - if ( 'repo' !== $this->plugins[ $slug ]['source_type'] ) { |
|
1888 | + if ( 'repo' !== $this->plugins[ $slug ][ 'source_type' ] ) { |
|
1889 | 1889 | if ( $this->does_plugin_require_update( $slug ) ) { |
1890 | - return $this->plugins[ $slug ]['version']; |
|
1890 | + return $this->plugins[ $slug ][ 'version' ]; |
|
1891 | 1891 | } |
1892 | 1892 | |
1893 | 1893 | return false; |
@@ -1895,8 +1895,8 @@ discard block |
||
1895 | 1895 | |
1896 | 1896 | $repo_updates = get_site_transient( 'update_plugins' ); |
1897 | 1897 | |
1898 | - if ( isset( $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->new_version ) ) { |
|
1899 | - return $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->new_version; |
|
1898 | + if ( isset( $repo_updates->response[ $this->plugins[ $slug ][ 'file_path' ] ]->new_version ) ) { |
|
1899 | + return $repo_updates->response[ $this->plugins[ $slug ][ 'file_path' ] ]->new_version; |
|
1900 | 1900 | } |
1901 | 1901 | |
1902 | 1902 | return false; |
@@ -1912,14 +1912,14 @@ discard block |
||
1912 | 1912 | */ |
1913 | 1913 | public function get_upgrade_notice( $slug ) { |
1914 | 1914 | // We currently can't get reliable info on non-WP-repo plugins - issue #380. |
1915 | - if ( 'repo' !== $this->plugins[ $slug ]['source_type'] ) { |
|
1915 | + if ( 'repo' !== $this->plugins[ $slug ][ 'source_type' ] ) { |
|
1916 | 1916 | return ''; |
1917 | 1917 | } |
1918 | 1918 | |
1919 | 1919 | $repo_updates = get_site_transient( 'update_plugins' ); |
1920 | 1920 | |
1921 | - if ( ! empty( $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->upgrade_notice ) ) { |
|
1922 | - return $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->upgrade_notice; |
|
1921 | + if ( ! empty( $repo_updates->response[ $this->plugins[ $slug ][ 'file_path' ] ]->upgrade_notice ) ) { |
|
1922 | + return $repo_updates->response[ $this->plugins[ $slug ][ 'file_path' ] ]->upgrade_notice; |
|
1923 | 1923 | } |
1924 | 1924 | |
1925 | 1925 | return ''; |
@@ -1935,7 +1935,7 @@ discard block |
||
1935 | 1935 | */ |
1936 | 1936 | public function get_plugins( $plugin_folder = '' ) { |
1937 | 1937 | if ( ! function_exists( 'get_plugins' ) ) { |
1938 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
1938 | + require_once ABSPATH.'wp-admin/includes/plugin.php'; |
|
1939 | 1939 | } |
1940 | 1940 | |
1941 | 1941 | return get_plugins( $plugin_folder ); |
@@ -1950,7 +1950,7 @@ discard block |
||
1950 | 1950 | * @since 2.1.1 |
1951 | 1951 | */ |
1952 | 1952 | public function update_dismiss() { |
1953 | - delete_metadata( 'user', null, 'tgmpa_dismissed_notice_' . $this->id, null, true ); |
|
1953 | + delete_metadata( 'user', null, 'tgmpa_dismissed_notice_'.$this->id, null, true ); |
|
1954 | 1954 | } |
1955 | 1955 | |
1956 | 1956 | /** |
@@ -1969,13 +1969,13 @@ discard block |
||
1969 | 1969 | */ |
1970 | 1970 | public function force_activation() { |
1971 | 1971 | foreach ( $this->plugins as $slug => $plugin ) { |
1972 | - if ( true === $plugin['force_activation'] ) { |
|
1972 | + if ( true === $plugin[ 'force_activation' ] ) { |
|
1973 | 1973 | if ( ! $this->is_plugin_installed( $slug ) ) { |
1974 | 1974 | // Oops, plugin isn't there so iterate to next condition. |
1975 | 1975 | continue; |
1976 | 1976 | } elseif ( $this->can_plugin_activate( $slug ) ) { |
1977 | 1977 | // There we go, activate the plugin. |
1978 | - activate_plugin( $plugin['file_path'] ); |
|
1978 | + activate_plugin( $plugin[ 'file_path' ] ); |
|
1979 | 1979 | } |
1980 | 1980 | } |
1981 | 1981 | } |
@@ -1996,8 +1996,8 @@ discard block |
||
1996 | 1996 | public function force_deactivation() { |
1997 | 1997 | foreach ( $this->plugins as $slug => $plugin ) { |
1998 | 1998 | // Only proceed forward if the parameter is set to true and plugin is active. |
1999 | - if ( true === $plugin['force_deactivation'] && $this->is_plugin_active( $slug ) ) { |
|
2000 | - deactivate_plugins( $plugin['file_path'] ); |
|
1999 | + if ( true === $plugin[ 'force_deactivation' ] && $this->is_plugin_active( $slug ) ) { |
|
2000 | + deactivate_plugins( $plugin[ 'file_path' ] ); |
|
2001 | 2001 | } |
2002 | 2002 | } |
2003 | 2003 | } |
@@ -2032,7 +2032,7 @@ discard block |
||
2032 | 2032 | * Ensure only one instance of the class is ever invoked. |
2033 | 2033 | */ |
2034 | 2034 | function load_tgm_plugin_activation() { |
2035 | - $GLOBALS['tgmpa'] = TGM_Plugin_Activation::get_instance(); |
|
2035 | + $GLOBALS[ 'tgmpa' ] = TGM_Plugin_Activation::get_instance(); |
|
2036 | 2036 | } |
2037 | 2037 | } |
2038 | 2038 | |
@@ -2054,7 +2054,7 @@ discard block |
||
2054 | 2054 | * @param array $config Optional. An array of configuration values. |
2055 | 2055 | */ |
2056 | 2056 | function tgmpa( $plugins, $config = array() ) { |
2057 | - $instance = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) ); |
|
2057 | + $instance = call_user_func( array( get_class( $GLOBALS[ 'tgmpa' ] ), 'get_instance' ) ); |
|
2058 | 2058 | |
2059 | 2059 | foreach ( $plugins as $plugin ) { |
2060 | 2060 | call_user_func( array( $instance, 'register' ), $plugin ); |
@@ -2062,17 +2062,17 @@ discard block |
||
2062 | 2062 | |
2063 | 2063 | if ( ! empty( $config ) && is_array( $config ) ) { |
2064 | 2064 | // Send out notices for deprecated arguments passed. |
2065 | - if ( isset( $config['notices'] ) ) { |
|
2065 | + if ( isset( $config[ 'notices' ] ) ) { |
|
2066 | 2066 | _deprecated_argument( __FUNCTION__, '2.2.0', 'The `notices` config parameter was renamed to `has_notices` in TGMPA 2.2.0. Please adjust your configuration.' ); |
2067 | - if ( ! isset( $config['has_notices'] ) ) { |
|
2068 | - $config['has_notices'] = $config['notices']; |
|
2067 | + if ( ! isset( $config[ 'has_notices' ] ) ) { |
|
2068 | + $config[ 'has_notices' ] = $config[ 'notices' ]; |
|
2069 | 2069 | } |
2070 | 2070 | } |
2071 | 2071 | |
2072 | - if ( isset( $config['parent_menu_slug'] ) ) { |
|
2072 | + if ( isset( $config[ 'parent_menu_slug' ] ) ) { |
|
2073 | 2073 | _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.' ); |
2074 | 2074 | } |
2075 | - if ( isset( $config['parent_url_slug'] ) ) { |
|
2075 | + if ( isset( $config[ 'parent_url_slug' ] ) ) { |
|
2076 | 2076 | _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.' ); |
2077 | 2077 | } |
2078 | 2078 | |
@@ -2088,7 +2088,7 @@ discard block |
||
2088 | 2088 | * @since 2.2.0 |
2089 | 2089 | */ |
2090 | 2090 | if ( ! class_exists( 'WP_List_Table' ) ) { |
2091 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
2091 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
2092 | 2092 | } |
2093 | 2093 | |
2094 | 2094 | if ( ! class_exists( 'TGMPA_List_Table' ) ) { |
@@ -2149,7 +2149,7 @@ discard block |
||
2149 | 2149 | * @since 2.2.0 |
2150 | 2150 | */ |
2151 | 2151 | public function __construct() { |
2152 | - $this->tgmpa = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) ); |
|
2152 | + $this->tgmpa = call_user_func( array( get_class( $GLOBALS[ 'tgmpa' ] ), 'get_instance' ) ); |
|
2153 | 2153 | |
2154 | 2154 | parent::__construct( |
2155 | 2155 | array( |
@@ -2159,8 +2159,8 @@ discard block |
||
2159 | 2159 | ) |
2160 | 2160 | ); |
2161 | 2161 | |
2162 | - if ( isset( $_REQUEST['plugin_status'] ) && in_array( $_REQUEST['plugin_status'], array( 'install', 'update', 'activate' ), true ) ) { |
|
2163 | - $this->view_context = sanitize_key( $_REQUEST['plugin_status'] ); |
|
2162 | + if ( isset( $_REQUEST[ 'plugin_status' ] ) && in_array( $_REQUEST[ 'plugin_status' ], array( 'install', 'update', 'activate' ), true ) ) { |
|
2163 | + $this->view_context = sanitize_key( $_REQUEST[ 'plugin_status' ] ); |
|
2164 | 2164 | } |
2165 | 2165 | |
2166 | 2166 | add_filter( 'tgmpa_table_data_items', array( $this, 'sort_table_items' ) ); |
@@ -2207,20 +2207,20 @@ discard block |
||
2207 | 2207 | } |
2208 | 2208 | |
2209 | 2209 | foreach ( $plugins[ $this->view_context ] as $slug => $plugin ) { |
2210 | - $table_data[ $i ]['sanitized_plugin'] = $plugin['name']; |
|
2211 | - $table_data[ $i ]['slug'] = $slug; |
|
2212 | - $table_data[ $i ]['plugin'] = '<strong>' . $this->tgmpa->get_info_link( $slug ) . '</strong>'; |
|
2213 | - $table_data[ $i ]['source'] = $this->get_plugin_source_type_text( $plugin['source_type'] ); |
|
2214 | - $table_data[ $i ]['type'] = $this->get_plugin_advise_type_text( $plugin['required'] ); |
|
2215 | - $table_data[ $i ]['status'] = $this->get_plugin_status_text( $slug ); |
|
2216 | - $table_data[ $i ]['installed_version'] = $this->tgmpa->get_installed_version( $slug ); |
|
2217 | - $table_data[ $i ]['minimum_version'] = $plugin['version']; |
|
2218 | - $table_data[ $i ]['available_version'] = $this->tgmpa->does_plugin_have_update( $slug ); |
|
2210 | + $table_data[ $i ][ 'sanitized_plugin' ] = $plugin[ 'name' ]; |
|
2211 | + $table_data[ $i ][ 'slug' ] = $slug; |
|
2212 | + $table_data[ $i ][ 'plugin' ] = '<strong>'.$this->tgmpa->get_info_link( $slug ).'</strong>'; |
|
2213 | + $table_data[ $i ][ 'source' ] = $this->get_plugin_source_type_text( $plugin[ 'source_type' ] ); |
|
2214 | + $table_data[ $i ][ 'type' ] = $this->get_plugin_advise_type_text( $plugin[ 'required' ] ); |
|
2215 | + $table_data[ $i ][ 'status' ] = $this->get_plugin_status_text( $slug ); |
|
2216 | + $table_data[ $i ][ 'installed_version' ] = $this->tgmpa->get_installed_version( $slug ); |
|
2217 | + $table_data[ $i ][ 'minimum_version' ] = $plugin[ 'version' ]; |
|
2218 | + $table_data[ $i ][ 'available_version' ] = $this->tgmpa->does_plugin_have_update( $slug ); |
|
2219 | 2219 | |
2220 | 2220 | // Prep the upgrade notice info. |
2221 | 2221 | $upgrade_notice = $this->tgmpa->get_upgrade_notice( $slug ); |
2222 | 2222 | if ( ! empty( $upgrade_notice ) ) { |
2223 | - $table_data[ $i ]['upgrade_notice'] = $upgrade_notice; |
|
2223 | + $table_data[ $i ][ 'upgrade_notice' ] = $upgrade_notice; |
|
2224 | 2224 | |
2225 | 2225 | add_action( "tgmpa_after_plugin_row_$slug", array( $this, 'wp_plugin_update_row' ), 10, 2 ); |
2226 | 2226 | } |
@@ -2251,17 +2251,17 @@ discard block |
||
2251 | 2251 | // No need to display plugins if they are installed, up-to-date and active. |
2252 | 2252 | continue; |
2253 | 2253 | } else { |
2254 | - $plugins['all'][ $slug ] = $plugin; |
|
2254 | + $plugins[ 'all' ][ $slug ] = $plugin; |
|
2255 | 2255 | |
2256 | 2256 | if ( ! $this->tgmpa->is_plugin_installed( $slug ) ) { |
2257 | - $plugins['install'][ $slug ] = $plugin; |
|
2257 | + $plugins[ 'install' ][ $slug ] = $plugin; |
|
2258 | 2258 | } else { |
2259 | 2259 | if ( false !== $this->tgmpa->does_plugin_have_update( $slug ) ) { |
2260 | - $plugins['update'][ $slug ] = $plugin; |
|
2260 | + $plugins[ 'update' ][ $slug ] = $plugin; |
|
2261 | 2261 | } |
2262 | 2262 | |
2263 | 2263 | if ( $this->tgmpa->can_plugin_activate( $slug ) ) { |
2264 | - $plugins['activate'][ $slug ] = $plugin; |
|
2264 | + $plugins[ 'activate' ][ $slug ] = $plugin; |
|
2265 | 2265 | } |
2266 | 2266 | } |
2267 | 2267 | } |
@@ -2380,8 +2380,8 @@ discard block |
||
2380 | 2380 | $name = array(); |
2381 | 2381 | |
2382 | 2382 | foreach ( $items as $i => $plugin ) { |
2383 | - $type[ $i ] = $plugin['type']; // Required / recommended. |
|
2384 | - $name[ $i ] = $plugin['sanitized_plugin']; |
|
2383 | + $type[ $i ] = $plugin[ 'type' ]; // Required / recommended. |
|
2384 | + $name[ $i ] = $plugin[ 'sanitized_plugin' ]; |
|
2385 | 2385 | } |
2386 | 2386 | |
2387 | 2387 | array_multisort( $type, SORT_DESC, $name, SORT_ASC, $items ); |
@@ -2463,9 +2463,9 @@ discard block |
||
2463 | 2463 | public function column_cb( $item ) { |
2464 | 2464 | return sprintf( |
2465 | 2465 | '<input type="checkbox" name="%1$s[]" value="%2$s" id="%3$s" />', |
2466 | - esc_attr( $this->_args['singular'] ), |
|
2467 | - esc_attr( $item['slug'] ), |
|
2468 | - esc_attr( $item['sanitized_plugin'] ) |
|
2466 | + esc_attr( $this->_args[ 'singular' ] ), |
|
2467 | + esc_attr( $item[ 'slug' ] ), |
|
2468 | + esc_attr( $item[ 'sanitized_plugin' ] ) |
|
2469 | 2469 | ); |
2470 | 2470 | } |
2471 | 2471 | |
@@ -2480,7 +2480,7 @@ discard block |
||
2480 | 2480 | public function column_plugin( $item ) { |
2481 | 2481 | return sprintf( |
2482 | 2482 | '%1$s %2$s', |
2483 | - $item['plugin'], |
|
2483 | + $item[ 'plugin' ], |
|
2484 | 2484 | $this->row_actions( $this->get_row_actions( $item ), true ) |
2485 | 2485 | ); |
2486 | 2486 | } |
@@ -2496,38 +2496,38 @@ discard block |
||
2496 | 2496 | public function column_version( $item ) { |
2497 | 2497 | $output = array(); |
2498 | 2498 | |
2499 | - if ( $this->tgmpa->is_plugin_installed( $item['slug'] ) ) { |
|
2500 | - $installed = ! empty( $item['installed_version'] ) ? $item['installed_version'] : _x( 'unknown', 'as in: "version nr unknown"', 'tgmpa' ); |
|
2499 | + if ( $this->tgmpa->is_plugin_installed( $item[ 'slug' ] ) ) { |
|
2500 | + $installed = ! empty( $item[ 'installed_version' ] ) ? $item[ 'installed_version' ] : _x( 'unknown', 'as in: "version nr unknown"', 'tgmpa' ); |
|
2501 | 2501 | |
2502 | 2502 | $color = ''; |
2503 | - if ( ! empty( $item['minimum_version'] ) && $this->tgmpa->does_plugin_require_update( $item['slug'] ) ) { |
|
2503 | + if ( ! empty( $item[ 'minimum_version' ] ) && $this->tgmpa->does_plugin_require_update( $item[ 'slug' ] ) ) { |
|
2504 | 2504 | $color = ' color: #ff0000; font-weight: bold;'; |
2505 | 2505 | } |
2506 | 2506 | |
2507 | - $output[] = sprintf( |
|
2508 | - '<p><span style="min-width: 32px; text-align: right; float: right;%1$s">%2$s</span>' . __( 'Installed version:', 'tgmpa' ) . '</p>', |
|
2507 | + $output[ ] = sprintf( |
|
2508 | + '<p><span style="min-width: 32px; text-align: right; float: right;%1$s">%2$s</span>'.__( 'Installed version:', 'tgmpa' ).'</p>', |
|
2509 | 2509 | $color, |
2510 | 2510 | $installed |
2511 | 2511 | ); |
2512 | 2512 | } |
2513 | 2513 | |
2514 | - if ( ! empty( $item['minimum_version'] ) ) { |
|
2515 | - $output[] = sprintf( |
|
2516 | - '<p><span style="min-width: 32px; text-align: right; float: right;">%1$s</span>' . __( 'Minimum required version:', 'tgmpa' ) . '</p>', |
|
2517 | - $item['minimum_version'] |
|
2514 | + if ( ! empty( $item[ 'minimum_version' ] ) ) { |
|
2515 | + $output[ ] = sprintf( |
|
2516 | + '<p><span style="min-width: 32px; text-align: right; float: right;">%1$s</span>'.__( 'Minimum required version:', 'tgmpa' ).'</p>', |
|
2517 | + $item[ 'minimum_version' ] |
|
2518 | 2518 | ); |
2519 | 2519 | } |
2520 | 2520 | |
2521 | - if ( ! empty( $item['available_version'] ) ) { |
|
2521 | + if ( ! empty( $item[ 'available_version' ] ) ) { |
|
2522 | 2522 | $color = ''; |
2523 | - if ( ! empty( $item['minimum_version'] ) && version_compare( $item['available_version'], $item['minimum_version'], '>=' ) ) { |
|
2523 | + if ( ! empty( $item[ 'minimum_version' ] ) && version_compare( $item[ 'available_version' ], $item[ 'minimum_version' ], '>=' ) ) { |
|
2524 | 2524 | $color = ' color: #71C671; font-weight: bold;'; |
2525 | 2525 | } |
2526 | 2526 | |
2527 | - $output[] = sprintf( |
|
2528 | - '<p><span style="min-width: 32px; text-align: right; float: right;%1$s">%2$s</span>' . __( 'Available version:', 'tgmpa' ) . '</p>', |
|
2527 | + $output[ ] = sprintf( |
|
2528 | + '<p><span style="min-width: 32px; text-align: right; float: right;%1$s">%2$s</span>'.__( 'Available version:', 'tgmpa' ).'</p>', |
|
2529 | 2529 | $color, |
2530 | - $item['available_version'] |
|
2530 | + $item[ 'available_version' ] |
|
2531 | 2531 | ); |
2532 | 2532 | } |
2533 | 2533 | |
@@ -2568,8 +2568,8 @@ discard block |
||
2568 | 2568 | ); |
2569 | 2569 | |
2570 | 2570 | if ( 'all' === $this->view_context || 'update' === $this->view_context ) { |
2571 | - $columns['version'] = __( 'Version', 'tgmpa' ); |
|
2572 | - $columns['status'] = __( 'Status', 'tgmpa' ); |
|
2571 | + $columns[ 'version' ] = __( 'Version', 'tgmpa' ); |
|
2572 | + $columns[ 'status' ] = __( 'Status', 'tgmpa' ); |
|
2573 | 2573 | } |
2574 | 2574 | |
2575 | 2575 | return apply_filters( 'tgmpa_table_columns', $columns ); |
@@ -2616,17 +2616,17 @@ discard block |
||
2616 | 2616 | $action_links = array(); |
2617 | 2617 | |
2618 | 2618 | // Display the 'Install' action link if the plugin is not yet available. |
2619 | - if ( ! $this->tgmpa->is_plugin_installed( $item['slug'] ) ) { |
|
2620 | - $actions['install'] = _x( 'Install %2$s', '%2$s = plugin name in screen reader markup', 'tgmpa' ); |
|
2619 | + if ( ! $this->tgmpa->is_plugin_installed( $item[ 'slug' ] ) ) { |
|
2620 | + $actions[ 'install' ] = _x( 'Install %2$s', '%2$s = plugin name in screen reader markup', 'tgmpa' ); |
|
2621 | 2621 | } else { |
2622 | 2622 | // Display the 'Update' action link if an update is available and WP complies with plugin minimum. |
2623 | - if ( false !== $this->tgmpa->does_plugin_have_update( $item['slug'] ) && $this->tgmpa->can_plugin_update( $item['slug'] ) ) { |
|
2624 | - $actions['update'] = _x( 'Update %2$s', '%2$s = plugin name in screen reader markup', 'tgmpa' ); |
|
2623 | + if ( false !== $this->tgmpa->does_plugin_have_update( $item[ 'slug' ] ) && $this->tgmpa->can_plugin_update( $item[ 'slug' ] ) ) { |
|
2624 | + $actions[ 'update' ] = _x( 'Update %2$s', '%2$s = plugin name in screen reader markup', 'tgmpa' ); |
|
2625 | 2625 | } |
2626 | 2626 | |
2627 | 2627 | // Display the 'Activate' action link, but only if the plugin meets the minimum version. |
2628 | - if ( $this->tgmpa->can_plugin_activate( $item['slug'] ) ) { |
|
2629 | - $actions['activate'] = _x( 'Activate %2$s', '%2$s = plugin name in screen reader markup', 'tgmpa' ); |
|
2628 | + if ( $this->tgmpa->can_plugin_activate( $item[ 'slug' ] ) ) { |
|
2629 | + $actions[ 'activate' ] = _x( 'Activate %2$s', '%2$s = plugin name in screen reader markup', 'tgmpa' ); |
|
2630 | 2630 | } |
2631 | 2631 | } |
2632 | 2632 | |
@@ -2635,24 +2635,24 @@ discard block |
||
2635 | 2635 | $nonce_url = wp_nonce_url( |
2636 | 2636 | add_query_arg( |
2637 | 2637 | array( |
2638 | - 'plugin' => urlencode( $item['slug'] ), |
|
2639 | - 'tgmpa-' . $action => $action . '-plugin', |
|
2638 | + 'plugin' => urlencode( $item[ 'slug' ] ), |
|
2639 | + 'tgmpa-'.$action => $action.'-plugin', |
|
2640 | 2640 | ), |
2641 | 2641 | $this->tgmpa->get_tgmpa_url() |
2642 | 2642 | ), |
2643 | - 'tgmpa-' . $action, |
|
2643 | + 'tgmpa-'.$action, |
|
2644 | 2644 | 'tgmpa-nonce' |
2645 | 2645 | ); |
2646 | 2646 | |
2647 | 2647 | $action_links[ $action ] = sprintf( |
2648 | - '<a href="%1$s">' . esc_html( $text ) . '</a>', |
|
2648 | + '<a href="%1$s">'.esc_html( $text ).'</a>', |
|
2649 | 2649 | esc_url( $nonce_url ), |
2650 | - '<span class="screen-reader-text">' . esc_html( $item['sanitized_plugin'] ) . '</span>' |
|
2650 | + '<span class="screen-reader-text">'.esc_html( $item[ 'sanitized_plugin' ] ).'</span>' |
|
2651 | 2651 | ); |
2652 | 2652 | } |
2653 | 2653 | |
2654 | 2654 | $prefix = ( defined( 'WP_NETWORK_ADMIN' ) && WP_NETWORK_ADMIN ) ? 'network_admin_' : ''; |
2655 | - return apply_filters( "tgmpa_{$prefix}plugin_action_links", array_filter( $action_links ), $item['slug'], $item, $this->view_context ); |
|
2655 | + return apply_filters( "tgmpa_{$prefix}plugin_action_links", array_filter( $action_links ), $item[ 'slug' ], $item, $this->view_context ); |
|
2656 | 2656 | } |
2657 | 2657 | |
2658 | 2658 | /** |
@@ -2673,7 +2673,7 @@ discard block |
||
2673 | 2673 | * |
2674 | 2674 | * @since 2.5.0 |
2675 | 2675 | */ |
2676 | - do_action( "tgmpa_after_plugin_row_{$item['slug']}", $item['slug'], $item, $this->view_context ); |
|
2676 | + do_action( "tgmpa_after_plugin_row_{$item[ 'slug' ]}", $item[ 'slug' ], $item, $this->view_context ); |
|
2677 | 2677 | } |
2678 | 2678 | |
2679 | 2679 | /** |
@@ -2688,7 +2688,7 @@ discard block |
||
2688 | 2688 | * @return null Return early if upgrade notice is empty. |
2689 | 2689 | */ |
2690 | 2690 | public function wp_plugin_update_row( $slug, $item ) { |
2691 | - if ( empty( $item['upgrade_notice'] ) ) { |
|
2691 | + if ( empty( $item[ 'upgrade_notice' ] ) ) { |
|
2692 | 2692 | return; |
2693 | 2693 | } |
2694 | 2694 | |
@@ -2697,7 +2697,7 @@ discard block |
||
2697 | 2697 | <td colspan="', absint( $this->get_column_count() ), '" class="plugin-update colspanchange"> |
2698 | 2698 | <div class="update-message">', |
2699 | 2699 | esc_html__( 'Upgrade message from the plugin author:', 'tgmpa' ), |
2700 | - ' <strong>', wp_kses_data( $item['upgrade_notice'] ), '</strong> |
|
2700 | + ' <strong>', wp_kses_data( $item[ 'upgrade_notice' ] ), '</strong> |
|
2701 | 2701 | </div> |
2702 | 2702 | </td> |
2703 | 2703 | </tr>'; |
@@ -2729,16 +2729,16 @@ discard block |
||
2729 | 2729 | |
2730 | 2730 | if ( 'update' !== $this->view_context && 'activate' !== $this->view_context ) { |
2731 | 2731 | if ( current_user_can( 'install_plugins' ) ) { |
2732 | - $actions['tgmpa-bulk-install'] = __( 'Install', 'tgmpa' ); |
|
2732 | + $actions[ 'tgmpa-bulk-install' ] = __( 'Install', 'tgmpa' ); |
|
2733 | 2733 | } |
2734 | 2734 | } |
2735 | 2735 | |
2736 | 2736 | if ( 'install' !== $this->view_context ) { |
2737 | 2737 | if ( current_user_can( 'update_plugins' ) ) { |
2738 | - $actions['tgmpa-bulk-update'] = __( 'Update', 'tgmpa' ); |
|
2738 | + $actions[ 'tgmpa-bulk-update' ] = __( 'Update', 'tgmpa' ); |
|
2739 | 2739 | } |
2740 | 2740 | if ( current_user_can( 'activate_plugins' ) ) { |
2741 | - $actions['tgmpa-bulk-activate'] = __( 'Activate', 'tgmpa' ); |
|
2741 | + $actions[ 'tgmpa-bulk-activate' ] = __( 'Activate', 'tgmpa' ); |
|
2742 | 2742 | } |
2743 | 2743 | } |
2744 | 2744 | |
@@ -2757,7 +2757,7 @@ discard block |
||
2757 | 2757 | // Bulk installation process. |
2758 | 2758 | if ( 'tgmpa-bulk-install' === $this->current_action() || 'tgmpa-bulk-update' === $this->current_action() ) { |
2759 | 2759 | |
2760 | - check_admin_referer( 'bulk-' . $this->_args['plural'] ); |
|
2760 | + check_admin_referer( 'bulk-'.$this->_args[ 'plural' ] ); |
|
2761 | 2761 | |
2762 | 2762 | $install_type = 'install'; |
2763 | 2763 | if ( 'tgmpa-bulk-update' === $this->current_action() ) { |
@@ -2767,7 +2767,7 @@ discard block |
||
2767 | 2767 | $plugins_to_install = array(); |
2768 | 2768 | |
2769 | 2769 | // Did user actually select any plugins to install/update ? |
2770 | - if ( empty( $_POST['plugin'] ) ) { |
|
2770 | + if ( empty( $_POST[ 'plugin' ] ) ) { |
|
2771 | 2771 | if ( 'install' === $install_type ) { |
2772 | 2772 | $message = __( 'No plugins were selected to be installed. No action taken.', 'tgmpa' ); |
2773 | 2773 | } else { |
@@ -2779,11 +2779,11 @@ discard block |
||
2779 | 2779 | return false; |
2780 | 2780 | } |
2781 | 2781 | |
2782 | - if ( is_array( $_POST['plugin'] ) ) { |
|
2783 | - $plugins_to_install = (array) $_POST['plugin']; |
|
2784 | - } elseif ( is_string( $_POST['plugin'] ) ) { |
|
2782 | + if ( is_array( $_POST[ 'plugin' ] ) ) { |
|
2783 | + $plugins_to_install = (array) $_POST[ 'plugin' ]; |
|
2784 | + } elseif ( is_string( $_POST[ 'plugin' ] ) ) { |
|
2785 | 2785 | // Received via Filesystem page - un-flatten array (WP bug #19643). |
2786 | - $plugins_to_install = explode( ',', $_POST['plugin'] ); |
|
2786 | + $plugins_to_install = explode( ',', $_POST[ 'plugin' ] ); |
|
2787 | 2787 | } |
2788 | 2788 | |
2789 | 2789 | // Sanitize the received input. |
@@ -2825,11 +2825,11 @@ discard block |
||
2825 | 2825 | // Pass all necessary information if WP_Filesystem is needed. |
2826 | 2826 | $url = wp_nonce_url( |
2827 | 2827 | $this->tgmpa->get_tgmpa_url(), |
2828 | - 'bulk-' . $this->_args['plural'] |
|
2828 | + 'bulk-'.$this->_args[ 'plural' ] |
|
2829 | 2829 | ); |
2830 | 2830 | |
2831 | 2831 | // Give validated data back to $_POST which is the only place the filesystem looks for extra fields. |
2832 | - $_POST['plugin'] = implode( ',', $plugins_to_install ); // Work around for WP bug #19643. |
|
2832 | + $_POST[ 'plugin' ] = implode( ',', $plugins_to_install ); // Work around for WP bug #19643. |
|
2833 | 2833 | |
2834 | 2834 | $method = ''; // Leave blank so WP_Filesystem can populate it as necessary. |
2835 | 2835 | $fields = array_keys( $_POST ); // Extra fields to pass to WP_Filesystem. |
@@ -2856,22 +2856,22 @@ discard block |
||
2856 | 2856 | |
2857 | 2857 | // Prepare the data for validated plugins for the install/upgrade. |
2858 | 2858 | foreach ( $plugins_to_install as $slug ) { |
2859 | - $name = $this->tgmpa->plugins[ $slug ]['name']; |
|
2859 | + $name = $this->tgmpa->plugins[ $slug ][ 'name' ]; |
|
2860 | 2860 | $source = $this->tgmpa->get_download_url( $slug ); |
2861 | 2861 | |
2862 | 2862 | if ( ! empty( $name ) && ! empty( $source ) ) { |
2863 | - $names[] = $name; |
|
2863 | + $names[ ] = $name; |
|
2864 | 2864 | |
2865 | 2865 | switch ( $install_type ) { |
2866 | 2866 | |
2867 | 2867 | case 'install': |
2868 | - $sources[] = $source; |
|
2868 | + $sources[ ] = $source; |
|
2869 | 2869 | break; |
2870 | 2870 | |
2871 | 2871 | case 'update': |
2872 | - $file_paths[] = $this->tgmpa->plugins[ $slug ]['file_path']; |
|
2872 | + $file_paths[ ] = $this->tgmpa->plugins[ $slug ][ 'file_path' ]; |
|
2873 | 2873 | $to_inject[ $slug ] = $this->tgmpa->plugins[ $slug ]; |
2874 | - $to_inject[ $slug ]['source'] = $source; |
|
2874 | + $to_inject[ $slug ][ 'source' ] = $source; |
|
2875 | 2875 | break; |
2876 | 2876 | } |
2877 | 2877 | } |
@@ -2883,7 +2883,7 @@ discard block |
||
2883 | 2883 | new TGMPA_Bulk_Installer_Skin( |
2884 | 2884 | array( |
2885 | 2885 | 'url' => esc_url_raw( $this->tgmpa->get_tgmpa_url() ), |
2886 | - 'nonce' => 'bulk-' . $this->_args['plural'], |
|
2886 | + 'nonce' => 'bulk-'.$this->_args[ 'plural' ], |
|
2887 | 2887 | 'names' => $names, |
2888 | 2888 | 'install_type' => $install_type, |
2889 | 2889 | ) |
@@ -2916,10 +2916,10 @@ discard block |
||
2916 | 2916 | |
2917 | 2917 | // Bulk activation process. |
2918 | 2918 | if ( 'tgmpa-bulk-activate' === $this->current_action() ) { |
2919 | - check_admin_referer( 'bulk-' . $this->_args['plural'] ); |
|
2919 | + check_admin_referer( 'bulk-'.$this->_args[ 'plural' ] ); |
|
2920 | 2920 | |
2921 | 2921 | // Did user actually select any plugins to activate ? |
2922 | - if ( empty( $_POST['plugin'] ) ) { |
|
2922 | + if ( empty( $_POST[ 'plugin' ] ) ) { |
|
2923 | 2923 | echo '<div id="message" class="error"><p>', esc_html__( 'No plugins were selected to be activated. No action taken.', 'tgmpa' ), '</p></div>'; |
2924 | 2924 | |
2925 | 2925 | return false; |
@@ -2927,8 +2927,8 @@ discard block |
||
2927 | 2927 | |
2928 | 2928 | // Grab plugin data from $_POST. |
2929 | 2929 | $plugins = array(); |
2930 | - if ( isset( $_POST['plugin'] ) ) { |
|
2931 | - $plugins = array_map( 'urldecode', (array) $_POST['plugin'] ); |
|
2930 | + if ( isset( $_POST[ 'plugin' ] ) ) { |
|
2931 | + $plugins = array_map( 'urldecode', (array) $_POST[ 'plugin' ] ); |
|
2932 | 2932 | $plugins = array_map( array( $this->tgmpa, 'sanitize_key' ), $plugins ); |
2933 | 2933 | } |
2934 | 2934 | |
@@ -2938,8 +2938,8 @@ discard block |
||
2938 | 2938 | // Grab the file paths for the selected & inactive plugins from the registration array. |
2939 | 2939 | foreach ( $plugins as $slug ) { |
2940 | 2940 | if ( $this->tgmpa->can_plugin_activate( $slug ) ) { |
2941 | - $plugins_to_activate[] = $this->tgmpa->plugins[ $slug ]['file_path']; |
|
2942 | - $plugin_names[] = $this->tgmpa->plugins[ $slug ]['name']; |
|
2941 | + $plugins_to_activate[ ] = $this->tgmpa->plugins[ $slug ][ 'file_path' ]; |
|
2942 | + $plugin_names[ ] = $this->tgmpa->plugins[ $slug ][ 'name' ]; |
|
2943 | 2943 | } |
2944 | 2944 | } |
2945 | 2945 | unset( $slug ); |
@@ -2960,7 +2960,7 @@ discard block |
||
2960 | 2960 | $count = count( $plugin_names ); // Count so we can use _n function. |
2961 | 2961 | $plugin_names = array_map( array( 'TGMPA_Utils', 'wrap_in_strong' ), $plugin_names ); |
2962 | 2962 | $last_plugin = array_pop( $plugin_names ); // Pop off last name to prep for readability. |
2963 | - $imploded = empty( $plugin_names ) ? $last_plugin : ( implode( ', ', $plugin_names ) . ' ' . esc_html_x( 'and', 'plugin A *and* plugin B', 'tgmpa' ) . ' ' . $last_plugin ); |
|
2963 | + $imploded = empty( $plugin_names ) ? $last_plugin : ( implode( ', ', $plugin_names ).' '.esc_html_x( 'and', 'plugin A *and* plugin B', 'tgmpa' ).' '.$last_plugin ); |
|
2964 | 2964 | |
2965 | 2965 | printf( // WPCS: xss ok. |
2966 | 2966 | '<div id="message" class="updated"><p>%1$s %2$s.</p></div>', |
@@ -3063,16 +3063,16 @@ discard block |
||
3063 | 3063 | */ |
3064 | 3064 | function tgmpa_load_bulk_installer() { |
3065 | 3065 | // Silently fail if 2.5+ is loaded *after* an older version. |
3066 | - if ( ! isset( $GLOBALS['tgmpa'] ) ) { |
|
3066 | + if ( ! isset( $GLOBALS[ 'tgmpa' ] ) ) { |
|
3067 | 3067 | return; |
3068 | 3068 | } |
3069 | 3069 | |
3070 | 3070 | // Get TGMPA class instance. |
3071 | - $tgmpa_instance = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) ); |
|
3071 | + $tgmpa_instance = call_user_func( array( get_class( $GLOBALS[ 'tgmpa' ] ), 'get_instance' ) ); |
|
3072 | 3072 | |
3073 | - if ( isset( $_GET['page'] ) && $tgmpa_instance->menu === $_GET['page'] ) { |
|
3073 | + if ( isset( $_GET[ 'page' ] ) && $tgmpa_instance->menu === $_GET[ 'page' ] ) { |
|
3074 | 3074 | if ( ! class_exists( 'Plugin_Upgrader', false ) ) { |
3075 | - require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
|
3075 | + require_once ABSPATH.'wp-admin/includes/class-wp-upgrader.php'; |
|
3076 | 3076 | } |
3077 | 3077 | |
3078 | 3078 | if ( ! class_exists( 'TGMPA_Bulk_Installer' ) ) { |
@@ -3139,11 +3139,11 @@ discard block |
||
3139 | 3139 | */ |
3140 | 3140 | public function __construct( $skin = null ) { |
3141 | 3141 | // Get TGMPA class instance. |
3142 | - $this->tgmpa = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) ); |
|
3142 | + $this->tgmpa = call_user_func( array( get_class( $GLOBALS[ 'tgmpa' ] ), 'get_instance' ) ); |
|
3143 | 3143 | |
3144 | 3144 | parent::__construct( $skin ); |
3145 | 3145 | |
3146 | - if ( isset( $this->skin->options['install_type'] ) && 'update' === $this->skin->options['install_type'] ) { |
|
3146 | + if ( isset( $this->skin->options[ 'install_type' ] ) && 'update' === $this->skin->options[ 'install_type' ] ) { |
|
3147 | 3147 | $this->clear_destination = true; |
3148 | 3148 | } |
3149 | 3149 | |
@@ -3160,8 +3160,8 @@ discard block |
||
3160 | 3160 | * @since 2.2.0 |
3161 | 3161 | */ |
3162 | 3162 | public function activate_strings() { |
3163 | - $this->strings['activation_failed'] = __( 'Plugin activation failed.', 'tgmpa' ); |
|
3164 | - $this->strings['activation_success'] = __( 'Plugin activated successfully.', 'tgmpa' ); |
|
3163 | + $this->strings[ 'activation_failed' ] = __( 'Plugin activation failed.', 'tgmpa' ); |
|
3164 | + $this->strings[ 'activation_success' ] = __( 'Plugin activated successfully.', 'tgmpa' ); |
|
3165 | 3165 | } |
3166 | 3166 | |
3167 | 3167 | /** |
@@ -3179,7 +3179,7 @@ discard block |
||
3179 | 3179 | |
3180 | 3180 | // Reset the strings in case we changed one during automatic activation. |
3181 | 3181 | if ( $this->tgmpa->is_automatic ) { |
3182 | - if ( 'update' === $this->skin->options['install_type'] ) { |
|
3182 | + if ( 'update' === $this->skin->options[ 'install_type' ] ) { |
|
3183 | 3183 | $this->upgrade_strings(); |
3184 | 3184 | } else { |
3185 | 3185 | $this->install_strings(); |
@@ -3337,7 +3337,7 @@ discard block |
||
3337 | 3337 | remove_filter( 'upgrader_post_install', array( $this, 'auto_activate' ), 10 ); |
3338 | 3338 | |
3339 | 3339 | // Force refresh of plugin update information. |
3340 | - wp_clean_plugins_cache( $parsed_args['clear_update_cache'] ); |
|
3340 | + wp_clean_plugins_cache( $parsed_args[ 'clear_update_cache' ] ); |
|
3341 | 3341 | |
3342 | 3342 | return $results; |
3343 | 3343 | } |
@@ -3388,13 +3388,13 @@ discard block |
||
3388 | 3388 | $activate = activate_plugin( $plugin_info ); |
3389 | 3389 | |
3390 | 3390 | // Adjust the success string based on the activation result. |
3391 | - $this->strings['process_success'] = $this->strings['process_success'] . "<br />\n"; |
|
3391 | + $this->strings[ 'process_success' ] = $this->strings[ 'process_success' ]."<br />\n"; |
|
3392 | 3392 | |
3393 | 3393 | if ( is_wp_error( $activate ) ) { |
3394 | 3394 | $this->skin->error( $activate ); |
3395 | - $this->strings['process_success'] .= $this->strings['activation_failed']; |
|
3395 | + $this->strings[ 'process_success' ] .= $this->strings[ 'activation_failed' ]; |
|
3396 | 3396 | } else { |
3397 | - $this->strings['process_success'] .= $this->strings['activation_success']; |
|
3397 | + $this->strings[ 'process_success' ] .= $this->strings[ 'activation_success' ]; |
|
3398 | 3398 | } |
3399 | 3399 | } |
3400 | 3400 | } |
@@ -3470,7 +3470,7 @@ discard block |
||
3470 | 3470 | */ |
3471 | 3471 | public function __construct( $args = array() ) { |
3472 | 3472 | // Get TGMPA class instance. |
3473 | - $this->tgmpa = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) ); |
|
3473 | + $this->tgmpa = call_user_func( array( get_class( $GLOBALS[ 'tgmpa' ] ), 'get_instance' ) ); |
|
3474 | 3474 | |
3475 | 3475 | // Parse default and new args. |
3476 | 3476 | $defaults = array( |
@@ -3479,10 +3479,10 @@ discard block |
||
3479 | 3479 | 'names' => array(), |
3480 | 3480 | 'install_type' => 'install', |
3481 | 3481 | ); |
3482 | - $args = wp_parse_args( $args, $defaults ); |
|
3482 | + $args = wp_parse_args( $args, $defaults ); |
|
3483 | 3483 | |
3484 | 3484 | // Set plugin names to $this->plugin_names property. |
3485 | - $this->plugin_names = $args['names']; |
|
3485 | + $this->plugin_names = $args[ 'names' ]; |
|
3486 | 3486 | |
3487 | 3487 | // Extract the new args. |
3488 | 3488 | parent::__construct( $args ); |
@@ -3497,25 +3497,25 @@ discard block |
||
3497 | 3497 | * @since 2.2.0 |
3498 | 3498 | */ |
3499 | 3499 | public function add_strings() { |
3500 | - if ( 'update' === $this->options['install_type'] ) { |
|
3500 | + if ( 'update' === $this->options[ 'install_type' ] ) { |
|
3501 | 3501 | parent::add_strings(); |
3502 | - $this->upgrader->strings['skin_before_update_header'] = __( 'Updating Plugin %1$s (%2$d/%3$d)', 'tgmpa' ); |
|
3502 | + $this->upgrader->strings[ 'skin_before_update_header' ] = __( 'Updating Plugin %1$s (%2$d/%3$d)', 'tgmpa' ); |
|
3503 | 3503 | } else { |
3504 | - $this->upgrader->strings['skin_update_failed_error'] = __( 'An error occurred while installing %1$s: <strong>%2$s</strong>.', 'tgmpa' ); |
|
3505 | - $this->upgrader->strings['skin_update_failed'] = __( 'The installation of %1$s failed.', 'tgmpa' ); |
|
3504 | + $this->upgrader->strings[ 'skin_update_failed_error' ] = __( 'An error occurred while installing %1$s: <strong>%2$s</strong>.', 'tgmpa' ); |
|
3505 | + $this->upgrader->strings[ 'skin_update_failed' ] = __( 'The installation of %1$s failed.', 'tgmpa' ); |
|
3506 | 3506 | |
3507 | 3507 | if ( $this->tgmpa->is_automatic ) { |
3508 | 3508 | // Automatic activation strings. |
3509 | - $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' ); |
|
3510 | - $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>'; |
|
3511 | - $this->upgrader->strings['skin_upgrade_end'] = __( 'All installations and activations have been completed.', 'tgmpa' ); |
|
3512 | - $this->upgrader->strings['skin_before_update_header'] = __( 'Installing and Activating Plugin %1$s (%2$d/%3$d)', 'tgmpa' ); |
|
3509 | + $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' ); |
|
3510 | + $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>'; |
|
3511 | + $this->upgrader->strings[ 'skin_upgrade_end' ] = __( 'All installations and activations have been completed.', 'tgmpa' ); |
|
3512 | + $this->upgrader->strings[ 'skin_before_update_header' ] = __( 'Installing and Activating Plugin %1$s (%2$d/%3$d)', 'tgmpa' ); |
|
3513 | 3513 | } else { |
3514 | 3514 | // Default installation strings. |
3515 | - $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' ); |
|
3516 | - $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>'; |
|
3517 | - $this->upgrader->strings['skin_upgrade_end'] = __( 'All installations have been completed.', 'tgmpa' ); |
|
3518 | - $this->upgrader->strings['skin_before_update_header'] = __( 'Installing Plugin %1$s (%2$d/%3$d)', 'tgmpa' ); |
|
3515 | + $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' ); |
|
3516 | + $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>'; |
|
3517 | + $this->upgrader->strings[ 'skin_upgrade_end' ] = __( 'All installations have been completed.', 'tgmpa' ); |
|
3518 | + $this->upgrader->strings[ 'skin_before_update_header' ] = __( 'Installing Plugin %1$s (%2$d/%3$d)', 'tgmpa' ); |
|
3519 | 3519 | } |
3520 | 3520 | } |
3521 | 3521 | } |
@@ -3573,12 +3573,12 @@ discard block |
||
3573 | 3573 | if ( $this->tgmpa->is_tgmpa_complete() ) { |
3574 | 3574 | // All plugins are active, so we display the complete string and hide the menu to protect users. |
3575 | 3575 | echo '<style type="text/css">#adminmenu .wp-submenu li.current { display: none !important; }</style>'; |
3576 | - $update_actions['dashboard'] = sprintf( |
|
3577 | - esc_html( $this->tgmpa->strings['complete'] ), |
|
3578 | - '<a href="' . esc_url( self_admin_url() ) . '">' . esc_html__( 'Return to the Dashboard', 'tgmpa' ) . '</a>' |
|
3576 | + $update_actions[ 'dashboard' ] = sprintf( |
|
3577 | + esc_html( $this->tgmpa->strings[ 'complete' ] ), |
|
3578 | + '<a href="'.esc_url( self_admin_url() ).'">'.esc_html__( 'Return to the Dashboard', 'tgmpa' ).'</a>' |
|
3579 | 3579 | ); |
3580 | 3580 | } else { |
3581 | - $update_actions['tgmpa_page'] = '<a href="' . esc_url( $this->tgmpa->get_tgmpa_url() ) . '" target="_parent">' . esc_html( $this->tgmpa->strings['return'] ) . '</a>'; |
|
3581 | + $update_actions[ 'tgmpa_page' ] = '<a href="'.esc_url( $this->tgmpa->get_tgmpa_url() ).'" target="_parent">'.esc_html( $this->tgmpa->strings[ 'return' ] ).'</a>'; |
|
3582 | 3582 | } |
3583 | 3583 | |
3584 | 3584 | /** |
@@ -3668,7 +3668,7 @@ discard block |
||
3668 | 3668 | * @return string |
3669 | 3669 | */ |
3670 | 3670 | public static function wrap_in_em( $string ) { |
3671 | - return '<em>' . wp_kses_post( $string ) . '</em>'; |
|
3671 | + return '<em>'.wp_kses_post( $string ).'</em>'; |
|
3672 | 3672 | } |
3673 | 3673 | |
3674 | 3674 | /** |
@@ -3682,7 +3682,7 @@ discard block |
||
3682 | 3682 | * @return string |
3683 | 3683 | */ |
3684 | 3684 | public static function wrap_in_strong( $string ) { |
3685 | - return '<strong>' . wp_kses_post( $string ) . '</strong>'; |
|
3685 | + return '<strong>'.wp_kses_post( $string ).'</strong>'; |
|
3686 | 3686 | } |
3687 | 3687 | |
3688 | 3688 | /** |
@@ -3719,7 +3719,7 @@ discard block |
||
3719 | 3719 | */ |
3720 | 3720 | protected static function emulate_filter_bool( $value ) { |
3721 | 3721 | // @codingStandardsIgnoreStart |
3722 | - static $true = array( |
|
3722 | + static $true = array( |
|
3723 | 3723 | '1', |
3724 | 3724 | 'true', 'True', 'TRUE', |
3725 | 3725 | 'y', 'Y', |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | /** |
21 | 21 | * Include the TGM_Plugin_Activation class. |
22 | 22 | */ |
23 | -require_once dirname( __FILE__ ) . '/class-tgm-plugin-activation.php'; |
|
23 | +require_once dirname( __FILE__ ).'/class-tgm-plugin-activation.php'; |
|
24 | 24 | |
25 | 25 | add_action( 'tgmpa_register', 'my_theme_register_required_plugins' ); |
26 | 26 | /** |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | array( |
49 | 49 | 'name' => 'TGM Example Plugin', // The plugin name. |
50 | 50 | 'slug' => 'tgm-example-plugin', // The plugin slug (typically the folder name). |
51 | - 'source' => get_stylesheet_directory() . '/lib/plugins/tgm-example-plugin.zip', // The plugin source. |
|
51 | + 'source' => get_stylesheet_directory().'/lib/plugins/tgm-example-plugin.zip', // The plugin source. |
|
52 | 52 | 'required' => true, // If false, the plugin is only 'recommended' instead of required. |
53 | 53 | 'version' => '', // E.g. 1.0.0. If set, the active plugin must be this version or higher. If the plugin version is higher than the plugin version installed, the user will be notified to update the plugin. |
54 | 54 | 'force_activation' => false, // If true, plugin is activated upon theme activation and cannot be deactivated until theme switch. |
@@ -106,16 +106,16 @@ discard block |
||
106 | 106 | * Only uncomment the strings in the config array if you want to customize the strings. |
107 | 107 | */ |
108 | 108 | $config = array( |
109 | - 'id' => 'tgmpa', // Unique ID for hashing notices for multiple instances of TGMPA. |
|
110 | - 'default_path' => '', // Default absolute path to bundled plugins. |
|
109 | + 'id' => 'tgmpa', // Unique ID for hashing notices for multiple instances of TGMPA. |
|
110 | + 'default_path' => '', // Default absolute path to bundled plugins. |
|
111 | 111 | 'menu' => 'tgmpa-install-plugins', // Menu slug. |
112 | - 'parent_slug' => 'themes.php', // Parent menu slug. |
|
113 | - 'capability' => 'edit_theme_options', // Capability needed to view plugin install page, should be a capability associated with the parent menu used. |
|
114 | - 'has_notices' => true, // Show admin notices or not. |
|
115 | - 'dismissable' => true, // If false, a user cannot dismiss the nag message. |
|
116 | - 'dismiss_msg' => '', // If 'dismissable' is false, this message will be output at top of nag. |
|
117 | - 'is_automatic' => false, // Automatically activate plugins after installation or not. |
|
118 | - 'message' => '', // Message to output right before the plugins table. |
|
112 | + 'parent_slug' => 'themes.php', // Parent menu slug. |
|
113 | + 'capability' => 'edit_theme_options', // Capability needed to view plugin install page, should be a capability associated with the parent menu used. |
|
114 | + 'has_notices' => true, // Show admin notices or not. |
|
115 | + 'dismissable' => true, // If false, a user cannot dismiss the nag message. |
|
116 | + 'dismiss_msg' => '', // If 'dismissable' is false, this message will be output at top of nag. |
|
117 | + 'is_automatic' => false, // Automatically activate plugins after installation or not. |
|
118 | + 'message' => '', // Message to output right before the plugins table. |
|
119 | 119 | |
120 | 120 | /* |
121 | 121 | 'strings' => array( |