|
@@ -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,15 +455,15 @@ discard block |
|
|
block discarded – undo |
|
455
|
455
|
public function add_plugin_action_link_filters() { |
|
456
|
456
|
foreach ( $this->plugins as $slug => $plugin ) { |
|
457
|
457
|
if ( false === $this->can_plugin_activate( $slug ) ) { |
|
458
|
|
- add_filter( 'plugin_action_links_' . $plugin['file_path'], array( $this, 'filter_plugin_action_links_activate' ), 20 ); |
|
|
458
|
+ add_filter( 'plugin_action_links_'.$plugin[ 'file_path' ], array( $this, 'filter_plugin_action_links_activate' ), 20 ); |
|
459
|
459
|
} |
|
460
|
460
|
|
|
461
|
|
- if ( true === $plugin['force_activation'] ) { |
|
462
|
|
- add_filter( 'plugin_action_links_' . $plugin['file_path'], array( $this, 'filter_plugin_action_links_deactivate' ), 20 ); |
|
|
461
|
+ if ( true === $plugin[ 'force_activation' ] ) { |
|
|
462
|
+ add_filter( 'plugin_action_links_'.$plugin[ 'file_path' ], array( $this, 'filter_plugin_action_links_deactivate' ), 20 ); |
|
463
|
463
|
} |
|
464
|
464
|
|
|
465
|
465
|
if ( false !== $this->does_plugin_require_update( $slug ) ) { |
|
466
|
|
- add_filter( 'plugin_action_links_' . $plugin['file_path'], array( $this, 'filter_plugin_action_links_update' ), 20 ); |
|
|
466
|
+ add_filter( 'plugin_action_links_'.$plugin[ 'file_path' ], array( $this, 'filter_plugin_action_links_update' ), 20 ); |
|
467
|
467
|
} |
|
468
|
468
|
} |
|
469
|
469
|
} |
|
@@ -478,7 +478,7 @@ discard block |
|
|
block discarded – undo |
|
478
|
478
|
* @return array |
|
479
|
479
|
*/ |
|
480
|
480
|
public function filter_plugin_action_links_activate( $actions ) { |
|
481
|
|
- unset( $actions['activate'] ); |
|
|
481
|
+ unset( $actions[ 'activate' ] ); |
|
482
|
482
|
|
|
483
|
483
|
return $actions; |
|
484
|
484
|
} |
|
@@ -492,7 +492,7 @@ discard block |
|
|
block discarded – undo |
|
492
|
492
|
* @return array |
|
493
|
493
|
*/ |
|
494
|
494
|
public function filter_plugin_action_links_deactivate( $actions ) { |
|
495
|
|
- unset( $actions['deactivate'] ); |
|
|
495
|
+ unset( $actions[ 'deactivate' ] ); |
|
496
|
496
|
|
|
497
|
497
|
return $actions; |
|
498
|
498
|
} |
|
@@ -507,7 +507,7 @@ discard block |
|
|
block discarded – undo |
|
507
|
507
|
* @return array |
|
508
|
508
|
*/ |
|
509
|
509
|
public function filter_plugin_action_links_update( $actions ) { |
|
510
|
|
- $actions['update'] = sprintf( |
|
|
510
|
+ $actions[ 'update' ] = sprintf( |
|
511
|
511
|
'<a href="%1$s" title="%2$s" class="edit">%3$s</a>', |
|
512
|
512
|
esc_url( $this->get_tgmpa_status_url( 'update' ) ), |
|
513
|
513
|
esc_attr__( 'This plugin needs to be updated to be compatible with your theme.', 'tgmpa' ), |
|
@@ -545,9 +545,9 @@ discard block |
|
|
block discarded – undo |
|
545
|
545
|
return; |
|
546
|
546
|
} |
|
547
|
547
|
|
|
548
|
|
- if ( isset( $_REQUEST['tab'] ) && 'plugin-information' === $_REQUEST['tab'] ) { |
|
|
548
|
+ if ( isset( $_REQUEST[ 'tab' ] ) && 'plugin-information' === $_REQUEST[ 'tab' ] ) { |
|
549
|
549
|
// Needed for install_plugin_information(). |
|
550
|
|
- require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; |
|
|
550
|
+ require_once ABSPATH.'wp-admin/includes/plugin-install.php'; |
|
551
|
551
|
|
|
552
|
552
|
wp_enqueue_style( 'plugin-install' ); |
|
553
|
553
|
|
|
@@ -575,7 +575,7 @@ discard block |
|
|
block discarded – undo |
|
575
|
575
|
* @since 2.1.0 |
|
576
|
576
|
*/ |
|
577
|
577
|
public function thickbox() { |
|
578
|
|
- if ( ! get_user_meta( get_current_user_id(), 'tgmpa_dismissed_notice_' . $this->id, true ) ) { |
|
|
578
|
+ if ( ! get_user_meta( get_current_user_id(), 'tgmpa_dismissed_notice_'.$this->id, true ) ) { |
|
579
|
579
|
add_thickbox(); |
|
580
|
580
|
} |
|
581
|
581
|
} |
|
@@ -604,11 +604,11 @@ discard block |
|
|
block discarded – undo |
|
604
|
604
|
$args = apply_filters( |
|
605
|
605
|
'tgmpa_admin_menu_args', |
|
606
|
606
|
array( |
|
607
|
|
- 'parent_slug' => $this->parent_slug, // Parent Menu slug. |
|
608
|
|
- 'page_title' => $this->strings['page_title'], // Page title. |
|
609
|
|
- 'menu_title' => $this->strings['menu_title'], // Menu title. |
|
610
|
|
- 'capability' => $this->capability, // Capability. |
|
611
|
|
- 'menu_slug' => $this->menu, // Menu slug. |
|
|
607
|
+ 'parent_slug' => $this->parent_slug, // Parent Menu slug. |
|
|
608
|
+ 'page_title' => $this->strings[ 'page_title' ], // Page title. |
|
|
609
|
+ 'menu_title' => $this->strings[ 'menu_title' ], // Menu title. |
|
|
610
|
+ 'capability' => $this->capability, // Capability. |
|
|
611
|
+ 'menu_slug' => $this->menu, // Menu slug. |
|
612
|
612
|
'function' => array( $this, 'install_plugins_page' ), // Callback. |
|
613
|
613
|
) |
|
614
|
614
|
); |
|
@@ -629,10 +629,10 @@ discard block |
|
|
block discarded – undo |
|
629
|
629
|
} |
|
630
|
630
|
|
|
631
|
631
|
if ( 'themes.php' === $this->parent_slug ) { |
|
632
|
|
- $this->page_hook = call_user_func( 'add_theme_page', $args['page_title'], $args['menu_title'], $args['capability'], $args['menu_slug'], $args['function'] ); |
|
|
632
|
+ $this->page_hook = call_user_func( 'add_theme_page', $args[ 'page_title' ], $args[ 'menu_title' ], $args[ 'capability' ], $args[ 'menu_slug' ], $args[ 'function' ] ); |
|
633
|
633
|
} else { |
|
634
|
634
|
$type = 'submenu'; |
|
635
|
|
- $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'] ); |
|
|
635
|
+ $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' ] ); |
|
636
|
636
|
} |
|
637
|
637
|
} |
|
638
|
638
|
|
|
@@ -701,37 +701,37 @@ discard block |
|
|
block discarded – undo |
|
701
|
701
|
* @return boolean True on success, false on failure. |
|
702
|
702
|
*/ |
|
703
|
703
|
protected function do_plugin_install() { |
|
704
|
|
- if ( empty( $_GET['plugin'] ) ) { |
|
|
704
|
+ if ( empty( $_GET[ 'plugin' ] ) ) { |
|
705
|
705
|
return false; |
|
706
|
706
|
} |
|
707
|
707
|
|
|
708
|
708
|
// All plugin information will be stored in an array for processing. |
|
709
|
|
- $slug = $this->sanitize_key( urldecode( $_GET['plugin'] ) ); |
|
|
709
|
+ $slug = $this->sanitize_key( urldecode( $_GET[ 'plugin' ] ) ); |
|
710
|
710
|
|
|
711
|
711
|
if ( ! isset( $this->plugins[ $slug ] ) ) { |
|
712
|
712
|
return false; |
|
713
|
713
|
} |
|
714
|
714
|
|
|
715
|
715
|
// Was an install or upgrade action link clicked? |
|
716
|
|
- if ( ( isset( $_GET['tgmpa-install'] ) && 'install-plugin' === $_GET['tgmpa-install'] ) || ( isset( $_GET['tgmpa-update'] ) && 'update-plugin' === $_GET['tgmpa-update'] ) ) { |
|
|
716
|
+ if ( ( isset( $_GET[ 'tgmpa-install' ] ) && 'install-plugin' === $_GET[ 'tgmpa-install' ] ) || ( isset( $_GET[ 'tgmpa-update' ] ) && 'update-plugin' === $_GET[ 'tgmpa-update' ] ) ) { |
|
717
|
717
|
|
|
718
|
718
|
$install_type = 'install'; |
|
719
|
|
- if ( isset( $_GET['tgmpa-update'] ) && 'update-plugin' === $_GET['tgmpa-update'] ) { |
|
|
719
|
+ if ( isset( $_GET[ 'tgmpa-update' ] ) && 'update-plugin' === $_GET[ 'tgmpa-update' ] ) { |
|
720
|
720
|
$install_type = 'update'; |
|
721
|
721
|
} |
|
722
|
722
|
|
|
723
|
|
- check_admin_referer( 'tgmpa-' . $install_type, 'tgmpa-nonce' ); |
|
|
723
|
+ check_admin_referer( 'tgmpa-'.$install_type, 'tgmpa-nonce' ); |
|
724
|
724
|
|
|
725
|
725
|
// Pass necessary information via URL if WP_Filesystem is needed. |
|
726
|
726
|
$url = wp_nonce_url( |
|
727
|
727
|
add_query_arg( |
|
728
|
728
|
array( |
|
729
|
729
|
'plugin' => urlencode( $slug ), |
|
730
|
|
- 'tgmpa-' . $install_type => $install_type . '-plugin', |
|
|
730
|
+ 'tgmpa-'.$install_type => $install_type.'-plugin', |
|
731
|
731
|
), |
|
732
|
732
|
$this->get_tgmpa_url() |
|
733
|
733
|
), |
|
734
|
|
- 'tgmpa-' . $install_type, |
|
|
734
|
+ 'tgmpa-'.$install_type, |
|
735
|
735
|
'tgmpa-nonce' |
|
736
|
736
|
); |
|
737
|
737
|
|
|
@@ -750,35 +750,35 @@ discard block |
|
|
block discarded – undo |
|
750
|
750
|
|
|
751
|
751
|
// Prep variables for Plugin_Installer_Skin class. |
|
752
|
752
|
$extra = array(); |
|
753
|
|
- $extra['slug'] = $slug; // Needed for potentially renaming of directory name. |
|
|
753
|
+ $extra[ 'slug' ] = $slug; // Needed for potentially renaming of directory name. |
|
754
|
754
|
$source = $this->get_download_url( $slug ); |
|
755
|
|
- $api = ( 'repo' === $this->plugins[ $slug ]['source_type'] ) ? $this->get_plugins_api( $slug ) : null; |
|
|
755
|
+ $api = ( 'repo' === $this->plugins[ $slug ][ 'source_type' ] ) ? $this->get_plugins_api( $slug ) : null; |
|
756
|
756
|
$api = ( false !== $api ) ? $api : null; |
|
757
|
757
|
|
|
758
|
758
|
$url = add_query_arg( |
|
759
|
759
|
array( |
|
760
|
|
- 'action' => $install_type . '-plugin', |
|
|
760
|
+ 'action' => $install_type.'-plugin', |
|
761
|
761
|
'plugin' => urlencode( $slug ), |
|
762
|
762
|
), |
|
763
|
763
|
'update.php' |
|
764
|
764
|
); |
|
765
|
765
|
|
|
766
|
766
|
if ( ! class_exists( 'Plugin_Upgrader', false ) ) { |
|
767
|
|
- require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
|
|
767
|
+ require_once ABSPATH.'wp-admin/includes/class-wp-upgrader.php'; |
|
768
|
768
|
} |
|
769
|
769
|
|
|
770
|
770
|
$skin_args = array( |
|
771
|
|
- 'type' => ( 'bundled' !== $this->plugins[ $slug ]['source_type'] ) ? 'web' : 'upload', |
|
772
|
|
- 'title' => sprintf( $this->strings['installing'], $this->plugins[ $slug ]['name'] ), |
|
|
771
|
+ 'type' => ( 'bundled' !== $this->plugins[ $slug ][ 'source_type' ] ) ? 'web' : 'upload', |
|
|
772
|
+ 'title' => sprintf( $this->strings[ 'installing' ], $this->plugins[ $slug ][ 'name' ] ), |
|
773
|
773
|
'url' => esc_url_raw( $url ), |
|
774
|
|
- 'nonce' => $install_type . '-plugin_' . $slug, |
|
|
774
|
+ 'nonce' => $install_type.'-plugin_'.$slug, |
|
775
|
775
|
'plugin' => '', |
|
776
|
776
|
'api' => $api, |
|
777
|
777
|
'extra' => $extra, |
|
778
|
778
|
); |
|
779
|
779
|
|
|
780
|
780
|
if ( 'update' === $install_type ) { |
|
781
|
|
- $skin_args['plugin'] = $this->plugins[ $slug ]['file_path']; |
|
|
781
|
+ $skin_args[ 'plugin' ] = $this->plugins[ $slug ][ 'file_path' ]; |
|
782
|
782
|
$skin = new Plugin_Upgrader_Skin( $skin_args ); |
|
783
|
783
|
} else { |
|
784
|
784
|
$skin = new Plugin_Installer_Skin( $skin_args ); |
|
@@ -793,10 +793,10 @@ discard block |
|
|
block discarded – undo |
|
793
|
793
|
if ( 'update' === $install_type ) { |
|
794
|
794
|
// Inject our info into the update transient. |
|
795
|
795
|
$to_inject = array( $slug => $this->plugins[ $slug ] ); |
|
796
|
|
- $to_inject[ $slug ]['source'] = $source; |
|
|
796
|
+ $to_inject[ $slug ][ 'source' ] = $source; |
|
797
|
797
|
$this->inject_update_info( $to_inject ); |
|
798
|
798
|
|
|
799
|
|
- $upgrader->upgrade( $this->plugins[ $slug ]['file_path'] ); |
|
|
799
|
+ $upgrader->upgrade( $this->plugins[ $slug ][ 'file_path' ] ); |
|
800
|
800
|
} else { |
|
801
|
801
|
$upgrader->install( $source ); |
|
802
|
802
|
} |
|
@@ -819,18 +819,18 @@ discard block |
|
|
block discarded – undo |
|
819
|
819
|
|
|
820
|
820
|
// Display message based on if all plugins are now active or not. |
|
821
|
821
|
if ( $this->is_tgmpa_complete() ) { |
|
822
|
|
- echo '<p>', sprintf( esc_html( $this->strings['complete'] ), '<a href="' . esc_url( self_admin_url() ) . '">' . esc_html__( 'Return to the Dashboard', 'tgmpa' ) . '</a>' ), '</p>'; |
|
|
822
|
+ echo '<p>', sprintf( esc_html( $this->strings[ 'complete' ] ), '<a href="'.esc_url( self_admin_url() ).'">'.esc_html__( 'Return to the Dashboard', 'tgmpa' ).'</a>' ), '</p>'; |
|
823
|
823
|
echo '<style type="text/css">#adminmenu .wp-submenu li.current { display: none !important; }</style>'; |
|
824
|
824
|
} else { |
|
825
|
|
- echo '<p><a href="', esc_url( $this->get_tgmpa_url() ), '" target="_parent">', esc_html( $this->strings['return'] ), '</a></p>'; |
|
|
825
|
+ echo '<p><a href="', esc_url( $this->get_tgmpa_url() ), '" target="_parent">', esc_html( $this->strings[ 'return' ] ), '</a></p>'; |
|
826
|
826
|
} |
|
827
|
827
|
|
|
828
|
828
|
return true; |
|
829
|
|
- } elseif ( isset( $this->plugins[ $slug ]['file_path'], $_GET['tgmpa-activate'] ) && 'activate-plugin' === $_GET['tgmpa-activate'] ) { |
|
|
829
|
+ } elseif ( isset( $this->plugins[ $slug ][ 'file_path' ], $_GET[ 'tgmpa-activate' ] ) && 'activate-plugin' === $_GET[ 'tgmpa-activate' ] ) { |
|
830
|
830
|
// Activate action link was clicked. |
|
831
|
831
|
check_admin_referer( 'tgmpa-activate', 'tgmpa-nonce' ); |
|
832
|
832
|
|
|
833
|
|
- if ( false === $this->activate_single_plugin( $this->plugins[ $slug ]['file_path'], $slug ) ) { |
|
|
833
|
+ if ( false === $this->activate_single_plugin( $this->plugins[ $slug ][ 'file_path' ], $slug ) ) { |
|
834
|
834
|
return true; // Finish execution of the function early as we encountered an error. |
|
835
|
835
|
} |
|
836
|
836
|
} |
|
@@ -853,7 +853,7 @@ discard block |
|
|
block discarded – undo |
|
853
|
853
|
} |
|
854
|
854
|
|
|
855
|
855
|
foreach ( $plugins as $slug => $plugin ) { |
|
856
|
|
- $file_path = $plugin['file_path']; |
|
|
856
|
+ $file_path = $plugin[ 'file_path' ]; |
|
857
|
857
|
|
|
858
|
858
|
if ( empty( $repo_updates->response[ $file_path ] ) ) { |
|
859
|
859
|
$repo_updates->response[ $file_path ] = new stdClass; |
|
@@ -862,10 +862,10 @@ discard block |
|
|
block discarded – undo |
|
862
|
862
|
// We only really need to set package, but let's do all we can in case WP changes something. |
|
863
|
863
|
$repo_updates->response[ $file_path ]->slug = $slug; |
|
864
|
864
|
$repo_updates->response[ $file_path ]->plugin = $file_path; |
|
865
|
|
- $repo_updates->response[ $file_path ]->new_version = $plugin['version']; |
|
866
|
|
- $repo_updates->response[ $file_path ]->package = $plugin['source']; |
|
867
|
|
- if ( empty( $repo_updates->response[ $file_path ]->url ) && ! empty( $plugin['external_url'] ) ) { |
|
868
|
|
- $repo_updates->response[ $file_path ]->url = $plugin['external_url']; |
|
|
865
|
+ $repo_updates->response[ $file_path ]->new_version = $plugin[ 'version' ]; |
|
|
866
|
+ $repo_updates->response[ $file_path ]->package = $plugin[ 'source' ]; |
|
|
867
|
+ if ( empty( $repo_updates->response[ $file_path ]->url ) && ! empty( $plugin[ 'external_url' ] ) ) { |
|
|
868
|
+ $repo_updates->response[ $file_path ]->url = $plugin[ 'external_url' ]; |
|
869
|
869
|
} |
|
870
|
870
|
} |
|
871
|
871
|
|
|
@@ -889,13 +889,13 @@ discard block |
|
|
block discarded – undo |
|
889
|
889
|
* @return string $source |
|
890
|
890
|
*/ |
|
891
|
891
|
public function maybe_adjust_source_dir( $source, $remote_source, $upgrader ) { |
|
892
|
|
- if ( ! $this->is_tgmpa_page() || ! is_object( $GLOBALS['wp_filesystem'] ) ) { |
|
|
892
|
+ if ( ! $this->is_tgmpa_page() || ! is_object( $GLOBALS[ 'wp_filesystem' ] ) ) { |
|
893
|
893
|
return $source; |
|
894
|
894
|
} |
|
895
|
895
|
|
|
896
|
896
|
// Check for single file plugins. |
|
897
|
|
- $source_files = array_keys( $GLOBALS['wp_filesystem']->dirlist( $remote_source ) ); |
|
898
|
|
- if ( 1 === count( $source_files ) && false === $GLOBALS['wp_filesystem']->is_dir( $source ) ) { |
|
|
897
|
+ $source_files = array_keys( $GLOBALS[ 'wp_filesystem' ]->dirlist( $remote_source ) ); |
|
|
898
|
+ if ( 1 === count( $source_files ) && false === $GLOBALS[ 'wp_filesystem' ]->is_dir( $source ) ) { |
|
899
|
899
|
return $source; |
|
900
|
900
|
} |
|
901
|
901
|
|
|
@@ -903,12 +903,12 @@ discard block |
|
|
block discarded – undo |
|
903
|
903
|
$desired_slug = ''; |
|
904
|
904
|
|
|
905
|
905
|
// Figure out what the slug is supposed to be. |
|
906
|
|
- if ( false === $upgrader->bulk && ! empty( $upgrader->skin->options['extra']['slug'] ) ) { |
|
907
|
|
- $desired_slug = $upgrader->skin->options['extra']['slug']; |
|
|
906
|
+ if ( false === $upgrader->bulk && ! empty( $upgrader->skin->options[ 'extra' ][ 'slug' ] ) ) { |
|
|
907
|
+ $desired_slug = $upgrader->skin->options[ 'extra' ][ 'slug' ]; |
|
908
|
908
|
} else { |
|
909
|
909
|
// Bulk installer contains less info, so fall back on the info registered here. |
|
910
|
910
|
foreach ( $this->plugins as $slug => $plugin ) { |
|
911
|
|
- if ( ! empty( $upgrader->skin->plugin_names[ $upgrader->skin->i ] ) && $plugin['name'] === $upgrader->skin->plugin_names[ $upgrader->skin->i ] ) { |
|
|
911
|
+ if ( ! empty( $upgrader->skin->plugin_names[ $upgrader->skin->i ] ) && $plugin[ 'name' ] === $upgrader->skin->plugin_names[ $upgrader->skin->i ] ) { |
|
912
|
912
|
$desired_slug = $slug; |
|
913
|
913
|
break; |
|
914
|
914
|
} |
|
@@ -921,15 +921,15 @@ discard block |
|
|
block discarded – undo |
|
921
|
921
|
|
|
922
|
922
|
if ( ! empty( $subdir_name ) && $subdir_name !== $desired_slug ) { |
|
923
|
923
|
$from = untrailingslashit( $source ); |
|
924
|
|
- $to = trailingslashit( $remote_source ) . $desired_slug; |
|
|
924
|
+ $to = trailingslashit( $remote_source ).$desired_slug; |
|
925
|
925
|
|
|
926
|
|
- if ( true === $GLOBALS['wp_filesystem']->move( $from, $to ) ) { |
|
|
926
|
+ if ( true === $GLOBALS[ 'wp_filesystem' ]->move( $from, $to ) ) { |
|
927
|
927
|
return trailingslashit( $to ); |
|
928
|
928
|
} else { |
|
929
|
|
- 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 ) ); |
|
|
929
|
+ 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 ) ); |
|
930
|
930
|
} |
|
931
|
931
|
} elseif ( empty( $subdir_name ) ) { |
|
932
|
|
- 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 ) ); |
|
|
932
|
+ 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 ) ); |
|
933
|
933
|
} |
|
934
|
934
|
} |
|
935
|
935
|
|
|
@@ -953,19 +953,19 @@ discard block |
|
|
block discarded – undo |
|
953
|
953
|
|
|
954
|
954
|
if ( is_wp_error( $activate ) ) { |
|
955
|
955
|
echo '<div id="message" class="error"><p>', wp_kses_post( $activate->get_error_message() ), '</p></div>', |
|
956
|
|
- '<p><a href="', esc_url( $this->get_tgmpa_url() ), '" target="_parent">', esc_html( $this->strings['return'] ), '</a></p>'; |
|
|
956
|
+ '<p><a href="', esc_url( $this->get_tgmpa_url() ), '" target="_parent">', esc_html( $this->strings[ 'return' ] ), '</a></p>'; |
|
957
|
957
|
|
|
958
|
958
|
return false; // End it here if there is an error with activation. |
|
959
|
959
|
} else { |
|
960
|
960
|
if ( ! $automatic ) { |
|
961
|
961
|
// Make sure message doesn't display again if bulk activation is performed |
|
962
|
962
|
// immediately after a single activation. |
|
963
|
|
- if ( ! isset( $_POST['action'] ) ) { // WPCS: CSRF OK. |
|
964
|
|
- echo '<div id="message" class="updated"><p>', esc_html( $this->strings['activated_successfully'] ), ' <strong>', esc_html( $this->plugins[ $slug ]['name'] ), '.</strong></p></div>'; |
|
|
963
|
+ if ( ! isset( $_POST[ 'action' ] ) ) { // WPCS: CSRF OK. |
|
|
964
|
+ echo '<div id="message" class="updated"><p>', esc_html( $this->strings[ 'activated_successfully' ] ), ' <strong>', esc_html( $this->plugins[ $slug ][ 'name' ] ), '.</strong></p></div>'; |
|
965
|
965
|
} |
|
966
|
966
|
} else { |
|
967
|
967
|
// Simpler message layout for use on the plugin install page. |
|
968
|
|
- echo '<p>', esc_html( $this->strings['plugin_activated'] ), '</p>'; |
|
|
968
|
+ echo '<p>', esc_html( $this->strings[ 'plugin_activated' ] ), '</p>'; |
|
969
|
969
|
} |
|
970
|
970
|
} |
|
971
|
971
|
} elseif ( $this->is_plugin_active( $slug ) ) { |
|
@@ -973,25 +973,25 @@ discard block |
|
|
block discarded – undo |
|
973
|
973
|
// on the plugin install page. |
|
974
|
974
|
echo '<div id="message" class="error"><p>', |
|
975
|
975
|
sprintf( |
|
976
|
|
- esc_html( $this->strings['plugin_already_active'] ), |
|
977
|
|
- '<strong>' . esc_html( $this->plugins[ $slug ]['name'] ) . '</strong>' |
|
|
976
|
+ esc_html( $this->strings[ 'plugin_already_active' ] ), |
|
|
977
|
+ '<strong>'.esc_html( $this->plugins[ $slug ][ 'name' ] ).'</strong>' |
|
978
|
978
|
), |
|
979
|
979
|
'</p></div>'; |
|
980
|
980
|
} elseif ( $this->does_plugin_require_update( $slug ) ) { |
|
981
|
981
|
if ( ! $automatic ) { |
|
982
|
982
|
// Make sure message doesn't display again if bulk activation is performed |
|
983
|
983
|
// immediately after a single activation. |
|
984
|
|
- if ( ! isset( $_POST['action'] ) ) { // WPCS: CSRF OK. |
|
|
984
|
+ if ( ! isset( $_POST[ 'action' ] ) ) { // WPCS: CSRF OK. |
|
985
|
985
|
echo '<div id="message" class="error"><p>', |
|
986
|
986
|
sprintf( |
|
987
|
|
- esc_html( $this->strings['plugin_needs_higher_version'] ), |
|
988
|
|
- '<strong>' . esc_html( $this->plugins[ $slug ]['name'] ) . '</strong>' |
|
|
987
|
+ esc_html( $this->strings[ 'plugin_needs_higher_version' ] ), |
|
|
988
|
+ '<strong>'.esc_html( $this->plugins[ $slug ][ 'name' ] ).'</strong>' |
|
989
|
989
|
), |
|
990
|
990
|
'</p></div>'; |
|
991
|
991
|
} |
|
992
|
992
|
} else { |
|
993
|
993
|
// Simpler message layout for use on the plugin install page. |
|
994
|
|
- echo '<p>', sprintf( esc_html( $this->strings['plugin_needs_higher_version'] ), esc_html( $this->plugins[ $slug ]['name'] ) ), '</p>'; |
|
|
994
|
+ echo '<p>', sprintf( esc_html( $this->strings[ 'plugin_needs_higher_version' ] ), esc_html( $this->plugins[ $slug ][ 'name' ] ) ), '</p>'; |
|
995
|
995
|
} |
|
996
|
996
|
} |
|
997
|
997
|
|
|
@@ -1015,7 +1015,7 @@ discard block |
|
|
block discarded – undo |
|
1015
|
1015
|
*/ |
|
1016
|
1016
|
public function notices() { |
|
1017
|
1017
|
// Remove nag on the install page / Return early if the nag message has been dismissed. |
|
1018
|
|
- if ( $this->is_tgmpa_page() || get_user_meta( get_current_user_id(), 'tgmpa_dismissed_notice_' . $this->id, true ) ) { |
|
|
1018
|
+ if ( $this->is_tgmpa_page() || get_user_meta( get_current_user_id(), 'tgmpa_dismissed_notice_'.$this->id, true ) ) { |
|
1019
|
1019
|
return; |
|
1020
|
1020
|
} |
|
1021
|
1021
|
|
|
@@ -1036,28 +1036,28 @@ discard block |
|
|
block discarded – undo |
|
1036
|
1036
|
if ( current_user_can( 'install_plugins' ) ) { |
|
1037
|
1037
|
$install_link_count++; |
|
1038
|
1038
|
|
|
1039
|
|
- if ( true === $plugin['required'] ) { |
|
1040
|
|
- $message['notice_can_install_required'][] = $slug; |
|
|
1039
|
+ if ( true === $plugin[ 'required' ] ) { |
|
|
1040
|
+ $message[ 'notice_can_install_required' ][ ] = $slug; |
|
1041
|
1041
|
} else { |
|
1042
|
|
- $message['notice_can_install_recommended'][] = $slug; |
|
|
1042
|
+ $message[ 'notice_can_install_recommended' ][ ] = $slug; |
|
1043
|
1043
|
} |
|
1044
|
1044
|
} else { |
|
1045
|
1045
|
// Need higher privileges to install the plugin. |
|
1046
|
|
- $message['notice_cannot_install'][] = $slug; |
|
|
1046
|
+ $message[ 'notice_cannot_install' ][ ] = $slug; |
|
1047
|
1047
|
} |
|
1048
|
1048
|
} else { |
|
1049
|
1049
|
if ( ! $this->is_plugin_active( $slug ) && $this->can_plugin_activate( $slug ) ) { |
|
1050
|
1050
|
if ( current_user_can( 'activate_plugins' ) ) { |
|
1051
|
1051
|
$activate_link_count++; |
|
1052
|
1052
|
|
|
1053
|
|
- if ( true === $plugin['required'] ) { |
|
1054
|
|
- $message['notice_can_activate_required'][] = $slug; |
|
|
1053
|
+ if ( true === $plugin[ 'required' ] ) { |
|
|
1054
|
+ $message[ 'notice_can_activate_required' ][ ] = $slug; |
|
1055
|
1055
|
} else { |
|
1056
|
|
- $message['notice_can_activate_recommended'][] = $slug; |
|
|
1056
|
+ $message[ 'notice_can_activate_recommended' ][ ] = $slug; |
|
1057
|
1057
|
} |
|
1058
|
1058
|
} else { |
|
1059
|
1059
|
// Need higher privileges to activate the plugin. |
|
1060
|
|
- $message['notice_cannot_activate'][] = $slug; |
|
|
1060
|
+ $message[ 'notice_cannot_activate' ][ ] = $slug; |
|
1061
|
1061
|
} |
|
1062
|
1062
|
} |
|
1063
|
1063
|
|
|
@@ -1067,13 +1067,13 @@ discard block |
|
|
block discarded – undo |
|
1067
|
1067
|
$update_link_count++; |
|
1068
|
1068
|
|
|
1069
|
1069
|
if ( $this->does_plugin_require_update( $slug ) ) { |
|
1070
|
|
- $message['notice_ask_to_update'][] = $slug; |
|
|
1070
|
+ $message[ 'notice_ask_to_update' ][ ] = $slug; |
|
1071
|
1071
|
} elseif ( false !== $this->does_plugin_have_update( $slug ) ) { |
|
1072
|
|
- $message['notice_ask_to_update_maybe'][] = $slug; |
|
|
1072
|
+ $message[ 'notice_ask_to_update_maybe' ][ ] = $slug; |
|
1073
|
1073
|
} |
|
1074
|
1074
|
} else { |
|
1075
|
1075
|
// Need higher privileges to update the plugin. |
|
1076
|
|
- $message['notice_cannot_update'][] = $slug; |
|
|
1076
|
+ $message[ 'notice_cannot_update' ][ ] = $slug; |
|
1077
|
1077
|
} |
|
1078
|
1078
|
} |
|
1079
|
1079
|
} |
|
@@ -1087,7 +1087,7 @@ discard block |
|
|
block discarded – undo |
|
1087
|
1087
|
|
|
1088
|
1088
|
// As add_settings_error() wraps the final message in a <p> and as the final message can't be |
|
1089
|
1089
|
// filtered, using <p>'s in our html would render invalid html output. |
|
1090
|
|
- $line_template = '<span style="display: block; margin: 0.5em 0.5em 0 0; clear: both;">%s</span>' . "\n"; |
|
|
1090
|
+ $line_template = '<span style="display: block; margin: 0.5em 0.5em 0 0; clear: both;">%s</span>'."\n"; |
|
1091
|
1091
|
|
|
1092
|
1092
|
// If dismissable is false and a message is set, output it now. |
|
1093
|
1093
|
if ( ! $this->dismissable && ! empty( $this->dismiss_msg ) ) { |
|
@@ -1100,14 +1100,14 @@ discard block |
|
|
block discarded – undo |
|
1100
|
1100
|
|
|
1101
|
1101
|
// Get the external info link for a plugin if one is available. |
|
1102
|
1102
|
foreach ( $plugin_group as $plugin_slug ) { |
|
1103
|
|
- $linked_plugins[] = $this->get_info_link( $plugin_slug ); |
|
|
1103
|
+ $linked_plugins[ ] = $this->get_info_link( $plugin_slug ); |
|
1104
|
1104
|
} |
|
1105
|
1105
|
unset( $plugin_slug ); |
|
1106
|
1106
|
|
|
1107
|
1107
|
$count = count( $plugin_group ); |
|
1108
|
1108
|
$linked_plugins = array_map( array( 'TGMPA_Utils', 'wrap_in_em' ), $linked_plugins ); |
|
1109
|
1109
|
$last_plugin = array_pop( $linked_plugins ); // Pop off last name to prep for readability. |
|
1110
|
|
- $imploded = empty( $linked_plugins ) ? $last_plugin : ( implode( ', ', $linked_plugins ) . ' ' . esc_html_x( 'and', 'plugin A *and* plugin B', 'tgmpa' ) . ' ' . $last_plugin ); |
|
|
1110
|
+ $imploded = empty( $linked_plugins ) ? $last_plugin : ( implode( ', ', $linked_plugins ).' '.esc_html_x( 'and', 'plugin A *and* plugin B', 'tgmpa' ).' '.$last_plugin ); |
|
1111
|
1111
|
|
|
1112
|
1112
|
$rendered .= sprintf( |
|
1113
|
1113
|
$line_template, |
|
@@ -1119,7 +1119,7 @@ discard block |
|
|
block discarded – undo |
|
1119
|
1119
|
); |
|
1120
|
1120
|
|
|
1121
|
1121
|
if ( 0 === strpos( $type, 'notice_cannot' ) ) { |
|
1122
|
|
- $rendered .= $this->strings['contact_admin']; |
|
|
1122
|
+ $rendered .= $this->strings[ 'contact_admin' ]; |
|
1123
|
1123
|
} |
|
1124
|
1124
|
} |
|
1125
|
1125
|
unset( $type, $plugin_group, $linked_plugins, $count, $last_plugin, $imploded ); |
|
@@ -1129,32 +1129,32 @@ discard block |
|
|
block discarded – undo |
|
1129
|
1129
|
'install' => '', |
|
1130
|
1130
|
'update' => '', |
|
1131
|
1131
|
'activate' => '', |
|
1132
|
|
- '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>' : '', |
|
|
1132
|
+ '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>' : '', |
|
1133
|
1133
|
); |
|
1134
|
1134
|
|
|
1135
|
1135
|
$link_template = '<a href="%2$s">%1$s</a>'; |
|
1136
|
1136
|
|
|
1137
|
1137
|
if ( current_user_can( 'install_plugins' ) ) { |
|
1138
|
1138
|
if ( $install_link_count > 0 ) { |
|
1139
|
|
- $action_links['install'] = sprintf( |
|
|
1139
|
+ $action_links[ 'install' ] = sprintf( |
|
1140
|
1140
|
$link_template, |
|
1141
|
|
- translate_nooped_plural( $this->strings['install_link'], $install_link_count, 'tgmpa' ), |
|
|
1141
|
+ translate_nooped_plural( $this->strings[ 'install_link' ], $install_link_count, 'tgmpa' ), |
|
1142
|
1142
|
esc_url( $this->get_tgmpa_status_url( 'install' ) ) |
|
1143
|
1143
|
); |
|
1144
|
1144
|
} |
|
1145
|
1145
|
if ( $update_link_count > 0 ) { |
|
1146
|
|
- $action_links['update'] = sprintf( |
|
|
1146
|
+ $action_links[ 'update' ] = sprintf( |
|
1147
|
1147
|
$link_template, |
|
1148
|
|
- translate_nooped_plural( $this->strings['update_link'], $update_link_count, 'tgmpa' ), |
|
|
1148
|
+ translate_nooped_plural( $this->strings[ 'update_link' ], $update_link_count, 'tgmpa' ), |
|
1149
|
1149
|
esc_url( $this->get_tgmpa_status_url( 'update' ) ) |
|
1150
|
1150
|
); |
|
1151
|
1151
|
} |
|
1152
|
1152
|
} |
|
1153
|
1153
|
|
|
1154
|
1154
|
if ( current_user_can( 'activate_plugins' ) && $activate_link_count > 0 ) { |
|
1155
|
|
- $action_links['activate'] = sprintf( |
|
|
1155
|
+ $action_links[ 'activate' ] = sprintf( |
|
1156
|
1156
|
$link_template, |
|
1157
|
|
- translate_nooped_plural( $this->strings['activate_link'], $activate_link_count, 'tgmpa' ), |
|
|
1157
|
+ translate_nooped_plural( $this->strings[ 'activate_link' ], $activate_link_count, 'tgmpa' ), |
|
1158
|
1158
|
esc_url( $this->get_tgmpa_status_url( 'activate' ) ) |
|
1159
|
1159
|
); |
|
1160
|
1160
|
} |
|
@@ -1173,7 +1173,7 @@ discard block |
|
|
block discarded – undo |
|
1173
|
1173
|
} |
|
1174
|
1174
|
|
|
1175
|
1175
|
// Admin options pages already output settings_errors, so this is to avoid duplication. |
|
1176
|
|
- if ( 'options-general' !== $GLOBALS['current_screen']->parent_base ) { |
|
|
1176
|
+ if ( 'options-general' !== $GLOBALS[ 'current_screen' ]->parent_base ) { |
|
1177
|
1177
|
$this->display_settings_errors(); |
|
1178
|
1178
|
} |
|
1179
|
1179
|
} |
|
@@ -1189,8 +1189,8 @@ discard block |
|
|
block discarded – undo |
|
1189
|
1189
|
* @return string |
|
1190
|
1190
|
*/ |
|
1191
|
1191
|
protected function get_admin_notice_class() { |
|
1192
|
|
- if ( ! empty( $this->strings['nag_type'] ) ) { |
|
1193
|
|
- return sanitize_html_class( strtolower( $this->strings['nag_type'] ) ); |
|
|
1192
|
+ if ( ! empty( $this->strings[ 'nag_type' ] ) ) { |
|
|
1193
|
+ return sanitize_html_class( strtolower( $this->strings[ 'nag_type' ] ) ); |
|
1194
|
1194
|
} else { |
|
1195
|
1195
|
if ( version_compare( $this->wp_version, '4.2', '>=' ) ) { |
|
1196
|
1196
|
return 'notice-warning'; |
|
@@ -1213,7 +1213,7 @@ discard block |
|
|
block discarded – undo |
|
1213
|
1213
|
settings_errors( 'tgmpa' ); |
|
1214
|
1214
|
|
|
1215
|
1215
|
foreach ( (array) $wp_settings_errors as $key => $details ) { |
|
1216
|
|
- if ( 'tgmpa' === $details['setting'] ) { |
|
|
1216
|
+ if ( 'tgmpa' === $details[ 'setting' ] ) { |
|
1217
|
1217
|
unset( $wp_settings_errors[ $key ] ); |
|
1218
|
1218
|
break; |
|
1219
|
1219
|
} |
|
@@ -1228,8 +1228,8 @@ discard block |
|
|
block discarded – undo |
|
1228
|
1228
|
* @since 2.1.0 |
|
1229
|
1229
|
*/ |
|
1230
|
1230
|
public function dismiss() { |
|
1231
|
|
- if ( isset( $_GET['tgmpa-dismiss'] ) && check_admin_referer( 'tgmpa-dismis-' . get_current_user_id() ) ) { |
|
1232
|
|
- update_user_meta( get_current_user_id(), 'tgmpa_dismissed_notice_' . $this->id, 1 ); |
|
|
1231
|
+ if ( isset( $_GET[ 'tgmpa-dismiss' ] ) && check_admin_referer( 'tgmpa-dismis-'.get_current_user_id() ) ) { |
|
|
1232
|
+ update_user_meta( get_current_user_id(), 'tgmpa_dismissed_notice_'.$this->id, 1 ); |
|
1233
|
1233
|
} |
|
1234
|
1234
|
} |
|
1235
|
1235
|
|
|
@@ -1245,54 +1245,54 @@ discard block |
|
|
block discarded – undo |
|
1245
|
1245
|
* @return null Return early if incorrect argument. |
|
1246
|
1246
|
*/ |
|
1247
|
1247
|
public function register( $plugin ) { |
|
1248
|
|
- if ( empty( $plugin['slug'] ) || empty( $plugin['name'] ) ) { |
|
|
1248
|
+ if ( empty( $plugin[ 'slug' ] ) || empty( $plugin[ 'name' ] ) ) { |
|
1249
|
1249
|
return; |
|
1250
|
1250
|
} |
|
1251
|
1251
|
|
|
1252
|
|
- if ( empty( $plugin['slug'] ) || ! is_string( $plugin['slug'] ) || isset( $this->plugins[ $plugin['slug'] ] ) ) { |
|
|
1252
|
+ if ( empty( $plugin[ 'slug' ] ) || ! is_string( $plugin[ 'slug' ] ) || isset( $this->plugins[ $plugin[ 'slug' ] ] ) ) { |
|
1253
|
1253
|
return; |
|
1254
|
1254
|
} |
|
1255
|
1255
|
|
|
1256
|
1256
|
$defaults = array( |
|
1257
|
|
- 'name' => '', // String |
|
1258
|
|
- 'slug' => '', // String |
|
1259
|
|
- 'source' => 'repo', // String |
|
1260
|
|
- 'required' => false, // Boolean |
|
1261
|
|
- 'version' => '', // String |
|
1262
|
|
- 'force_activation' => false, // Boolean |
|
1263
|
|
- 'force_deactivation' => false, // Boolean |
|
1264
|
|
- 'external_url' => '', // String |
|
1265
|
|
- 'is_callable' => '', // String|Array. |
|
|
1257
|
+ 'name' => '', // String |
|
|
1258
|
+ 'slug' => '', // String |
|
|
1259
|
+ 'source' => 'repo', // String |
|
|
1260
|
+ 'required' => false, // Boolean |
|
|
1261
|
+ 'version' => '', // String |
|
|
1262
|
+ 'force_activation' => false, // Boolean |
|
|
1263
|
+ 'force_deactivation' => false, // Boolean |
|
|
1264
|
+ 'external_url' => '', // String |
|
|
1265
|
+ 'is_callable' => '', // String|Array. |
|
1266
|
1266
|
); |
|
1267
|
1267
|
|
|
1268
|
1268
|
// Prepare the received data. |
|
1269
|
1269
|
$plugin = wp_parse_args( $plugin, $defaults ); |
|
1270
|
1270
|
|
|
1271
|
1271
|
// Standardize the received slug. |
|
1272
|
|
- $plugin['slug'] = $this->sanitize_key( $plugin['slug'] ); |
|
|
1272
|
+ $plugin[ 'slug' ] = $this->sanitize_key( $plugin[ 'slug' ] ); |
|
1273
|
1273
|
|
|
1274
|
1274
|
// Forgive users for using string versions of booleans or floats for version number. |
|
1275
|
|
- $plugin['version'] = (string) $plugin['version']; |
|
1276
|
|
- $plugin['source'] = empty( $plugin['source'] ) ? 'repo' : $plugin['source']; |
|
1277
|
|
- $plugin['required'] = TGMPA_Utils::validate_bool( $plugin['required'] ); |
|
1278
|
|
- $plugin['force_activation'] = TGMPA_Utils::validate_bool( $plugin['force_activation'] ); |
|
1279
|
|
- $plugin['force_deactivation'] = TGMPA_Utils::validate_bool( $plugin['force_deactivation'] ); |
|
|
1275
|
+ $plugin[ 'version' ] = (string) $plugin[ 'version' ]; |
|
|
1276
|
+ $plugin[ 'source' ] = empty( $plugin[ 'source' ] ) ? 'repo' : $plugin[ 'source' ]; |
|
|
1277
|
+ $plugin[ 'required' ] = TGMPA_Utils::validate_bool( $plugin[ 'required' ] ); |
|
|
1278
|
+ $plugin[ 'force_activation' ] = TGMPA_Utils::validate_bool( $plugin[ 'force_activation' ] ); |
|
|
1279
|
+ $plugin[ 'force_deactivation' ] = TGMPA_Utils::validate_bool( $plugin[ 'force_deactivation' ] ); |
|
1280
|
1280
|
|
|
1281
|
1281
|
// Enrich the received data. |
|
1282
|
|
- $plugin['file_path'] = $this->_get_plugin_basename_from_slug( $plugin['slug'] ); |
|
1283
|
|
- $plugin['source_type'] = $this->get_plugin_source_type( $plugin['source'] ); |
|
|
1282
|
+ $plugin[ 'file_path' ] = $this->_get_plugin_basename_from_slug( $plugin[ 'slug' ] ); |
|
|
1283
|
+ $plugin[ 'source_type' ] = $this->get_plugin_source_type( $plugin[ 'source' ] ); |
|
1284
|
1284
|
|
|
1285
|
1285
|
// Set the class properties. |
|
1286
|
|
- $this->plugins[ $plugin['slug'] ] = $plugin; |
|
1287
|
|
- $this->sort_order[ $plugin['slug'] ] = $plugin['name']; |
|
|
1286
|
+ $this->plugins[ $plugin[ 'slug' ] ] = $plugin; |
|
|
1287
|
+ $this->sort_order[ $plugin[ 'slug' ] ] = $plugin[ 'name' ]; |
|
1288
|
1288
|
|
|
1289
|
1289
|
// Should we add the force activation hook ? |
|
1290
|
|
- if ( true === $plugin['force_activation'] ) { |
|
|
1290
|
+ if ( true === $plugin[ 'force_activation' ] ) { |
|
1291
|
1291
|
$this->has_forced_activation = true; |
|
1292
|
1292
|
} |
|
1293
|
1293
|
|
|
1294
|
1294
|
// Should we add the force deactivation hook ? |
|
1295
|
|
- if ( true === $plugin['force_deactivation'] ) { |
|
|
1295
|
+ if ( true === $plugin[ 'force_deactivation' ] ) { |
|
1296
|
1296
|
$this->has_forced_deactivation = true; |
|
1297
|
1297
|
} |
|
1298
|
1298
|
} |
|
@@ -1418,11 +1418,11 @@ discard block |
|
|
block discarded – undo |
|
1418
|
1418
|
*/ |
|
1419
|
1419
|
public function populate_file_path( $plugin_slug = '' ) { |
|
1420
|
1420
|
if ( ! empty( $plugin_slug ) && is_string( $plugin_slug ) && isset( $this->plugins[ $plugin_slug ] ) ) { |
|
1421
|
|
- $this->plugins[ $plugin_slug ]['file_path'] = $this->_get_plugin_basename_from_slug( $plugin_slug ); |
|
|
1421
|
+ $this->plugins[ $plugin_slug ][ 'file_path' ] = $this->_get_plugin_basename_from_slug( $plugin_slug ); |
|
1422
|
1422
|
} else { |
|
1423
|
1423
|
// Add file_path key for all plugins. |
|
1424
|
1424
|
foreach ( $this->plugins as $slug => $values ) { |
|
1425
|
|
- $this->plugins[ $slug ]['file_path'] = $this->_get_plugin_basename_from_slug( $slug ); |
|
|
1425
|
+ $this->plugins[ $slug ][ 'file_path' ] = $this->_get_plugin_basename_from_slug( $slug ); |
|
1426
|
1426
|
} |
|
1427
|
1427
|
} |
|
1428
|
1428
|
} |
|
@@ -1440,7 +1440,7 @@ discard block |
|
|
block discarded – undo |
|
1440
|
1440
|
$keys = array_keys( $this->get_plugins() ); |
|
1441
|
1441
|
|
|
1442
|
1442
|
foreach ( $keys as $key ) { |
|
1443
|
|
- if ( preg_match( '|^' . $slug . '/|', $key ) ) { |
|
|
1443
|
+ if ( preg_match( '|^'.$slug.'/|', $key ) ) { |
|
1444
|
1444
|
return $key; |
|
1445
|
1445
|
} |
|
1446
|
1446
|
} |
|
@@ -1462,7 +1462,7 @@ discard block |
|
|
block discarded – undo |
|
1462
|
1462
|
*/ |
|
1463
|
1463
|
public function _get_plugin_data_from_name( $name, $data = 'slug' ) { |
|
1464
|
1464
|
foreach ( $this->plugins as $values ) { |
|
1465
|
|
- if ( $name === $values['name'] && isset( $values[ $data ] ) ) { |
|
|
1465
|
+ if ( $name === $values[ 'name' ] && isset( $values[ $data ] ) ) { |
|
1466
|
1466
|
return $values[ $data ]; |
|
1467
|
1467
|
} |
|
1468
|
1468
|
} |
|
@@ -1481,13 +1481,13 @@ discard block |
|
|
block discarded – undo |
|
1481
|
1481
|
public function get_download_url( $slug ) { |
|
1482
|
1482
|
$dl_source = ''; |
|
1483
|
1483
|
|
|
1484
|
|
- switch ( $this->plugins[ $slug ]['source_type'] ) { |
|
|
1484
|
+ switch ( $this->plugins[ $slug ][ 'source_type' ] ) { |
|
1485
|
1485
|
case 'repo': |
|
1486
|
1486
|
return $this->get_wp_repo_download_url( $slug ); |
|
1487
|
1487
|
case 'external': |
|
1488
|
|
- return $this->plugins[ $slug ]['source']; |
|
|
1488
|
+ return $this->plugins[ $slug ][ 'source' ]; |
|
1489
|
1489
|
case 'bundled': |
|
1490
|
|
- return $this->default_path . $this->plugins[ $slug ]['source']; |
|
|
1490
|
+ return $this->default_path.$this->plugins[ $slug ][ 'source' ]; |
|
1491
|
1491
|
} |
|
1492
|
1492
|
|
|
1493
|
1493
|
return $dl_source; // Should never happen. |
|
@@ -1525,7 +1525,7 @@ discard block |
|
|
block discarded – undo |
|
1525
|
1525
|
|
|
1526
|
1526
|
if ( ! isset( $api[ $slug ] ) ) { |
|
1527
|
1527
|
if ( ! function_exists( 'plugins_api' ) ) { |
|
1528
|
|
- require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; |
|
|
1528
|
+ require_once ABSPATH.'wp-admin/includes/plugin-install.php'; |
|
1529
|
1529
|
} |
|
1530
|
1530
|
|
|
1531
|
1531
|
$response = plugins_api( 'plugin_information', array( 'slug' => $slug, 'fields' => array( 'sections' => false ) ) ); |
|
@@ -1533,7 +1533,7 @@ discard block |
|
|
block discarded – undo |
|
1533
|
1533
|
$api[ $slug ] = false; |
|
1534
|
1534
|
|
|
1535
|
1535
|
if ( is_wp_error( $response ) ) { |
|
1536
|
|
- wp_die( esc_html( $this->strings['oops'] ) ); |
|
|
1536
|
+ wp_die( esc_html( $this->strings[ 'oops' ] ) ); |
|
1537
|
1537
|
} else { |
|
1538
|
1538
|
$api[ $slug ] = $response; |
|
1539
|
1539
|
} |
|
@@ -1552,13 +1552,13 @@ discard block |
|
|
block discarded – undo |
|
1552
|
1552
|
* or the plugin name if not. |
|
1553
|
1553
|
*/ |
|
1554
|
1554
|
public function get_info_link( $slug ) { |
|
1555
|
|
- if ( ! empty( $this->plugins[ $slug ]['external_url'] ) && preg_match( self::IS_URL_REGEX, $this->plugins[ $slug ]['external_url'] ) ) { |
|
|
1555
|
+ if ( ! empty( $this->plugins[ $slug ][ 'external_url' ] ) && preg_match( self::IS_URL_REGEX, $this->plugins[ $slug ][ 'external_url' ] ) ) { |
|
1556
|
1556
|
$link = sprintf( |
|
1557
|
1557
|
'<a href="%1$s" target="_blank">%2$s</a>', |
|
1558
|
|
- esc_url( $this->plugins[ $slug ]['external_url'] ), |
|
1559
|
|
- esc_html( $this->plugins[ $slug ]['name'] ) |
|
|
1558
|
+ esc_url( $this->plugins[ $slug ][ 'external_url' ] ), |
|
|
1559
|
+ esc_html( $this->plugins[ $slug ][ 'name' ] ) |
|
1560
|
1560
|
); |
|
1561
|
|
- } elseif ( 'repo' === $this->plugins[ $slug ]['source_type'] ) { |
|
|
1561
|
+ } elseif ( 'repo' === $this->plugins[ $slug ][ 'source_type' ] ) { |
|
1562
|
1562
|
$url = add_query_arg( |
|
1563
|
1563
|
array( |
|
1564
|
1564
|
'tab' => 'plugin-information', |
|
@@ -1573,10 +1573,10 @@ discard block |
|
|
block discarded – undo |
|
1573
|
1573
|
$link = sprintf( |
|
1574
|
1574
|
'<a href="%1$s" class="thickbox">%2$s</a>', |
|
1575
|
1575
|
esc_url( $url ), |
|
1576
|
|
- esc_html( $this->plugins[ $slug ]['name'] ) |
|
|
1576
|
+ esc_html( $this->plugins[ $slug ][ 'name' ] ) |
|
1577
|
1577
|
); |
|
1578
|
1578
|
} else { |
|
1579
|
|
- $link = esc_html( $this->plugins[ $slug ]['name'] ); // No hyperlink. |
|
|
1579
|
+ $link = esc_html( $this->plugins[ $slug ][ 'name' ] ); // No hyperlink. |
|
1580
|
1580
|
} |
|
1581
|
1581
|
|
|
1582
|
1582
|
return $link; |
|
@@ -1590,7 +1590,7 @@ discard block |
|
|
block discarded – undo |
|
1590
|
1590
|
* @return boolean True when on the TGMPA page, false otherwise. |
|
1591
|
1591
|
*/ |
|
1592
|
1592
|
protected function is_tgmpa_page() { |
|
1593
|
|
- return isset( $_GET['page'] ) && $this->menu === $_GET['page']; |
|
|
1593
|
+ return isset( $_GET[ 'page' ] ) && $this->menu === $_GET[ 'page' ]; |
|
1594
|
1594
|
} |
|
1595
|
1595
|
|
|
1596
|
1596
|
/** |
|
@@ -1672,7 +1672,7 @@ discard block |
|
|
block discarded – undo |
|
1672
|
1672
|
public function is_plugin_installed( $slug ) { |
|
1673
|
1673
|
$installed_plugins = $this->get_plugins(); // Retrieve a list of all installed plugins (WP cached). |
|
1674
|
1674
|
|
|
1675
|
|
- return ( ! empty( $installed_plugins[ $this->plugins[ $slug ]['file_path'] ] ) ); |
|
|
1675
|
+ return ( ! empty( $installed_plugins[ $this->plugins[ $slug ][ 'file_path' ] ] ) ); |
|
1676
|
1676
|
} |
|
1677
|
1677
|
|
|
1678
|
1678
|
/** |
|
@@ -1684,7 +1684,7 @@ discard block |
|
|
block discarded – undo |
|
1684
|
1684
|
* @return bool True if active, false otherwise. |
|
1685
|
1685
|
*/ |
|
1686
|
1686
|
public function is_plugin_active( $slug ) { |
|
1687
|
|
- return ( ( ! empty( $this->plugins[ $slug ]['is_callable'] ) && is_callable( $this->plugins[ $slug ]['is_callable'] ) ) || is_plugin_active( $this->plugins[ $slug ]['file_path'] ) ); |
|
|
1687
|
+ return ( ( ! empty( $this->plugins[ $slug ][ 'is_callable' ] ) && is_callable( $this->plugins[ $slug ][ 'is_callable' ] ) ) || is_plugin_active( $this->plugins[ $slug ][ 'file_path' ] ) ); |
|
1688
|
1688
|
} |
|
1689
|
1689
|
|
|
1690
|
1690
|
/** |
|
@@ -1698,14 +1698,14 @@ discard block |
|
|
block discarded – undo |
|
1698
|
1698
|
*/ |
|
1699
|
1699
|
public function can_plugin_update( $slug ) { |
|
1700
|
1700
|
// We currently can't get reliable info on non-WP-repo plugins - issue #380. |
|
1701
|
|
- if ( 'repo' !== $this->plugins[ $slug ]['source_type'] ) { |
|
|
1701
|
+ if ( 'repo' !== $this->plugins[ $slug ][ 'source_type' ] ) { |
|
1702
|
1702
|
return true; |
|
1703
|
1703
|
} |
|
1704
|
1704
|
|
|
1705
|
1705
|
$api = $this->get_plugins_api( $slug ); |
|
1706
|
1706
|
|
|
1707
|
1707
|
if ( false !== $api && isset( $api->requires ) ) { |
|
1708
|
|
- return version_compare( $GLOBALS['wp_version'], $api->requires, '>=' ); |
|
|
1708
|
+ return version_compare( $GLOBALS[ 'wp_version' ], $api->requires, '>=' ); |
|
1709
|
1709
|
} |
|
1710
|
1710
|
|
|
1711
|
1711
|
// No usable info received from the plugins API, presume we can update. |
|
@@ -1737,8 +1737,8 @@ discard block |
|
|
block discarded – undo |
|
1737
|
1737
|
public function get_installed_version( $slug ) { |
|
1738
|
1738
|
$installed_plugins = $this->get_plugins(); // Retrieve a list of all installed plugins (WP cached). |
|
1739
|
1739
|
|
|
1740
|
|
- if ( ! empty( $installed_plugins[ $this->plugins[ $slug ]['file_path'] ]['Version'] ) ) { |
|
1741
|
|
- return $installed_plugins[ $this->plugins[ $slug ]['file_path'] ]['Version']; |
|
|
1740
|
+ if ( ! empty( $installed_plugins[ $this->plugins[ $slug ][ 'file_path' ] ][ 'Version' ] ) ) { |
|
|
1741
|
+ return $installed_plugins[ $this->plugins[ $slug ][ 'file_path' ] ][ 'Version' ]; |
|
1742
|
1742
|
} |
|
1743
|
1743
|
|
|
1744
|
1744
|
return ''; |
|
@@ -1754,7 +1754,7 @@ discard block |
|
|
block discarded – undo |
|
1754
|
1754
|
*/ |
|
1755
|
1755
|
public function does_plugin_require_update( $slug ) { |
|
1756
|
1756
|
$installed_version = $this->get_installed_version( $slug ); |
|
1757
|
|
- $minimum_version = $this->plugins[ $slug ]['version']; |
|
|
1757
|
+ $minimum_version = $this->plugins[ $slug ][ 'version' ]; |
|
1758
|
1758
|
|
|
1759
|
1759
|
return version_compare( $minimum_version, $installed_version, '>' ); |
|
1760
|
1760
|
} |
|
@@ -1769,9 +1769,9 @@ discard block |
|
|
block discarded – undo |
|
1769
|
1769
|
*/ |
|
1770
|
1770
|
public function does_plugin_have_update( $slug ) { |
|
1771
|
1771
|
// Presume bundled and external plugins will point to a package which meets the minimum required version. |
|
1772
|
|
- if ( 'repo' !== $this->plugins[ $slug ]['source_type'] ) { |
|
|
1772
|
+ if ( 'repo' !== $this->plugins[ $slug ][ 'source_type' ] ) { |
|
1773
|
1773
|
if ( $this->does_plugin_require_update( $slug ) ) { |
|
1774
|
|
- return $this->plugins[ $slug ]['version']; |
|
|
1774
|
+ return $this->plugins[ $slug ][ 'version' ]; |
|
1775
|
1775
|
} |
|
1776
|
1776
|
|
|
1777
|
1777
|
return false; |
|
@@ -1779,8 +1779,8 @@ discard block |
|
|
block discarded – undo |
|
1779
|
1779
|
|
|
1780
|
1780
|
$repo_updates = get_site_transient( 'update_plugins' ); |
|
1781
|
1781
|
|
|
1782
|
|
- if ( isset( $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->new_version ) ) { |
|
1783
|
|
- return $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->new_version; |
|
|
1782
|
+ if ( isset( $repo_updates->response[ $this->plugins[ $slug ][ 'file_path' ] ]->new_version ) ) { |
|
|
1783
|
+ return $repo_updates->response[ $this->plugins[ $slug ][ 'file_path' ] ]->new_version; |
|
1784
|
1784
|
} |
|
1785
|
1785
|
|
|
1786
|
1786
|
return false; |
|
@@ -1796,14 +1796,14 @@ discard block |
|
|
block discarded – undo |
|
1796
|
1796
|
*/ |
|
1797
|
1797
|
public function get_upgrade_notice( $slug ) { |
|
1798
|
1798
|
// We currently can't get reliable info on non-WP-repo plugins - issue #380. |
|
1799
|
|
- if ( 'repo' !== $this->plugins[ $slug ]['source_type'] ) { |
|
|
1799
|
+ if ( 'repo' !== $this->plugins[ $slug ][ 'source_type' ] ) { |
|
1800
|
1800
|
return ''; |
|
1801
|
1801
|
} |
|
1802
|
1802
|
|
|
1803
|
1803
|
$repo_updates = get_site_transient( 'update_plugins' ); |
|
1804
|
1804
|
|
|
1805
|
|
- if ( ! empty( $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->upgrade_notice ) ) { |
|
1806
|
|
- return $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->upgrade_notice; |
|
|
1805
|
+ if ( ! empty( $repo_updates->response[ $this->plugins[ $slug ][ 'file_path' ] ]->upgrade_notice ) ) { |
|
|
1806
|
+ return $repo_updates->response[ $this->plugins[ $slug ][ 'file_path' ] ]->upgrade_notice; |
|
1807
|
1807
|
} |
|
1808
|
1808
|
|
|
1809
|
1809
|
return ''; |
|
@@ -1819,7 +1819,7 @@ discard block |
|
|
block discarded – undo |
|
1819
|
1819
|
*/ |
|
1820
|
1820
|
public function get_plugins( $plugin_folder = '' ) { |
|
1821
|
1821
|
if ( ! function_exists( 'get_plugins' ) ) { |
|
1822
|
|
- require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
|
1822
|
+ require_once ABSPATH.'wp-admin/includes/plugin.php'; |
|
1823
|
1823
|
} |
|
1824
|
1824
|
|
|
1825
|
1825
|
return get_plugins( $plugin_folder ); |
|
@@ -1834,7 +1834,7 @@ discard block |
|
|
block discarded – undo |
|
1834
|
1834
|
* @since 2.1.1 |
|
1835
|
1835
|
*/ |
|
1836
|
1836
|
public function update_dismiss() { |
|
1837
|
|
- delete_metadata( 'user', null, 'tgmpa_dismissed_notice_' . $this->id, null, true ); |
|
|
1837
|
+ delete_metadata( 'user', null, 'tgmpa_dismissed_notice_'.$this->id, null, true ); |
|
1838
|
1838
|
} |
|
1839
|
1839
|
|
|
1840
|
1840
|
/** |
|
@@ -1853,13 +1853,13 @@ discard block |
|
|
block discarded – undo |
|
1853
|
1853
|
*/ |
|
1854
|
1854
|
public function force_activation() { |
|
1855
|
1855
|
foreach ( $this->plugins as $slug => $plugin ) { |
|
1856
|
|
- if ( true === $plugin['force_activation'] ) { |
|
|
1856
|
+ if ( true === $plugin[ 'force_activation' ] ) { |
|
1857
|
1857
|
if ( ! $this->is_plugin_installed( $slug ) ) { |
|
1858
|
1858
|
// Oops, plugin isn't there so iterate to next condition. |
|
1859
|
1859
|
continue; |
|
1860
|
1860
|
} elseif ( $this->can_plugin_activate( $slug ) ) { |
|
1861
|
1861
|
// There we go, activate the plugin. |
|
1862
|
|
- activate_plugin( $plugin['file_path'] ); |
|
|
1862
|
+ activate_plugin( $plugin[ 'file_path' ] ); |
|
1863
|
1863
|
} |
|
1864
|
1864
|
} |
|
1865
|
1865
|
} |
|
@@ -1880,8 +1880,8 @@ discard block |
|
|
block discarded – undo |
|
1880
|
1880
|
public function force_deactivation() { |
|
1881
|
1881
|
foreach ( $this->plugins as $slug => $plugin ) { |
|
1882
|
1882
|
// Only proceed forward if the parameter is set to true and plugin is active. |
|
1883
|
|
- if ( true === $plugin['force_deactivation'] && $this->is_plugin_active( $slug ) ) { |
|
1884
|
|
- deactivate_plugins( $plugin['file_path'] ); |
|
|
1883
|
+ if ( true === $plugin[ 'force_deactivation' ] && $this->is_plugin_active( $slug ) ) { |
|
|
1884
|
+ deactivate_plugins( $plugin[ 'file_path' ] ); |
|
1885
|
1885
|
} |
|
1886
|
1886
|
} |
|
1887
|
1887
|
} |
|
@@ -1916,7 +1916,7 @@ discard block |
|
|
block discarded – undo |
|
1916
|
1916
|
* Ensure only one instance of the class is ever invoked. |
|
1917
|
1917
|
*/ |
|
1918
|
1918
|
function load_tgm_plugin_activation() { |
|
1919
|
|
- $GLOBALS['tgmpa'] = TGM_Plugin_Activation::get_instance(); |
|
|
1919
|
+ $GLOBALS[ 'tgmpa' ] = TGM_Plugin_Activation::get_instance(); |
|
1920
|
1920
|
} |
|
1921
|
1921
|
} |
|
1922
|
1922
|
|
|
@@ -1938,7 +1938,7 @@ discard block |
|
|
block discarded – undo |
|
1938
|
1938
|
* @param array $config Optional. An array of configuration values. |
|
1939
|
1939
|
*/ |
|
1940
|
1940
|
function tgmpa( $plugins, $config = array() ) { |
|
1941
|
|
- $instance = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) ); |
|
|
1941
|
+ $instance = call_user_func( array( get_class( $GLOBALS[ 'tgmpa' ] ), 'get_instance' ) ); |
|
1942
|
1942
|
|
|
1943
|
1943
|
foreach ( $plugins as $plugin ) { |
|
1944
|
1944
|
call_user_func( array( $instance, 'register' ), $plugin ); |
|
@@ -1946,17 +1946,17 @@ discard block |
|
|
block discarded – undo |
|
1946
|
1946
|
|
|
1947
|
1947
|
if ( ! empty( $config ) && is_array( $config ) ) { |
|
1948
|
1948
|
// Send out notices for deprecated arguments passed. |
|
1949
|
|
- if ( isset( $config['notices'] ) ) { |
|
|
1949
|
+ if ( isset( $config[ 'notices' ] ) ) { |
|
1950
|
1950
|
_deprecated_argument( __FUNCTION__, '2.2.0', 'The `notices` config parameter was renamed to `has_notices` in TGMPA 2.2.0. Please adjust your configuration.' ); |
|
1951
|
|
- if ( ! isset( $config['has_notices'] ) ) { |
|
1952
|
|
- $config['has_notices'] = $config['notices']; |
|
|
1951
|
+ if ( ! isset( $config[ 'has_notices' ] ) ) { |
|
|
1952
|
+ $config[ 'has_notices' ] = $config[ 'notices' ]; |
|
1953
|
1953
|
} |
|
1954
|
1954
|
} |
|
1955
|
1955
|
|
|
1956
|
|
- if ( isset( $config['parent_menu_slug'] ) ) { |
|
|
1956
|
+ if ( isset( $config[ 'parent_menu_slug' ] ) ) { |
|
1957
|
1957
|
_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.' ); |
|
1958
|
1958
|
} |
|
1959
|
|
- if ( isset( $config['parent_url_slug'] ) ) { |
|
|
1959
|
+ if ( isset( $config[ 'parent_url_slug' ] ) ) { |
|
1960
|
1960
|
_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.' ); |
|
1961
|
1961
|
} |
|
1962
|
1962
|
|
|
@@ -1972,7 +1972,7 @@ discard block |
|
|
block discarded – undo |
|
1972
|
1972
|
* @since 2.2.0 |
|
1973
|
1973
|
*/ |
|
1974
|
1974
|
if ( ! class_exists( 'WP_List_Table' ) ) { |
|
1975
|
|
- require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
|
1975
|
+ require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
1976
|
1976
|
} |
|
1977
|
1977
|
|
|
1978
|
1978
|
if ( ! class_exists( 'TGMPA_List_Table' ) ) { |
|
@@ -2033,7 +2033,7 @@ discard block |
|
|
block discarded – undo |
|
2033
|
2033
|
* @since 2.2.0 |
|
2034
|
2034
|
*/ |
|
2035
|
2035
|
public function __construct() { |
|
2036
|
|
- $this->tgmpa = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) ); |
|
|
2036
|
+ $this->tgmpa = call_user_func( array( get_class( $GLOBALS[ 'tgmpa' ] ), 'get_instance' ) ); |
|
2037
|
2037
|
|
|
2038
|
2038
|
parent::__construct( |
|
2039
|
2039
|
array( |
|
@@ -2043,8 +2043,8 @@ discard block |
|
|
block discarded – undo |
|
2043
|
2043
|
) |
|
2044
|
2044
|
); |
|
2045
|
2045
|
|
|
2046
|
|
- if ( isset( $_REQUEST['plugin_status'] ) && in_array( $_REQUEST['plugin_status'], array( 'install', 'update', 'activate' ), true ) ) { |
|
2047
|
|
- $this->view_context = sanitize_key( $_REQUEST['plugin_status'] ); |
|
|
2046
|
+ if ( isset( $_REQUEST[ 'plugin_status' ] ) && in_array( $_REQUEST[ 'plugin_status' ], array( 'install', 'update', 'activate' ), true ) ) { |
|
|
2047
|
+ $this->view_context = sanitize_key( $_REQUEST[ 'plugin_status' ] ); |
|
2048
|
2048
|
} |
|
2049
|
2049
|
|
|
2050
|
2050
|
add_filter( 'tgmpa_table_data_items', array( $this, 'sort_table_items' ) ); |
|
@@ -2091,20 +2091,20 @@ discard block |
|
|
block discarded – undo |
|
2091
|
2091
|
} |
|
2092
|
2092
|
|
|
2093
|
2093
|
foreach ( $plugins[ $this->view_context ] as $slug => $plugin ) { |
|
2094
|
|
- $table_data[ $i ]['sanitized_plugin'] = $plugin['name']; |
|
2095
|
|
- $table_data[ $i ]['slug'] = $slug; |
|
2096
|
|
- $table_data[ $i ]['plugin'] = '<strong>' . $this->tgmpa->get_info_link( $slug ) . '</strong>'; |
|
2097
|
|
- $table_data[ $i ]['source'] = $this->get_plugin_source_type_text( $plugin['source_type'] ); |
|
2098
|
|
- $table_data[ $i ]['type'] = $this->get_plugin_advise_type_text( $plugin['required'] ); |
|
2099
|
|
- $table_data[ $i ]['status'] = $this->get_plugin_status_text( $slug ); |
|
2100
|
|
- $table_data[ $i ]['installed_version'] = $this->tgmpa->get_installed_version( $slug ); |
|
2101
|
|
- $table_data[ $i ]['minimum_version'] = $plugin['version']; |
|
2102
|
|
- $table_data[ $i ]['available_version'] = $this->tgmpa->does_plugin_have_update( $slug ); |
|
|
2094
|
+ $table_data[ $i ][ 'sanitized_plugin' ] = $plugin[ 'name' ]; |
|
|
2095
|
+ $table_data[ $i ][ 'slug' ] = $slug; |
|
|
2096
|
+ $table_data[ $i ][ 'plugin' ] = '<strong>'.$this->tgmpa->get_info_link( $slug ).'</strong>'; |
|
|
2097
|
+ $table_data[ $i ][ 'source' ] = $this->get_plugin_source_type_text( $plugin[ 'source_type' ] ); |
|
|
2098
|
+ $table_data[ $i ][ 'type' ] = $this->get_plugin_advise_type_text( $plugin[ 'required' ] ); |
|
|
2099
|
+ $table_data[ $i ][ 'status' ] = $this->get_plugin_status_text( $slug ); |
|
|
2100
|
+ $table_data[ $i ][ 'installed_version' ] = $this->tgmpa->get_installed_version( $slug ); |
|
|
2101
|
+ $table_data[ $i ][ 'minimum_version' ] = $plugin[ 'version' ]; |
|
|
2102
|
+ $table_data[ $i ][ 'available_version' ] = $this->tgmpa->does_plugin_have_update( $slug ); |
|
2103
|
2103
|
|
|
2104
|
2104
|
// Prep the upgrade notice info. |
|
2105
|
2105
|
$upgrade_notice = $this->tgmpa->get_upgrade_notice( $slug ); |
|
2106
|
2106
|
if ( ! empty( $upgrade_notice ) ) { |
|
2107
|
|
- $table_data[ $i ]['upgrade_notice'] = $upgrade_notice; |
|
|
2107
|
+ $table_data[ $i ][ 'upgrade_notice' ] = $upgrade_notice; |
|
2108
|
2108
|
|
|
2109
|
2109
|
add_action( "tgmpa_after_plugin_row_$slug", array( $this, 'wp_plugin_update_row' ), 10, 2 ); |
|
2110
|
2110
|
} |
|
@@ -2135,17 +2135,17 @@ discard block |
|
|
block discarded – undo |
|
2135
|
2135
|
// No need to display plugins if they are installed, up-to-date and active. |
|
2136
|
2136
|
continue; |
|
2137
|
2137
|
} else { |
|
2138
|
|
- $plugins['all'][ $slug ] = $plugin; |
|
|
2138
|
+ $plugins[ 'all' ][ $slug ] = $plugin; |
|
2139
|
2139
|
|
|
2140
|
2140
|
if ( ! $this->tgmpa->is_plugin_installed( $slug ) ) { |
|
2141
|
|
- $plugins['install'][ $slug ] = $plugin; |
|
|
2141
|
+ $plugins[ 'install' ][ $slug ] = $plugin; |
|
2142
|
2142
|
} else { |
|
2143
|
2143
|
if ( false !== $this->tgmpa->does_plugin_have_update( $slug ) ) { |
|
2144
|
|
- $plugins['update'][ $slug ] = $plugin; |
|
|
2144
|
+ $plugins[ 'update' ][ $slug ] = $plugin; |
|
2145
|
2145
|
} |
|
2146
|
2146
|
|
|
2147
|
2147
|
if ( $this->tgmpa->can_plugin_activate( $slug ) ) { |
|
2148
|
|
- $plugins['activate'][ $slug ] = $plugin; |
|
|
2148
|
+ $plugins[ 'activate' ][ $slug ] = $plugin; |
|
2149
|
2149
|
} |
|
2150
|
2150
|
} |
|
2151
|
2151
|
} |
|
@@ -2264,8 +2264,8 @@ discard block |
|
|
block discarded – undo |
|
2264
|
2264
|
$name = array(); |
|
2265
|
2265
|
|
|
2266
|
2266
|
foreach ( $items as $i => $plugin ) { |
|
2267
|
|
- $type[ $i ] = $plugin['type']; // Required / recommended. |
|
2268
|
|
- $name[ $i ] = $plugin['sanitized_plugin']; |
|
|
2267
|
+ $type[ $i ] = $plugin[ 'type' ]; // Required / recommended. |
|
|
2268
|
+ $name[ $i ] = $plugin[ 'sanitized_plugin' ]; |
|
2269
|
2269
|
} |
|
2270
|
2270
|
|
|
2271
|
2271
|
array_multisort( $type, SORT_DESC, $name, SORT_ASC, $items ); |
|
@@ -2347,9 +2347,9 @@ discard block |
|
|
block discarded – undo |
|
2347
|
2347
|
public function column_cb( $item ) { |
|
2348
|
2348
|
return sprintf( |
|
2349
|
2349
|
'<input type="checkbox" name="%1$s[]" value="%2$s" id="%3$s" />', |
|
2350
|
|
- esc_attr( $this->_args['singular'] ), |
|
2351
|
|
- esc_attr( $item['slug'] ), |
|
2352
|
|
- esc_attr( $item['sanitized_plugin'] ) |
|
|
2350
|
+ esc_attr( $this->_args[ 'singular' ] ), |
|
|
2351
|
+ esc_attr( $item[ 'slug' ] ), |
|
|
2352
|
+ esc_attr( $item[ 'sanitized_plugin' ] ) |
|
2353
|
2353
|
); |
|
2354
|
2354
|
} |
|
2355
|
2355
|
|
|
@@ -2364,7 +2364,7 @@ discard block |
|
|
block discarded – undo |
|
2364
|
2364
|
public function column_plugin( $item ) { |
|
2365
|
2365
|
return sprintf( |
|
2366
|
2366
|
'%1$s %2$s', |
|
2367
|
|
- $item['plugin'], |
|
|
2367
|
+ $item[ 'plugin' ], |
|
2368
|
2368
|
$this->row_actions( $this->get_row_actions( $item ), true ) |
|
2369
|
2369
|
); |
|
2370
|
2370
|
} |
|
@@ -2380,38 +2380,38 @@ discard block |
|
|
block discarded – undo |
|
2380
|
2380
|
public function column_version( $item ) { |
|
2381
|
2381
|
$output = array(); |
|
2382
|
2382
|
|
|
2383
|
|
- if ( $this->tgmpa->is_plugin_installed( $item['slug'] ) ) { |
|
2384
|
|
- $installed = ! empty( $item['installed_version'] ) ? $item['installed_version'] : _x( 'unknown', 'as in: "version nr unknown"', 'tgmpa' ); |
|
|
2383
|
+ if ( $this->tgmpa->is_plugin_installed( $item[ 'slug' ] ) ) { |
|
|
2384
|
+ $installed = ! empty( $item[ 'installed_version' ] ) ? $item[ 'installed_version' ] : _x( 'unknown', 'as in: "version nr unknown"', 'tgmpa' ); |
|
2385
|
2385
|
|
|
2386
|
2386
|
$color = ''; |
|
2387
|
|
- if ( ! empty( $item['minimum_version'] ) && $this->tgmpa->does_plugin_require_update( $item['slug'] ) ) { |
|
|
2387
|
+ if ( ! empty( $item[ 'minimum_version' ] ) && $this->tgmpa->does_plugin_require_update( $item[ 'slug' ] ) ) { |
|
2388
|
2388
|
$color = ' color: #ff0000; font-weight: bold;'; |
|
2389
|
2389
|
} |
|
2390
|
2390
|
|
|
2391
|
|
- $output[] = sprintf( |
|
2392
|
|
- '<p><span style="min-width: 32px; text-align: right; float: right;%1$s">%2$s</span>' . __( 'Installed version:', 'tgmpa' ) . '</p>', |
|
|
2391
|
+ $output[ ] = sprintf( |
|
|
2392
|
+ '<p><span style="min-width: 32px; text-align: right; float: right;%1$s">%2$s</span>'.__( 'Installed version:', 'tgmpa' ).'</p>', |
|
2393
|
2393
|
$color, |
|
2394
|
2394
|
$installed |
|
2395
|
2395
|
); |
|
2396
|
2396
|
} |
|
2397
|
2397
|
|
|
2398
|
|
- if ( ! empty( $item['minimum_version'] ) ) { |
|
2399
|
|
- $output[] = sprintf( |
|
2400
|
|
- '<p><span style="min-width: 32px; text-align: right; float: right;">%1$s</span>' . __( 'Minimum required version:', 'tgmpa' ) . '</p>', |
|
2401
|
|
- $item['minimum_version'] |
|
|
2398
|
+ if ( ! empty( $item[ 'minimum_version' ] ) ) { |
|
|
2399
|
+ $output[ ] = sprintf( |
|
|
2400
|
+ '<p><span style="min-width: 32px; text-align: right; float: right;">%1$s</span>'.__( 'Minimum required version:', 'tgmpa' ).'</p>', |
|
|
2401
|
+ $item[ 'minimum_version' ] |
|
2402
|
2402
|
); |
|
2403
|
2403
|
} |
|
2404
|
2404
|
|
|
2405
|
|
- if ( ! empty( $item['available_version'] ) ) { |
|
|
2405
|
+ if ( ! empty( $item[ 'available_version' ] ) ) { |
|
2406
|
2406
|
$color = ''; |
|
2407
|
|
- if ( ! empty( $item['minimum_version'] ) && version_compare( $item['available_version'], $item['minimum_version'], '>=' ) ) { |
|
|
2407
|
+ if ( ! empty( $item[ 'minimum_version' ] ) && version_compare( $item[ 'available_version' ], $item[ 'minimum_version' ], '>=' ) ) { |
|
2408
|
2408
|
$color = ' color: #71C671; font-weight: bold;'; |
|
2409
|
2409
|
} |
|
2410
|
2410
|
|
|
2411
|
|
- $output[] = sprintf( |
|
2412
|
|
- '<p><span style="min-width: 32px; text-align: right; float: right;%1$s">%2$s</span>' . __( 'Available version:', 'tgmpa' ) . '</p>', |
|
|
2411
|
+ $output[ ] = sprintf( |
|
|
2412
|
+ '<p><span style="min-width: 32px; text-align: right; float: right;%1$s">%2$s</span>'.__( 'Available version:', 'tgmpa' ).'</p>', |
|
2413
|
2413
|
$color, |
|
2414
|
|
- $item['available_version'] |
|
|
2414
|
+ $item[ 'available_version' ] |
|
2415
|
2415
|
); |
|
2416
|
2416
|
} |
|
2417
|
2417
|
|
|
@@ -2452,8 +2452,8 @@ discard block |
|
|
block discarded – undo |
|
2452
|
2452
|
); |
|
2453
|
2453
|
|
|
2454
|
2454
|
if ( 'all' === $this->view_context || 'update' === $this->view_context ) { |
|
2455
|
|
- $columns['version'] = __( 'Version', 'tgmpa' ); |
|
2456
|
|
- $columns['status'] = __( 'Status', 'tgmpa' ); |
|
|
2455
|
+ $columns[ 'version' ] = __( 'Version', 'tgmpa' ); |
|
|
2456
|
+ $columns[ 'status' ] = __( 'Status', 'tgmpa' ); |
|
2457
|
2457
|
} |
|
2458
|
2458
|
|
|
2459
|
2459
|
return apply_filters( 'tgmpa_table_columns', $columns ); |
|
@@ -2500,17 +2500,17 @@ discard block |
|
|
block discarded – undo |
|
2500
|
2500
|
$action_links = array(); |
|
2501
|
2501
|
|
|
2502
|
2502
|
// Display the 'Install' action link if the plugin is not yet available. |
|
2503
|
|
- if ( ! $this->tgmpa->is_plugin_installed( $item['slug'] ) ) { |
|
2504
|
|
- $actions['install'] = _x( 'Install %2$s', '%2$s = plugin name in screen reader markup', 'tgmpa' ); |
|
|
2503
|
+ if ( ! $this->tgmpa->is_plugin_installed( $item[ 'slug' ] ) ) { |
|
|
2504
|
+ $actions[ 'install' ] = _x( 'Install %2$s', '%2$s = plugin name in screen reader markup', 'tgmpa' ); |
|
2505
|
2505
|
} else { |
|
2506
|
2506
|
// Display the 'Update' action link if an update is available and WP complies with plugin minimum. |
|
2507
|
|
- if ( false !== $this->tgmpa->does_plugin_have_update( $item['slug'] ) && $this->tgmpa->can_plugin_update( $item['slug'] ) ) { |
|
2508
|
|
- $actions['update'] = _x( 'Update %2$s', '%2$s = plugin name in screen reader markup', 'tgmpa' ); |
|
|
2507
|
+ if ( false !== $this->tgmpa->does_plugin_have_update( $item[ 'slug' ] ) && $this->tgmpa->can_plugin_update( $item[ 'slug' ] ) ) { |
|
|
2508
|
+ $actions[ 'update' ] = _x( 'Update %2$s', '%2$s = plugin name in screen reader markup', 'tgmpa' ); |
|
2509
|
2509
|
} |
|
2510
|
2510
|
|
|
2511
|
2511
|
// Display the 'Activate' action link, but only if the plugin meets the minimum version. |
|
2512
|
|
- if ( $this->tgmpa->can_plugin_activate( $item['slug'] ) ) { |
|
2513
|
|
- $actions['activate'] = _x( 'Activate %2$s', '%2$s = plugin name in screen reader markup', 'tgmpa' ); |
|
|
2512
|
+ if ( $this->tgmpa->can_plugin_activate( $item[ 'slug' ] ) ) { |
|
|
2513
|
+ $actions[ 'activate' ] = _x( 'Activate %2$s', '%2$s = plugin name in screen reader markup', 'tgmpa' ); |
|
2514
|
2514
|
} |
|
2515
|
2515
|
} |
|
2516
|
2516
|
|
|
@@ -2519,24 +2519,24 @@ discard block |
|
|
block discarded – undo |
|
2519
|
2519
|
$nonce_url = wp_nonce_url( |
|
2520
|
2520
|
add_query_arg( |
|
2521
|
2521
|
array( |
|
2522
|
|
- 'plugin' => urlencode( $item['slug'] ), |
|
2523
|
|
- 'tgmpa-' . $action => $action . '-plugin', |
|
|
2522
|
+ 'plugin' => urlencode( $item[ 'slug' ] ), |
|
|
2523
|
+ 'tgmpa-'.$action => $action.'-plugin', |
|
2524
|
2524
|
), |
|
2525
|
2525
|
$this->tgmpa->get_tgmpa_url() |
|
2526
|
2526
|
), |
|
2527
|
|
- 'tgmpa-' . $action, |
|
|
2527
|
+ 'tgmpa-'.$action, |
|
2528
|
2528
|
'tgmpa-nonce' |
|
2529
|
2529
|
); |
|
2530
|
2530
|
|
|
2531
|
2531
|
$action_links[ $action ] = sprintf( |
|
2532
|
|
- '<a href="%1$s">' . esc_html( $text ) . '</a>', |
|
|
2532
|
+ '<a href="%1$s">'.esc_html( $text ).'</a>', |
|
2533
|
2533
|
esc_url( $nonce_url ), |
|
2534
|
|
- '<span class="screen-reader-text">' . esc_html( $item['sanitized_plugin'] ) . '</span>' |
|
|
2534
|
+ '<span class="screen-reader-text">'.esc_html( $item[ 'sanitized_plugin' ] ).'</span>' |
|
2535
|
2535
|
); |
|
2536
|
2536
|
} |
|
2537
|
2537
|
|
|
2538
|
2538
|
$prefix = ( defined( 'WP_NETWORK_ADMIN' ) && WP_NETWORK_ADMIN ) ? 'network_admin_' : ''; |
|
2539
|
|
- return apply_filters( "tgmpa_{$prefix}plugin_action_links", array_filter( $action_links ), $item['slug'], $item, $this->view_context ); |
|
|
2539
|
+ return apply_filters( "tgmpa_{$prefix}plugin_action_links", array_filter( $action_links ), $item[ 'slug' ], $item, $this->view_context ); |
|
2540
|
2540
|
} |
|
2541
|
2541
|
|
|
2542
|
2542
|
/** |
|
@@ -2557,7 +2557,7 @@ discard block |
|
|
block discarded – undo |
|
2557
|
2557
|
* |
|
2558
|
2558
|
* @since 2.5.0 |
|
2559
|
2559
|
*/ |
|
2560
|
|
- do_action( "tgmpa_after_plugin_row_{$item['slug']}", $item['slug'], $item, $this->view_context ); |
|
|
2560
|
+ do_action( "tgmpa_after_plugin_row_{$item[ 'slug' ]}", $item[ 'slug' ], $item, $this->view_context ); |
|
2561
|
2561
|
} |
|
2562
|
2562
|
|
|
2563
|
2563
|
/** |
|
@@ -2572,7 +2572,7 @@ discard block |
|
|
block discarded – undo |
|
2572
|
2572
|
* @return null Return early if upgrade notice is empty. |
|
2573
|
2573
|
*/ |
|
2574
|
2574
|
public function wp_plugin_update_row( $slug, $item ) { |
|
2575
|
|
- if ( empty( $item['upgrade_notice'] ) ) { |
|
|
2575
|
+ if ( empty( $item[ 'upgrade_notice' ] ) ) { |
|
2576
|
2576
|
return; |
|
2577
|
2577
|
} |
|
2578
|
2578
|
|
|
@@ -2581,7 +2581,7 @@ discard block |
|
|
block discarded – undo |
|
2581
|
2581
|
<td colspan="', absint( $this->get_column_count() ), '" class="plugin-update colspanchange"> |
|
2582
|
2582
|
<div class="update-message">', |
|
2583
|
2583
|
esc_html__( 'Upgrade message from the plugin author:', 'tgmpa' ), |
|
2584
|
|
- ' <strong>', wp_kses_data( $item['upgrade_notice'] ), '</strong> |
|
|
2584
|
+ ' <strong>', wp_kses_data( $item[ 'upgrade_notice' ] ), '</strong> |
|
2585
|
2585
|
</div> |
|
2586
|
2586
|
</td> |
|
2587
|
2587
|
</tr>'; |
|
@@ -2613,16 +2613,16 @@ discard block |
|
|
block discarded – undo |
|
2613
|
2613
|
|
|
2614
|
2614
|
if ( 'update' !== $this->view_context && 'activate' !== $this->view_context ) { |
|
2615
|
2615
|
if ( current_user_can( 'install_plugins' ) ) { |
|
2616
|
|
- $actions['tgmpa-bulk-install'] = __( 'Install', 'tgmpa' ); |
|
|
2616
|
+ $actions[ 'tgmpa-bulk-install' ] = __( 'Install', 'tgmpa' ); |
|
2617
|
2617
|
} |
|
2618
|
2618
|
} |
|
2619
|
2619
|
|
|
2620
|
2620
|
if ( 'install' !== $this->view_context ) { |
|
2621
|
2621
|
if ( current_user_can( 'update_plugins' ) ) { |
|
2622
|
|
- $actions['tgmpa-bulk-update'] = __( 'Update', 'tgmpa' ); |
|
|
2622
|
+ $actions[ 'tgmpa-bulk-update' ] = __( 'Update', 'tgmpa' ); |
|
2623
|
2623
|
} |
|
2624
|
2624
|
if ( current_user_can( 'activate_plugins' ) ) { |
|
2625
|
|
- $actions['tgmpa-bulk-activate'] = __( 'Activate', 'tgmpa' ); |
|
|
2625
|
+ $actions[ 'tgmpa-bulk-activate' ] = __( 'Activate', 'tgmpa' ); |
|
2626
|
2626
|
} |
|
2627
|
2627
|
} |
|
2628
|
2628
|
|
|
@@ -2641,7 +2641,7 @@ discard block |
|
|
block discarded – undo |
|
2641
|
2641
|
// Bulk installation process. |
|
2642
|
2642
|
if ( 'tgmpa-bulk-install' === $this->current_action() || 'tgmpa-bulk-update' === $this->current_action() ) { |
|
2643
|
2643
|
|
|
2644
|
|
- check_admin_referer( 'bulk-' . $this->_args['plural'] ); |
|
|
2644
|
+ check_admin_referer( 'bulk-'.$this->_args[ 'plural' ] ); |
|
2645
|
2645
|
|
|
2646
|
2646
|
$install_type = 'install'; |
|
2647
|
2647
|
if ( 'tgmpa-bulk-update' === $this->current_action() ) { |
|
@@ -2651,7 +2651,7 @@ discard block |
|
|
block discarded – undo |
|
2651
|
2651
|
$plugins_to_install = array(); |
|
2652
|
2652
|
|
|
2653
|
2653
|
// Did user actually select any plugins to install/update ? |
|
2654
|
|
- if ( empty( $_POST['plugin'] ) ) { |
|
|
2654
|
+ if ( empty( $_POST[ 'plugin' ] ) ) { |
|
2655
|
2655
|
if ( 'install' === $install_type ) { |
|
2656
|
2656
|
$message = __( 'No plugins were selected to be installed. No action taken.', 'tgmpa' ); |
|
2657
|
2657
|
} else { |
|
@@ -2663,11 +2663,11 @@ discard block |
|
|
block discarded – undo |
|
2663
|
2663
|
return false; |
|
2664
|
2664
|
} |
|
2665
|
2665
|
|
|
2666
|
|
- if ( is_array( $_POST['plugin'] ) ) { |
|
2667
|
|
- $plugins_to_install = (array) $_POST['plugin']; |
|
2668
|
|
- } elseif ( is_string( $_POST['plugin'] ) ) { |
|
|
2666
|
+ if ( is_array( $_POST[ 'plugin' ] ) ) { |
|
|
2667
|
+ $plugins_to_install = (array) $_POST[ 'plugin' ]; |
|
|
2668
|
+ } elseif ( is_string( $_POST[ 'plugin' ] ) ) { |
|
2669
|
2669
|
// Received via Filesystem page - un-flatten array (WP bug #19643). |
|
2670
|
|
- $plugins_to_install = explode( ',', $_POST['plugin'] ); |
|
|
2670
|
+ $plugins_to_install = explode( ',', $_POST[ 'plugin' ] ); |
|
2671
|
2671
|
} |
|
2672
|
2672
|
|
|
2673
|
2673
|
// Sanitize the received input. |
|
@@ -2709,11 +2709,11 @@ discard block |
|
|
block discarded – undo |
|
2709
|
2709
|
// Pass all necessary information if WP_Filesystem is needed. |
|
2710
|
2710
|
$url = wp_nonce_url( |
|
2711
|
2711
|
$this->tgmpa->get_tgmpa_url(), |
|
2712
|
|
- 'bulk-' . $this->_args['plural'] |
|
|
2712
|
+ 'bulk-'.$this->_args[ 'plural' ] |
|
2713
|
2713
|
); |
|
2714
|
2714
|
|
|
2715
|
2715
|
// Give validated data back to $_POST which is the only place the filesystem looks for extra fields. |
|
2716
|
|
- $_POST['plugin'] = implode( ',', $plugins_to_install ); // Work around for WP bug #19643. |
|
|
2716
|
+ $_POST[ 'plugin' ] = implode( ',', $plugins_to_install ); // Work around for WP bug #19643. |
|
2717
|
2717
|
|
|
2718
|
2718
|
$method = ''; // Leave blank so WP_Filesystem can populate it as necessary. |
|
2719
|
2719
|
$fields = array_keys( $_POST ); // Extra fields to pass to WP_Filesystem. |
|
@@ -2740,22 +2740,22 @@ discard block |
|
|
block discarded – undo |
|
2740
|
2740
|
|
|
2741
|
2741
|
// Prepare the data for validated plugins for the install/upgrade. |
|
2742
|
2742
|
foreach ( $plugins_to_install as $slug ) { |
|
2743
|
|
- $name = $this->tgmpa->plugins[ $slug ]['name']; |
|
|
2743
|
+ $name = $this->tgmpa->plugins[ $slug ][ 'name' ]; |
|
2744
|
2744
|
$source = $this->tgmpa->get_download_url( $slug ); |
|
2745
|
2745
|
|
|
2746
|
2746
|
if ( ! empty( $name ) && ! empty( $source ) ) { |
|
2747
|
|
- $names[] = $name; |
|
|
2747
|
+ $names[ ] = $name; |
|
2748
|
2748
|
|
|
2749
|
2749
|
switch ( $install_type ) { |
|
2750
|
2750
|
|
|
2751
|
2751
|
case 'install': |
|
2752
|
|
- $sources[] = $source; |
|
|
2752
|
+ $sources[ ] = $source; |
|
2753
|
2753
|
break; |
|
2754
|
2754
|
|
|
2755
|
2755
|
case 'update': |
|
2756
|
|
- $file_paths[] = $this->tgmpa->plugins[ $slug ]['file_path']; |
|
|
2756
|
+ $file_paths[ ] = $this->tgmpa->plugins[ $slug ][ 'file_path' ]; |
|
2757
|
2757
|
$to_inject[ $slug ] = $this->tgmpa->plugins[ $slug ]; |
|
2758
|
|
- $to_inject[ $slug ]['source'] = $source; |
|
|
2758
|
+ $to_inject[ $slug ][ 'source' ] = $source; |
|
2759
|
2759
|
break; |
|
2760
|
2760
|
} |
|
2761
|
2761
|
} |
|
@@ -2767,7 +2767,7 @@ discard block |
|
|
block discarded – undo |
|
2767
|
2767
|
new TGMPA_Bulk_Installer_Skin( |
|
2768
|
2768
|
array( |
|
2769
|
2769
|
'url' => esc_url_raw( $this->tgmpa->get_tgmpa_url() ), |
|
2770
|
|
- 'nonce' => 'bulk-' . $this->_args['plural'], |
|
|
2770
|
+ 'nonce' => 'bulk-'.$this->_args[ 'plural' ], |
|
2771
|
2771
|
'names' => $names, |
|
2772
|
2772
|
'install_type' => $install_type, |
|
2773
|
2773
|
) |
|
@@ -2799,10 +2799,10 @@ discard block |
|
|
block discarded – undo |
|
2799
|
2799
|
|
|
2800
|
2800
|
// Bulk activation process. |
|
2801
|
2801
|
if ( 'tgmpa-bulk-activate' === $this->current_action() ) { |
|
2802
|
|
- check_admin_referer( 'bulk-' . $this->_args['plural'] ); |
|
|
2802
|
+ check_admin_referer( 'bulk-'.$this->_args[ 'plural' ] ); |
|
2803
|
2803
|
|
|
2804
|
2804
|
// Did user actually select any plugins to activate ? |
|
2805
|
|
- if ( empty( $_POST['plugin'] ) ) { |
|
|
2805
|
+ if ( empty( $_POST[ 'plugin' ] ) ) { |
|
2806
|
2806
|
echo '<div id="message" class="error"><p>', esc_html__( 'No plugins were selected to be activated. No action taken.', 'tgmpa' ), '</p></div>'; |
|
2807
|
2807
|
|
|
2808
|
2808
|
return false; |
|
@@ -2810,8 +2810,8 @@ discard block |
|
|
block discarded – undo |
|
2810
|
2810
|
|
|
2811
|
2811
|
// Grab plugin data from $_POST. |
|
2812
|
2812
|
$plugins = array(); |
|
2813
|
|
- if ( isset( $_POST['plugin'] ) ) { |
|
2814
|
|
- $plugins = array_map( 'urldecode', (array) $_POST['plugin'] ); |
|
|
2813
|
+ if ( isset( $_POST[ 'plugin' ] ) ) { |
|
|
2814
|
+ $plugins = array_map( 'urldecode', (array) $_POST[ 'plugin' ] ); |
|
2815
|
2815
|
$plugins = array_map( array( $this->tgmpa, 'sanitize_key' ), $plugins ); |
|
2816
|
2816
|
} |
|
2817
|
2817
|
|
|
@@ -2821,8 +2821,8 @@ discard block |
|
|
block discarded – undo |
|
2821
|
2821
|
// Grab the file paths for the selected & inactive plugins from the registration array. |
|
2822
|
2822
|
foreach ( $plugins as $slug ) { |
|
2823
|
2823
|
if ( $this->tgmpa->can_plugin_activate( $slug ) ) { |
|
2824
|
|
- $plugins_to_activate[] = $this->tgmpa->plugins[ $slug ]['file_path']; |
|
2825
|
|
- $plugin_names[] = $this->tgmpa->plugins[ $slug ]['name']; |
|
|
2824
|
+ $plugins_to_activate[ ] = $this->tgmpa->plugins[ $slug ][ 'file_path' ]; |
|
|
2825
|
+ $plugin_names[ ] = $this->tgmpa->plugins[ $slug ][ 'name' ]; |
|
2826
|
2826
|
} |
|
2827
|
2827
|
} |
|
2828
|
2828
|
unset( $slug ); |
|
@@ -2843,7 +2843,7 @@ discard block |
|
|
block discarded – undo |
|
2843
|
2843
|
$count = count( $plugin_names ); // Count so we can use _n function. |
|
2844
|
2844
|
$plugin_names = array_map( array( 'TGMPA_Utils', 'wrap_in_strong' ), $plugin_names ); |
|
2845
|
2845
|
$last_plugin = array_pop( $plugin_names ); // Pop off last name to prep for readability. |
|
2846
|
|
- $imploded = empty( $plugin_names ) ? $last_plugin : ( implode( ', ', $plugin_names ) . ' ' . esc_html_x( 'and', 'plugin A *and* plugin B', 'tgmpa' ) . ' ' . $last_plugin ); |
|
|
2846
|
+ $imploded = empty( $plugin_names ) ? $last_plugin : ( implode( ', ', $plugin_names ).' '.esc_html_x( 'and', 'plugin A *and* plugin B', 'tgmpa' ).' '.$last_plugin ); |
|
2847
|
2847
|
|
|
2848
|
2848
|
printf( // WPCS: xss ok. |
|
2849
|
2849
|
'<div id="message" class="updated"><p>%1$s %2$s.</p></div>', |
|
@@ -2946,16 +2946,16 @@ discard block |
|
|
block discarded – undo |
|
2946
|
2946
|
*/ |
|
2947
|
2947
|
function tgmpa_load_bulk_installer() { |
|
2948
|
2948
|
// Silently fail if 2.5+ is loaded *after* an older version. |
|
2949
|
|
- if ( ! isset( $GLOBALS['tgmpa'] ) ) { |
|
|
2949
|
+ if ( ! isset( $GLOBALS[ 'tgmpa' ] ) ) { |
|
2950
|
2950
|
return; |
|
2951
|
2951
|
} |
|
2952
|
2952
|
|
|
2953
|
2953
|
// Get TGMPA class instance. |
|
2954
|
|
- $tgmpa_instance = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) ); |
|
|
2954
|
+ $tgmpa_instance = call_user_func( array( get_class( $GLOBALS[ 'tgmpa' ] ), 'get_instance' ) ); |
|
2955
|
2955
|
|
|
2956
|
|
- if ( isset( $_GET['page'] ) && $tgmpa_instance->menu === $_GET['page'] ) { |
|
|
2956
|
+ if ( isset( $_GET[ 'page' ] ) && $tgmpa_instance->menu === $_GET[ 'page' ] ) { |
|
2957
|
2957
|
if ( ! class_exists( 'Plugin_Upgrader', false ) ) { |
|
2958
|
|
- require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
|
|
2958
|
+ require_once ABSPATH.'wp-admin/includes/class-wp-upgrader.php'; |
|
2959
|
2959
|
} |
|
2960
|
2960
|
|
|
2961
|
2961
|
if ( ! class_exists( 'TGMPA_Bulk_Installer' ) ) { |
|
@@ -3022,11 +3022,11 @@ discard block |
|
|
block discarded – undo |
|
3022
|
3022
|
*/ |
|
3023
|
3023
|
public function __construct( $skin = null ) { |
|
3024
|
3024
|
// Get TGMPA class instance. |
|
3025
|
|
- $this->tgmpa = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) ); |
|
|
3025
|
+ $this->tgmpa = call_user_func( array( get_class( $GLOBALS[ 'tgmpa' ] ), 'get_instance' ) ); |
|
3026
|
3026
|
|
|
3027
|
3027
|
parent::__construct( $skin ); |
|
3028
|
3028
|
|
|
3029
|
|
- if ( isset( $this->skin->options['install_type'] ) && 'update' === $this->skin->options['install_type'] ) { |
|
|
3029
|
+ if ( isset( $this->skin->options[ 'install_type' ] ) && 'update' === $this->skin->options[ 'install_type' ] ) { |
|
3030
|
3030
|
$this->clear_destination = true; |
|
3031
|
3031
|
} |
|
3032
|
3032
|
|
|
@@ -3043,8 +3043,8 @@ discard block |
|
|
block discarded – undo |
|
3043
|
3043
|
* @since 2.2.0 |
|
3044
|
3044
|
*/ |
|
3045
|
3045
|
public function activate_strings() { |
|
3046
|
|
- $this->strings['activation_failed'] = __( 'Plugin activation failed.', 'tgmpa' ); |
|
3047
|
|
- $this->strings['activation_success'] = __( 'Plugin activated successfully.', 'tgmpa' ); |
|
|
3046
|
+ $this->strings[ 'activation_failed' ] = __( 'Plugin activation failed.', 'tgmpa' ); |
|
|
3047
|
+ $this->strings[ 'activation_success' ] = __( 'Plugin activated successfully.', 'tgmpa' ); |
|
3048
|
3048
|
} |
|
3049
|
3049
|
|
|
3050
|
3050
|
/** |
|
@@ -3062,7 +3062,7 @@ discard block |
|
|
block discarded – undo |
|
3062
|
3062
|
|
|
3063
|
3063
|
// Reset the strings in case we changed one during automatic activation. |
|
3064
|
3064
|
if ( $this->tgmpa->is_automatic ) { |
|
3065
|
|
- if ( 'update' === $this->skin->options['install_type'] ) { |
|
|
3065
|
+ if ( 'update' === $this->skin->options[ 'install_type' ] ) { |
|
3066
|
3066
|
$this->upgrade_strings(); |
|
3067
|
3067
|
} else { |
|
3068
|
3068
|
$this->install_strings(); |
|
@@ -3217,7 +3217,7 @@ discard block |
|
|
block discarded – undo |
|
3217
|
3217
|
remove_filter( 'upgrader_post_install', array( $this, 'auto_activate' ), 10 ); |
|
3218
|
3218
|
|
|
3219
|
3219
|
// Force refresh of plugin update information. |
|
3220
|
|
- wp_clean_plugins_cache( $parsed_args['clear_update_cache'] ); |
|
|
3220
|
+ wp_clean_plugins_cache( $parsed_args[ 'clear_update_cache' ] ); |
|
3221
|
3221
|
|
|
3222
|
3222
|
return $results; |
|
3223
|
3223
|
} |
|
@@ -3268,13 +3268,13 @@ discard block |
|
|
block discarded – undo |
|
3268
|
3268
|
$activate = activate_plugin( $plugin_info ); |
|
3269
|
3269
|
|
|
3270
|
3270
|
// Adjust the success string based on the activation result. |
|
3271
|
|
- $this->strings['process_success'] = $this->strings['process_success'] . "<br />\n"; |
|
|
3271
|
+ $this->strings[ 'process_success' ] = $this->strings[ 'process_success' ]."<br />\n"; |
|
3272
|
3272
|
|
|
3273
|
3273
|
if ( is_wp_error( $activate ) ) { |
|
3274
|
3274
|
$this->skin->error( $activate ); |
|
3275
|
|
- $this->strings['process_success'] .= $this->strings['activation_failed']; |
|
|
3275
|
+ $this->strings[ 'process_success' ] .= $this->strings[ 'activation_failed' ]; |
|
3276
|
3276
|
} else { |
|
3277
|
|
- $this->strings['process_success'] .= $this->strings['activation_success']; |
|
|
3277
|
+ $this->strings[ 'process_success' ] .= $this->strings[ 'activation_success' ]; |
|
3278
|
3278
|
} |
|
3279
|
3279
|
} |
|
3280
|
3280
|
} |
|
@@ -3350,7 +3350,7 @@ discard block |
|
|
block discarded – undo |
|
3350
|
3350
|
*/ |
|
3351
|
3351
|
public function __construct( $args = array() ) { |
|
3352
|
3352
|
// Get TGMPA class instance. |
|
3353
|
|
- $this->tgmpa = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) ); |
|
|
3353
|
+ $this->tgmpa = call_user_func( array( get_class( $GLOBALS[ 'tgmpa' ] ), 'get_instance' ) ); |
|
3354
|
3354
|
|
|
3355
|
3355
|
// Parse default and new args. |
|
3356
|
3356
|
$defaults = array( |
|
@@ -3359,10 +3359,10 @@ discard block |
|
|
block discarded – undo |
|
3359
|
3359
|
'names' => array(), |
|
3360
|
3360
|
'install_type' => 'install', |
|
3361
|
3361
|
); |
|
3362
|
|
- $args = wp_parse_args( $args, $defaults ); |
|
|
3362
|
+ $args = wp_parse_args( $args, $defaults ); |
|
3363
|
3363
|
|
|
3364
|
3364
|
// Set plugin names to $this->plugin_names property. |
|
3365
|
|
- $this->plugin_names = $args['names']; |
|
|
3365
|
+ $this->plugin_names = $args[ 'names' ]; |
|
3366
|
3366
|
|
|
3367
|
3367
|
// Extract the new args. |
|
3368
|
3368
|
parent::__construct( $args ); |
|
@@ -3377,25 +3377,25 @@ discard block |
|
|
block discarded – undo |
|
3377
|
3377
|
* @since 2.2.0 |
|
3378
|
3378
|
*/ |
|
3379
|
3379
|
public function add_strings() { |
|
3380
|
|
- if ( 'update' === $this->options['install_type'] ) { |
|
|
3380
|
+ if ( 'update' === $this->options[ 'install_type' ] ) { |
|
3381
|
3381
|
parent::add_strings(); |
|
3382
|
|
- $this->upgrader->strings['skin_before_update_header'] = __( 'Updating Plugin %1$s (%2$d/%3$d)', 'tgmpa' ); |
|
|
3382
|
+ $this->upgrader->strings[ 'skin_before_update_header' ] = __( 'Updating Plugin %1$s (%2$d/%3$d)', 'tgmpa' ); |
|
3383
|
3383
|
} else { |
|
3384
|
|
- $this->upgrader->strings['skin_update_failed_error'] = __( 'An error occurred while installing %1$s: <strong>%2$s</strong>.', 'tgmpa' ); |
|
3385
|
|
- $this->upgrader->strings['skin_update_failed'] = __( 'The installation of %1$s failed.', 'tgmpa' ); |
|
|
3384
|
+ $this->upgrader->strings[ 'skin_update_failed_error' ] = __( 'An error occurred while installing %1$s: <strong>%2$s</strong>.', 'tgmpa' ); |
|
|
3385
|
+ $this->upgrader->strings[ 'skin_update_failed' ] = __( 'The installation of %1$s failed.', 'tgmpa' ); |
|
3386
|
3386
|
|
|
3387
|
3387
|
if ( $this->tgmpa->is_automatic ) { |
|
3388
|
3388
|
// Automatic activation strings. |
|
3389
|
|
- $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' ); |
|
3390
|
|
- $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>'; |
|
3391
|
|
- $this->upgrader->strings['skin_upgrade_end'] = __( 'All installations and activations have been completed.', 'tgmpa' ); |
|
3392
|
|
- $this->upgrader->strings['skin_before_update_header'] = __( 'Installing and Activating Plugin %1$s (%2$d/%3$d)', 'tgmpa' ); |
|
|
3389
|
+ $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' ); |
|
|
3390
|
+ $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>'; |
|
|
3391
|
+ $this->upgrader->strings[ 'skin_upgrade_end' ] = __( 'All installations and activations have been completed.', 'tgmpa' ); |
|
|
3392
|
+ $this->upgrader->strings[ 'skin_before_update_header' ] = __( 'Installing and Activating Plugin %1$s (%2$d/%3$d)', 'tgmpa' ); |
|
3393
|
3393
|
} else { |
|
3394
|
3394
|
// Default installation strings. |
|
3395
|
|
- $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' ); |
|
3396
|
|
- $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>'; |
|
3397
|
|
- $this->upgrader->strings['skin_upgrade_end'] = __( 'All installations have been completed.', 'tgmpa' ); |
|
3398
|
|
- $this->upgrader->strings['skin_before_update_header'] = __( 'Installing Plugin %1$s (%2$d/%3$d)', 'tgmpa' ); |
|
|
3395
|
+ $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' ); |
|
|
3396
|
+ $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>'; |
|
|
3397
|
+ $this->upgrader->strings[ 'skin_upgrade_end' ] = __( 'All installations have been completed.', 'tgmpa' ); |
|
|
3398
|
+ $this->upgrader->strings[ 'skin_before_update_header' ] = __( 'Installing Plugin %1$s (%2$d/%3$d)', 'tgmpa' ); |
|
3399
|
3399
|
} |
|
3400
|
3400
|
} |
|
3401
|
3401
|
} |
|
@@ -3453,12 +3453,12 @@ discard block |
|
|
block discarded – undo |
|
3453
|
3453
|
if ( $this->tgmpa->is_tgmpa_complete() ) { |
|
3454
|
3454
|
// All plugins are active, so we display the complete string and hide the menu to protect users. |
|
3455
|
3455
|
echo '<style type="text/css">#adminmenu .wp-submenu li.current { display: none !important; }</style>'; |
|
3456
|
|
- $update_actions['dashboard'] = sprintf( |
|
3457
|
|
- esc_html( $this->tgmpa->strings['complete'] ), |
|
3458
|
|
- '<a href="' . esc_url( self_admin_url() ) . '">' . esc_html__( 'Return to the Dashboard', 'tgmpa' ) . '</a>' |
|
|
3456
|
+ $update_actions[ 'dashboard' ] = sprintf( |
|
|
3457
|
+ esc_html( $this->tgmpa->strings[ 'complete' ] ), |
|
|
3458
|
+ '<a href="'.esc_url( self_admin_url() ).'">'.esc_html__( 'Return to the Dashboard', 'tgmpa' ).'</a>' |
|
3459
|
3459
|
); |
|
3460
|
3460
|
} else { |
|
3461
|
|
- $update_actions['tgmpa_page'] = '<a href="' . esc_url( $this->tgmpa->get_tgmpa_url() ) . '" target="_parent">' . esc_html( $this->tgmpa->strings['return'] ) . '</a>'; |
|
|
3461
|
+ $update_actions[ 'tgmpa_page' ] = '<a href="'.esc_url( $this->tgmpa->get_tgmpa_url() ).'" target="_parent">'.esc_html( $this->tgmpa->strings[ 'return' ] ).'</a>'; |
|
3462
|
3462
|
} |
|
3463
|
3463
|
|
|
3464
|
3464
|
/** |
|
@@ -3548,7 +3548,7 @@ discard block |
|
|
block discarded – undo |
|
3548
|
3548
|
* @return string |
|
3549
|
3549
|
*/ |
|
3550
|
3550
|
public static function wrap_in_em( $string ) { |
|
3551
|
|
- return '<em>' . wp_kses_post( $string ) . '</em>'; |
|
|
3551
|
+ return '<em>'.wp_kses_post( $string ).'</em>'; |
|
3552
|
3552
|
} |
|
3553
|
3553
|
|
|
3554
|
3554
|
/** |
|
@@ -3562,7 +3562,7 @@ discard block |
|
|
block discarded – undo |
|
3562
|
3562
|
* @return string |
|
3563
|
3563
|
*/ |
|
3564
|
3564
|
public static function wrap_in_strong( $string ) { |
|
3565
|
|
- return '<strong>' . wp_kses_post( $string ) . '</strong>'; |
|
|
3565
|
+ return '<strong>'.wp_kses_post( $string ).'</strong>'; |
|
3566
|
3566
|
} |
|
3567
|
3567
|
|
|
3568
|
3568
|
/** |
|
@@ -3599,7 +3599,7 @@ discard block |
|
|
block discarded – undo |
|
3599
|
3599
|
*/ |
|
3600
|
3600
|
protected static function emulate_filter_bool( $value ) { |
|
3601
|
3601
|
// @codingStandardsIgnoreStart |
|
3602
|
|
- static $true = array( |
|
|
3602
|
+ static $true = array( |
|
3603
|
3603
|
'1', |
|
3604
|
3604
|
'true', 'True', 'TRUE', |
|
3605
|
3605
|
'y', 'Y', |