@@ -121,16 +121,16 @@ |
||
| 121 | 121 | * Only uncomment the strings in the config array if you want to customize the strings. |
| 122 | 122 | */ |
| 123 | 123 | $config = array( |
| 124 | - 'id' => 'tgmpa', // Unique ID for hashing notices for multiple instances of TGMPA. |
|
| 125 | - 'default_path' => '', // Default absolute path to bundled plugins. |
|
| 124 | + 'id' => 'tgmpa', // Unique ID for hashing notices for multiple instances of TGMPA. |
|
| 125 | + 'default_path' => '', // Default absolute path to bundled plugins. |
|
| 126 | 126 | 'menu' => 'tgmpa-install-plugins', // Menu slug. |
| 127 | - 'parent_slug' => 'themes.php', // Parent menu slug. |
|
| 128 | - 'capability' => 'edit_theme_options', // Capability needed to view plugin install page, should be a capability associated with the parent menu used. |
|
| 129 | - 'has_notices' => true, // Show admin notices or not. |
|
| 130 | - 'dismissable' => true, // If false, a user cannot dismiss the nag message. |
|
| 131 | - 'dismiss_msg' => '', // If 'dismissable' is false, this message will be output at top of nag. |
|
| 132 | - 'is_automatic' => false, // Automatically activate plugins after installation or not. |
|
| 133 | - 'message' => '', // Message to output right before the plugins table. |
|
| 127 | + 'parent_slug' => 'themes.php', // Parent menu slug. |
|
| 128 | + 'capability' => 'edit_theme_options', // Capability needed to view plugin install page, should be a capability associated with the parent menu used. |
|
| 129 | + 'has_notices' => true, // Show admin notices or not. |
|
| 130 | + 'dismissable' => true, // If false, a user cannot dismiss the nag message. |
|
| 131 | + 'dismiss_msg' => '', // If 'dismissable' is false, this message will be output at top of nag. |
|
| 132 | + 'is_automatic' => false, // Automatically activate plugins after installation or not. |
|
| 133 | + 'message' => '', // Message to output right before the plugins table. |
|
| 134 | 134 | |
| 135 | 135 | /* |
| 136 | 136 | 'strings' => array( |
@@ -949,7 +949,8 @@ discard block |
||
| 949 | 949 | if ( ! $automatic ) { |
| 950 | 950 | // Make sure message doesn't display again if bulk activation is performed |
| 951 | 951 | // immediately after a single activation. |
| 952 | - if ( ! isset( $_POST['action'] ) ) { // WPCS: CSRF OK. |
|
| 952 | + if ( ! isset( $_POST['action'] ) ) { |
|
| 953 | +// WPCS: CSRF OK. |
|
| 953 | 954 | echo '<div id="message" class="updated"><p>', esc_html( $this->strings['activated_successfully'] ), ' <strong>', esc_html( $this->plugins[ $slug ]['name'] ), '.</strong></p></div>'; |
| 954 | 955 | } |
| 955 | 956 | } else { |
@@ -970,7 +971,8 @@ discard block |
||
| 970 | 971 | if ( ! $automatic ) { |
| 971 | 972 | // Make sure message doesn't display again if bulk activation is performed |
| 972 | 973 | // immediately after a single activation. |
| 973 | - if ( ! isset( $_POST['action'] ) ) { // WPCS: CSRF OK. |
|
| 974 | + if ( ! isset( $_POST['action'] ) ) { |
|
| 975 | +// WPCS: CSRF OK. |
|
| 974 | 976 | echo '<div id="message" class="error"><p>', |
| 975 | 977 | sprintf( |
| 976 | 978 | esc_html( $this->strings['plugin_needs_higher_version'] ), |
@@ -1621,10 +1623,12 @@ discard block |
||
| 1621 | 1623 | if ( 'update-core' === $screen->base ) { |
| 1622 | 1624 | // Core update screen. |
| 1623 | 1625 | return true; |
| 1624 | - } elseif ( 'plugins' === $screen->base && ! empty( $_POST['action'] ) ) { // WPCS: CSRF ok. |
|
| 1626 | + } elseif ( 'plugins' === $screen->base && ! empty( $_POST['action'] ) ) { |
|
| 1627 | +// WPCS: CSRF ok. |
|
| 1625 | 1628 | // Plugins bulk update screen. |
| 1626 | 1629 | return true; |
| 1627 | - } elseif ( 'update' === $screen->base && ! empty( $_POST['action'] ) ) { // WPCS: CSRF ok. |
|
| 1630 | + } elseif ( 'update' === $screen->base && ! empty( $_POST['action'] ) ) { |
|
| 1631 | +// WPCS: CSRF ok. |
|
| 1628 | 1632 | // Individual updates (ajax call). |
| 1629 | 1633 | return true; |
| 1630 | 1634 | } |
@@ -2107,7 +2107,7 @@ |
||
| 2107 | 2107 | * |
| 2108 | 2108 | * @since 2.4.0 |
| 2109 | 2109 | * |
| 2110 | - * @return \TGM_Plugin_Activation The TGM_Plugin_Activation object. |
|
| 2110 | + * @return TGM_Plugin_Activation The TGM_Plugin_Activation object. |
|
| 2111 | 2111 | */ |
| 2112 | 2112 | public static function get_instance() { |
| 2113 | 2113 | if ( ! isset( self::$instance ) && ! ( self::$instance instanceof self ) ) { |
@@ -667,11 +667,11 @@ discard block |
||
| 667 | 667 | $args = apply_filters( |
| 668 | 668 | 'tgmpa_admin_menu_args', |
| 669 | 669 | array( |
| 670 | - 'parent_slug' => $this->parent_slug, // Parent Menu slug. |
|
| 671 | - 'page_title' => $this->strings['page_title'], // Page title. |
|
| 672 | - 'menu_title' => $this->strings['menu_title'], // Menu title. |
|
| 673 | - 'capability' => $this->capability, // Capability. |
|
| 674 | - 'menu_slug' => $this->menu, // Menu slug. |
|
| 670 | + 'parent_slug' => $this->parent_slug, // Parent Menu slug. |
|
| 671 | + 'page_title' => $this->strings['page_title'], // Page title. |
|
| 672 | + 'menu_title' => $this->strings['menu_title'], // Menu title. |
|
| 673 | + 'capability' => $this->capability, // Capability. |
|
| 674 | + 'menu_slug' => $this->menu, // Menu slug. |
|
| 675 | 675 | 'function' => array( $this, 'install_plugins_page' ), // Callback. |
| 676 | 676 | ) |
| 677 | 677 | ); |
@@ -784,7 +784,7 @@ discard block |
||
| 784 | 784 | // All plugin information will be stored in an array for processing. |
| 785 | 785 | $slug = $this->sanitize_key( urldecode( $_GET['plugin'] ) ); |
| 786 | 786 | |
| 787 | - if ( ! isset( $this->plugins[ $slug ] ) ) { |
|
| 787 | + if ( ! isset( $this->plugins[$slug] ) ) { |
|
| 788 | 788 | return false; |
| 789 | 789 | } |
| 790 | 790 | |
@@ -829,7 +829,7 @@ discard block |
||
| 829 | 829 | $extra = array(); |
| 830 | 830 | $extra['slug'] = $slug; // Needed for potentially renaming of directory name. |
| 831 | 831 | $source = $this->get_download_url( $slug ); |
| 832 | - $api = ( 'repo' === $this->plugins[ $slug ]['source_type'] ) ? $this->get_plugins_api( $slug ) : null; |
|
| 832 | + $api = ( 'repo' === $this->plugins[$slug]['source_type'] ) ? $this->get_plugins_api( $slug ) : null; |
|
| 833 | 833 | $api = ( false !== $api ) ? $api : null; |
| 834 | 834 | |
| 835 | 835 | $url = add_query_arg( |
@@ -846,8 +846,8 @@ discard block |
||
| 846 | 846 | |
| 847 | 847 | $title = ( 'update' === $install_type ) ? $this->strings['updating'] : $this->strings['installing']; |
| 848 | 848 | $skin_args = array( |
| 849 | - 'type' => ( 'bundled' !== $this->plugins[ $slug ]['source_type'] ) ? 'web' : 'upload', |
|
| 850 | - 'title' => sprintf( $title, $this->plugins[ $slug ]['name'] ), |
|
| 849 | + 'type' => ( 'bundled' !== $this->plugins[$slug]['source_type'] ) ? 'web' : 'upload', |
|
| 850 | + 'title' => sprintf( $title, $this->plugins[$slug]['name'] ), |
|
| 851 | 851 | 'url' => esc_url_raw( $url ), |
| 852 | 852 | 'nonce' => $install_type . '-plugin_' . $slug, |
| 853 | 853 | 'plugin' => '', |
@@ -857,7 +857,7 @@ discard block |
||
| 857 | 857 | unset( $title ); |
| 858 | 858 | |
| 859 | 859 | if ( 'update' === $install_type ) { |
| 860 | - $skin_args['plugin'] = $this->plugins[ $slug ]['file_path']; |
|
| 860 | + $skin_args['plugin'] = $this->plugins[$slug]['file_path']; |
|
| 861 | 861 | $skin = new Plugin_Upgrader_Skin( $skin_args ); |
| 862 | 862 | } else { |
| 863 | 863 | $skin = new Plugin_Installer_Skin( $skin_args ); |
@@ -872,12 +872,12 @@ discard block |
||
| 872 | 872 | if ( 'update' === $install_type ) { |
| 873 | 873 | // Inject our info into the update transient. |
| 874 | 874 | $to_inject = array( |
| 875 | - $slug => $this->plugins[ $slug ], |
|
| 875 | + $slug => $this->plugins[$slug], |
|
| 876 | 876 | ); |
| 877 | - $to_inject[ $slug ]['source'] = $source; |
|
| 877 | + $to_inject[$slug]['source'] = $source; |
|
| 878 | 878 | $this->inject_update_info( $to_inject ); |
| 879 | 879 | |
| 880 | - $upgrader->upgrade( $this->plugins[ $slug ]['file_path'] ); |
|
| 880 | + $upgrader->upgrade( $this->plugins[$slug]['file_path'] ); |
|
| 881 | 881 | } else { |
| 882 | 882 | $upgrader->install( $source ); |
| 883 | 883 | } |
@@ -907,11 +907,11 @@ discard block |
||
| 907 | 907 | } |
| 908 | 908 | |
| 909 | 909 | return true; |
| 910 | - } elseif ( isset( $this->plugins[ $slug ]['file_path'], $_GET['tgmpa-activate'] ) && 'activate-plugin' === $_GET['tgmpa-activate'] ) { |
|
| 910 | + } elseif ( isset( $this->plugins[$slug]['file_path'], $_GET['tgmpa-activate'] ) && 'activate-plugin' === $_GET['tgmpa-activate'] ) { |
|
| 911 | 911 | // Activate action link was clicked. |
| 912 | 912 | check_admin_referer( 'tgmpa-activate', 'tgmpa-nonce' ); |
| 913 | 913 | |
| 914 | - if ( false === $this->activate_single_plugin( $this->plugins[ $slug ]['file_path'], $slug ) ) { |
|
| 914 | + if ( false === $this->activate_single_plugin( $this->plugins[$slug]['file_path'], $slug ) ) { |
|
| 915 | 915 | return true; // Finish execution of the function early as we encountered an error. |
| 916 | 916 | } |
| 917 | 917 | } |
@@ -936,17 +936,17 @@ discard block |
||
| 936 | 936 | foreach ( $plugins as $slug => $plugin ) { |
| 937 | 937 | $file_path = $plugin['file_path']; |
| 938 | 938 | |
| 939 | - if ( empty( $repo_updates->response[ $file_path ] ) ) { |
|
| 940 | - $repo_updates->response[ $file_path ] = new stdClass(); |
|
| 939 | + if ( empty( $repo_updates->response[$file_path] ) ) { |
|
| 940 | + $repo_updates->response[$file_path] = new stdClass(); |
|
| 941 | 941 | } |
| 942 | 942 | |
| 943 | 943 | // We only really need to set package, but let's do all we can in case WP changes something. |
| 944 | - $repo_updates->response[ $file_path ]->slug = $slug; |
|
| 945 | - $repo_updates->response[ $file_path ]->plugin = $file_path; |
|
| 946 | - $repo_updates->response[ $file_path ]->new_version = $plugin['version']; |
|
| 947 | - $repo_updates->response[ $file_path ]->package = $plugin['source']; |
|
| 948 | - if ( empty( $repo_updates->response[ $file_path ]->url ) && ! empty( $plugin['external_url'] ) ) { |
|
| 949 | - $repo_updates->response[ $file_path ]->url = $plugin['external_url']; |
|
| 944 | + $repo_updates->response[$file_path]->slug = $slug; |
|
| 945 | + $repo_updates->response[$file_path]->plugin = $file_path; |
|
| 946 | + $repo_updates->response[$file_path]->new_version = $plugin['version']; |
|
| 947 | + $repo_updates->response[$file_path]->package = $plugin['source']; |
|
| 948 | + if ( empty( $repo_updates->response[$file_path]->url ) && ! empty( $plugin['external_url'] ) ) { |
|
| 949 | + $repo_updates->response[$file_path]->url = $plugin['external_url']; |
|
| 950 | 950 | } |
| 951 | 951 | } |
| 952 | 952 | |
@@ -989,7 +989,7 @@ discard block |
||
| 989 | 989 | } else { |
| 990 | 990 | // Bulk installer contains less info, so fall back on the info registered here. |
| 991 | 991 | foreach ( $this->plugins as $slug => $plugin ) { |
| 992 | - if ( ! empty( $upgrader->skin->plugin_names[ $upgrader->skin->i ] ) && $plugin['name'] === $upgrader->skin->plugin_names[ $upgrader->skin->i ] ) { |
|
| 992 | + if ( ! empty( $upgrader->skin->plugin_names[$upgrader->skin->i] ) && $plugin['name'] === $upgrader->skin->plugin_names[$upgrader->skin->i] ) { |
|
| 993 | 993 | $desired_slug = $slug; |
| 994 | 994 | break; |
| 995 | 995 | } |
@@ -1056,7 +1056,7 @@ discard block |
||
| 1056 | 1056 | // Make sure message doesn't display again if bulk activation is performed |
| 1057 | 1057 | // immediately after a single activation. |
| 1058 | 1058 | if ( ! isset( $_POST['action'] ) ) { // WPCS: CSRF OK. |
| 1059 | - echo '<div id="message" class="updated"><p>', esc_html( $this->strings['activated_successfully'] ), ' <strong>', esc_html( $this->plugins[ $slug ]['name'] ), '.</strong></p></div>'; |
|
| 1059 | + echo '<div id="message" class="updated"><p>', esc_html( $this->strings['activated_successfully'] ), ' <strong>', esc_html( $this->plugins[$slug]['name'] ), '.</strong></p></div>'; |
|
| 1060 | 1060 | } |
| 1061 | 1061 | } else { |
| 1062 | 1062 | // Simpler message layout for use on the plugin install page. |
@@ -1069,7 +1069,7 @@ discard block |
||
| 1069 | 1069 | echo '<div id="message" class="error"><p>', |
| 1070 | 1070 | sprintf( |
| 1071 | 1071 | esc_html( $this->strings['plugin_already_active'] ), |
| 1072 | - '<strong>' . esc_html( $this->plugins[ $slug ]['name'] ) . '</strong>' |
|
| 1072 | + '<strong>' . esc_html( $this->plugins[$slug]['name'] ) . '</strong>' |
|
| 1073 | 1073 | ), |
| 1074 | 1074 | '</p></div>'; |
| 1075 | 1075 | } elseif ( $this->does_plugin_require_update( $slug ) ) { |
@@ -1080,13 +1080,13 @@ discard block |
||
| 1080 | 1080 | echo '<div id="message" class="error"><p>', |
| 1081 | 1081 | sprintf( |
| 1082 | 1082 | esc_html( $this->strings['plugin_needs_higher_version'] ), |
| 1083 | - '<strong>' . esc_html( $this->plugins[ $slug ]['name'] ) . '</strong>' |
|
| 1083 | + '<strong>' . esc_html( $this->plugins[$slug]['name'] ) . '</strong>' |
|
| 1084 | 1084 | ), |
| 1085 | 1085 | '</p></div>'; |
| 1086 | 1086 | } |
| 1087 | 1087 | } else { |
| 1088 | 1088 | // Simpler message layout for use on the plugin install page. |
| 1089 | - echo '<p>', sprintf( esc_html( $this->strings['plugin_needs_higher_version'] ), esc_html( $this->plugins[ $slug ]['name'] ) ), '</p>'; |
|
| 1089 | + echo '<p>', sprintf( esc_html( $this->strings['plugin_needs_higher_version'] ), esc_html( $this->plugins[$slug]['name'] ) ), '</p>'; |
|
| 1090 | 1090 | } |
| 1091 | 1091 | } |
| 1092 | 1092 | |
@@ -1213,7 +1213,7 @@ discard block |
||
| 1213 | 1213 | $rendered .= sprintf( |
| 1214 | 1214 | $line_template, |
| 1215 | 1215 | sprintf( |
| 1216 | - translate_nooped_plural( $this->strings[ $type ], $count, 'tgmpa' ), |
|
| 1216 | + translate_nooped_plural( $this->strings[$type], $count, 'tgmpa' ), |
|
| 1217 | 1217 | $imploded, |
| 1218 | 1218 | $count |
| 1219 | 1219 | ) |
@@ -1330,7 +1330,7 @@ discard block |
||
| 1330 | 1330 | |
| 1331 | 1331 | foreach ( (array) $wp_settings_errors as $key => $details ) { |
| 1332 | 1332 | if ( 'tgmpa' === $details['setting'] ) { |
| 1333 | - unset( $wp_settings_errors[ $key ] ); |
|
| 1333 | + unset( $wp_settings_errors[$key] ); |
|
| 1334 | 1334 | break; |
| 1335 | 1335 | } |
| 1336 | 1336 | } |
@@ -1366,20 +1366,20 @@ discard block |
||
| 1366 | 1366 | return; |
| 1367 | 1367 | } |
| 1368 | 1368 | |
| 1369 | - if ( empty( $plugin['slug'] ) || ! is_string( $plugin['slug'] ) || isset( $this->plugins[ $plugin['slug'] ] ) ) { |
|
| 1369 | + if ( empty( $plugin['slug'] ) || ! is_string( $plugin['slug'] ) || isset( $this->plugins[$plugin['slug']] ) ) { |
|
| 1370 | 1370 | return; |
| 1371 | 1371 | } |
| 1372 | 1372 | |
| 1373 | 1373 | $defaults = array( |
| 1374 | - 'name' => '', // String |
|
| 1375 | - 'slug' => '', // String |
|
| 1376 | - 'source' => 'repo', // String |
|
| 1377 | - 'required' => false, // Boolean |
|
| 1378 | - 'version' => '', // String |
|
| 1379 | - 'force_activation' => false, // Boolean |
|
| 1380 | - 'force_deactivation' => false, // Boolean |
|
| 1381 | - 'external_url' => '', // String |
|
| 1382 | - 'is_callable' => '', // String|Array. |
|
| 1374 | + 'name' => '', // String |
|
| 1375 | + 'slug' => '', // String |
|
| 1376 | + 'source' => 'repo', // String |
|
| 1377 | + 'required' => false, // Boolean |
|
| 1378 | + 'version' => '', // String |
|
| 1379 | + 'force_activation' => false, // Boolean |
|
| 1380 | + 'force_deactivation' => false, // Boolean |
|
| 1381 | + 'external_url' => '', // String |
|
| 1382 | + 'is_callable' => '', // String|Array. |
|
| 1383 | 1383 | ); |
| 1384 | 1384 | |
| 1385 | 1385 | // Prepare the received data. |
@@ -1400,8 +1400,8 @@ discard block |
||
| 1400 | 1400 | $plugin['source_type'] = $this->get_plugin_source_type( $plugin['source'] ); |
| 1401 | 1401 | |
| 1402 | 1402 | // Set the class properties. |
| 1403 | - $this->plugins[ $plugin['slug'] ] = $plugin; |
|
| 1404 | - $this->sort_order[ $plugin['slug'] ] = $plugin['name']; |
|
| 1403 | + $this->plugins[$plugin['slug']] = $plugin; |
|
| 1404 | + $this->sort_order[$plugin['slug']] = $plugin['name']; |
|
| 1405 | 1405 | |
| 1406 | 1406 | // Should we add the force activation hook ? |
| 1407 | 1407 | if ( true === $plugin['force_activation'] ) { |
@@ -1485,11 +1485,11 @@ discard block |
||
| 1485 | 1485 | ); |
| 1486 | 1486 | |
| 1487 | 1487 | foreach ( $keys as $key ) { |
| 1488 | - if ( isset( $config[ $key ] ) ) { |
|
| 1489 | - if ( is_array( $config[ $key ] ) ) { |
|
| 1490 | - $this->$key = array_merge( $this->$key, $config[ $key ] ); |
|
| 1488 | + if ( isset( $config[$key] ) ) { |
|
| 1489 | + if ( is_array( $config[$key] ) ) { |
|
| 1490 | + $this->$key = array_merge( $this->$key, $config[$key] ); |
|
| 1491 | 1491 | } else { |
| 1492 | - $this->$key = $config[ $key ]; |
|
| 1492 | + $this->$key = $config[$key]; |
|
| 1493 | 1493 | } |
| 1494 | 1494 | } |
| 1495 | 1495 | } |
@@ -1534,12 +1534,12 @@ discard block |
||
| 1534 | 1534 | * Parameter added in v2.5.0. |
| 1535 | 1535 | */ |
| 1536 | 1536 | public function populate_file_path( $plugin_slug = '' ) { |
| 1537 | - if ( ! empty( $plugin_slug ) && is_string( $plugin_slug ) && isset( $this->plugins[ $plugin_slug ] ) ) { |
|
| 1538 | - $this->plugins[ $plugin_slug ]['file_path'] = $this->_get_plugin_basename_from_slug( $plugin_slug ); |
|
| 1537 | + if ( ! empty( $plugin_slug ) && is_string( $plugin_slug ) && isset( $this->plugins[$plugin_slug] ) ) { |
|
| 1538 | + $this->plugins[$plugin_slug]['file_path'] = $this->_get_plugin_basename_from_slug( $plugin_slug ); |
|
| 1539 | 1539 | } else { |
| 1540 | 1540 | // Add file_path key for all plugins. |
| 1541 | 1541 | foreach ( $this->plugins as $slug => $values ) { |
| 1542 | - $this->plugins[ $slug ]['file_path'] = $this->_get_plugin_basename_from_slug( $slug ); |
|
| 1542 | + $this->plugins[$slug]['file_path'] = $this->_get_plugin_basename_from_slug( $slug ); |
|
| 1543 | 1543 | } |
| 1544 | 1544 | } |
| 1545 | 1545 | } |
@@ -1579,8 +1579,8 @@ discard block |
||
| 1579 | 1579 | */ |
| 1580 | 1580 | public function _get_plugin_data_from_name( $name, $data = 'slug' ) { |
| 1581 | 1581 | foreach ( $this->plugins as $values ) { |
| 1582 | - if ( $name === $values['name'] && isset( $values[ $data ] ) ) { |
|
| 1583 | - return $values[ $data ]; |
|
| 1582 | + if ( $name === $values['name'] && isset( $values[$data] ) ) { |
|
| 1583 | + return $values[$data]; |
|
| 1584 | 1584 | } |
| 1585 | 1585 | } |
| 1586 | 1586 | |
@@ -1598,13 +1598,13 @@ discard block |
||
| 1598 | 1598 | public function get_download_url( $slug ) { |
| 1599 | 1599 | $dl_source = ''; |
| 1600 | 1600 | |
| 1601 | - switch ( $this->plugins[ $slug ]['source_type'] ) { |
|
| 1601 | + switch ( $this->plugins[$slug]['source_type'] ) { |
|
| 1602 | 1602 | case 'repo': |
| 1603 | 1603 | return $this->get_wp_repo_download_url( $slug ); |
| 1604 | 1604 | case 'external': |
| 1605 | - return $this->plugins[ $slug ]['source']; |
|
| 1605 | + return $this->plugins[$slug]['source']; |
|
| 1606 | 1606 | case 'bundled': |
| 1607 | - return $this->default_path . $this->plugins[ $slug ]['source']; |
|
| 1607 | + return $this->default_path . $this->plugins[$slug]['source']; |
|
| 1608 | 1608 | } |
| 1609 | 1609 | |
| 1610 | 1610 | return $dl_source; // Should never happen. |
@@ -1640,7 +1640,7 @@ discard block |
||
| 1640 | 1640 | protected function get_plugins_api( $slug ) { |
| 1641 | 1641 | static $api = array(); // Cache received responses. |
| 1642 | 1642 | |
| 1643 | - if ( ! isset( $api[ $slug ] ) ) { |
|
| 1643 | + if ( ! isset( $api[$slug] ) ) { |
|
| 1644 | 1644 | if ( ! function_exists( 'plugins_api' ) ) { |
| 1645 | 1645 | require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; |
| 1646 | 1646 | } |
@@ -1655,16 +1655,16 @@ discard block |
||
| 1655 | 1655 | ) |
| 1656 | 1656 | ); |
| 1657 | 1657 | |
| 1658 | - $api[ $slug ] = false; |
|
| 1658 | + $api[$slug] = false; |
|
| 1659 | 1659 | |
| 1660 | 1660 | if ( is_wp_error( $response ) ) { |
| 1661 | 1661 | wp_die( esc_html( $this->strings['oops'] ) ); |
| 1662 | 1662 | } else { |
| 1663 | - $api[ $slug ] = $response; |
|
| 1663 | + $api[$slug] = $response; |
|
| 1664 | 1664 | } |
| 1665 | 1665 | } |
| 1666 | 1666 | |
| 1667 | - return $api[ $slug ]; |
|
| 1667 | + return $api[$slug]; |
|
| 1668 | 1668 | } |
| 1669 | 1669 | |
| 1670 | 1670 | /** |
@@ -1677,13 +1677,13 @@ discard block |
||
| 1677 | 1677 | * or the plugin name if not. |
| 1678 | 1678 | */ |
| 1679 | 1679 | public function get_info_link( $slug ) { |
| 1680 | - if ( ! empty( $this->plugins[ $slug ]['external_url'] ) && preg_match( self::IS_URL_REGEX, $this->plugins[ $slug ]['external_url'] ) ) { |
|
| 1680 | + if ( ! empty( $this->plugins[$slug]['external_url'] ) && preg_match( self::IS_URL_REGEX, $this->plugins[$slug]['external_url'] ) ) { |
|
| 1681 | 1681 | $link = sprintf( |
| 1682 | 1682 | '<a href="%1$s" target="_blank">%2$s</a>', |
| 1683 | - esc_url( $this->plugins[ $slug ]['external_url'] ), |
|
| 1684 | - esc_html( $this->plugins[ $slug ]['name'] ) |
|
| 1683 | + esc_url( $this->plugins[$slug]['external_url'] ), |
|
| 1684 | + esc_html( $this->plugins[$slug]['name'] ) |
|
| 1685 | 1685 | ); |
| 1686 | - } elseif ( 'repo' === $this->plugins[ $slug ]['source_type'] ) { |
|
| 1686 | + } elseif ( 'repo' === $this->plugins[$slug]['source_type'] ) { |
|
| 1687 | 1687 | $url = add_query_arg( |
| 1688 | 1688 | array( |
| 1689 | 1689 | 'tab' => 'plugin-information', |
@@ -1698,10 +1698,10 @@ discard block |
||
| 1698 | 1698 | $link = sprintf( |
| 1699 | 1699 | '<a href="%1$s" class="thickbox">%2$s</a>', |
| 1700 | 1700 | esc_url( $url ), |
| 1701 | - esc_html( $this->plugins[ $slug ]['name'] ) |
|
| 1701 | + esc_html( $this->plugins[$slug]['name'] ) |
|
| 1702 | 1702 | ); |
| 1703 | 1703 | } else { |
| 1704 | - $link = esc_html( $this->plugins[ $slug ]['name'] ); // No hyperlink. |
|
| 1704 | + $link = esc_html( $this->plugins[$slug]['name'] ); // No hyperlink. |
|
| 1705 | 1705 | } |
| 1706 | 1706 | |
| 1707 | 1707 | return $link; |
@@ -1826,7 +1826,7 @@ discard block |
||
| 1826 | 1826 | public function is_plugin_installed( $slug ) { |
| 1827 | 1827 | $installed_plugins = $this->get_plugins(); // Retrieve a list of all installed plugins (WP cached). |
| 1828 | 1828 | |
| 1829 | - return ( ! empty( $installed_plugins[ $this->plugins[ $slug ]['file_path'] ] ) ); |
|
| 1829 | + return ( ! empty( $installed_plugins[$this->plugins[$slug]['file_path']] ) ); |
|
| 1830 | 1830 | } |
| 1831 | 1831 | |
| 1832 | 1832 | /** |
@@ -1838,7 +1838,7 @@ discard block |
||
| 1838 | 1838 | * @return bool True if active, false otherwise. |
| 1839 | 1839 | */ |
| 1840 | 1840 | public function is_plugin_active( $slug ) { |
| 1841 | - return ( ( ! empty( $this->plugins[ $slug ]['is_callable'] ) && is_callable( $this->plugins[ $slug ]['is_callable'] ) ) || is_plugin_active( $this->plugins[ $slug ]['file_path'] ) ); |
|
| 1841 | + return ( ( ! empty( $this->plugins[$slug]['is_callable'] ) && is_callable( $this->plugins[$slug]['is_callable'] ) ) || is_plugin_active( $this->plugins[$slug]['file_path'] ) ); |
|
| 1842 | 1842 | } |
| 1843 | 1843 | |
| 1844 | 1844 | /** |
@@ -1852,7 +1852,7 @@ discard block |
||
| 1852 | 1852 | */ |
| 1853 | 1853 | public function can_plugin_update( $slug ) { |
| 1854 | 1854 | // We currently can't get reliable info on non-WP-repo plugins - issue #380. |
| 1855 | - if ( 'repo' !== $this->plugins[ $slug ]['source_type'] ) { |
|
| 1855 | + if ( 'repo' !== $this->plugins[$slug]['source_type'] ) { |
|
| 1856 | 1856 | return true; |
| 1857 | 1857 | } |
| 1858 | 1858 | |
@@ -1908,8 +1908,8 @@ discard block |
||
| 1908 | 1908 | public function get_installed_version( $slug ) { |
| 1909 | 1909 | $installed_plugins = $this->get_plugins(); // Retrieve a list of all installed plugins (WP cached). |
| 1910 | 1910 | |
| 1911 | - if ( ! empty( $installed_plugins[ $this->plugins[ $slug ]['file_path'] ]['Version'] ) ) { |
|
| 1912 | - return $installed_plugins[ $this->plugins[ $slug ]['file_path'] ]['Version']; |
|
| 1911 | + if ( ! empty( $installed_plugins[$this->plugins[$slug]['file_path']]['Version'] ) ) { |
|
| 1912 | + return $installed_plugins[$this->plugins[$slug]['file_path']]['Version']; |
|
| 1913 | 1913 | } |
| 1914 | 1914 | |
| 1915 | 1915 | return ''; |
@@ -1925,7 +1925,7 @@ discard block |
||
| 1925 | 1925 | */ |
| 1926 | 1926 | public function does_plugin_require_update( $slug ) { |
| 1927 | 1927 | $installed_version = $this->get_installed_version( $slug ); |
| 1928 | - $minimum_version = $this->plugins[ $slug ]['version']; |
|
| 1928 | + $minimum_version = $this->plugins[$slug]['version']; |
|
| 1929 | 1929 | |
| 1930 | 1930 | return version_compare( $minimum_version, $installed_version, '>' ); |
| 1931 | 1931 | } |
@@ -1940,9 +1940,9 @@ discard block |
||
| 1940 | 1940 | */ |
| 1941 | 1941 | public function does_plugin_have_update( $slug ) { |
| 1942 | 1942 | // Presume bundled and external plugins will point to a package which meets the minimum required version. |
| 1943 | - if ( 'repo' !== $this->plugins[ $slug ]['source_type'] ) { |
|
| 1943 | + if ( 'repo' !== $this->plugins[$slug]['source_type'] ) { |
|
| 1944 | 1944 | if ( $this->does_plugin_require_update( $slug ) ) { |
| 1945 | - return $this->plugins[ $slug ]['version']; |
|
| 1945 | + return $this->plugins[$slug]['version']; |
|
| 1946 | 1946 | } |
| 1947 | 1947 | |
| 1948 | 1948 | return false; |
@@ -1950,8 +1950,8 @@ discard block |
||
| 1950 | 1950 | |
| 1951 | 1951 | $repo_updates = get_site_transient( 'update_plugins' ); |
| 1952 | 1952 | |
| 1953 | - if ( isset( $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->new_version ) ) { |
|
| 1954 | - return $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->new_version; |
|
| 1953 | + if ( isset( $repo_updates->response[$this->plugins[$slug]['file_path']]->new_version ) ) { |
|
| 1954 | + return $repo_updates->response[$this->plugins[$slug]['file_path']]->new_version; |
|
| 1955 | 1955 | } |
| 1956 | 1956 | |
| 1957 | 1957 | return false; |
@@ -1967,14 +1967,14 @@ discard block |
||
| 1967 | 1967 | */ |
| 1968 | 1968 | public function get_upgrade_notice( $slug ) { |
| 1969 | 1969 | // We currently can't get reliable info on non-WP-repo plugins - issue #380. |
| 1970 | - if ( 'repo' !== $this->plugins[ $slug ]['source_type'] ) { |
|
| 1970 | + if ( 'repo' !== $this->plugins[$slug]['source_type'] ) { |
|
| 1971 | 1971 | return ''; |
| 1972 | 1972 | } |
| 1973 | 1973 | |
| 1974 | 1974 | $repo_updates = get_site_transient( 'update_plugins' ); |
| 1975 | 1975 | |
| 1976 | - if ( ! empty( $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->upgrade_notice ) ) { |
|
| 1977 | - return $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->upgrade_notice; |
|
| 1976 | + if ( ! empty( $repo_updates->response[$this->plugins[$slug]['file_path']]->upgrade_notice ) ) { |
|
| 1977 | + return $repo_updates->response[$this->plugins[$slug]['file_path']]->upgrade_notice; |
|
| 1978 | 1978 | } |
| 1979 | 1979 | |
| 1980 | 1980 | return ''; |
@@ -2058,7 +2058,7 @@ discard block |
||
| 2058 | 2058 | */ |
| 2059 | 2059 | if ( true === $plugin['force_deactivation'] && is_plugin_active( $plugin['file_path'] ) ) { |
| 2060 | 2060 | deactivate_plugins( $plugin['file_path'] ); |
| 2061 | - $deactivated[ $plugin['file_path'] ] = time(); |
|
| 2061 | + $deactivated[$plugin['file_path']] = time(); |
|
| 2062 | 2062 | } |
| 2063 | 2063 | } |
| 2064 | 2064 | |
@@ -2226,7 +2226,7 @@ |
||
| 2226 | 2226 | * |
| 2227 | 2227 | * @since 2.5.0 |
| 2228 | 2228 | * |
| 2229 | - * @return array CSS classnames. |
|
| 2229 | + * @return string[] CSS classnames. |
|
| 2230 | 2230 | */ |
| 2231 | 2231 | public function get_table_classes() { |
| 2232 | 2232 | return array( 'widefat', 'fixed' ); |
@@ -111,30 +111,30 @@ discard block |
||
| 111 | 111 | $i = 0; |
| 112 | 112 | |
| 113 | 113 | // Redirect to the 'all' view if no plugins were found for the selected view context. |
| 114 | - if ( empty( $plugins[ $this->view_context ] ) ) { |
|
| 114 | + if ( empty( $plugins[$this->view_context] ) ) { |
|
| 115 | 115 | $this->view_context = 'all'; |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - foreach ( $plugins[ $this->view_context ] as $slug => $plugin ) { |
|
| 119 | - $table_data[ $i ]['sanitized_plugin'] = $plugin['name']; |
|
| 120 | - $table_data[ $i ]['slug'] = $slug; |
|
| 121 | - $table_data[ $i ]['plugin'] = '<strong>' . $this->tgmpa->get_info_link( $slug ) . '</strong>'; |
|
| 122 | - $table_data[ $i ]['source'] = $this->get_plugin_source_type_text( $plugin['source_type'] ); |
|
| 123 | - $table_data[ $i ]['type'] = $this->get_plugin_advise_type_text( $plugin['required'] ); |
|
| 124 | - $table_data[ $i ]['status'] = $this->get_plugin_status_text( $slug ); |
|
| 125 | - $table_data[ $i ]['installed_version'] = $this->tgmpa->get_installed_version( $slug ); |
|
| 126 | - $table_data[ $i ]['minimum_version'] = $plugin['version']; |
|
| 127 | - $table_data[ $i ]['available_version'] = $this->tgmpa->does_plugin_have_update( $slug ); |
|
| 118 | + foreach ( $plugins[$this->view_context] as $slug => $plugin ) { |
|
| 119 | + $table_data[$i]['sanitized_plugin'] = $plugin['name']; |
|
| 120 | + $table_data[$i]['slug'] = $slug; |
|
| 121 | + $table_data[$i]['plugin'] = '<strong>' . $this->tgmpa->get_info_link( $slug ) . '</strong>'; |
|
| 122 | + $table_data[$i]['source'] = $this->get_plugin_source_type_text( $plugin['source_type'] ); |
|
| 123 | + $table_data[$i]['type'] = $this->get_plugin_advise_type_text( $plugin['required'] ); |
|
| 124 | + $table_data[$i]['status'] = $this->get_plugin_status_text( $slug ); |
|
| 125 | + $table_data[$i]['installed_version'] = $this->tgmpa->get_installed_version( $slug ); |
|
| 126 | + $table_data[$i]['minimum_version'] = $plugin['version']; |
|
| 127 | + $table_data[$i]['available_version'] = $this->tgmpa->does_plugin_have_update( $slug ); |
|
| 128 | 128 | |
| 129 | 129 | // Prep the upgrade notice info. |
| 130 | 130 | $upgrade_notice = $this->tgmpa->get_upgrade_notice( $slug ); |
| 131 | 131 | if ( ! empty( $upgrade_notice ) ) { |
| 132 | - $table_data[ $i ]['upgrade_notice'] = $upgrade_notice; |
|
| 132 | + $table_data[$i]['upgrade_notice'] = $upgrade_notice; |
|
| 133 | 133 | |
| 134 | 134 | add_action( "tgmpa_after_plugin_row_{$slug}", array( $this, 'wp_plugin_update_row' ), 10, 2 ); |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - $table_data[ $i ] = apply_filters( 'tgmpa_table_data_item', $table_data[ $i ], $plugin ); |
|
| 137 | + $table_data[$i] = apply_filters( 'tgmpa_table_data_item', $table_data[$i], $plugin ); |
|
| 138 | 138 | |
| 139 | 139 | $i++; |
| 140 | 140 | } |
@@ -160,17 +160,17 @@ discard block |
||
| 160 | 160 | // No need to display plugins if they are installed, up-to-date and active. |
| 161 | 161 | continue; |
| 162 | 162 | } else { |
| 163 | - $plugins['all'][ $slug ] = $plugin; |
|
| 163 | + $plugins['all'][$slug] = $plugin; |
|
| 164 | 164 | |
| 165 | 165 | if ( ! $this->tgmpa->is_plugin_installed( $slug ) ) { |
| 166 | - $plugins['install'][ $slug ] = $plugin; |
|
| 166 | + $plugins['install'][$slug] = $plugin; |
|
| 167 | 167 | } else { |
| 168 | 168 | if ( false !== $this->tgmpa->does_plugin_have_update( $slug ) ) { |
| 169 | - $plugins['update'][ $slug ] = $plugin; |
|
| 169 | + $plugins['update'][$slug] = $plugin; |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | if ( $this->tgmpa->can_plugin_activate( $slug ) ) { |
| 173 | - $plugins['activate'][ $slug ] = $plugin; |
|
| 173 | + $plugins['activate'][$slug] = $plugin; |
|
| 174 | 174 | } |
| 175 | 175 | } |
| 176 | 176 | } |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | */ |
| 189 | 189 | protected function set_view_totals( $plugins ) { |
| 190 | 190 | foreach ( $plugins as $type => $list ) { |
| 191 | - $this->view_totals[ $type ] = count( $list ); |
|
| 191 | + $this->view_totals[$type] = count( $list ); |
|
| 192 | 192 | } |
| 193 | 193 | } |
| 194 | 194 | |
@@ -290,8 +290,8 @@ discard block |
||
| 290 | 290 | $name = array(); |
| 291 | 291 | |
| 292 | 292 | foreach ( $items as $i => $plugin ) { |
| 293 | - $type[ $i ] = $plugin['type']; // Required / recommended. |
|
| 294 | - $name[ $i ] = $plugin['sanitized_plugin']; |
|
| 293 | + $type[$i] = $plugin['type']; // Required / recommended. |
|
| 294 | + $name[$i] = $plugin['sanitized_plugin']; |
|
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | array_multisort( $type, SORT_DESC, $name, SORT_ASC, $items ); |
@@ -338,7 +338,7 @@ discard block |
||
| 338 | 338 | |
| 339 | 339 | if ( ! empty( $text ) ) { |
| 340 | 340 | |
| 341 | - $status_links[ $type ] = sprintf( |
|
| 341 | + $status_links[$type] = sprintf( |
|
| 342 | 342 | '<a href="%s"%s>%s</a>', |
| 343 | 343 | esc_url( $this->tgmpa->get_tgmpa_status_url( $type ) ), |
| 344 | 344 | ( $type === $this->view_context ) ? ' class="current"' : '', |
@@ -361,7 +361,7 @@ discard block |
||
| 361 | 361 | * @return string |
| 362 | 362 | */ |
| 363 | 363 | public function column_default( $item, $column_name ) { |
| 364 | - return $item[ $column_name ]; |
|
| 364 | + return $item[$column_name]; |
|
| 365 | 365 | } |
| 366 | 366 | |
| 367 | 367 | /** |
@@ -561,7 +561,7 @@ discard block |
||
| 561 | 561 | 'tgmpa-nonce' |
| 562 | 562 | ); |
| 563 | 563 | |
| 564 | - $action_links[ $action ] = sprintf( |
|
| 564 | + $action_links[$action] = sprintf( |
|
| 565 | 565 | '<a href="%1$s">' . esc_html( $text ) . '</a>', // $text contains the second placeholder. |
| 566 | 566 | esc_url( $nonce_url ), |
| 567 | 567 | '<span class="screen-reader-text">' . esc_html( $item['sanitized_plugin'] ) . '</span>' |
@@ -712,19 +712,19 @@ discard block |
||
| 712 | 712 | // Validate the received input. |
| 713 | 713 | foreach ( $plugins_to_install as $key => $slug ) { |
| 714 | 714 | // Check if the plugin was registered with TGMPA and remove if not. |
| 715 | - if ( ! isset( $this->tgmpa->plugins[ $slug ] ) ) { |
|
| 716 | - unset( $plugins_to_install[ $key ] ); |
|
| 715 | + if ( ! isset( $this->tgmpa->plugins[$slug] ) ) { |
|
| 716 | + unset( $plugins_to_install[$key] ); |
|
| 717 | 717 | continue; |
| 718 | 718 | } |
| 719 | 719 | |
| 720 | 720 | // For install: make sure this is a plugin we *can* install and not one already installed. |
| 721 | 721 | if ( 'install' === $install_type && true === $this->tgmpa->is_plugin_installed( $slug ) ) { |
| 722 | - unset( $plugins_to_install[ $key ] ); |
|
| 722 | + unset( $plugins_to_install[$key] ); |
|
| 723 | 723 | } |
| 724 | 724 | |
| 725 | 725 | // For updates: make sure this is a plugin we *can* update (update available and WP version ok). |
| 726 | 726 | if ( 'update' === $install_type && false === $this->tgmpa->is_plugin_updatetable( $slug ) ) { |
| 727 | - unset( $plugins_to_install[ $key ] ); |
|
| 727 | + unset( $plugins_to_install[$key] ); |
|
| 728 | 728 | } |
| 729 | 729 | } |
| 730 | 730 | |
@@ -776,7 +776,7 @@ discard block |
||
| 776 | 776 | |
| 777 | 777 | // Prepare the data for validated plugins for the install/upgrade. |
| 778 | 778 | foreach ( $plugins_to_install as $slug ) { |
| 779 | - $name = $this->tgmpa->plugins[ $slug ]['name']; |
|
| 779 | + $name = $this->tgmpa->plugins[$slug]['name']; |
|
| 780 | 780 | $source = $this->tgmpa->get_download_url( $slug ); |
| 781 | 781 | |
| 782 | 782 | if ( ! empty( $name ) && ! empty( $source ) ) { |
@@ -789,9 +789,9 @@ discard block |
||
| 789 | 789 | break; |
| 790 | 790 | |
| 791 | 791 | case 'update': |
| 792 | - $file_paths[] = $this->tgmpa->plugins[ $slug ]['file_path']; |
|
| 793 | - $to_inject[ $slug ] = $this->tgmpa->plugins[ $slug ]; |
|
| 794 | - $to_inject[ $slug ]['source'] = $source; |
|
| 792 | + $file_paths[] = $this->tgmpa->plugins[$slug]['file_path']; |
|
| 793 | + $to_inject[$slug] = $this->tgmpa->plugins[$slug]; |
|
| 794 | + $to_inject[$slug]['source'] = $source; |
|
| 795 | 795 | break; |
| 796 | 796 | } |
| 797 | 797 | } |
@@ -862,8 +862,8 @@ discard block |
||
| 862 | 862 | // Grab the file paths for the selected & inactive plugins from the registration array. |
| 863 | 863 | foreach ( $plugins as $slug ) { |
| 864 | 864 | if ( $this->tgmpa->can_plugin_activate( $slug ) ) { |
| 865 | - $plugins_to_activate[] = $this->tgmpa->plugins[ $slug ]['file_path']; |
|
| 866 | - $plugin_names[] = $this->tgmpa->plugins[ $slug ]['name']; |
|
| 865 | + $plugins_to_activate[] = $this->tgmpa->plugins[$slug]['file_path']; |
|
| 866 | + $plugin_names[] = $this->tgmpa->plugins[$slug]['name']; |
|
| 867 | 867 | } |
| 868 | 868 | } |
| 869 | 869 | unset( $slug ); |
@@ -895,8 +895,8 @@ discard block |
||
| 895 | 895 | // Update recently activated plugins option. |
| 896 | 896 | $recent = (array) get_option( 'recently_activated' ); |
| 897 | 897 | foreach ( $plugins_to_activate as $plugin => $time ) { |
| 898 | - if ( isset( $recent[ $plugin ] ) ) { |
|
| 899 | - unset( $recent[ $plugin ] ); |
|
| 898 | + if ( isset( $recent[$plugin] ) ) { |
|
| 899 | + unset( $recent[$plugin] ); |
|
| 900 | 900 | } |
| 901 | 901 | } |
| 902 | 902 | update_option( 'recently_activated', $recent ); |
@@ -90,7 +90,7 @@ |
||
| 90 | 90 | */ |
| 91 | 91 | protected static function emulate_filter_bool( $value ) { |
| 92 | 92 | // @codingStandardsIgnoreStart |
| 93 | - static $true = array( |
|
| 93 | + static $true = array( |
|
| 94 | 94 | '1', |
| 95 | 95 | 'true', 'True', 'TRUE', |
| 96 | 96 | 'y', 'Y', |
@@ -65,23 +65,23 @@ discard block |
||
| 65 | 65 | * @param array $args Arguments to pass for use within the class. |
| 66 | 66 | */ |
| 67 | 67 | public function __construct( $args = array() ) { |
| 68 | - // Get TGMPA class instance. |
|
| 69 | - $this->tgmpa = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) ); |
|
| 70 | - |
|
| 71 | - // Parse default and new args. |
|
| 72 | - $defaults = array( |
|
| 73 | - 'url' => '', |
|
| 74 | - 'nonce' => '', |
|
| 75 | - 'names' => array(), |
|
| 76 | - 'install_type' => 'install', |
|
| 77 | - ); |
|
| 78 | - $args = wp_parse_args( $args, $defaults ); |
|
| 79 | - |
|
| 80 | - // Set plugin names to $this->plugin_names property. |
|
| 81 | - $this->plugin_names = $args['names']; |
|
| 82 | - |
|
| 83 | - // Extract the new args. |
|
| 84 | - parent::__construct( $args ); |
|
| 68 | + // Get TGMPA class instance. |
|
| 69 | + $this->tgmpa = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) ); |
|
| 70 | + |
|
| 71 | + // Parse default and new args. |
|
| 72 | + $defaults = array( |
|
| 73 | + 'url' => '', |
|
| 74 | + 'nonce' => '', |
|
| 75 | + 'names' => array(), |
|
| 76 | + 'install_type' => 'install', |
|
| 77 | + ); |
|
| 78 | + $args = wp_parse_args( $args, $defaults ); |
|
| 79 | + |
|
| 80 | + // Set plugin names to $this->plugin_names property. |
|
| 81 | + $this->plugin_names = $args['names']; |
|
| 82 | + |
|
| 83 | + // Extract the new args. |
|
| 84 | + parent::__construct( $args ); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | /** |
@@ -93,39 +93,39 @@ discard block |
||
| 93 | 93 | * @since 2.2.0 |
| 94 | 94 | */ |
| 95 | 95 | public function add_strings() { |
| 96 | - if ( 'update' === $this->options['install_type'] ) { |
|
| 97 | - parent::add_strings(); |
|
| 98 | - /* translators: 1: plugin name, 2: action number 3: total number of actions. */ |
|
| 99 | - $this->upgrader->strings['skin_before_update_header'] = __( 'Updating Plugin %1$s (%2$d/%3$d)', 'tgmpa' ); |
|
| 100 | - } else { |
|
| 101 | - /* translators: 1: plugin name, 2: error message. */ |
|
| 102 | - $this->upgrader->strings['skin_update_failed_error'] = __( 'An error occurred while installing %1$s: <strong>%2$s</strong>.', 'tgmpa' ); |
|
| 103 | - /* translators: 1: plugin name. */ |
|
| 104 | - $this->upgrader->strings['skin_update_failed'] = __( 'The installation of %1$s failed.', 'tgmpa' ); |
|
| 105 | - |
|
| 106 | - if ( $this->tgmpa->is_automatic ) { |
|
| 107 | - // Automatic activation strings. |
|
| 108 | - $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' ); |
|
| 109 | - /* translators: 1: plugin name. */ |
|
| 110 | - $this->upgrader->strings['skin_update_successful'] = __( '%1$s installed and activated successfully.', 'tgmpa' ); |
|
| 111 | - $this->upgrader->strings['skin_upgrade_end'] = __( 'All installations and activations have been completed.', 'tgmpa' ); |
|
| 112 | - /* translators: 1: plugin name, 2: action number 3: total number of actions. */ |
|
| 113 | - $this->upgrader->strings['skin_before_update_header'] = __( 'Installing and Activating Plugin %1$s (%2$d/%3$d)', 'tgmpa' ); |
|
| 114 | - } else { |
|
| 115 | - // Default installation strings. |
|
| 116 | - $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' ); |
|
| 117 | - /* translators: 1: plugin name. */ |
|
| 118 | - $this->upgrader->strings['skin_update_successful'] = __( '%1$s installed successfully.', 'tgmpa' ); |
|
| 119 | - $this->upgrader->strings['skin_upgrade_end'] = __( 'All installations have been completed.', 'tgmpa' ); |
|
| 120 | - /* translators: 1: plugin name, 2: action number 3: total number of actions. */ |
|
| 121 | - $this->upgrader->strings['skin_before_update_header'] = __( 'Installing Plugin %1$s (%2$d/%3$d)', 'tgmpa' ); |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - // Add "read more" link only for WP < 4.8. |
|
| 125 | - if ( version_compare( $this->tgmpa->wp_version, '4.8', '<' ) ) { |
|
| 126 | - $this->upgrader->strings['skin_update_successful'] .= ' <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>'; |
|
| 127 | - } |
|
| 128 | - } |
|
| 96 | + if ( 'update' === $this->options['install_type'] ) { |
|
| 97 | + parent::add_strings(); |
|
| 98 | + /* translators: 1: plugin name, 2: action number 3: total number of actions. */ |
|
| 99 | + $this->upgrader->strings['skin_before_update_header'] = __( 'Updating Plugin %1$s (%2$d/%3$d)', 'tgmpa' ); |
|
| 100 | + } else { |
|
| 101 | + /* translators: 1: plugin name, 2: error message. */ |
|
| 102 | + $this->upgrader->strings['skin_update_failed_error'] = __( 'An error occurred while installing %1$s: <strong>%2$s</strong>.', 'tgmpa' ); |
|
| 103 | + /* translators: 1: plugin name. */ |
|
| 104 | + $this->upgrader->strings['skin_update_failed'] = __( 'The installation of %1$s failed.', 'tgmpa' ); |
|
| 105 | + |
|
| 106 | + if ( $this->tgmpa->is_automatic ) { |
|
| 107 | + // Automatic activation strings. |
|
| 108 | + $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' ); |
|
| 109 | + /* translators: 1: plugin name. */ |
|
| 110 | + $this->upgrader->strings['skin_update_successful'] = __( '%1$s installed and activated successfully.', 'tgmpa' ); |
|
| 111 | + $this->upgrader->strings['skin_upgrade_end'] = __( 'All installations and activations have been completed.', 'tgmpa' ); |
|
| 112 | + /* translators: 1: plugin name, 2: action number 3: total number of actions. */ |
|
| 113 | + $this->upgrader->strings['skin_before_update_header'] = __( 'Installing and Activating Plugin %1$s (%2$d/%3$d)', 'tgmpa' ); |
|
| 114 | + } else { |
|
| 115 | + // Default installation strings. |
|
| 116 | + $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' ); |
|
| 117 | + /* translators: 1: plugin name. */ |
|
| 118 | + $this->upgrader->strings['skin_update_successful'] = __( '%1$s installed successfully.', 'tgmpa' ); |
|
| 119 | + $this->upgrader->strings['skin_upgrade_end'] = __( 'All installations have been completed.', 'tgmpa' ); |
|
| 120 | + /* translators: 1: plugin name, 2: action number 3: total number of actions. */ |
|
| 121 | + $this->upgrader->strings['skin_before_update_header'] = __( 'Installing Plugin %1$s (%2$d/%3$d)', 'tgmpa' ); |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + // Add "read more" link only for WP < 4.8. |
|
| 125 | + if ( version_compare( $this->tgmpa->wp_version, '4.8', '<' ) ) { |
|
| 126 | + $this->upgrader->strings['skin_update_successful'] .= ' <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>'; |
|
| 127 | + } |
|
| 128 | + } |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | /** |
@@ -136,10 +136,10 @@ discard block |
||
| 136 | 136 | * @param string $title Unused in this implementation. |
| 137 | 137 | */ |
| 138 | 138 | public function before( $title = '' ) { |
| 139 | - if ( empty( $title ) ) { |
|
| 140 | - $title = esc_html( $this->plugin_names[ $this->i ] ); |
|
| 141 | - } |
|
| 142 | - parent::before( $title ); |
|
| 139 | + if ( empty( $title ) ) { |
|
| 140 | + $title = esc_html( $this->plugin_names[ $this->i ] ); |
|
| 141 | + } |
|
| 142 | + parent::before( $title ); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | /** |
@@ -153,12 +153,12 @@ discard block |
||
| 153 | 153 | * @param string $title Unused in this implementation. |
| 154 | 154 | */ |
| 155 | 155 | public function after( $title = '' ) { |
| 156 | - if ( empty( $title ) ) { |
|
| 157 | - $title = esc_html( $this->plugin_names[ $this->i ] ); |
|
| 158 | - } |
|
| 159 | - parent::after( $title ); |
|
| 156 | + if ( empty( $title ) ) { |
|
| 157 | + $title = esc_html( $this->plugin_names[ $this->i ] ); |
|
| 158 | + } |
|
| 159 | + parent::after( $title ); |
|
| 160 | 160 | |
| 161 | - $this->i++; |
|
| 161 | + $this->i++; |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | /** |
@@ -167,41 +167,41 @@ discard block |
||
| 167 | 167 | * @since 2.2.0 |
| 168 | 168 | */ |
| 169 | 169 | public function bulk_footer() { |
| 170 | - // Serve up the string to say installations (and possibly activations) are complete. |
|
| 171 | - parent::bulk_footer(); |
|
| 172 | - |
|
| 173 | - // Flush plugins cache so we can make sure that the installed plugins list is always up to date. |
|
| 174 | - wp_clean_plugins_cache(); |
|
| 175 | - |
|
| 176 | - $this->tgmpa->show_tgmpa_version(); |
|
| 177 | - |
|
| 178 | - // Display message based on if all plugins are now active or not. |
|
| 179 | - $update_actions = array(); |
|
| 180 | - |
|
| 181 | - if ( $this->tgmpa->is_tgmpa_complete() ) { |
|
| 182 | - // All plugins are active, so we display the complete string and hide the menu to protect users. |
|
| 183 | - echo '<style type="text/css">#adminmenu .wp-submenu li.current { display: none !important; }</style>'; |
|
| 184 | - $update_actions['dashboard'] = sprintf( |
|
| 185 | - esc_html( $this->tgmpa->strings['complete'] ), |
|
| 186 | - '<a href="' . esc_url( self_admin_url() ) . '">' . esc_html( $this->tgmpa->strings['dashboard'] ) . '</a>' |
|
| 187 | - ); |
|
| 188 | - } else { |
|
| 189 | - $update_actions['tgmpa_page'] = '<a href="' . esc_url( $this->tgmpa->get_tgmpa_url() ) . '" target="_parent">' . esc_html( $this->tgmpa->strings['return'] ) . '</a>'; |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - /** |
|
| 193 | - * Filter the list of action links available following bulk plugin installs/updates. |
|
| 194 | - * |
|
| 195 | - * @since 2.5.0 |
|
| 196 | - * |
|
| 197 | - * @param array $update_actions Array of plugin action links. |
|
| 198 | - * @param array $plugin_info Array of information for the last-handled plugin. |
|
| 199 | - */ |
|
| 200 | - $update_actions = apply_filters( 'tgmpa_update_bulk_plugins_complete_actions', $update_actions, $this->plugin_info ); |
|
| 201 | - |
|
| 202 | - if ( ! empty( $update_actions ) ) { |
|
| 203 | - $this->feedback( implode( ' | ', (array) $update_actions ) ); |
|
| 204 | - } |
|
| 170 | + // Serve up the string to say installations (and possibly activations) are complete. |
|
| 171 | + parent::bulk_footer(); |
|
| 172 | + |
|
| 173 | + // Flush plugins cache so we can make sure that the installed plugins list is always up to date. |
|
| 174 | + wp_clean_plugins_cache(); |
|
| 175 | + |
|
| 176 | + $this->tgmpa->show_tgmpa_version(); |
|
| 177 | + |
|
| 178 | + // Display message based on if all plugins are now active or not. |
|
| 179 | + $update_actions = array(); |
|
| 180 | + |
|
| 181 | + if ( $this->tgmpa->is_tgmpa_complete() ) { |
|
| 182 | + // All plugins are active, so we display the complete string and hide the menu to protect users. |
|
| 183 | + echo '<style type="text/css">#adminmenu .wp-submenu li.current { display: none !important; }</style>'; |
|
| 184 | + $update_actions['dashboard'] = sprintf( |
|
| 185 | + esc_html( $this->tgmpa->strings['complete'] ), |
|
| 186 | + '<a href="' . esc_url( self_admin_url() ) . '">' . esc_html( $this->tgmpa->strings['dashboard'] ) . '</a>' |
|
| 187 | + ); |
|
| 188 | + } else { |
|
| 189 | + $update_actions['tgmpa_page'] = '<a href="' . esc_url( $this->tgmpa->get_tgmpa_url() ) . '" target="_parent">' . esc_html( $this->tgmpa->strings['return'] ) . '</a>'; |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + /** |
|
| 193 | + * Filter the list of action links available following bulk plugin installs/updates. |
|
| 194 | + * |
|
| 195 | + * @since 2.5.0 |
|
| 196 | + * |
|
| 197 | + * @param array $update_actions Array of plugin action links. |
|
| 198 | + * @param array $plugin_info Array of information for the last-handled plugin. |
|
| 199 | + */ |
|
| 200 | + $update_actions = apply_filters( 'tgmpa_update_bulk_plugins_complete_actions', $update_actions, $this->plugin_info ); |
|
| 201 | + |
|
| 202 | + if ( ! empty( $update_actions ) ) { |
|
| 203 | + $this->feedback( implode( ' | ', (array) $update_actions ) ); |
|
| 204 | + } |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | /* *********** DEPRECATED METHODS *********** */ |
@@ -214,8 +214,8 @@ discard block |
||
| 214 | 214 | * @see Bulk_Upgrader_Skin::flush_output() |
| 215 | 215 | */ |
| 216 | 216 | public function before_flush_output() { |
| 217 | - _deprecated_function( __FUNCTION__, 'TGMPA 2.5.0', 'Bulk_Upgrader_Skin::flush_output()' ); |
|
| 218 | - $this->flush_output(); |
|
| 217 | + _deprecated_function( __FUNCTION__, 'TGMPA 2.5.0', 'Bulk_Upgrader_Skin::flush_output()' ); |
|
| 218 | + $this->flush_output(); |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | /** |
@@ -227,8 +227,8 @@ discard block |
||
| 227 | 227 | * @see Bulk_Upgrader_Skin::flush_output() |
| 228 | 228 | */ |
| 229 | 229 | public function after_flush_output() { |
| 230 | - _deprecated_function( __FUNCTION__, 'TGMPA 2.5.0', 'Bulk_Upgrader_Skin::flush_output()' ); |
|
| 231 | - $this->flush_output(); |
|
| 232 | - $this->i++; |
|
| 230 | + _deprecated_function( __FUNCTION__, 'TGMPA 2.5.0', 'Bulk_Upgrader_Skin::flush_output()' ); |
|
| 231 | + $this->flush_output(); |
|
| 232 | + $this->i++; |
|
| 233 | 233 | } |
| 234 | 234 | } |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | 'names' => array(), |
| 76 | 76 | 'install_type' => 'install', |
| 77 | 77 | ); |
| 78 | - $args = wp_parse_args( $args, $defaults ); |
|
| 78 | + $args = wp_parse_args( $args, $defaults ); |
|
| 79 | 79 | |
| 80 | 80 | // Set plugin names to $this->plugin_names property. |
| 81 | 81 | $this->plugin_names = $args['names']; |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | */ |
| 138 | 138 | public function before( $title = '' ) { |
| 139 | 139 | if ( empty( $title ) ) { |
| 140 | - $title = esc_html( $this->plugin_names[ $this->i ] ); |
|
| 140 | + $title = esc_html( $this->plugin_names[$this->i] ); |
|
| 141 | 141 | } |
| 142 | 142 | parent::before( $title ); |
| 143 | 143 | } |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | */ |
| 155 | 155 | public function after( $title = '' ) { |
| 156 | 156 | if ( empty( $title ) ) { |
| 157 | - $title = esc_html( $this->plugin_names[ $this->i ] ); |
|
| 157 | + $title = esc_html( $this->plugin_names[$this->i] ); |
|
| 158 | 158 | } |
| 159 | 159 | parent::after( $title ); |
| 160 | 160 | |
@@ -63,20 +63,20 @@ discard block |
||
| 63 | 63 | * @param \Bulk_Upgrader_Skin|null $skin Installer skin. |
| 64 | 64 | */ |
| 65 | 65 | public function __construct( $skin = null ) { |
| 66 | - // Get TGMPA class instance. |
|
| 67 | - $this->tgmpa = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) ); |
|
| 66 | + // Get TGMPA class instance. |
|
| 67 | + $this->tgmpa = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) ); |
|
| 68 | 68 | |
| 69 | - parent::__construct( $skin ); |
|
| 69 | + parent::__construct( $skin ); |
|
| 70 | 70 | |
| 71 | - if ( isset( $this->skin->options['install_type'] ) && 'update' === $this->skin->options['install_type'] ) { |
|
| 72 | - $this->clear_destination = true; |
|
| 73 | - } |
|
| 71 | + if ( isset( $this->skin->options['install_type'] ) && 'update' === $this->skin->options['install_type'] ) { |
|
| 72 | + $this->clear_destination = true; |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - if ( $this->tgmpa->is_automatic ) { |
|
| 76 | - $this->activate_strings(); |
|
| 77 | - } |
|
| 75 | + if ( $this->tgmpa->is_automatic ) { |
|
| 76 | + $this->activate_strings(); |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - add_action( 'upgrader_process_complete', array( $this->tgmpa, 'populate_file_path' ) ); |
|
| 79 | + add_action( 'upgrader_process_complete', array( $this->tgmpa, 'populate_file_path' ) ); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | /** |
@@ -85,8 +85,8 @@ discard block |
||
| 85 | 85 | * @since 2.2.0 |
| 86 | 86 | */ |
| 87 | 87 | public function activate_strings() { |
| 88 | - $this->strings['activation_failed'] = __( 'Plugin activation failed.', 'tgmpa' ); |
|
| 89 | - $this->strings['activation_success'] = __( 'Plugin activated successfully.', 'tgmpa' ); |
|
| 88 | + $this->strings['activation_failed'] = __( 'Plugin activation failed.', 'tgmpa' ); |
|
| 89 | + $this->strings['activation_success'] = __( 'Plugin activated successfully.', 'tgmpa' ); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | /** |
@@ -100,18 +100,18 @@ discard block |
||
| 100 | 100 | * @return null|array Return early if error, array of installation data on success. |
| 101 | 101 | */ |
| 102 | 102 | public function run( $options ) { |
| 103 | - $result = parent::run( $options ); |
|
| 104 | - |
|
| 105 | - // Reset the strings in case we changed one during automatic activation. |
|
| 106 | - if ( $this->tgmpa->is_automatic ) { |
|
| 107 | - if ( 'update' === $this->skin->options['install_type'] ) { |
|
| 108 | - $this->upgrade_strings(); |
|
| 109 | - } else { |
|
| 110 | - $this->install_strings(); |
|
| 111 | - } |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - return $result; |
|
| 103 | + $result = parent::run( $options ); |
|
| 104 | + |
|
| 105 | + // Reset the strings in case we changed one during automatic activation. |
|
| 106 | + if ( $this->tgmpa->is_automatic ) { |
|
| 107 | + if ( 'update' === $this->skin->options['install_type'] ) { |
|
| 108 | + $this->upgrade_strings(); |
|
| 109 | + } else { |
|
| 110 | + $this->install_strings(); |
|
| 111 | + } |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + return $result; |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | /** |
@@ -134,59 +134,59 @@ discard block |
||
| 134 | 134 | * @return array|false Install confirmation messages on success, false on failure. |
| 135 | 135 | */ |
| 136 | 136 | public function bulk_install( $plugins, $args = array() ) { |
| 137 | - // [TGMPA + ] Hook auto-activation in. |
|
| 138 | - add_filter( 'upgrader_post_install', array( $this, 'auto_activate' ), 10 ); |
|
| 137 | + // [TGMPA + ] Hook auto-activation in. |
|
| 138 | + add_filter( 'upgrader_post_install', array( $this, 'auto_activate' ), 10 ); |
|
| 139 | 139 | |
| 140 | - $defaults = array( |
|
| 141 | - 'clear_update_cache' => true, |
|
| 142 | - ); |
|
| 143 | - $parsed_args = wp_parse_args( $args, $defaults ); |
|
| 140 | + $defaults = array( |
|
| 141 | + 'clear_update_cache' => true, |
|
| 142 | + ); |
|
| 143 | + $parsed_args = wp_parse_args( $args, $defaults ); |
|
| 144 | 144 | |
| 145 | - $this->init(); |
|
| 146 | - $this->bulk = true; |
|
| 145 | + $this->init(); |
|
| 146 | + $this->bulk = true; |
|
| 147 | 147 | |
| 148 | - $this->install_strings(); // [TGMPA + ] adjusted. |
|
| 148 | + $this->install_strings(); // [TGMPA + ] adjusted. |
|
| 149 | 149 | |
| 150 | - /* [TGMPA - ] $current = get_site_transient( 'update_plugins' ); */ |
|
| 150 | + /* [TGMPA - ] $current = get_site_transient( 'update_plugins' ); */ |
|
| 151 | 151 | |
| 152 | - /* [TGMPA - ] add_filter('upgrader_clear_destination', array($this, 'delete_old_plugin'), 10, 4); */ |
|
| 152 | + /* [TGMPA - ] add_filter('upgrader_clear_destination', array($this, 'delete_old_plugin'), 10, 4); */ |
|
| 153 | 153 | |
| 154 | - $this->skin->header(); |
|
| 154 | + $this->skin->header(); |
|
| 155 | 155 | |
| 156 | - // Connect to the Filesystem first. |
|
| 157 | - $res = $this->fs_connect( array( WP_CONTENT_DIR, WP_PLUGIN_DIR ) ); |
|
| 158 | - if ( ! $res ) { |
|
| 159 | - $this->skin->footer(); |
|
| 160 | - return false; |
|
| 161 | - } |
|
| 156 | + // Connect to the Filesystem first. |
|
| 157 | + $res = $this->fs_connect( array( WP_CONTENT_DIR, WP_PLUGIN_DIR ) ); |
|
| 158 | + if ( ! $res ) { |
|
| 159 | + $this->skin->footer(); |
|
| 160 | + return false; |
|
| 161 | + } |
|
| 162 | 162 | |
| 163 | - $this->skin->bulk_header(); |
|
| 163 | + $this->skin->bulk_header(); |
|
| 164 | 164 | |
| 165 | - /* |
|
| 165 | + /* |
|
| 166 | 166 | * Only start maintenance mode if: |
| 167 | 167 | * - running Multisite and there are one or more plugins specified, OR |
| 168 | 168 | * - a plugin with an update available is currently active. |
| 169 | 169 | * @TODO: For multisite, maintenance mode should only kick in for individual sites if at all possible. |
| 170 | 170 | */ |
| 171 | - $maintenance = ( is_multisite() && ! empty( $plugins ) ); |
|
| 171 | + $maintenance = ( is_multisite() && ! empty( $plugins ) ); |
|
| 172 | 172 | |
| 173 | - /* |
|
| 173 | + /* |
|
| 174 | 174 | [TGMPA - ] |
| 175 | 175 | foreach ( $plugins as $plugin ) |
| 176 | 176 | $maintenance = $maintenance || ( is_plugin_active( $plugin ) && isset( $current->response[ $plugin] ) ); |
| 177 | 177 | */ |
| 178 | - if ( $maintenance ) { |
|
| 179 | - $this->maintenance_mode( true ); |
|
| 180 | - } |
|
| 178 | + if ( $maintenance ) { |
|
| 179 | + $this->maintenance_mode( true ); |
|
| 180 | + } |
|
| 181 | 181 | |
| 182 | - $results = array(); |
|
| 182 | + $results = array(); |
|
| 183 | 183 | |
| 184 | - $this->update_count = count( $plugins ); |
|
| 185 | - $this->update_current = 0; |
|
| 186 | - foreach ( $plugins as $plugin ) { |
|
| 187 | - $this->update_current++; |
|
| 184 | + $this->update_count = count( $plugins ); |
|
| 185 | + $this->update_current = 0; |
|
| 186 | + foreach ( $plugins as $plugin ) { |
|
| 187 | + $this->update_current++; |
|
| 188 | 188 | |
| 189 | - /* |
|
| 189 | + /* |
|
| 190 | 190 | [TGMPA - ] |
| 191 | 191 | $this->skin->plugin_info = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin, false, true); |
| 192 | 192 | |
@@ -205,70 +205,70 @@ discard block |
||
| 205 | 205 | $this->skin->plugin_active = is_plugin_active($plugin); |
| 206 | 206 | */ |
| 207 | 207 | |
| 208 | - $result = $this->run( |
|
| 209 | - array( |
|
| 210 | - 'package' => $plugin, // [TGMPA + ] adjusted. |
|
| 211 | - 'destination' => WP_PLUGIN_DIR, |
|
| 212 | - 'clear_destination' => false, // [TGMPA + ] adjusted. |
|
| 213 | - 'clear_working' => true, |
|
| 214 | - 'is_multi' => true, |
|
| 215 | - 'hook_extra' => array( |
|
| 216 | - 'plugin' => $plugin, |
|
| 217 | - ), |
|
| 218 | - ) |
|
| 219 | - ); |
|
| 220 | - |
|
| 221 | - $results[ $plugin ] = $this->result; |
|
| 222 | - |
|
| 223 | - // Prevent credentials auth screen from displaying multiple times. |
|
| 224 | - if ( false === $result ) { |
|
| 225 | - break; |
|
| 226 | - } |
|
| 227 | - } |
|
| 228 | - |
|
| 229 | - $this->maintenance_mode( false ); |
|
| 230 | - |
|
| 231 | - /** |
|
| 232 | - * Fires when the bulk upgrader process is complete. |
|
| 233 | - * |
|
| 234 | - * @since WP 3.6.0 / TGMPA 2.5.0 |
|
| 235 | - * |
|
| 236 | - * @param Plugin_Upgrader $this Plugin_Upgrader instance. In other contexts, $this, might |
|
| 237 | - * be a Theme_Upgrader or Core_Upgrade instance. |
|
| 238 | - * @param array $data { |
|
| 239 | - * Array of bulk item update data. |
|
| 240 | - * |
|
| 241 | - * @type string $action Type of action. Default 'update'. |
|
| 242 | - * @type string $type Type of update process. Accepts 'plugin', 'theme', or 'core'. |
|
| 243 | - * @type bool $bulk Whether the update process is a bulk update. Default true. |
|
| 244 | - * @type array $packages Array of plugin, theme, or core packages to update. |
|
| 245 | - * } |
|
| 246 | - */ |
|
| 247 | - do_action( // WPCS: prefix OK. |
|
| 248 | - 'upgrader_process_complete', |
|
| 249 | - $this, |
|
| 250 | - array( |
|
| 251 | - 'action' => 'install', // [TGMPA + ] adjusted. |
|
| 252 | - 'type' => 'plugin', |
|
| 253 | - 'bulk' => true, |
|
| 254 | - 'plugins' => $plugins, |
|
| 255 | - ) |
|
| 256 | - ); |
|
| 257 | - |
|
| 258 | - $this->skin->bulk_footer(); |
|
| 259 | - |
|
| 260 | - $this->skin->footer(); |
|
| 261 | - |
|
| 262 | - // Cleanup our hooks, in case something else does a upgrade on this connection. |
|
| 263 | - /* [TGMPA - ] remove_filter('upgrader_clear_destination', array($this, 'delete_old_plugin')); */ |
|
| 264 | - |
|
| 265 | - // [TGMPA + ] Remove our auto-activation hook. |
|
| 266 | - remove_filter( 'upgrader_post_install', array( $this, 'auto_activate' ), 10 ); |
|
| 267 | - |
|
| 268 | - // Force refresh of plugin update information. |
|
| 269 | - wp_clean_plugins_cache( $parsed_args['clear_update_cache'] ); |
|
| 270 | - |
|
| 271 | - return $results; |
|
| 208 | + $result = $this->run( |
|
| 209 | + array( |
|
| 210 | + 'package' => $plugin, // [TGMPA + ] adjusted. |
|
| 211 | + 'destination' => WP_PLUGIN_DIR, |
|
| 212 | + 'clear_destination' => false, // [TGMPA + ] adjusted. |
|
| 213 | + 'clear_working' => true, |
|
| 214 | + 'is_multi' => true, |
|
| 215 | + 'hook_extra' => array( |
|
| 216 | + 'plugin' => $plugin, |
|
| 217 | + ), |
|
| 218 | + ) |
|
| 219 | + ); |
|
| 220 | + |
|
| 221 | + $results[ $plugin ] = $this->result; |
|
| 222 | + |
|
| 223 | + // Prevent credentials auth screen from displaying multiple times. |
|
| 224 | + if ( false === $result ) { |
|
| 225 | + break; |
|
| 226 | + } |
|
| 227 | + } |
|
| 228 | + |
|
| 229 | + $this->maintenance_mode( false ); |
|
| 230 | + |
|
| 231 | + /** |
|
| 232 | + * Fires when the bulk upgrader process is complete. |
|
| 233 | + * |
|
| 234 | + * @since WP 3.6.0 / TGMPA 2.5.0 |
|
| 235 | + * |
|
| 236 | + * @param Plugin_Upgrader $this Plugin_Upgrader instance. In other contexts, $this, might |
|
| 237 | + * be a Theme_Upgrader or Core_Upgrade instance. |
|
| 238 | + * @param array $data { |
|
| 239 | + * Array of bulk item update data. |
|
| 240 | + * |
|
| 241 | + * @type string $action Type of action. Default 'update'. |
|
| 242 | + * @type string $type Type of update process. Accepts 'plugin', 'theme', or 'core'. |
|
| 243 | + * @type bool $bulk Whether the update process is a bulk update. Default true. |
|
| 244 | + * @type array $packages Array of plugin, theme, or core packages to update. |
|
| 245 | + * } |
|
| 246 | + */ |
|
| 247 | + do_action( // WPCS: prefix OK. |
|
| 248 | + 'upgrader_process_complete', |
|
| 249 | + $this, |
|
| 250 | + array( |
|
| 251 | + 'action' => 'install', // [TGMPA + ] adjusted. |
|
| 252 | + 'type' => 'plugin', |
|
| 253 | + 'bulk' => true, |
|
| 254 | + 'plugins' => $plugins, |
|
| 255 | + ) |
|
| 256 | + ); |
|
| 257 | + |
|
| 258 | + $this->skin->bulk_footer(); |
|
| 259 | + |
|
| 260 | + $this->skin->footer(); |
|
| 261 | + |
|
| 262 | + // Cleanup our hooks, in case something else does a upgrade on this connection. |
|
| 263 | + /* [TGMPA - ] remove_filter('upgrader_clear_destination', array($this, 'delete_old_plugin')); */ |
|
| 264 | + |
|
| 265 | + // [TGMPA + ] Remove our auto-activation hook. |
|
| 266 | + remove_filter( 'upgrader_post_install', array( $this, 'auto_activate' ), 10 ); |
|
| 267 | + |
|
| 268 | + // Force refresh of plugin update information. |
|
| 269 | + wp_clean_plugins_cache( $parsed_args['clear_update_cache'] ); |
|
| 270 | + |
|
| 271 | + return $results; |
|
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | /** |
@@ -284,13 +284,13 @@ discard block |
||
| 284 | 284 | */ |
| 285 | 285 | public function bulk_upgrade( $plugins, $args = array() ) { |
| 286 | 286 | |
| 287 | - add_filter( 'upgrader_post_install', array( $this, 'auto_activate' ), 10 ); |
|
| 287 | + add_filter( 'upgrader_post_install', array( $this, 'auto_activate' ), 10 ); |
|
| 288 | 288 | |
| 289 | - $result = parent::bulk_upgrade( $plugins, $args ); |
|
| 289 | + $result = parent::bulk_upgrade( $plugins, $args ); |
|
| 290 | 290 | |
| 291 | - remove_filter( 'upgrader_post_install', array( $this, 'auto_activate' ), 10 ); |
|
| 291 | + remove_filter( 'upgrader_post_install', array( $this, 'auto_activate' ), 10 ); |
|
| 292 | 292 | |
| 293 | - return $result; |
|
| 293 | + return $result; |
|
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | /** |
@@ -304,30 +304,30 @@ discard block |
||
| 304 | 304 | * @return bool |
| 305 | 305 | */ |
| 306 | 306 | public function auto_activate( $bool ) { |
| 307 | - // Only process the activation of installed plugins if the automatic flag is set to true. |
|
| 308 | - if ( $this->tgmpa->is_automatic ) { |
|
| 309 | - // Flush plugins cache so the headers of the newly installed plugins will be read correctly. |
|
| 310 | - wp_clean_plugins_cache(); |
|
| 311 | - |
|
| 312 | - // Get the installed plugin file. |
|
| 313 | - $plugin_info = $this->plugin_info(); |
|
| 314 | - |
|
| 315 | - // Don't try to activate on upgrade of active plugin as WP will do this already. |
|
| 316 | - if ( ! is_plugin_active( $plugin_info ) ) { |
|
| 317 | - $activate = activate_plugin( $plugin_info ); |
|
| 318 | - |
|
| 319 | - // Adjust the success string based on the activation result. |
|
| 320 | - $this->strings['process_success'] = $this->strings['process_success'] . "<br />\n"; |
|
| 321 | - |
|
| 322 | - if ( is_wp_error( $activate ) ) { |
|
| 323 | - $this->skin->error( $activate ); |
|
| 324 | - $this->strings['process_success'] .= $this->strings['activation_failed']; |
|
| 325 | - } else { |
|
| 326 | - $this->strings['process_success'] .= $this->strings['activation_success']; |
|
| 327 | - } |
|
| 328 | - } |
|
| 329 | - } |
|
| 330 | - |
|
| 331 | - return $bool; |
|
| 307 | + // Only process the activation of installed plugins if the automatic flag is set to true. |
|
| 308 | + if ( $this->tgmpa->is_automatic ) { |
|
| 309 | + // Flush plugins cache so the headers of the newly installed plugins will be read correctly. |
|
| 310 | + wp_clean_plugins_cache(); |
|
| 311 | + |
|
| 312 | + // Get the installed plugin file. |
|
| 313 | + $plugin_info = $this->plugin_info(); |
|
| 314 | + |
|
| 315 | + // Don't try to activate on upgrade of active plugin as WP will do this already. |
|
| 316 | + if ( ! is_plugin_active( $plugin_info ) ) { |
|
| 317 | + $activate = activate_plugin( $plugin_info ); |
|
| 318 | + |
|
| 319 | + // Adjust the success string based on the activation result. |
|
| 320 | + $this->strings['process_success'] = $this->strings['process_success'] . "<br />\n"; |
|
| 321 | + |
|
| 322 | + if ( is_wp_error( $activate ) ) { |
|
| 323 | + $this->skin->error( $activate ); |
|
| 324 | + $this->strings['process_success'] .= $this->strings['activation_failed']; |
|
| 325 | + } else { |
|
| 326 | + $this->strings['process_success'] .= $this->strings['activation_success']; |
|
| 327 | + } |
|
| 328 | + } |
|
| 329 | + } |
|
| 330 | + |
|
| 331 | + return $bool; |
|
| 332 | 332 | } |
| 333 | 333 | } |
@@ -218,7 +218,7 @@ |
||
| 218 | 218 | ) |
| 219 | 219 | ); |
| 220 | 220 | |
| 221 | - $results[ $plugin ] = $this->result; |
|
| 221 | + $results[$plugin] = $this->result; |
|
| 222 | 222 | |
| 223 | 223 | // Prevent credentials auth screen from displaying multiple times. |
| 224 | 224 | if ( false === $result ) { |