|
@@ -255,7 +255,7 @@ discard block |
|
|
block discarded – undo |
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 |
|
|
block discarded – undo |
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 |
|
|
block discarded – undo |
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 |
|
|
block discarded – undo |
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 |
|
|
block discarded – undo |
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 |
|
|
block discarded – undo |
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 |
|
|
block discarded – undo |
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 |
|
|
block discarded – undo |
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 |
|
|
block discarded – undo |
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
|
); |
|
@@ -708,9 +708,9 @@ discard block |
|
|
block discarded – undo |
708
|
708
|
} |
709
|
709
|
|
710
|
710
|
if ( 'themes.php' === $this->parent_slug ) { |
711
|
|
- $this->page_hook = call_user_func( 'add_theme_page', $args['page_title'], $args['menu_title'], $args['capability'], $args['menu_slug'], $args['function'] ); |
|
711
|
+ $this->page_hook = call_user_func( 'add_theme_page', $args[ 'page_title' ], $args[ 'menu_title' ], $args[ 'capability' ], $args[ 'menu_slug' ], $args[ 'function' ] ); |
712
|
712
|
} else { |
713
|
|
- $this->page_hook = call_user_func( 'add_submenu_page', $args['parent_slug'], $args['page_title'], $args['menu_title'], $args['capability'], $args['menu_slug'], $args['function'] ); |
|
713
|
+ $this->page_hook = call_user_func( 'add_submenu_page', $args[ 'parent_slug' ], $args[ 'page_title' ], $args[ 'menu_title' ], $args[ 'capability' ], $args[ 'menu_slug' ], $args[ 'function' ] ); |
714
|
714
|
} |
715
|
715
|
} |
716
|
716
|
|
|
@@ -779,37 +779,37 @@ discard block |
|
|
block discarded – undo |
779
|
779
|
* @return boolean True on success, false on failure. |
780
|
780
|
*/ |
781
|
781
|
protected function do_plugin_install() { |
782
|
|
- if ( empty( $_GET['plugin'] ) ) { |
|
782
|
+ if ( empty( $_GET[ 'plugin' ] ) ) { |
783
|
783
|
return false; |
784
|
784
|
} |
785
|
785
|
|
786
|
786
|
// All plugin information will be stored in an array for processing. |
787
|
|
- $slug = $this->sanitize_key( urldecode( $_GET['plugin'] ) ); |
|
787
|
+ $slug = $this->sanitize_key( urldecode( $_GET[ 'plugin' ] ) ); |
788
|
788
|
|
789
|
789
|
if ( ! isset( $this->plugins[ $slug ] ) ) { |
790
|
790
|
return false; |
791
|
791
|
} |
792
|
792
|
|
793
|
793
|
// Was an install or upgrade action link clicked? |
794
|
|
- if ( ( isset( $_GET['tgmpa-install'] ) && 'install-plugin' === $_GET['tgmpa-install'] ) || ( isset( $_GET['tgmpa-update'] ) && 'update-plugin' === $_GET['tgmpa-update'] ) ) { |
|
794
|
+ if ( ( isset( $_GET[ 'tgmpa-install' ] ) && 'install-plugin' === $_GET[ 'tgmpa-install' ] ) || ( isset( $_GET[ 'tgmpa-update' ] ) && 'update-plugin' === $_GET[ 'tgmpa-update' ] ) ) { |
795
|
795
|
|
796
|
796
|
$install_type = 'install'; |
797
|
|
- if ( isset( $_GET['tgmpa-update'] ) && 'update-plugin' === $_GET['tgmpa-update'] ) { |
|
797
|
+ if ( isset( $_GET[ 'tgmpa-update' ] ) && 'update-plugin' === $_GET[ 'tgmpa-update' ] ) { |
798
|
798
|
$install_type = 'update'; |
799
|
799
|
} |
800
|
800
|
|
801
|
|
- check_admin_referer( 'tgmpa-' . $install_type, 'tgmpa-nonce' ); |
|
801
|
+ check_admin_referer( 'tgmpa-'.$install_type, 'tgmpa-nonce' ); |
802
|
802
|
|
803
|
803
|
// Pass necessary information via URL if WP_Filesystem is needed. |
804
|
804
|
$url = wp_nonce_url( |
805
|
805
|
add_query_arg( |
806
|
806
|
array( |
807
|
807
|
'plugin' => urlencode( $slug ), |
808
|
|
- 'tgmpa-' . $install_type => $install_type . '-plugin', |
|
808
|
+ 'tgmpa-'.$install_type => $install_type.'-plugin', |
809
|
809
|
), |
810
|
810
|
$this->get_tgmpa_url() |
811
|
811
|
), |
812
|
|
- 'tgmpa-' . $install_type, |
|
812
|
+ 'tgmpa-'.$install_type, |
813
|
813
|
'tgmpa-nonce' |
814
|
814
|
); |
815
|
815
|
|
|
@@ -828,29 +828,29 @@ discard block |
|
|
block discarded – undo |
828
|
828
|
|
829
|
829
|
// Prep variables for Plugin_Installer_Skin class. |
830
|
830
|
$extra = array(); |
831
|
|
- $extra['slug'] = $slug; // Needed for potentially renaming of directory name. |
|
831
|
+ $extra[ 'slug' ] = $slug; // Needed for potentially renaming of directory name. |
832
|
832
|
$source = $this->get_download_url( $slug ); |
833
|
|
- $api = ( 'repo' === $this->plugins[ $slug ]['source_type'] ) ? $this->get_plugins_api( $slug ) : null; |
|
833
|
+ $api = ( 'repo' === $this->plugins[ $slug ][ 'source_type' ] ) ? $this->get_plugins_api( $slug ) : null; |
834
|
834
|
$api = ( false !== $api ) ? $api : null; |
835
|
835
|
|
836
|
836
|
$url = add_query_arg( |
837
|
837
|
array( |
838
|
|
- 'action' => $install_type . '-plugin', |
|
838
|
+ 'action' => $install_type.'-plugin', |
839
|
839
|
'plugin' => urlencode( $slug ), |
840
|
840
|
), |
841
|
841
|
'update.php' |
842
|
842
|
); |
843
|
843
|
|
844
|
844
|
if ( ! class_exists( 'Plugin_Upgrader', false ) ) { |
845
|
|
- require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
|
845
|
+ require_once ABSPATH.'wp-admin/includes/class-wp-upgrader.php'; |
846
|
846
|
} |
847
|
847
|
|
848
|
|
- $title = ( 'update' === $install_type ) ? $this->strings['updating'] : $this->strings['installing']; |
|
848
|
+ $title = ( 'update' === $install_type ) ? $this->strings[ 'updating' ] : $this->strings[ 'installing' ]; |
849
|
849
|
$skin_args = array( |
850
|
|
- 'type' => ( 'bundled' !== $this->plugins[ $slug ]['source_type'] ) ? 'web' : 'upload', |
851
|
|
- 'title' => sprintf( $title, $this->plugins[ $slug ]['name'] ), |
|
850
|
+ 'type' => ( 'bundled' !== $this->plugins[ $slug ][ 'source_type' ] ) ? 'web' : 'upload', |
|
851
|
+ 'title' => sprintf( $title, $this->plugins[ $slug ][ 'name' ] ), |
852
|
852
|
'url' => esc_url_raw( $url ), |
853
|
|
- 'nonce' => $install_type . '-plugin_' . $slug, |
|
853
|
+ 'nonce' => $install_type.'-plugin_'.$slug, |
854
|
854
|
'plugin' => '', |
855
|
855
|
'api' => $api, |
856
|
856
|
'extra' => $extra, |
|
@@ -858,7 +858,7 @@ discard block |
|
|
block discarded – undo |
858
|
858
|
unset( $title ); |
859
|
859
|
|
860
|
860
|
if ( 'update' === $install_type ) { |
861
|
|
- $skin_args['plugin'] = $this->plugins[ $slug ]['file_path']; |
|
861
|
+ $skin_args[ 'plugin' ] = $this->plugins[ $slug ][ 'file_path' ]; |
862
|
862
|
$skin = new Plugin_Upgrader_Skin( $skin_args ); |
863
|
863
|
} else { |
864
|
864
|
$skin = new Plugin_Installer_Skin( $skin_args ); |
|
@@ -873,10 +873,10 @@ discard block |
|
|
block discarded – undo |
873
|
873
|
if ( 'update' === $install_type ) { |
874
|
874
|
// Inject our info into the update transient. |
875
|
875
|
$to_inject = array( $slug => $this->plugins[ $slug ] ); |
876
|
|
- $to_inject[ $slug ]['source'] = $source; |
|
876
|
+ $to_inject[ $slug ][ 'source' ] = $source; |
877
|
877
|
$this->inject_update_info( $to_inject ); |
878
|
878
|
|
879
|
|
- $upgrader->upgrade( $this->plugins[ $slug ]['file_path'] ); |
|
879
|
+ $upgrader->upgrade( $this->plugins[ $slug ][ 'file_path' ] ); |
880
|
880
|
} else { |
881
|
881
|
$upgrader->install( $source ); |
882
|
882
|
} |
|
@@ -899,18 +899,18 @@ discard block |
|
|
block discarded – undo |
899
|
899
|
|
900
|
900
|
// Display message based on if all plugins are now active or not. |
901
|
901
|
if ( $this->is_tgmpa_complete() ) { |
902
|
|
- echo '<p>', sprintf( esc_html( $this->strings['complete'] ), '<a href="' . esc_url( self_admin_url() ) . '">' . esc_html__( 'Return to the Dashboard', 'tgmpa' ) . '</a>' ), '</p>'; |
|
902
|
+ echo '<p>', sprintf( esc_html( $this->strings[ 'complete' ] ), '<a href="'.esc_url( self_admin_url() ).'">'.esc_html__( 'Return to the Dashboard', 'tgmpa' ).'</a>' ), '</p>'; |
903
|
903
|
echo '<style type="text/css">#adminmenu .wp-submenu li.current { display: none !important; }</style>'; |
904
|
904
|
} else { |
905
|
|
- echo '<p><a href="', esc_url( $this->get_tgmpa_url() ), '" target="_parent">', esc_html( $this->strings['return'] ), '</a></p>'; |
|
905
|
+ echo '<p><a href="', esc_url( $this->get_tgmpa_url() ), '" target="_parent">', esc_html( $this->strings[ 'return' ] ), '</a></p>'; |
906
|
906
|
} |
907
|
907
|
|
908
|
908
|
return true; |
909
|
|
- } elseif ( isset( $this->plugins[ $slug ]['file_path'], $_GET['tgmpa-activate'] ) && 'activate-plugin' === $_GET['tgmpa-activate'] ) { |
|
909
|
+ } elseif ( isset( $this->plugins[ $slug ][ 'file_path' ], $_GET[ 'tgmpa-activate' ] ) && 'activate-plugin' === $_GET[ 'tgmpa-activate' ] ) { |
910
|
910
|
// Activate action link was clicked. |
911
|
911
|
check_admin_referer( 'tgmpa-activate', 'tgmpa-nonce' ); |
912
|
912
|
|
913
|
|
- if ( false === $this->activate_single_plugin( $this->plugins[ $slug ]['file_path'], $slug ) ) { |
|
913
|
+ if ( false === $this->activate_single_plugin( $this->plugins[ $slug ][ 'file_path' ], $slug ) ) { |
914
|
914
|
return true; // Finish execution of the function early as we encountered an error. |
915
|
915
|
} |
916
|
916
|
} |
|
@@ -933,7 +933,7 @@ discard block |
|
|
block discarded – undo |
933
|
933
|
} |
934
|
934
|
|
935
|
935
|
foreach ( $plugins as $slug => $plugin ) { |
936
|
|
- $file_path = $plugin['file_path']; |
|
936
|
+ $file_path = $plugin[ 'file_path' ]; |
937
|
937
|
|
938
|
938
|
if ( empty( $repo_updates->response[ $file_path ] ) ) { |
939
|
939
|
$repo_updates->response[ $file_path ] = new stdClass; |
|
@@ -942,10 +942,10 @@ discard block |
|
|
block discarded – undo |
942
|
942
|
// We only really need to set package, but let's do all we can in case WP changes something. |
943
|
943
|
$repo_updates->response[ $file_path ]->slug = $slug; |
944
|
944
|
$repo_updates->response[ $file_path ]->plugin = $file_path; |
945
|
|
- $repo_updates->response[ $file_path ]->new_version = $plugin['version']; |
946
|
|
- $repo_updates->response[ $file_path ]->package = $plugin['source']; |
947
|
|
- if ( empty( $repo_updates->response[ $file_path ]->url ) && ! empty( $plugin['external_url'] ) ) { |
948
|
|
- $repo_updates->response[ $file_path ]->url = $plugin['external_url']; |
|
945
|
+ $repo_updates->response[ $file_path ]->new_version = $plugin[ 'version' ]; |
|
946
|
+ $repo_updates->response[ $file_path ]->package = $plugin[ 'source' ]; |
|
947
|
+ if ( empty( $repo_updates->response[ $file_path ]->url ) && ! empty( $plugin[ 'external_url' ] ) ) { |
|
948
|
+ $repo_updates->response[ $file_path ]->url = $plugin[ 'external_url' ]; |
949
|
949
|
} |
950
|
950
|
} |
951
|
951
|
|
|
@@ -969,13 +969,13 @@ discard block |
|
|
block discarded – undo |
969
|
969
|
* @return string $source |
970
|
970
|
*/ |
971
|
971
|
public function maybe_adjust_source_dir( $source, $remote_source, $upgrader ) { |
972
|
|
- if ( ! $this->is_tgmpa_page() || ! is_object( $GLOBALS['wp_filesystem'] ) ) { |
|
972
|
+ if ( ! $this->is_tgmpa_page() || ! is_object( $GLOBALS[ 'wp_filesystem' ] ) ) { |
973
|
973
|
return $source; |
974
|
974
|
} |
975
|
975
|
|
976
|
976
|
// Check for single file plugins. |
977
|
|
- $source_files = array_keys( $GLOBALS['wp_filesystem']->dirlist( $remote_source ) ); |
978
|
|
- if ( 1 === count( $source_files ) && false === $GLOBALS['wp_filesystem']->is_dir( $source ) ) { |
|
977
|
+ $source_files = array_keys( $GLOBALS[ 'wp_filesystem' ]->dirlist( $remote_source ) ); |
|
978
|
+ if ( 1 === count( $source_files ) && false === $GLOBALS[ 'wp_filesystem' ]->is_dir( $source ) ) { |
979
|
979
|
return $source; |
980
|
980
|
} |
981
|
981
|
|
|
@@ -983,12 +983,12 @@ discard block |
|
|
block discarded – undo |
983
|
983
|
$desired_slug = ''; |
984
|
984
|
|
985
|
985
|
// Figure out what the slug is supposed to be. |
986
|
|
- if ( false === $upgrader->bulk && ! empty( $upgrader->skin->options['extra']['slug'] ) ) { |
987
|
|
- $desired_slug = $upgrader->skin->options['extra']['slug']; |
|
986
|
+ if ( false === $upgrader->bulk && ! empty( $upgrader->skin->options[ 'extra' ][ 'slug' ] ) ) { |
|
987
|
+ $desired_slug = $upgrader->skin->options[ 'extra' ][ 'slug' ]; |
988
|
988
|
} else { |
989
|
989
|
// Bulk installer contains less info, so fall back on the info registered here. |
990
|
990
|
foreach ( $this->plugins as $slug => $plugin ) { |
991
|
|
- if ( ! empty( $upgrader->skin->plugin_names[ $upgrader->skin->i ] ) && $plugin['name'] === $upgrader->skin->plugin_names[ $upgrader->skin->i ] ) { |
|
991
|
+ if ( ! empty( $upgrader->skin->plugin_names[ $upgrader->skin->i ] ) && $plugin[ 'name' ] === $upgrader->skin->plugin_names[ $upgrader->skin->i ] ) { |
992
|
992
|
$desired_slug = $slug; |
993
|
993
|
break; |
994
|
994
|
} |
|
@@ -1001,15 +1001,15 @@ discard block |
|
|
block discarded – undo |
1001
|
1001
|
|
1002
|
1002
|
if ( ! empty( $subdir_name ) && $subdir_name !== $desired_slug ) { |
1003
|
1003
|
$from = untrailingslashit( $source ); |
1004
|
|
- $to = trailingslashit( $remote_source ) . $desired_slug; |
|
1004
|
+ $to = trailingslashit( $remote_source ).$desired_slug; |
1005
|
1005
|
|
1006
|
|
- if ( true === $GLOBALS['wp_filesystem']->move( $from, $to ) ) { |
|
1006
|
+ if ( true === $GLOBALS[ 'wp_filesystem' ]->move( $from, $to ) ) { |
1007
|
1007
|
return trailingslashit( $to ); |
1008
|
1008
|
} else { |
1009
|
|
- 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 ) ); |
|
1009
|
+ 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 ) ); |
1010
|
1010
|
} |
1011
|
1011
|
} elseif ( empty( $subdir_name ) ) { |
1012
|
|
- 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 ) ); |
|
1012
|
+ 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 ) ); |
1013
|
1013
|
} |
1014
|
1014
|
} |
1015
|
1015
|
|
|
@@ -1033,19 +1033,19 @@ discard block |
|
|
block discarded – undo |
1033
|
1033
|
|
1034
|
1034
|
if ( is_wp_error( $activate ) ) { |
1035
|
1035
|
echo '<div id="message" class="error"><p>', wp_kses_post( $activate->get_error_message() ), '</p></div>', |
1036
|
|
- '<p><a href="', esc_url( $this->get_tgmpa_url() ), '" target="_parent">', esc_html( $this->strings['return'] ), '</a></p>'; |
|
1036
|
+ '<p><a href="', esc_url( $this->get_tgmpa_url() ), '" target="_parent">', esc_html( $this->strings[ 'return' ] ), '</a></p>'; |
1037
|
1037
|
|
1038
|
1038
|
return false; // End it here if there is an error with activation. |
1039
|
1039
|
} else { |
1040
|
1040
|
if ( ! $automatic ) { |
1041
|
1041
|
// Make sure message doesn't display again if bulk activation is performed |
1042
|
1042
|
// immediately after a single activation. |
1043
|
|
- if ( ! isset( $_POST['action'] ) ) { // WPCS: CSRF OK. |
1044
|
|
- echo '<div id="message" class="updated"><p>', esc_html( $this->strings['activated_successfully'] ), ' <strong>', esc_html( $this->plugins[ $slug ]['name'] ), '.</strong></p></div>'; |
|
1043
|
+ if ( ! isset( $_POST[ 'action' ] ) ) { // WPCS: CSRF OK. |
|
1044
|
+ echo '<div id="message" class="updated"><p>', esc_html( $this->strings[ 'activated_successfully' ] ), ' <strong>', esc_html( $this->plugins[ $slug ][ 'name' ] ), '.</strong></p></div>'; |
1045
|
1045
|
} |
1046
|
1046
|
} else { |
1047
|
1047
|
// Simpler message layout for use on the plugin install page. |
1048
|
|
- echo '<p>', esc_html( $this->strings['plugin_activated'] ), '</p>'; |
|
1048
|
+ echo '<p>', esc_html( $this->strings[ 'plugin_activated' ] ), '</p>'; |
1049
|
1049
|
} |
1050
|
1050
|
} |
1051
|
1051
|
} elseif ( $this->is_plugin_active( $slug ) ) { |
|
@@ -1053,25 +1053,25 @@ discard block |
|
|
block discarded – undo |
1053
|
1053
|
// on the plugin install page. |
1054
|
1054
|
echo '<div id="message" class="error"><p>', |
1055
|
1055
|
sprintf( |
1056
|
|
- esc_html( $this->strings['plugin_already_active'] ), |
1057
|
|
- '<strong>' . esc_html( $this->plugins[ $slug ]['name'] ) . '</strong>' |
|
1056
|
+ esc_html( $this->strings[ 'plugin_already_active' ] ), |
|
1057
|
+ '<strong>'.esc_html( $this->plugins[ $slug ][ 'name' ] ).'</strong>' |
1058
|
1058
|
), |
1059
|
1059
|
'</p></div>'; |
1060
|
1060
|
} elseif ( $this->does_plugin_require_update( $slug ) ) { |
1061
|
1061
|
if ( ! $automatic ) { |
1062
|
1062
|
// Make sure message doesn't display again if bulk activation is performed |
1063
|
1063
|
// immediately after a single activation. |
1064
|
|
- if ( ! isset( $_POST['action'] ) ) { // WPCS: CSRF OK. |
|
1064
|
+ if ( ! isset( $_POST[ 'action' ] ) ) { // WPCS: CSRF OK. |
1065
|
1065
|
echo '<div id="message" class="error"><p>', |
1066
|
1066
|
sprintf( |
1067
|
|
- esc_html( $this->strings['plugin_needs_higher_version'] ), |
1068
|
|
- '<strong>' . esc_html( $this->plugins[ $slug ]['name'] ) . '</strong>' |
|
1067
|
+ esc_html( $this->strings[ 'plugin_needs_higher_version' ] ), |
|
1068
|
+ '<strong>'.esc_html( $this->plugins[ $slug ][ 'name' ] ).'</strong>' |
1069
|
1069
|
), |
1070
|
1070
|
'</p></div>'; |
1071
|
1071
|
} |
1072
|
1072
|
} else { |
1073
|
1073
|
// Simpler message layout for use on the plugin install page. |
1074
|
|
- echo '<p>', sprintf( esc_html( $this->strings['plugin_needs_higher_version'] ), esc_html( $this->plugins[ $slug ]['name'] ) ), '</p>'; |
|
1074
|
+ echo '<p>', sprintf( esc_html( $this->strings[ 'plugin_needs_higher_version' ] ), esc_html( $this->plugins[ $slug ][ 'name' ] ) ), '</p>'; |
1075
|
1075
|
} |
1076
|
1076
|
} |
1077
|
1077
|
|
|
@@ -1095,7 +1095,7 @@ discard block |
|
|
block discarded – undo |
1095
|
1095
|
*/ |
1096
|
1096
|
public function notices() { |
1097
|
1097
|
// Remove nag on the install page / Return early if the nag message has been dismissed or user < author. |
1098
|
|
- 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' ) ) ) { |
|
1098
|
+ 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' ) ) ) { |
1099
|
1099
|
return; |
1100
|
1100
|
} |
1101
|
1101
|
|
|
@@ -1117,13 +1117,13 @@ discard block |
|
|
block discarded – undo |
1117
|
1117
|
if ( current_user_can( 'install_plugins' ) ) { |
1118
|
1118
|
$install_link_count++; |
1119
|
1119
|
|
1120
|
|
- if ( true === $plugin['required'] ) { |
1121
|
|
- $message['notice_can_install_required'][] = $slug; |
|
1120
|
+ if ( true === $plugin[ 'required' ] ) { |
|
1121
|
+ $message[ 'notice_can_install_required' ][ ] = $slug; |
1122
|
1122
|
} else { |
1123
|
|
- $message['notice_can_install_recommended'][] = $slug; |
|
1123
|
+ $message[ 'notice_can_install_recommended' ][ ] = $slug; |
1124
|
1124
|
} |
1125
|
1125
|
} |
1126
|
|
- if ( true === $plugin['required'] ) { |
|
1126
|
+ if ( true === $plugin[ 'required' ] ) { |
1127
|
1127
|
$total_required_action_count++; |
1128
|
1128
|
} |
1129
|
1129
|
} else { |
|
@@ -1131,13 +1131,13 @@ discard block |
|
|
block discarded – undo |
1131
|
1131
|
if ( current_user_can( 'activate_plugins' ) ) { |
1132
|
1132
|
$activate_link_count++; |
1133
|
1133
|
|
1134
|
|
- if ( true === $plugin['required'] ) { |
1135
|
|
- $message['notice_can_activate_required'][] = $slug; |
|
1134
|
+ if ( true === $plugin[ 'required' ] ) { |
|
1135
|
+ $message[ 'notice_can_activate_required' ][ ] = $slug; |
1136
|
1136
|
} else { |
1137
|
|
- $message['notice_can_activate_recommended'][] = $slug; |
|
1137
|
+ $message[ 'notice_can_activate_recommended' ][ ] = $slug; |
1138
|
1138
|
} |
1139
|
1139
|
} |
1140
|
|
- if ( true === $plugin['required'] ) { |
|
1140
|
+ if ( true === $plugin[ 'required' ] ) { |
1141
|
1141
|
$total_required_action_count++; |
1142
|
1142
|
} |
1143
|
1143
|
} |
|
@@ -1148,12 +1148,12 @@ discard block |
|
|
block discarded – undo |
1148
|
1148
|
$update_link_count++; |
1149
|
1149
|
|
1150
|
1150
|
if ( $this->does_plugin_require_update( $slug ) ) { |
1151
|
|
- $message['notice_ask_to_update'][] = $slug; |
|
1151
|
+ $message[ 'notice_ask_to_update' ][ ] = $slug; |
1152
|
1152
|
} elseif ( false !== $this->does_plugin_have_update( $slug ) ) { |
1153
|
|
- $message['notice_ask_to_update_maybe'][] = $slug; |
|
1153
|
+ $message[ 'notice_ask_to_update_maybe' ][ ] = $slug; |
1154
|
1154
|
} |
1155
|
1155
|
} |
1156
|
|
- if ( true === $plugin['required'] ) { |
|
1156
|
+ if ( true === $plugin[ 'required' ] ) { |
1157
|
1157
|
$total_required_action_count++; |
1158
|
1158
|
} |
1159
|
1159
|
} |
|
@@ -1168,10 +1168,10 @@ discard block |
|
|
block discarded – undo |
1168
|
1168
|
|
1169
|
1169
|
// As add_settings_error() wraps the final message in a <p> and as the final message can't be |
1170
|
1170
|
// filtered, using <p>'s in our html would render invalid html output. |
1171
|
|
- $line_template = '<span style="display: block; margin: 0.5em 0.5em 0 0; clear: both;">%s</span>' . "\n"; |
|
1171
|
+ $line_template = '<span style="display: block; margin: 0.5em 0.5em 0 0; clear: both;">%s</span>'."\n"; |
1172
|
1172
|
|
1173
|
1173
|
if ( ! current_user_can( 'activate_plugins' ) && ! current_user_can( 'install_plugins' ) && ! current_user_can( 'update_plugins' ) ) { |
1174
|
|
- $rendered = esc_html__( $this->strings['notice_cannot_install_activate'] ) . ' ' . esc_html__( $this->strings['contact_admin'] ); |
|
1174
|
+ $rendered = esc_html__( $this->strings[ 'notice_cannot_install_activate' ] ).' '.esc_html__( $this->strings[ 'contact_admin' ] ); |
1175
|
1175
|
$rendered .= $this->create_user_action_links_for_notice( 0, 0, 0, $line_template ); |
1176
|
1176
|
} else { |
1177
|
1177
|
|
|
@@ -1186,14 +1186,14 @@ discard block |
|
|
block discarded – undo |
1186
|
1186
|
|
1187
|
1187
|
// Get the external info link for a plugin if one is available. |
1188
|
1188
|
foreach ( $plugin_group as $plugin_slug ) { |
1189
|
|
- $linked_plugins[] = $this->get_info_link( $plugin_slug ); |
|
1189
|
+ $linked_plugins[ ] = $this->get_info_link( $plugin_slug ); |
1190
|
1190
|
} |
1191
|
1191
|
unset( $plugin_slug ); |
1192
|
1192
|
|
1193
|
1193
|
$count = count( $plugin_group ); |
1194
|
1194
|
$linked_plugins = array_map( array( 'TGMPA_Utils', 'wrap_in_em' ), $linked_plugins ); |
1195
|
1195
|
$last_plugin = array_pop( $linked_plugins ); // Pop off last name to prep for readability. |
1196
|
|
- $imploded = empty( $linked_plugins ) ? $last_plugin : ( implode( ', ', $linked_plugins ) . ' ' . esc_html_x( 'and', 'plugin A *and* plugin B', 'tgmpa' ) . ' ' . $last_plugin ); |
|
1196
|
+ $imploded = empty( $linked_plugins ) ? $last_plugin : ( implode( ', ', $linked_plugins ).' '.esc_html_x( 'and', 'plugin A *and* plugin B', 'tgmpa' ).' '.$last_plugin ); |
1197
|
1197
|
|
1198
|
1198
|
$rendered .= sprintf( |
1199
|
1199
|
$line_template, |
|
@@ -1215,7 +1215,7 @@ discard block |
|
|
block discarded – undo |
1215
|
1215
|
} |
1216
|
1216
|
|
1217
|
1217
|
// Admin options pages already output settings_errors, so this is to avoid duplication. |
1218
|
|
- if ( 'options-general' !== $GLOBALS['current_screen']->parent_base ) { |
|
1218
|
+ if ( 'options-general' !== $GLOBALS[ 'current_screen' ]->parent_base ) { |
1219
|
1219
|
$this->display_settings_errors(); |
1220
|
1220
|
} |
1221
|
1221
|
} |
|
@@ -1237,32 +1237,32 @@ discard block |
|
|
block discarded – undo |
1237
|
1237
|
'install' => '', |
1238
|
1238
|
'update' => '', |
1239
|
1239
|
'activate' => '', |
1240
|
|
- '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>' : '', |
|
1240
|
+ '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>' : '', |
1241
|
1241
|
); |
1242
|
1242
|
|
1243
|
1243
|
$link_template = '<a href="%2$s">%1$s</a>'; |
1244
|
1244
|
|
1245
|
1245
|
if ( current_user_can( 'install_plugins' ) ) { |
1246
|
1246
|
if ( $install_count > 0 ) { |
1247
|
|
- $action_links['install'] = sprintf( |
|
1247
|
+ $action_links[ 'install' ] = sprintf( |
1248
|
1248
|
$link_template, |
1249
|
|
- translate_nooped_plural( $this->strings['install_link'], $install_count, 'tgmpa' ), |
|
1249
|
+ translate_nooped_plural( $this->strings[ 'install_link' ], $install_count, 'tgmpa' ), |
1250
|
1250
|
esc_url( $this->get_tgmpa_status_url( 'install' ) ) |
1251
|
1251
|
); |
1252
|
1252
|
} |
1253
|
1253
|
if ( $update_count > 0 ) { |
1254
|
|
- $action_links['update'] = sprintf( |
|
1254
|
+ $action_links[ 'update' ] = sprintf( |
1255
|
1255
|
$link_template, |
1256
|
|
- translate_nooped_plural( $this->strings['update_link'], $update_count, 'tgmpa' ), |
|
1256
|
+ translate_nooped_plural( $this->strings[ 'update_link' ], $update_count, 'tgmpa' ), |
1257
|
1257
|
esc_url( $this->get_tgmpa_status_url( 'update' ) ) |
1258
|
1258
|
); |
1259
|
1259
|
} |
1260
|
1260
|
} |
1261
|
1261
|
|
1262
|
1262
|
if ( current_user_can( 'activate_plugins' ) && $activate_count > 0 ) { |
1263
|
|
- $action_links['activate'] = sprintf( |
|
1263
|
+ $action_links[ 'activate' ] = sprintf( |
1264
|
1264
|
$link_template, |
1265
|
|
- translate_nooped_plural( $this->strings['activate_link'], $activate_count, 'tgmpa' ), |
|
1265
|
+ translate_nooped_plural( $this->strings[ 'activate_link' ], $activate_count, 'tgmpa' ), |
1266
|
1266
|
esc_url( $this->get_tgmpa_status_url( 'activate' ) ) |
1267
|
1267
|
); |
1268
|
1268
|
} |
|
@@ -1290,8 +1290,8 @@ discard block |
|
|
block discarded – undo |
1290
|
1290
|
* @return string |
1291
|
1291
|
*/ |
1292
|
1292
|
protected function get_admin_notice_class() { |
1293
|
|
- if ( ! empty( $this->strings['nag_type'] ) ) { |
1294
|
|
- return sanitize_html_class( strtolower( $this->strings['nag_type'] ) ); |
|
1293
|
+ if ( ! empty( $this->strings[ 'nag_type' ] ) ) { |
|
1294
|
+ return sanitize_html_class( strtolower( $this->strings[ 'nag_type' ] ) ); |
1295
|
1295
|
} else { |
1296
|
1296
|
if ( version_compare( $this->wp_version, '4.2', '>=' ) ) { |
1297
|
1297
|
return 'notice-warning'; |
|
@@ -1314,7 +1314,7 @@ discard block |
|
|
block discarded – undo |
1314
|
1314
|
settings_errors( 'tgmpa' ); |
1315
|
1315
|
|
1316
|
1316
|
foreach ( (array) $wp_settings_errors as $key => $details ) { |
1317
|
|
- if ( 'tgmpa' === $details['setting'] ) { |
|
1317
|
+ if ( 'tgmpa' === $details[ 'setting' ] ) { |
1318
|
1318
|
unset( $wp_settings_errors[ $key ] ); |
1319
|
1319
|
break; |
1320
|
1320
|
} |
|
@@ -1329,8 +1329,8 @@ discard block |
|
|
block discarded – undo |
1329
|
1329
|
* @since 2.1.0 |
1330
|
1330
|
*/ |
1331
|
1331
|
public function dismiss() { |
1332
|
|
- if ( isset( $_GET['tgmpa-dismiss'] ) && check_admin_referer( 'tgmpa-dismis-' . get_current_user_id() ) ) { |
1333
|
|
- update_user_meta( get_current_user_id(), 'tgmpa_dismissed_notice_' . $this->id, 1 ); |
|
1332
|
+ if ( isset( $_GET[ 'tgmpa-dismiss' ] ) && check_admin_referer( 'tgmpa-dismis-'.get_current_user_id() ) ) { |
|
1333
|
+ update_user_meta( get_current_user_id(), 'tgmpa_dismissed_notice_'.$this->id, 1 ); |
1334
|
1334
|
} |
1335
|
1335
|
} |
1336
|
1336
|
|
|
@@ -1346,54 +1346,54 @@ discard block |
|
|
block discarded – undo |
1346
|
1346
|
* @return null Return early if incorrect argument. |
1347
|
1347
|
*/ |
1348
|
1348
|
public function register( $plugin ) { |
1349
|
|
- if ( empty( $plugin['slug'] ) || empty( $plugin['name'] ) ) { |
|
1349
|
+ if ( empty( $plugin[ 'slug' ] ) || empty( $plugin[ 'name' ] ) ) { |
1350
|
1350
|
return; |
1351
|
1351
|
} |
1352
|
1352
|
|
1353
|
|
- if ( empty( $plugin['slug'] ) || ! is_string( $plugin['slug'] ) || isset( $this->plugins[ $plugin['slug'] ] ) ) { |
|
1353
|
+ if ( empty( $plugin[ 'slug' ] ) || ! is_string( $plugin[ 'slug' ] ) || isset( $this->plugins[ $plugin[ 'slug' ] ] ) ) { |
1354
|
1354
|
return; |
1355
|
1355
|
} |
1356
|
1356
|
|
1357
|
1357
|
$defaults = array( |
1358
|
|
- 'name' => '', // String |
1359
|
|
- 'slug' => '', // String |
1360
|
|
- 'source' => 'repo', // String |
1361
|
|
- 'required' => false, // Boolean |
1362
|
|
- 'version' => '', // String |
1363
|
|
- 'force_activation' => false, // Boolean |
1364
|
|
- 'force_deactivation' => false, // Boolean |
1365
|
|
- 'external_url' => '', // String |
1366
|
|
- 'is_callable' => '', // String|Array. |
|
1358
|
+ 'name' => '', // String |
|
1359
|
+ 'slug' => '', // String |
|
1360
|
+ 'source' => 'repo', // String |
|
1361
|
+ 'required' => false, // Boolean |
|
1362
|
+ 'version' => '', // String |
|
1363
|
+ 'force_activation' => false, // Boolean |
|
1364
|
+ 'force_deactivation' => false, // Boolean |
|
1365
|
+ 'external_url' => '', // String |
|
1366
|
+ 'is_callable' => '', // String|Array. |
1367
|
1367
|
); |
1368
|
1368
|
|
1369
|
1369
|
// Prepare the received data. |
1370
|
1370
|
$plugin = wp_parse_args( $plugin, $defaults ); |
1371
|
1371
|
|
1372
|
1372
|
// Standardize the received slug. |
1373
|
|
- $plugin['slug'] = $this->sanitize_key( $plugin['slug'] ); |
|
1373
|
+ $plugin[ 'slug' ] = $this->sanitize_key( $plugin[ 'slug' ] ); |
1374
|
1374
|
|
1375
|
1375
|
// Forgive users for using string versions of booleans or floats for version number. |
1376
|
|
- $plugin['version'] = (string) $plugin['version']; |
1377
|
|
- $plugin['source'] = empty( $plugin['source'] ) ? 'repo' : $plugin['source']; |
1378
|
|
- $plugin['required'] = TGMPA_Utils::validate_bool( $plugin['required'] ); |
1379
|
|
- $plugin['force_activation'] = TGMPA_Utils::validate_bool( $plugin['force_activation'] ); |
1380
|
|
- $plugin['force_deactivation'] = TGMPA_Utils::validate_bool( $plugin['force_deactivation'] ); |
|
1376
|
+ $plugin[ 'version' ] = (string) $plugin[ 'version' ]; |
|
1377
|
+ $plugin[ 'source' ] = empty( $plugin[ 'source' ] ) ? 'repo' : $plugin[ 'source' ]; |
|
1378
|
+ $plugin[ 'required' ] = TGMPA_Utils::validate_bool( $plugin[ 'required' ] ); |
|
1379
|
+ $plugin[ 'force_activation' ] = TGMPA_Utils::validate_bool( $plugin[ 'force_activation' ] ); |
|
1380
|
+ $plugin[ 'force_deactivation' ] = TGMPA_Utils::validate_bool( $plugin[ 'force_deactivation' ] ); |
1381
|
1381
|
|
1382
|
1382
|
// Enrich the received data. |
1383
|
|
- $plugin['file_path'] = $this->_get_plugin_basename_from_slug( $plugin['slug'] ); |
1384
|
|
- $plugin['source_type'] = $this->get_plugin_source_type( $plugin['source'] ); |
|
1383
|
+ $plugin[ 'file_path' ] = $this->_get_plugin_basename_from_slug( $plugin[ 'slug' ] ); |
|
1384
|
+ $plugin[ 'source_type' ] = $this->get_plugin_source_type( $plugin[ 'source' ] ); |
1385
|
1385
|
|
1386
|
1386
|
// Set the class properties. |
1387
|
|
- $this->plugins[ $plugin['slug'] ] = $plugin; |
1388
|
|
- $this->sort_order[ $plugin['slug'] ] = $plugin['name']; |
|
1387
|
+ $this->plugins[ $plugin[ 'slug' ] ] = $plugin; |
|
1388
|
+ $this->sort_order[ $plugin[ 'slug' ] ] = $plugin[ 'name' ]; |
1389
|
1389
|
|
1390
|
1390
|
// Should we add the force activation hook ? |
1391
|
|
- if ( true === $plugin['force_activation'] ) { |
|
1391
|
+ if ( true === $plugin[ 'force_activation' ] ) { |
1392
|
1392
|
$this->has_forced_activation = true; |
1393
|
1393
|
} |
1394
|
1394
|
|
1395
|
1395
|
// Should we add the force deactivation hook ? |
1396
|
|
- if ( true === $plugin['force_deactivation'] ) { |
|
1396
|
+ if ( true === $plugin[ 'force_deactivation' ] ) { |
1397
|
1397
|
$this->has_forced_deactivation = true; |
1398
|
1398
|
} |
1399
|
1399
|
} |
|
@@ -1519,11 +1519,11 @@ discard block |
|
|
block discarded – undo |
1519
|
1519
|
*/ |
1520
|
1520
|
public function populate_file_path( $plugin_slug = '' ) { |
1521
|
1521
|
if ( ! empty( $plugin_slug ) && is_string( $plugin_slug ) && isset( $this->plugins[ $plugin_slug ] ) ) { |
1522
|
|
- $this->plugins[ $plugin_slug ]['file_path'] = $this->_get_plugin_basename_from_slug( $plugin_slug ); |
|
1522
|
+ $this->plugins[ $plugin_slug ][ 'file_path' ] = $this->_get_plugin_basename_from_slug( $plugin_slug ); |
1523
|
1523
|
} else { |
1524
|
1524
|
// Add file_path key for all plugins. |
1525
|
1525
|
foreach ( $this->plugins as $slug => $values ) { |
1526
|
|
- $this->plugins[ $slug ]['file_path'] = $this->_get_plugin_basename_from_slug( $slug ); |
|
1526
|
+ $this->plugins[ $slug ][ 'file_path' ] = $this->_get_plugin_basename_from_slug( $slug ); |
1527
|
1527
|
} |
1528
|
1528
|
} |
1529
|
1529
|
} |
|
@@ -1541,7 +1541,7 @@ discard block |
|
|
block discarded – undo |
1541
|
1541
|
$keys = array_keys( $this->get_plugins() ); |
1542
|
1542
|
|
1543
|
1543
|
foreach ( $keys as $key ) { |
1544
|
|
- if ( preg_match( '|^' . $slug . '/|', $key ) ) { |
|
1544
|
+ if ( preg_match( '|^'.$slug.'/|', $key ) ) { |
1545
|
1545
|
return $key; |
1546
|
1546
|
} |
1547
|
1547
|
} |
|
@@ -1563,7 +1563,7 @@ discard block |
|
|
block discarded – undo |
1563
|
1563
|
*/ |
1564
|
1564
|
public function _get_plugin_data_from_name( $name, $data = 'slug' ) { |
1565
|
1565
|
foreach ( $this->plugins as $values ) { |
1566
|
|
- if ( $name === $values['name'] && isset( $values[ $data ] ) ) { |
|
1566
|
+ if ( $name === $values[ 'name' ] && isset( $values[ $data ] ) ) { |
1567
|
1567
|
return $values[ $data ]; |
1568
|
1568
|
} |
1569
|
1569
|
} |
|
@@ -1582,13 +1582,13 @@ discard block |
|
|
block discarded – undo |
1582
|
1582
|
public function get_download_url( $slug ) { |
1583
|
1583
|
$dl_source = ''; |
1584
|
1584
|
|
1585
|
|
- switch ( $this->plugins[ $slug ]['source_type'] ) { |
|
1585
|
+ switch ( $this->plugins[ $slug ][ 'source_type' ] ) { |
1586
|
1586
|
case 'repo': |
1587
|
1587
|
return $this->get_wp_repo_download_url( $slug ); |
1588
|
1588
|
case 'external': |
1589
|
|
- return $this->plugins[ $slug ]['source']; |
|
1589
|
+ return $this->plugins[ $slug ][ 'source' ]; |
1590
|
1590
|
case 'bundled': |
1591
|
|
- return $this->default_path . $this->plugins[ $slug ]['source']; |
|
1591
|
+ return $this->default_path.$this->plugins[ $slug ][ 'source' ]; |
1592
|
1592
|
} |
1593
|
1593
|
|
1594
|
1594
|
return $dl_source; // Should never happen. |
|
@@ -1626,7 +1626,7 @@ discard block |
|
|
block discarded – undo |
1626
|
1626
|
|
1627
|
1627
|
if ( ! isset( $api[ $slug ] ) ) { |
1628
|
1628
|
if ( ! function_exists( 'plugins_api' ) ) { |
1629
|
|
- require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; |
|
1629
|
+ require_once ABSPATH.'wp-admin/includes/plugin-install.php'; |
1630
|
1630
|
} |
1631
|
1631
|
|
1632
|
1632
|
$response = plugins_api( 'plugin_information', array( 'slug' => $slug, 'fields' => array( 'sections' => false ) ) ); |
|
@@ -1634,7 +1634,7 @@ discard block |
|
|
block discarded – undo |
1634
|
1634
|
$api[ $slug ] = false; |
1635
|
1635
|
|
1636
|
1636
|
if ( is_wp_error( $response ) ) { |
1637
|
|
- wp_die( esc_html( $this->strings['oops'] ) ); |
|
1637
|
+ wp_die( esc_html( $this->strings[ 'oops' ] ) ); |
1638
|
1638
|
} else { |
1639
|
1639
|
$api[ $slug ] = $response; |
1640
|
1640
|
} |
|
@@ -1653,13 +1653,13 @@ discard block |
|
|
block discarded – undo |
1653
|
1653
|
* or the plugin name if not. |
1654
|
1654
|
*/ |
1655
|
1655
|
public function get_info_link( $slug ) { |
1656
|
|
- if ( ! empty( $this->plugins[ $slug ]['external_url'] ) && preg_match( self::IS_URL_REGEX, $this->plugins[ $slug ]['external_url'] ) ) { |
|
1656
|
+ if ( ! empty( $this->plugins[ $slug ][ 'external_url' ] ) && preg_match( self::IS_URL_REGEX, $this->plugins[ $slug ][ 'external_url' ] ) ) { |
1657
|
1657
|
$link = sprintf( |
1658
|
1658
|
'<a href="%1$s" target="_blank">%2$s</a>', |
1659
|
|
- esc_url( $this->plugins[ $slug ]['external_url'] ), |
1660
|
|
- esc_html( $this->plugins[ $slug ]['name'] ) |
|
1659
|
+ esc_url( $this->plugins[ $slug ][ 'external_url' ] ), |
|
1660
|
+ esc_html( $this->plugins[ $slug ][ 'name' ] ) |
1661
|
1661
|
); |
1662
|
|
- } elseif ( 'repo' === $this->plugins[ $slug ]['source_type'] ) { |
|
1662
|
+ } elseif ( 'repo' === $this->plugins[ $slug ][ 'source_type' ] ) { |
1663
|
1663
|
$url = add_query_arg( |
1664
|
1664
|
array( |
1665
|
1665
|
'tab' => 'plugin-information', |
|
@@ -1674,10 +1674,10 @@ discard block |
|
|
block discarded – undo |
1674
|
1674
|
$link = sprintf( |
1675
|
1675
|
'<a href="%1$s" class="thickbox">%2$s</a>', |
1676
|
1676
|
esc_url( $url ), |
1677
|
|
- esc_html( $this->plugins[ $slug ]['name'] ) |
|
1677
|
+ esc_html( $this->plugins[ $slug ][ 'name' ] ) |
1678
|
1678
|
); |
1679
|
1679
|
} else { |
1680
|
|
- $link = esc_html( $this->plugins[ $slug ]['name'] ); // No hyperlink. |
|
1680
|
+ $link = esc_html( $this->plugins[ $slug ][ 'name' ] ); // No hyperlink. |
1681
|
1681
|
} |
1682
|
1682
|
|
1683
|
1683
|
return $link; |
|
@@ -1691,7 +1691,7 @@ discard block |
|
|
block discarded – undo |
1691
|
1691
|
* @return boolean True when on the TGMPA page, false otherwise. |
1692
|
1692
|
*/ |
1693
|
1693
|
protected function is_tgmpa_page() { |
1694
|
|
- return isset( $_GET['page'] ) && $this->menu === $_GET['page']; |
|
1694
|
+ return isset( $_GET[ 'page' ] ) && $this->menu === $_GET[ 'page' ]; |
1695
|
1695
|
} |
1696
|
1696
|
|
1697
|
1697
|
/** |
|
@@ -1773,7 +1773,7 @@ discard block |
|
|
block discarded – undo |
1773
|
1773
|
public function is_plugin_installed( $slug ) { |
1774
|
1774
|
$installed_plugins = $this->get_plugins(); // Retrieve a list of all installed plugins (WP cached). |
1775
|
1775
|
|
1776
|
|
- return ( ! empty( $installed_plugins[ $this->plugins[ $slug ]['file_path'] ] ) ); |
|
1776
|
+ return ( ! empty( $installed_plugins[ $this->plugins[ $slug ][ 'file_path' ] ] ) ); |
1777
|
1777
|
} |
1778
|
1778
|
|
1779
|
1779
|
/** |
|
@@ -1785,7 +1785,7 @@ discard block |
|
|
block discarded – undo |
1785
|
1785
|
* @return bool True if active, false otherwise. |
1786
|
1786
|
*/ |
1787
|
1787
|
public function is_plugin_active( $slug ) { |
1788
|
|
- return ( ( ! empty( $this->plugins[ $slug ]['is_callable'] ) && is_callable( $this->plugins[ $slug ]['is_callable'] ) ) || is_plugin_active( $this->plugins[ $slug ]['file_path'] ) ); |
|
1788
|
+ return ( ( ! empty( $this->plugins[ $slug ][ 'is_callable' ] ) && is_callable( $this->plugins[ $slug ][ 'is_callable' ] ) ) || is_plugin_active( $this->plugins[ $slug ][ 'file_path' ] ) ); |
1789
|
1789
|
} |
1790
|
1790
|
|
1791
|
1791
|
/** |
|
@@ -1799,7 +1799,7 @@ discard block |
|
|
block discarded – undo |
1799
|
1799
|
*/ |
1800
|
1800
|
public function can_plugin_update( $slug ) { |
1801
|
1801
|
// We currently can't get reliable info on non-WP-repo plugins - issue #380. |
1802
|
|
- if ( 'repo' !== $this->plugins[ $slug ]['source_type'] ) { |
|
1802
|
+ if ( 'repo' !== $this->plugins[ $slug ][ 'source_type' ] ) { |
1803
|
1803
|
return true; |
1804
|
1804
|
} |
1805
|
1805
|
|
|
@@ -1855,8 +1855,8 @@ discard block |
|
|
block discarded – undo |
1855
|
1855
|
public function get_installed_version( $slug ) { |
1856
|
1856
|
$installed_plugins = $this->get_plugins(); // Retrieve a list of all installed plugins (WP cached). |
1857
|
1857
|
|
1858
|
|
- if ( ! empty( $installed_plugins[ $this->plugins[ $slug ]['file_path'] ]['Version'] ) ) { |
1859
|
|
- return $installed_plugins[ $this->plugins[ $slug ]['file_path'] ]['Version']; |
|
1858
|
+ if ( ! empty( $installed_plugins[ $this->plugins[ $slug ][ 'file_path' ] ][ 'Version' ] ) ) { |
|
1859
|
+ return $installed_plugins[ $this->plugins[ $slug ][ 'file_path' ] ][ 'Version' ]; |
1860
|
1860
|
} |
1861
|
1861
|
|
1862
|
1862
|
return ''; |
|
@@ -1872,7 +1872,7 @@ discard block |
|
|
block discarded – undo |
1872
|
1872
|
*/ |
1873
|
1873
|
public function does_plugin_require_update( $slug ) { |
1874
|
1874
|
$installed_version = $this->get_installed_version( $slug ); |
1875
|
|
- $minimum_version = $this->plugins[ $slug ]['version']; |
|
1875
|
+ $minimum_version = $this->plugins[ $slug ][ 'version' ]; |
1876
|
1876
|
|
1877
|
1877
|
return version_compare( $minimum_version, $installed_version, '>' ); |
1878
|
1878
|
} |
|
@@ -1887,9 +1887,9 @@ discard block |
|
|
block discarded – undo |
1887
|
1887
|
*/ |
1888
|
1888
|
public function does_plugin_have_update( $slug ) { |
1889
|
1889
|
// Presume bundled and external plugins will point to a package which meets the minimum required version. |
1890
|
|
- if ( 'repo' !== $this->plugins[ $slug ]['source_type'] ) { |
|
1890
|
+ if ( 'repo' !== $this->plugins[ $slug ][ 'source_type' ] ) { |
1891
|
1891
|
if ( $this->does_plugin_require_update( $slug ) ) { |
1892
|
|
- return $this->plugins[ $slug ]['version']; |
|
1892
|
+ return $this->plugins[ $slug ][ 'version' ]; |
1893
|
1893
|
} |
1894
|
1894
|
|
1895
|
1895
|
return false; |
|
@@ -1897,8 +1897,8 @@ discard block |
|
|
block discarded – undo |
1897
|
1897
|
|
1898
|
1898
|
$repo_updates = get_site_transient( 'update_plugins' ); |
1899
|
1899
|
|
1900
|
|
- if ( isset( $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->new_version ) ) { |
1901
|
|
- return $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->new_version; |
|
1900
|
+ if ( isset( $repo_updates->response[ $this->plugins[ $slug ][ 'file_path' ] ]->new_version ) ) { |
|
1901
|
+ return $repo_updates->response[ $this->plugins[ $slug ][ 'file_path' ] ]->new_version; |
1902
|
1902
|
} |
1903
|
1903
|
|
1904
|
1904
|
return false; |
|
@@ -1914,14 +1914,14 @@ discard block |
|
|
block discarded – undo |
1914
|
1914
|
*/ |
1915
|
1915
|
public function get_upgrade_notice( $slug ) { |
1916
|
1916
|
// We currently can't get reliable info on non-WP-repo plugins - issue #380. |
1917
|
|
- if ( 'repo' !== $this->plugins[ $slug ]['source_type'] ) { |
|
1917
|
+ if ( 'repo' !== $this->plugins[ $slug ][ 'source_type' ] ) { |
1918
|
1918
|
return ''; |
1919
|
1919
|
} |
1920
|
1920
|
|
1921
|
1921
|
$repo_updates = get_site_transient( 'update_plugins' ); |
1922
|
1922
|
|
1923
|
|
- if ( ! empty( $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->upgrade_notice ) ) { |
1924
|
|
- return $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->upgrade_notice; |
|
1923
|
+ if ( ! empty( $repo_updates->response[ $this->plugins[ $slug ][ 'file_path' ] ]->upgrade_notice ) ) { |
|
1924
|
+ return $repo_updates->response[ $this->plugins[ $slug ][ 'file_path' ] ]->upgrade_notice; |
1925
|
1925
|
} |
1926
|
1926
|
|
1927
|
1927
|
return ''; |
|
@@ -1937,7 +1937,7 @@ discard block |
|
|
block discarded – undo |
1937
|
1937
|
*/ |
1938
|
1938
|
public function get_plugins( $plugin_folder = '' ) { |
1939
|
1939
|
if ( ! function_exists( 'get_plugins' ) ) { |
1940
|
|
- require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
1940
|
+ require_once ABSPATH.'wp-admin/includes/plugin.php'; |
1941
|
1941
|
} |
1942
|
1942
|
|
1943
|
1943
|
return get_plugins( $plugin_folder ); |
|
@@ -1952,7 +1952,7 @@ discard block |
|
|
block discarded – undo |
1952
|
1952
|
* @since 2.1.1 |
1953
|
1953
|
*/ |
1954
|
1954
|
public function update_dismiss() { |
1955
|
|
- delete_metadata( 'user', null, 'tgmpa_dismissed_notice_' . $this->id, null, true ); |
|
1955
|
+ delete_metadata( 'user', null, 'tgmpa_dismissed_notice_'.$this->id, null, true ); |
1956
|
1956
|
} |
1957
|
1957
|
|
1958
|
1958
|
/** |
|
@@ -1971,13 +1971,13 @@ discard block |
|
|
block discarded – undo |
1971
|
1971
|
*/ |
1972
|
1972
|
public function force_activation() { |
1973
|
1973
|
foreach ( $this->plugins as $slug => $plugin ) { |
1974
|
|
- if ( true === $plugin['force_activation'] ) { |
|
1974
|
+ if ( true === $plugin[ 'force_activation' ] ) { |
1975
|
1975
|
if ( ! $this->is_plugin_installed( $slug ) ) { |
1976
|
1976
|
// Oops, plugin isn't there so iterate to next condition. |
1977
|
1977
|
continue; |
1978
|
1978
|
} elseif ( $this->can_plugin_activate( $slug ) ) { |
1979
|
1979
|
// There we go, activate the plugin. |
1980
|
|
- activate_plugin( $plugin['file_path'] ); |
|
1980
|
+ activate_plugin( $plugin[ 'file_path' ] ); |
1981
|
1981
|
} |
1982
|
1982
|
} |
1983
|
1983
|
} |
|
@@ -1998,8 +1998,8 @@ discard block |
|
|
block discarded – undo |
1998
|
1998
|
public function force_deactivation() { |
1999
|
1999
|
foreach ( $this->plugins as $slug => $plugin ) { |
2000
|
2000
|
// Only proceed forward if the parameter is set to true and plugin is active. |
2001
|
|
- if ( true === $plugin['force_deactivation'] && $this->is_plugin_active( $slug ) ) { |
2002
|
|
- deactivate_plugins( $plugin['file_path'] ); |
|
2001
|
+ if ( true === $plugin[ 'force_deactivation' ] && $this->is_plugin_active( $slug ) ) { |
|
2002
|
+ deactivate_plugins( $plugin[ 'file_path' ] ); |
2003
|
2003
|
} |
2004
|
2004
|
} |
2005
|
2005
|
} |
|
@@ -2034,7 +2034,7 @@ discard block |
|
|
block discarded – undo |
2034
|
2034
|
* Ensure only one instance of the class is ever invoked. |
2035
|
2035
|
*/ |
2036
|
2036
|
function load_tgm_plugin_activation() { |
2037
|
|
- $GLOBALS['tgmpa'] = TGM_Plugin_Activation::get_instance(); |
|
2037
|
+ $GLOBALS[ 'tgmpa' ] = TGM_Plugin_Activation::get_instance(); |
2038
|
2038
|
} |
2039
|
2039
|
} |
2040
|
2040
|
|
|
@@ -2056,7 +2056,7 @@ discard block |
|
|
block discarded – undo |
2056
|
2056
|
* @param array $config Optional. An array of configuration values. |
2057
|
2057
|
*/ |
2058
|
2058
|
function tgmpa( $plugins, $config = array() ) { |
2059
|
|
- $instance = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) ); |
|
2059
|
+ $instance = call_user_func( array( get_class( $GLOBALS[ 'tgmpa' ] ), 'get_instance' ) ); |
2060
|
2060
|
|
2061
|
2061
|
foreach ( $plugins as $plugin ) { |
2062
|
2062
|
call_user_func( array( $instance, 'register' ), $plugin ); |
|
@@ -2064,17 +2064,17 @@ discard block |
|
|
block discarded – undo |
2064
|
2064
|
|
2065
|
2065
|
if ( ! empty( $config ) && is_array( $config ) ) { |
2066
|
2066
|
// Send out notices for deprecated arguments passed. |
2067
|
|
- if ( isset( $config['notices'] ) ) { |
|
2067
|
+ if ( isset( $config[ 'notices' ] ) ) { |
2068
|
2068
|
_deprecated_argument( __FUNCTION__, '2.2.0', 'The `notices` config parameter was renamed to `has_notices` in TGMPA 2.2.0. Please adjust your configuration.' ); |
2069
|
|
- if ( ! isset( $config['has_notices'] ) ) { |
2070
|
|
- $config['has_notices'] = $config['notices']; |
|
2069
|
+ if ( ! isset( $config[ 'has_notices' ] ) ) { |
|
2070
|
+ $config[ 'has_notices' ] = $config[ 'notices' ]; |
2071
|
2071
|
} |
2072
|
2072
|
} |
2073
|
2073
|
|
2074
|
|
- if ( isset( $config['parent_menu_slug'] ) ) { |
|
2074
|
+ if ( isset( $config[ 'parent_menu_slug' ] ) ) { |
2075
|
2075
|
_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.' ); |
2076
|
2076
|
} |
2077
|
|
- if ( isset( $config['parent_url_slug'] ) ) { |
|
2077
|
+ if ( isset( $config[ 'parent_url_slug' ] ) ) { |
2078
|
2078
|
_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.' ); |
2079
|
2079
|
} |
2080
|
2080
|
|
|
@@ -2090,7 +2090,7 @@ discard block |
|
|
block discarded – undo |
2090
|
2090
|
* @since 2.2.0 |
2091
|
2091
|
*/ |
2092
|
2092
|
if ( ! class_exists( 'WP_List_Table' ) ) { |
2093
|
|
- require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
2093
|
+ require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
2094
|
2094
|
} |
2095
|
2095
|
|
2096
|
2096
|
if ( ! class_exists( 'TGMPA_List_Table' ) ) { |
|
@@ -2151,7 +2151,7 @@ discard block |
|
|
block discarded – undo |
2151
|
2151
|
* @since 2.2.0 |
2152
|
2152
|
*/ |
2153
|
2153
|
public function __construct() { |
2154
|
|
- $this->tgmpa = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) ); |
|
2154
|
+ $this->tgmpa = call_user_func( array( get_class( $GLOBALS[ 'tgmpa' ] ), 'get_instance' ) ); |
2155
|
2155
|
|
2156
|
2156
|
parent::__construct( |
2157
|
2157
|
array( |
|
@@ -2161,8 +2161,8 @@ discard block |
|
|
block discarded – undo |
2161
|
2161
|
) |
2162
|
2162
|
); |
2163
|
2163
|
|
2164
|
|
- if ( isset( $_REQUEST['plugin_status'] ) && in_array( $_REQUEST['plugin_status'], array( 'install', 'update', 'activate' ), true ) ) { |
2165
|
|
- $this->view_context = sanitize_key( $_REQUEST['plugin_status'] ); |
|
2164
|
+ if ( isset( $_REQUEST[ 'plugin_status' ] ) && in_array( $_REQUEST[ 'plugin_status' ], array( 'install', 'update', 'activate' ), true ) ) { |
|
2165
|
+ $this->view_context = sanitize_key( $_REQUEST[ 'plugin_status' ] ); |
2166
|
2166
|
} |
2167
|
2167
|
|
2168
|
2168
|
add_filter( 'tgmpa_table_data_items', array( $this, 'sort_table_items' ) ); |
|
@@ -2209,20 +2209,20 @@ discard block |
|
|
block discarded – undo |
2209
|
2209
|
} |
2210
|
2210
|
|
2211
|
2211
|
foreach ( $plugins[ $this->view_context ] as $slug => $plugin ) { |
2212
|
|
- $table_data[ $i ]['sanitized_plugin'] = $plugin['name']; |
2213
|
|
- $table_data[ $i ]['slug'] = $slug; |
2214
|
|
- $table_data[ $i ]['plugin'] = '<strong>' . $this->tgmpa->get_info_link( $slug ) . '</strong>'; |
2215
|
|
- $table_data[ $i ]['source'] = $this->get_plugin_source_type_text( $plugin['source_type'] ); |
2216
|
|
- $table_data[ $i ]['type'] = $this->get_plugin_advise_type_text( $plugin['required'] ); |
2217
|
|
- $table_data[ $i ]['status'] = $this->get_plugin_status_text( $slug ); |
2218
|
|
- $table_data[ $i ]['installed_version'] = $this->tgmpa->get_installed_version( $slug ); |
2219
|
|
- $table_data[ $i ]['minimum_version'] = $plugin['version']; |
2220
|
|
- $table_data[ $i ]['available_version'] = $this->tgmpa->does_plugin_have_update( $slug ); |
|
2212
|
+ $table_data[ $i ][ 'sanitized_plugin' ] = $plugin[ 'name' ]; |
|
2213
|
+ $table_data[ $i ][ 'slug' ] = $slug; |
|
2214
|
+ $table_data[ $i ][ 'plugin' ] = '<strong>'.$this->tgmpa->get_info_link( $slug ).'</strong>'; |
|
2215
|
+ $table_data[ $i ][ 'source' ] = $this->get_plugin_source_type_text( $plugin[ 'source_type' ] ); |
|
2216
|
+ $table_data[ $i ][ 'type' ] = $this->get_plugin_advise_type_text( $plugin[ 'required' ] ); |
|
2217
|
+ $table_data[ $i ][ 'status' ] = $this->get_plugin_status_text( $slug ); |
|
2218
|
+ $table_data[ $i ][ 'installed_version' ] = $this->tgmpa->get_installed_version( $slug ); |
|
2219
|
+ $table_data[ $i ][ 'minimum_version' ] = $plugin[ 'version' ]; |
|
2220
|
+ $table_data[ $i ][ 'available_version' ] = $this->tgmpa->does_plugin_have_update( $slug ); |
2221
|
2221
|
|
2222
|
2222
|
// Prep the upgrade notice info. |
2223
|
2223
|
$upgrade_notice = $this->tgmpa->get_upgrade_notice( $slug ); |
2224
|
2224
|
if ( ! empty( $upgrade_notice ) ) { |
2225
|
|
- $table_data[ $i ]['upgrade_notice'] = $upgrade_notice; |
|
2225
|
+ $table_data[ $i ][ 'upgrade_notice' ] = $upgrade_notice; |
2226
|
2226
|
|
2227
|
2227
|
add_action( "tgmpa_after_plugin_row_$slug", array( $this, 'wp_plugin_update_row' ), 10, 2 ); |
2228
|
2228
|
} |
|
@@ -2253,17 +2253,17 @@ discard block |
|
|
block discarded – undo |
2253
|
2253
|
// No need to display plugins if they are installed, up-to-date and active. |
2254
|
2254
|
continue; |
2255
|
2255
|
} else { |
2256
|
|
- $plugins['all'][ $slug ] = $plugin; |
|
2256
|
+ $plugins[ 'all' ][ $slug ] = $plugin; |
2257
|
2257
|
|
2258
|
2258
|
if ( ! $this->tgmpa->is_plugin_installed( $slug ) ) { |
2259
|
|
- $plugins['install'][ $slug ] = $plugin; |
|
2259
|
+ $plugins[ 'install' ][ $slug ] = $plugin; |
2260
|
2260
|
} else { |
2261
|
2261
|
if ( false !== $this->tgmpa->does_plugin_have_update( $slug ) ) { |
2262
|
|
- $plugins['update'][ $slug ] = $plugin; |
|
2262
|
+ $plugins[ 'update' ][ $slug ] = $plugin; |
2263
|
2263
|
} |
2264
|
2264
|
|
2265
|
2265
|
if ( $this->tgmpa->can_plugin_activate( $slug ) ) { |
2266
|
|
- $plugins['activate'][ $slug ] = $plugin; |
|
2266
|
+ $plugins[ 'activate' ][ $slug ] = $plugin; |
2267
|
2267
|
} |
2268
|
2268
|
} |
2269
|
2269
|
} |
|
@@ -2382,8 +2382,8 @@ discard block |
|
|
block discarded – undo |
2382
|
2382
|
$name = array(); |
2383
|
2383
|
|
2384
|
2384
|
foreach ( $items as $i => $plugin ) { |
2385
|
|
- $type[ $i ] = $plugin['type']; // Required / recommended. |
2386
|
|
- $name[ $i ] = $plugin['sanitized_plugin']; |
|
2385
|
+ $type[ $i ] = $plugin[ 'type' ]; // Required / recommended. |
|
2386
|
+ $name[ $i ] = $plugin[ 'sanitized_plugin' ]; |
2387
|
2387
|
} |
2388
|
2388
|
|
2389
|
2389
|
array_multisort( $type, SORT_DESC, $name, SORT_ASC, $items ); |
|
@@ -2465,9 +2465,9 @@ discard block |
|
|
block discarded – undo |
2465
|
2465
|
public function column_cb( $item ) { |
2466
|
2466
|
return sprintf( |
2467
|
2467
|
'<input type="checkbox" name="%1$s[]" value="%2$s" id="%3$s" />', |
2468
|
|
- esc_attr( $this->_args['singular'] ), |
2469
|
|
- esc_attr( $item['slug'] ), |
2470
|
|
- esc_attr( $item['sanitized_plugin'] ) |
|
2468
|
+ esc_attr( $this->_args[ 'singular' ] ), |
|
2469
|
+ esc_attr( $item[ 'slug' ] ), |
|
2470
|
+ esc_attr( $item[ 'sanitized_plugin' ] ) |
2471
|
2471
|
); |
2472
|
2472
|
} |
2473
|
2473
|
|
|
@@ -2482,7 +2482,7 @@ discard block |
|
|
block discarded – undo |
2482
|
2482
|
public function column_plugin( $item ) { |
2483
|
2483
|
return sprintf( |
2484
|
2484
|
'%1$s %2$s', |
2485
|
|
- $item['plugin'], |
|
2485
|
+ $item[ 'plugin' ], |
2486
|
2486
|
$this->row_actions( $this->get_row_actions( $item ), true ) |
2487
|
2487
|
); |
2488
|
2488
|
} |
|
@@ -2498,38 +2498,38 @@ discard block |
|
|
block discarded – undo |
2498
|
2498
|
public function column_version( $item ) { |
2499
|
2499
|
$output = array(); |
2500
|
2500
|
|
2501
|
|
- if ( $this->tgmpa->is_plugin_installed( $item['slug'] ) ) { |
2502
|
|
- $installed = ! empty( $item['installed_version'] ) ? $item['installed_version'] : _x( 'unknown', 'as in: "version nr unknown"', 'tgmpa' ); |
|
2501
|
+ if ( $this->tgmpa->is_plugin_installed( $item[ 'slug' ] ) ) { |
|
2502
|
+ $installed = ! empty( $item[ 'installed_version' ] ) ? $item[ 'installed_version' ] : _x( 'unknown', 'as in: "version nr unknown"', 'tgmpa' ); |
2503
|
2503
|
|
2504
|
2504
|
$color = ''; |
2505
|
|
- if ( ! empty( $item['minimum_version'] ) && $this->tgmpa->does_plugin_require_update( $item['slug'] ) ) { |
|
2505
|
+ if ( ! empty( $item[ 'minimum_version' ] ) && $this->tgmpa->does_plugin_require_update( $item[ 'slug' ] ) ) { |
2506
|
2506
|
$color = ' color: #ff0000; font-weight: bold;'; |
2507
|
2507
|
} |
2508
|
2508
|
|
2509
|
|
- $output[] = sprintf( |
2510
|
|
- '<p><span style="min-width: 32px; text-align: right; float: right;%1$s">%2$s</span>' . __( 'Installed version:', 'tgmpa' ) . '</p>', |
|
2509
|
+ $output[ ] = sprintf( |
|
2510
|
+ '<p><span style="min-width: 32px; text-align: right; float: right;%1$s">%2$s</span>'.__( 'Installed version:', 'tgmpa' ).'</p>', |
2511
|
2511
|
$color, |
2512
|
2512
|
$installed |
2513
|
2513
|
); |
2514
|
2514
|
} |
2515
|
2515
|
|
2516
|
|
- if ( ! empty( $item['minimum_version'] ) ) { |
2517
|
|
- $output[] = sprintf( |
2518
|
|
- '<p><span style="min-width: 32px; text-align: right; float: right;">%1$s</span>' . __( 'Minimum required version:', 'tgmpa' ) . '</p>', |
2519
|
|
- $item['minimum_version'] |
|
2516
|
+ if ( ! empty( $item[ 'minimum_version' ] ) ) { |
|
2517
|
+ $output[ ] = sprintf( |
|
2518
|
+ '<p><span style="min-width: 32px; text-align: right; float: right;">%1$s</span>'.__( 'Minimum required version:', 'tgmpa' ).'</p>', |
|
2519
|
+ $item[ 'minimum_version' ] |
2520
|
2520
|
); |
2521
|
2521
|
} |
2522
|
2522
|
|
2523
|
|
- if ( ! empty( $item['available_version'] ) ) { |
|
2523
|
+ if ( ! empty( $item[ 'available_version' ] ) ) { |
2524
|
2524
|
$color = ''; |
2525
|
|
- if ( ! empty( $item['minimum_version'] ) && version_compare( $item['available_version'], $item['minimum_version'], '>=' ) ) { |
|
2525
|
+ if ( ! empty( $item[ 'minimum_version' ] ) && version_compare( $item[ 'available_version' ], $item[ 'minimum_version' ], '>=' ) ) { |
2526
|
2526
|
$color = ' color: #71C671; font-weight: bold;'; |
2527
|
2527
|
} |
2528
|
2528
|
|
2529
|
|
- $output[] = sprintf( |
2530
|
|
- '<p><span style="min-width: 32px; text-align: right; float: right;%1$s">%2$s</span>' . __( 'Available version:', 'tgmpa' ) . '</p>', |
|
2529
|
+ $output[ ] = sprintf( |
|
2530
|
+ '<p><span style="min-width: 32px; text-align: right; float: right;%1$s">%2$s</span>'.__( 'Available version:', 'tgmpa' ).'</p>', |
2531
|
2531
|
$color, |
2532
|
|
- $item['available_version'] |
|
2532
|
+ $item[ 'available_version' ] |
2533
|
2533
|
); |
2534
|
2534
|
} |
2535
|
2535
|
|
|
@@ -2570,8 +2570,8 @@ discard block |
|
|
block discarded – undo |
2570
|
2570
|
); |
2571
|
2571
|
|
2572
|
2572
|
if ( 'all' === $this->view_context || 'update' === $this->view_context ) { |
2573
|
|
- $columns['version'] = __( 'Version', 'tgmpa' ); |
2574
|
|
- $columns['status'] = __( 'Status', 'tgmpa' ); |
|
2573
|
+ $columns[ 'version' ] = __( 'Version', 'tgmpa' ); |
|
2574
|
+ $columns[ 'status' ] = __( 'Status', 'tgmpa' ); |
2575
|
2575
|
} |
2576
|
2576
|
|
2577
|
2577
|
return apply_filters( 'tgmpa_table_columns', $columns ); |
|
@@ -2618,17 +2618,17 @@ discard block |
|
|
block discarded – undo |
2618
|
2618
|
$action_links = array(); |
2619
|
2619
|
|
2620
|
2620
|
// Display the 'Install' action link if the plugin is not yet available. |
2621
|
|
- if ( ! $this->tgmpa->is_plugin_installed( $item['slug'] ) ) { |
2622
|
|
- $actions['install'] = _x( 'Install %2$s', '%2$s = plugin name in screen reader markup', 'tgmpa' ); |
|
2621
|
+ if ( ! $this->tgmpa->is_plugin_installed( $item[ 'slug' ] ) ) { |
|
2622
|
+ $actions[ 'install' ] = _x( 'Install %2$s', '%2$s = plugin name in screen reader markup', 'tgmpa' ); |
2623
|
2623
|
} else { |
2624
|
2624
|
// Display the 'Update' action link if an update is available and WP complies with plugin minimum. |
2625
|
|
- if ( false !== $this->tgmpa->does_plugin_have_update( $item['slug'] ) && $this->tgmpa->can_plugin_update( $item['slug'] ) ) { |
2626
|
|
- $actions['update'] = _x( 'Update %2$s', '%2$s = plugin name in screen reader markup', 'tgmpa' ); |
|
2625
|
+ if ( false !== $this->tgmpa->does_plugin_have_update( $item[ 'slug' ] ) && $this->tgmpa->can_plugin_update( $item[ 'slug' ] ) ) { |
|
2626
|
+ $actions[ 'update' ] = _x( 'Update %2$s', '%2$s = plugin name in screen reader markup', 'tgmpa' ); |
2627
|
2627
|
} |
2628
|
2628
|
|
2629
|
2629
|
// Display the 'Activate' action link, but only if the plugin meets the minimum version. |
2630
|
|
- if ( $this->tgmpa->can_plugin_activate( $item['slug'] ) ) { |
2631
|
|
- $actions['activate'] = _x( 'Activate %2$s', '%2$s = plugin name in screen reader markup', 'tgmpa' ); |
|
2630
|
+ if ( $this->tgmpa->can_plugin_activate( $item[ 'slug' ] ) ) { |
|
2631
|
+ $actions[ 'activate' ] = _x( 'Activate %2$s', '%2$s = plugin name in screen reader markup', 'tgmpa' ); |
2632
|
2632
|
} |
2633
|
2633
|
} |
2634
|
2634
|
|
|
@@ -2637,24 +2637,24 @@ discard block |
|
|
block discarded – undo |
2637
|
2637
|
$nonce_url = wp_nonce_url( |
2638
|
2638
|
add_query_arg( |
2639
|
2639
|
array( |
2640
|
|
- 'plugin' => urlencode( $item['slug'] ), |
2641
|
|
- 'tgmpa-' . $action => $action . '-plugin', |
|
2640
|
+ 'plugin' => urlencode( $item[ 'slug' ] ), |
|
2641
|
+ 'tgmpa-'.$action => $action.'-plugin', |
2642
|
2642
|
), |
2643
|
2643
|
$this->tgmpa->get_tgmpa_url() |
2644
|
2644
|
), |
2645
|
|
- 'tgmpa-' . $action, |
|
2645
|
+ 'tgmpa-'.$action, |
2646
|
2646
|
'tgmpa-nonce' |
2647
|
2647
|
); |
2648
|
2648
|
|
2649
|
2649
|
$action_links[ $action ] = sprintf( |
2650
|
|
- '<a href="%1$s">' . esc_html( $text ) . '</a>', |
|
2650
|
+ '<a href="%1$s">'.esc_html( $text ).'</a>', |
2651
|
2651
|
esc_url( $nonce_url ), |
2652
|
|
- '<span class="screen-reader-text">' . esc_html( $item['sanitized_plugin'] ) . '</span>' |
|
2652
|
+ '<span class="screen-reader-text">'.esc_html( $item[ 'sanitized_plugin' ] ).'</span>' |
2653
|
2653
|
); |
2654
|
2654
|
} |
2655
|
2655
|
|
2656
|
2656
|
$prefix = ( defined( 'WP_NETWORK_ADMIN' ) && WP_NETWORK_ADMIN ) ? 'network_admin_' : ''; |
2657
|
|
- return apply_filters( "tgmpa_{$prefix}plugin_action_links", array_filter( $action_links ), $item['slug'], $item, $this->view_context ); |
|
2657
|
+ return apply_filters( "tgmpa_{$prefix}plugin_action_links", array_filter( $action_links ), $item[ 'slug' ], $item, $this->view_context ); |
2658
|
2658
|
} |
2659
|
2659
|
|
2660
|
2660
|
/** |
|
@@ -2675,7 +2675,7 @@ discard block |
|
|
block discarded – undo |
2675
|
2675
|
* |
2676
|
2676
|
* @since 2.5.0 |
2677
|
2677
|
*/ |
2678
|
|
- do_action( "tgmpa_after_plugin_row_{$item['slug']}", $item['slug'], $item, $this->view_context ); |
|
2678
|
+ do_action( "tgmpa_after_plugin_row_{$item[ 'slug' ]}", $item[ 'slug' ], $item, $this->view_context ); |
2679
|
2679
|
} |
2680
|
2680
|
|
2681
|
2681
|
/** |
|
@@ -2690,7 +2690,7 @@ discard block |
|
|
block discarded – undo |
2690
|
2690
|
* @return null Return early if upgrade notice is empty. |
2691
|
2691
|
*/ |
2692
|
2692
|
public function wp_plugin_update_row( $slug, $item ) { |
2693
|
|
- if ( empty( $item['upgrade_notice'] ) ) { |
|
2693
|
+ if ( empty( $item[ 'upgrade_notice' ] ) ) { |
2694
|
2694
|
return; |
2695
|
2695
|
} |
2696
|
2696
|
|
|
@@ -2699,7 +2699,7 @@ discard block |
|
|
block discarded – undo |
2699
|
2699
|
<td colspan="', absint( $this->get_column_count() ), '" class="plugin-update colspanchange"> |
2700
|
2700
|
<div class="update-message">', |
2701
|
2701
|
esc_html__( 'Upgrade message from the plugin author:', 'tgmpa' ), |
2702
|
|
- ' <strong>', wp_kses_data( $item['upgrade_notice'] ), '</strong> |
|
2702
|
+ ' <strong>', wp_kses_data( $item[ 'upgrade_notice' ] ), '</strong> |
2703
|
2703
|
</div> |
2704
|
2704
|
</td> |
2705
|
2705
|
</tr>'; |
|
@@ -2731,16 +2731,16 @@ discard block |
|
|
block discarded – undo |
2731
|
2731
|
|
2732
|
2732
|
if ( 'update' !== $this->view_context && 'activate' !== $this->view_context ) { |
2733
|
2733
|
if ( current_user_can( 'install_plugins' ) ) { |
2734
|
|
- $actions['tgmpa-bulk-install'] = __( 'Install', 'tgmpa' ); |
|
2734
|
+ $actions[ 'tgmpa-bulk-install' ] = __( 'Install', 'tgmpa' ); |
2735
|
2735
|
} |
2736
|
2736
|
} |
2737
|
2737
|
|
2738
|
2738
|
if ( 'install' !== $this->view_context ) { |
2739
|
2739
|
if ( current_user_can( 'update_plugins' ) ) { |
2740
|
|
- $actions['tgmpa-bulk-update'] = __( 'Update', 'tgmpa' ); |
|
2740
|
+ $actions[ 'tgmpa-bulk-update' ] = __( 'Update', 'tgmpa' ); |
2741
|
2741
|
} |
2742
|
2742
|
if ( current_user_can( 'activate_plugins' ) ) { |
2743
|
|
- $actions['tgmpa-bulk-activate'] = __( 'Activate', 'tgmpa' ); |
|
2743
|
+ $actions[ 'tgmpa-bulk-activate' ] = __( 'Activate', 'tgmpa' ); |
2744
|
2744
|
} |
2745
|
2745
|
} |
2746
|
2746
|
|
|
@@ -2759,7 +2759,7 @@ discard block |
|
|
block discarded – undo |
2759
|
2759
|
// Bulk installation process. |
2760
|
2760
|
if ( 'tgmpa-bulk-install' === $this->current_action() || 'tgmpa-bulk-update' === $this->current_action() ) { |
2761
|
2761
|
|
2762
|
|
- check_admin_referer( 'bulk-' . $this->_args['plural'] ); |
|
2762
|
+ check_admin_referer( 'bulk-'.$this->_args[ 'plural' ] ); |
2763
|
2763
|
|
2764
|
2764
|
$install_type = 'install'; |
2765
|
2765
|
if ( 'tgmpa-bulk-update' === $this->current_action() ) { |
|
@@ -2769,7 +2769,7 @@ discard block |
|
|
block discarded – undo |
2769
|
2769
|
$plugins_to_install = array(); |
2770
|
2770
|
|
2771
|
2771
|
// Did user actually select any plugins to install/update ? |
2772
|
|
- if ( empty( $_POST['plugin'] ) ) { |
|
2772
|
+ if ( empty( $_POST[ 'plugin' ] ) ) { |
2773
|
2773
|
if ( 'install' === $install_type ) { |
2774
|
2774
|
$message = __( 'No plugins were selected to be installed. No action taken.', 'tgmpa' ); |
2775
|
2775
|
} else { |
|
@@ -2781,11 +2781,11 @@ discard block |
|
|
block discarded – undo |
2781
|
2781
|
return false; |
2782
|
2782
|
} |
2783
|
2783
|
|
2784
|
|
- if ( is_array( $_POST['plugin'] ) ) { |
2785
|
|
- $plugins_to_install = (array) $_POST['plugin']; |
2786
|
|
- } elseif ( is_string( $_POST['plugin'] ) ) { |
|
2784
|
+ if ( is_array( $_POST[ 'plugin' ] ) ) { |
|
2785
|
+ $plugins_to_install = (array) $_POST[ 'plugin' ]; |
|
2786
|
+ } elseif ( is_string( $_POST[ 'plugin' ] ) ) { |
2787
|
2787
|
// Received via Filesystem page - un-flatten array (WP bug #19643). |
2788
|
|
- $plugins_to_install = explode( ',', $_POST['plugin'] ); |
|
2788
|
+ $plugins_to_install = explode( ',', $_POST[ 'plugin' ] ); |
2789
|
2789
|
} |
2790
|
2790
|
|
2791
|
2791
|
// Sanitize the received input. |
|
@@ -2827,11 +2827,11 @@ discard block |
|
|
block discarded – undo |
2827
|
2827
|
// Pass all necessary information if WP_Filesystem is needed. |
2828
|
2828
|
$url = wp_nonce_url( |
2829
|
2829
|
$this->tgmpa->get_tgmpa_url(), |
2830
|
|
- 'bulk-' . $this->_args['plural'] |
|
2830
|
+ 'bulk-'.$this->_args[ 'plural' ] |
2831
|
2831
|
); |
2832
|
2832
|
|
2833
|
2833
|
// Give validated data back to $_POST which is the only place the filesystem looks for extra fields. |
2834
|
|
- $_POST['plugin'] = implode( ',', $plugins_to_install ); // Work around for WP bug #19643. |
|
2834
|
+ $_POST[ 'plugin' ] = implode( ',', $plugins_to_install ); // Work around for WP bug #19643. |
2835
|
2835
|
|
2836
|
2836
|
$method = ''; // Leave blank so WP_Filesystem can populate it as necessary. |
2837
|
2837
|
$fields = array_keys( $_POST ); // Extra fields to pass to WP_Filesystem. |
|
@@ -2858,22 +2858,22 @@ discard block |
|
|
block discarded – undo |
2858
|
2858
|
|
2859
|
2859
|
// Prepare the data for validated plugins for the install/upgrade. |
2860
|
2860
|
foreach ( $plugins_to_install as $slug ) { |
2861
|
|
- $name = $this->tgmpa->plugins[ $slug ]['name']; |
|
2861
|
+ $name = $this->tgmpa->plugins[ $slug ][ 'name' ]; |
2862
|
2862
|
$source = $this->tgmpa->get_download_url( $slug ); |
2863
|
2863
|
|
2864
|
2864
|
if ( ! empty( $name ) && ! empty( $source ) ) { |
2865
|
|
- $names[] = $name; |
|
2865
|
+ $names[ ] = $name; |
2866
|
2866
|
|
2867
|
2867
|
switch ( $install_type ) { |
2868
|
2868
|
|
2869
|
2869
|
case 'install': |
2870
|
|
- $sources[] = $source; |
|
2870
|
+ $sources[ ] = $source; |
2871
|
2871
|
break; |
2872
|
2872
|
|
2873
|
2873
|
case 'update': |
2874
|
|
- $file_paths[] = $this->tgmpa->plugins[ $slug ]['file_path']; |
|
2874
|
+ $file_paths[ ] = $this->tgmpa->plugins[ $slug ][ 'file_path' ]; |
2875
|
2875
|
$to_inject[ $slug ] = $this->tgmpa->plugins[ $slug ]; |
2876
|
|
- $to_inject[ $slug ]['source'] = $source; |
|
2876
|
+ $to_inject[ $slug ][ 'source' ] = $source; |
2877
|
2877
|
break; |
2878
|
2878
|
} |
2879
|
2879
|
} |
|
@@ -2885,7 +2885,7 @@ discard block |
|
|
block discarded – undo |
2885
|
2885
|
new TGMPA_Bulk_Installer_Skin( |
2886
|
2886
|
array( |
2887
|
2887
|
'url' => esc_url_raw( $this->tgmpa->get_tgmpa_url() ), |
2888
|
|
- 'nonce' => 'bulk-' . $this->_args['plural'], |
|
2888
|
+ 'nonce' => 'bulk-'.$this->_args[ 'plural' ], |
2889
|
2889
|
'names' => $names, |
2890
|
2890
|
'install_type' => $install_type, |
2891
|
2891
|
) |
|
@@ -2918,10 +2918,10 @@ discard block |
|
|
block discarded – undo |
2918
|
2918
|
|
2919
|
2919
|
// Bulk activation process. |
2920
|
2920
|
if ( 'tgmpa-bulk-activate' === $this->current_action() ) { |
2921
|
|
- check_admin_referer( 'bulk-' . $this->_args['plural'] ); |
|
2921
|
+ check_admin_referer( 'bulk-'.$this->_args[ 'plural' ] ); |
2922
|
2922
|
|
2923
|
2923
|
// Did user actually select any plugins to activate ? |
2924
|
|
- if ( empty( $_POST['plugin'] ) ) { |
|
2924
|
+ if ( empty( $_POST[ 'plugin' ] ) ) { |
2925
|
2925
|
echo '<div id="message" class="error"><p>', esc_html__( 'No plugins were selected to be activated. No action taken.', 'tgmpa' ), '</p></div>'; |
2926
|
2926
|
|
2927
|
2927
|
return false; |
|
@@ -2929,8 +2929,8 @@ discard block |
|
|
block discarded – undo |
2929
|
2929
|
|
2930
|
2930
|
// Grab plugin data from $_POST. |
2931
|
2931
|
$plugins = array(); |
2932
|
|
- if ( isset( $_POST['plugin'] ) ) { |
2933
|
|
- $plugins = array_map( 'urldecode', (array) $_POST['plugin'] ); |
|
2932
|
+ if ( isset( $_POST[ 'plugin' ] ) ) { |
|
2933
|
+ $plugins = array_map( 'urldecode', (array) $_POST[ 'plugin' ] ); |
2934
|
2934
|
$plugins = array_map( array( $this->tgmpa, 'sanitize_key' ), $plugins ); |
2935
|
2935
|
} |
2936
|
2936
|
|
|
@@ -2940,8 +2940,8 @@ discard block |
|
|
block discarded – undo |
2940
|
2940
|
// Grab the file paths for the selected & inactive plugins from the registration array. |
2941
|
2941
|
foreach ( $plugins as $slug ) { |
2942
|
2942
|
if ( $this->tgmpa->can_plugin_activate( $slug ) ) { |
2943
|
|
- $plugins_to_activate[] = $this->tgmpa->plugins[ $slug ]['file_path']; |
2944
|
|
- $plugin_names[] = $this->tgmpa->plugins[ $slug ]['name']; |
|
2943
|
+ $plugins_to_activate[ ] = $this->tgmpa->plugins[ $slug ][ 'file_path' ]; |
|
2944
|
+ $plugin_names[ ] = $this->tgmpa->plugins[ $slug ][ 'name' ]; |
2945
|
2945
|
} |
2946
|
2946
|
} |
2947
|
2947
|
unset( $slug ); |
|
@@ -2962,7 +2962,7 @@ discard block |
|
|
block discarded – undo |
2962
|
2962
|
$count = count( $plugin_names ); // Count so we can use _n function. |
2963
|
2963
|
$plugin_names = array_map( array( 'TGMPA_Utils', 'wrap_in_strong' ), $plugin_names ); |
2964
|
2964
|
$last_plugin = array_pop( $plugin_names ); // Pop off last name to prep for readability. |
2965
|
|
- $imploded = empty( $plugin_names ) ? $last_plugin : ( implode( ', ', $plugin_names ) . ' ' . esc_html_x( 'and', 'plugin A *and* plugin B', 'tgmpa' ) . ' ' . $last_plugin ); |
|
2965
|
+ $imploded = empty( $plugin_names ) ? $last_plugin : ( implode( ', ', $plugin_names ).' '.esc_html_x( 'and', 'plugin A *and* plugin B', 'tgmpa' ).' '.$last_plugin ); |
2966
|
2966
|
|
2967
|
2967
|
printf( // WPCS: xss ok. |
2968
|
2968
|
'<div id="message" class="updated"><p>%1$s %2$s.</p></div>', |
|
@@ -3065,16 +3065,16 @@ discard block |
|
|
block discarded – undo |
3065
|
3065
|
*/ |
3066
|
3066
|
function tgmpa_load_bulk_installer() { |
3067
|
3067
|
// Silently fail if 2.5+ is loaded *after* an older version. |
3068
|
|
- if ( ! isset( $GLOBALS['tgmpa'] ) ) { |
|
3068
|
+ if ( ! isset( $GLOBALS[ 'tgmpa' ] ) ) { |
3069
|
3069
|
return; |
3070
|
3070
|
} |
3071
|
3071
|
|
3072
|
3072
|
// Get TGMPA class instance. |
3073
|
|
- $tgmpa_instance = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) ); |
|
3073
|
+ $tgmpa_instance = call_user_func( array( get_class( $GLOBALS[ 'tgmpa' ] ), 'get_instance' ) ); |
3074
|
3074
|
|
3075
|
|
- if ( isset( $_GET['page'] ) && $tgmpa_instance->menu === $_GET['page'] ) { |
|
3075
|
+ if ( isset( $_GET[ 'page' ] ) && $tgmpa_instance->menu === $_GET[ 'page' ] ) { |
3076
|
3076
|
if ( ! class_exists( 'Plugin_Upgrader', false ) ) { |
3077
|
|
- require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
|
3077
|
+ require_once ABSPATH.'wp-admin/includes/class-wp-upgrader.php'; |
3078
|
3078
|
} |
3079
|
3079
|
|
3080
|
3080
|
if ( ! class_exists( 'TGMPA_Bulk_Installer' ) ) { |
|
@@ -3141,11 +3141,11 @@ discard block |
|
|
block discarded – undo |
3141
|
3141
|
*/ |
3142
|
3142
|
public function __construct( $skin = null ) { |
3143
|
3143
|
// Get TGMPA class instance. |
3144
|
|
- $this->tgmpa = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) ); |
|
3144
|
+ $this->tgmpa = call_user_func( array( get_class( $GLOBALS[ 'tgmpa' ] ), 'get_instance' ) ); |
3145
|
3145
|
|
3146
|
3146
|
parent::__construct( $skin ); |
3147
|
3147
|
|
3148
|
|
- if ( isset( $this->skin->options['install_type'] ) && 'update' === $this->skin->options['install_type'] ) { |
|
3148
|
+ if ( isset( $this->skin->options[ 'install_type' ] ) && 'update' === $this->skin->options[ 'install_type' ] ) { |
3149
|
3149
|
$this->clear_destination = true; |
3150
|
3150
|
} |
3151
|
3151
|
|
|
@@ -3162,8 +3162,8 @@ discard block |
|
|
block discarded – undo |
3162
|
3162
|
* @since 2.2.0 |
3163
|
3163
|
*/ |
3164
|
3164
|
public function activate_strings() { |
3165
|
|
- $this->strings['activation_failed'] = __( 'Plugin activation failed.', 'tgmpa' ); |
3166
|
|
- $this->strings['activation_success'] = __( 'Plugin activated successfully.', 'tgmpa' ); |
|
3165
|
+ $this->strings[ 'activation_failed' ] = __( 'Plugin activation failed.', 'tgmpa' ); |
|
3166
|
+ $this->strings[ 'activation_success' ] = __( 'Plugin activated successfully.', 'tgmpa' ); |
3167
|
3167
|
} |
3168
|
3168
|
|
3169
|
3169
|
/** |
|
@@ -3181,7 +3181,7 @@ discard block |
|
|
block discarded – undo |
3181
|
3181
|
|
3182
|
3182
|
// Reset the strings in case we changed one during automatic activation. |
3183
|
3183
|
if ( $this->tgmpa->is_automatic ) { |
3184
|
|
- if ( 'update' === $this->skin->options['install_type'] ) { |
|
3184
|
+ if ( 'update' === $this->skin->options[ 'install_type' ] ) { |
3185
|
3185
|
$this->upgrade_strings(); |
3186
|
3186
|
} else { |
3187
|
3187
|
$this->install_strings(); |
|
@@ -3339,7 +3339,7 @@ discard block |
|
|
block discarded – undo |
3339
|
3339
|
remove_filter( 'upgrader_post_install', array( $this, 'auto_activate' ), 10 ); |
3340
|
3340
|
|
3341
|
3341
|
// Force refresh of plugin update information. |
3342
|
|
- wp_clean_plugins_cache( $parsed_args['clear_update_cache'] ); |
|
3342
|
+ wp_clean_plugins_cache( $parsed_args[ 'clear_update_cache' ] ); |
3343
|
3343
|
|
3344
|
3344
|
return $results; |
3345
|
3345
|
} |
|
@@ -3390,13 +3390,13 @@ discard block |
|
|
block discarded – undo |
3390
|
3390
|
$activate = activate_plugin( $plugin_info ); |
3391
|
3391
|
|
3392
|
3392
|
// Adjust the success string based on the activation result. |
3393
|
|
- $this->strings['process_success'] = $this->strings['process_success'] . "<br />\n"; |
|
3393
|
+ $this->strings[ 'process_success' ] = $this->strings[ 'process_success' ]."<br />\n"; |
3394
|
3394
|
|
3395
|
3395
|
if ( is_wp_error( $activate ) ) { |
3396
|
3396
|
$this->skin->error( $activate ); |
3397
|
|
- $this->strings['process_success'] .= $this->strings['activation_failed']; |
|
3397
|
+ $this->strings[ 'process_success' ] .= $this->strings[ 'activation_failed' ]; |
3398
|
3398
|
} else { |
3399
|
|
- $this->strings['process_success'] .= $this->strings['activation_success']; |
|
3399
|
+ $this->strings[ 'process_success' ] .= $this->strings[ 'activation_success' ]; |
3400
|
3400
|
} |
3401
|
3401
|
} |
3402
|
3402
|
} |
|
@@ -3472,7 +3472,7 @@ discard block |
|
|
block discarded – undo |
3472
|
3472
|
*/ |
3473
|
3473
|
public function __construct( $args = array() ) { |
3474
|
3474
|
// Get TGMPA class instance. |
3475
|
|
- $this->tgmpa = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) ); |
|
3475
|
+ $this->tgmpa = call_user_func( array( get_class( $GLOBALS[ 'tgmpa' ] ), 'get_instance' ) ); |
3476
|
3476
|
|
3477
|
3477
|
// Parse default and new args. |
3478
|
3478
|
$defaults = array( |
|
@@ -3481,10 +3481,10 @@ discard block |
|
|
block discarded – undo |
3481
|
3481
|
'names' => array(), |
3482
|
3482
|
'install_type' => 'install', |
3483
|
3483
|
); |
3484
|
|
- $args = wp_parse_args( $args, $defaults ); |
|
3484
|
+ $args = wp_parse_args( $args, $defaults ); |
3485
|
3485
|
|
3486
|
3486
|
// Set plugin names to $this->plugin_names property. |
3487
|
|
- $this->plugin_names = $args['names']; |
|
3487
|
+ $this->plugin_names = $args[ 'names' ]; |
3488
|
3488
|
|
3489
|
3489
|
// Extract the new args. |
3490
|
3490
|
parent::__construct( $args ); |
|
@@ -3499,25 +3499,25 @@ discard block |
|
|
block discarded – undo |
3499
|
3499
|
* @since 2.2.0 |
3500
|
3500
|
*/ |
3501
|
3501
|
public function add_strings() { |
3502
|
|
- if ( 'update' === $this->options['install_type'] ) { |
|
3502
|
+ if ( 'update' === $this->options[ 'install_type' ] ) { |
3503
|
3503
|
parent::add_strings(); |
3504
|
|
- $this->upgrader->strings['skin_before_update_header'] = __( 'Updating Plugin %1$s (%2$d/%3$d)', 'tgmpa' ); |
|
3504
|
+ $this->upgrader->strings[ 'skin_before_update_header' ] = __( 'Updating Plugin %1$s (%2$d/%3$d)', 'tgmpa' ); |
3505
|
3505
|
} else { |
3506
|
|
- $this->upgrader->strings['skin_update_failed_error'] = __( 'An error occurred while installing %1$s: <strong>%2$s</strong>.', 'tgmpa' ); |
3507
|
|
- $this->upgrader->strings['skin_update_failed'] = __( 'The installation of %1$s failed.', 'tgmpa' ); |
|
3506
|
+ $this->upgrader->strings[ 'skin_update_failed_error' ] = __( 'An error occurred while installing %1$s: <strong>%2$s</strong>.', 'tgmpa' ); |
|
3507
|
+ $this->upgrader->strings[ 'skin_update_failed' ] = __( 'The installation of %1$s failed.', 'tgmpa' ); |
3508
|
3508
|
|
3509
|
3509
|
if ( $this->tgmpa->is_automatic ) { |
3510
|
3510
|
// Automatic activation strings. |
3511
|
|
- $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' ); |
3512
|
|
- $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>'; |
3513
|
|
- $this->upgrader->strings['skin_upgrade_end'] = __( 'All installations and activations have been completed.', 'tgmpa' ); |
3514
|
|
- $this->upgrader->strings['skin_before_update_header'] = __( 'Installing and Activating Plugin %1$s (%2$d/%3$d)', 'tgmpa' ); |
|
3511
|
+ $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' ); |
|
3512
|
+ $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>'; |
|
3513
|
+ $this->upgrader->strings[ 'skin_upgrade_end' ] = __( 'All installations and activations have been completed.', 'tgmpa' ); |
|
3514
|
+ $this->upgrader->strings[ 'skin_before_update_header' ] = __( 'Installing and Activating Plugin %1$s (%2$d/%3$d)', 'tgmpa' ); |
3515
|
3515
|
} else { |
3516
|
3516
|
// Default installation strings. |
3517
|
|
- $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' ); |
3518
|
|
- $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>'; |
3519
|
|
- $this->upgrader->strings['skin_upgrade_end'] = __( 'All installations have been completed.', 'tgmpa' ); |
3520
|
|
- $this->upgrader->strings['skin_before_update_header'] = __( 'Installing Plugin %1$s (%2$d/%3$d)', 'tgmpa' ); |
|
3517
|
+ $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' ); |
|
3518
|
+ $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>'; |
|
3519
|
+ $this->upgrader->strings[ 'skin_upgrade_end' ] = __( 'All installations have been completed.', 'tgmpa' ); |
|
3520
|
+ $this->upgrader->strings[ 'skin_before_update_header' ] = __( 'Installing Plugin %1$s (%2$d/%3$d)', 'tgmpa' ); |
3521
|
3521
|
} |
3522
|
3522
|
} |
3523
|
3523
|
} |
|
@@ -3575,12 +3575,12 @@ discard block |
|
|
block discarded – undo |
3575
|
3575
|
if ( $this->tgmpa->is_tgmpa_complete() ) { |
3576
|
3576
|
// All plugins are active, so we display the complete string and hide the menu to protect users. |
3577
|
3577
|
echo '<style type="text/css">#adminmenu .wp-submenu li.current { display: none !important; }</style>'; |
3578
|
|
- $update_actions['dashboard'] = sprintf( |
3579
|
|
- esc_html( $this->tgmpa->strings['complete'] ), |
3580
|
|
- '<a href="' . esc_url( self_admin_url() ) . '">' . esc_html__( 'Return to the Dashboard', 'tgmpa' ) . '</a>' |
|
3578
|
+ $update_actions[ 'dashboard' ] = sprintf( |
|
3579
|
+ esc_html( $this->tgmpa->strings[ 'complete' ] ), |
|
3580
|
+ '<a href="'.esc_url( self_admin_url() ).'">'.esc_html__( 'Return to the Dashboard', 'tgmpa' ).'</a>' |
3581
|
3581
|
); |
3582
|
3582
|
} else { |
3583
|
|
- $update_actions['tgmpa_page'] = '<a href="' . esc_url( $this->tgmpa->get_tgmpa_url() ) . '" target="_parent">' . esc_html( $this->tgmpa->strings['return'] ) . '</a>'; |
|
3583
|
+ $update_actions[ 'tgmpa_page' ] = '<a href="'.esc_url( $this->tgmpa->get_tgmpa_url() ).'" target="_parent">'.esc_html( $this->tgmpa->strings[ 'return' ] ).'</a>'; |
3584
|
3584
|
} |
3585
|
3585
|
|
3586
|
3586
|
/** |
|
@@ -3670,7 +3670,7 @@ discard block |
|
|
block discarded – undo |
3670
|
3670
|
* @return string |
3671
|
3671
|
*/ |
3672
|
3672
|
public static function wrap_in_em( $string ) { |
3673
|
|
- return '<em>' . wp_kses_post( $string ) . '</em>'; |
|
3673
|
+ return '<em>'.wp_kses_post( $string ).'</em>'; |
3674
|
3674
|
} |
3675
|
3675
|
|
3676
|
3676
|
/** |
|
@@ -3684,7 +3684,7 @@ discard block |
|
|
block discarded – undo |
3684
|
3684
|
* @return string |
3685
|
3685
|
*/ |
3686
|
3686
|
public static function wrap_in_strong( $string ) { |
3687
|
|
- return '<strong>' . wp_kses_post( $string ) . '</strong>'; |
|
3687
|
+ return '<strong>'.wp_kses_post( $string ).'</strong>'; |
3688
|
3688
|
} |
3689
|
3689
|
|
3690
|
3690
|
/** |
|
@@ -3721,7 +3721,7 @@ discard block |
|
|
block discarded – undo |
3721
|
3721
|
*/ |
3722
|
3722
|
protected static function emulate_filter_bool( $value ) { |
3723
|
3723
|
// @codingStandardsIgnoreStart |
3724
|
|
- static $true = array( |
|
3724
|
+ static $true = array( |
3725
|
3725
|
'1', |
3726
|
3726
|
'true', 'True', 'TRUE', |
3727
|
3727
|
'y', 'Y', |