@@ -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 | } |
@@ -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' ); |
@@ -701,11 +701,11 @@ discard block |
||
701 | 701 | $args = apply_filters( |
702 | 702 | 'tgmpa_admin_menu_args', |
703 | 703 | array( |
704 | - 'parent_slug' => $this->parent_slug, // Parent Menu slug. |
|
705 | - 'page_title' => $this->strings['page_title'], // Page title. |
|
706 | - 'menu_title' => $this->strings['menu_title'], // Menu title. |
|
707 | - 'capability' => $this->capability, // Capability. |
|
708 | - 'menu_slug' => $this->menu, // Menu slug. |
|
704 | + 'parent_slug' => $this->parent_slug, // Parent Menu slug. |
|
705 | + 'page_title' => $this->strings['page_title'], // Page title. |
|
706 | + 'menu_title' => $this->strings['menu_title'], // Menu title. |
|
707 | + 'capability' => $this->capability, // Capability. |
|
708 | + 'menu_slug' => $this->menu, // Menu slug. |
|
709 | 709 | 'function' => array( $this, 'install_plugins_page' ), // Callback. |
710 | 710 | ) |
711 | 711 | ); |
@@ -807,7 +807,7 @@ discard block |
||
807 | 807 | // All plugin information will be stored in an array for processing. |
808 | 808 | $slug = $this->sanitize_key( urldecode( $_GET['plugin'] ) ); |
809 | 809 | |
810 | - if ( ! isset( $this->plugins[ $slug ] ) ) { |
|
810 | + if ( ! isset( $this->plugins[$slug] ) ) { |
|
811 | 811 | return false; |
812 | 812 | } |
813 | 813 | |
@@ -852,7 +852,7 @@ discard block |
||
852 | 852 | $extra = array(); |
853 | 853 | $extra['slug'] = $slug; // Needed for potentially renaming of directory name. |
854 | 854 | $source = $this->get_download_url( $slug ); |
855 | - $api = ( 'repo' === $this->plugins[ $slug ]['source_type'] ) ? $this->get_plugins_api( $slug ) : null; |
|
855 | + $api = ( 'repo' === $this->plugins[$slug]['source_type'] ) ? $this->get_plugins_api( $slug ) : null; |
|
856 | 856 | $api = ( false !== $api ) ? $api : null; |
857 | 857 | |
858 | 858 | $url = add_query_arg( |
@@ -869,8 +869,8 @@ discard block |
||
869 | 869 | |
870 | 870 | $title = ( 'update' === $install_type ) ? $this->strings['updating'] : $this->strings['installing']; |
871 | 871 | $skin_args = array( |
872 | - 'type' => ( 'bundled' !== $this->plugins[ $slug ]['source_type'] ) ? 'web' : 'upload', |
|
873 | - 'title' => sprintf( $title, $this->plugins[ $slug ]['name'] ), |
|
872 | + 'type' => ( 'bundled' !== $this->plugins[$slug]['source_type'] ) ? 'web' : 'upload', |
|
873 | + 'title' => sprintf( $title, $this->plugins[$slug]['name'] ), |
|
874 | 874 | 'url' => esc_url_raw( $url ), |
875 | 875 | 'nonce' => $install_type . '-plugin_' . $slug, |
876 | 876 | 'plugin' => '', |
@@ -880,7 +880,7 @@ discard block |
||
880 | 880 | unset( $title ); |
881 | 881 | |
882 | 882 | if ( 'update' === $install_type ) { |
883 | - $skin_args['plugin'] = $this->plugins[ $slug ]['file_path']; |
|
883 | + $skin_args['plugin'] = $this->plugins[$slug]['file_path']; |
|
884 | 884 | $skin = new Plugin_Upgrader_Skin( $skin_args ); |
885 | 885 | } else { |
886 | 886 | $skin = new Plugin_Installer_Skin( $skin_args ); |
@@ -895,12 +895,12 @@ discard block |
||
895 | 895 | if ( 'update' === $install_type ) { |
896 | 896 | // Inject our info into the update transient. |
897 | 897 | $to_inject = array( |
898 | - $slug => $this->plugins[ $slug ], |
|
898 | + $slug => $this->plugins[$slug], |
|
899 | 899 | ); |
900 | - $to_inject[ $slug ]['source'] = $source; |
|
900 | + $to_inject[$slug]['source'] = $source; |
|
901 | 901 | $this->inject_update_info( $to_inject ); |
902 | 902 | |
903 | - $upgrader->upgrade( $this->plugins[ $slug ]['file_path'] ); |
|
903 | + $upgrader->upgrade( $this->plugins[$slug]['file_path'] ); |
|
904 | 904 | } else { |
905 | 905 | $upgrader->install( $source ); |
906 | 906 | } |
@@ -930,11 +930,11 @@ discard block |
||
930 | 930 | } |
931 | 931 | |
932 | 932 | return true; |
933 | - } elseif ( isset( $this->plugins[ $slug ]['file_path'], $_GET['tgmpa-activate'] ) && 'activate-plugin' === $_GET['tgmpa-activate'] ) { |
|
933 | + } elseif ( isset( $this->plugins[$slug]['file_path'], $_GET['tgmpa-activate'] ) && 'activate-plugin' === $_GET['tgmpa-activate'] ) { |
|
934 | 934 | // Activate action link was clicked. |
935 | 935 | check_admin_referer( 'tgmpa-activate', 'tgmpa-nonce' ); |
936 | 936 | |
937 | - if ( false === $this->activate_single_plugin( $this->plugins[ $slug ]['file_path'], $slug ) ) { |
|
937 | + if ( false === $this->activate_single_plugin( $this->plugins[$slug]['file_path'], $slug ) ) { |
|
938 | 938 | return true; // Finish execution of the function early as we encountered an error. |
939 | 939 | } |
940 | 940 | } // End if(). |
@@ -959,17 +959,17 @@ discard block |
||
959 | 959 | foreach ( $plugins as $slug => $plugin ) { |
960 | 960 | $file_path = $plugin['file_path']; |
961 | 961 | |
962 | - if ( empty( $repo_updates->response[ $file_path ] ) ) { |
|
963 | - $repo_updates->response[ $file_path ] = new stdClass; |
|
962 | + if ( empty( $repo_updates->response[$file_path] ) ) { |
|
963 | + $repo_updates->response[$file_path] = new stdClass; |
|
964 | 964 | } |
965 | 965 | |
966 | 966 | // We only really need to set package, but let's do all we can in case WP changes something. |
967 | - $repo_updates->response[ $file_path ]->slug = $slug; |
|
968 | - $repo_updates->response[ $file_path ]->plugin = $file_path; |
|
969 | - $repo_updates->response[ $file_path ]->new_version = $plugin['version']; |
|
970 | - $repo_updates->response[ $file_path ]->package = $plugin['source']; |
|
971 | - if ( empty( $repo_updates->response[ $file_path ]->url ) && ! empty( $plugin['external_url'] ) ) { |
|
972 | - $repo_updates->response[ $file_path ]->url = $plugin['external_url']; |
|
967 | + $repo_updates->response[$file_path]->slug = $slug; |
|
968 | + $repo_updates->response[$file_path]->plugin = $file_path; |
|
969 | + $repo_updates->response[$file_path]->new_version = $plugin['version']; |
|
970 | + $repo_updates->response[$file_path]->package = $plugin['source']; |
|
971 | + if ( empty( $repo_updates->response[$file_path]->url ) && ! empty( $plugin['external_url'] ) ) { |
|
972 | + $repo_updates->response[$file_path]->url = $plugin['external_url']; |
|
973 | 973 | } |
974 | 974 | } |
975 | 975 | |
@@ -1012,7 +1012,7 @@ discard block |
||
1012 | 1012 | } else { |
1013 | 1013 | // Bulk installer contains less info, so fall back on the info registered here. |
1014 | 1014 | foreach ( $this->plugins as $slug => $plugin ) { |
1015 | - if ( ! empty( $upgrader->skin->plugin_names[ $upgrader->skin->i ] ) && $plugin['name'] === $upgrader->skin->plugin_names[ $upgrader->skin->i ] ) { |
|
1015 | + if ( ! empty( $upgrader->skin->plugin_names[$upgrader->skin->i] ) && $plugin['name'] === $upgrader->skin->plugin_names[$upgrader->skin->i] ) { |
|
1016 | 1016 | $desired_slug = $slug; |
1017 | 1017 | break; |
1018 | 1018 | } |
@@ -1079,7 +1079,7 @@ discard block |
||
1079 | 1079 | // Make sure message doesn't display again if bulk activation is performed |
1080 | 1080 | // immediately after a single activation. |
1081 | 1081 | if ( ! isset( $_POST['action'] ) ) { // WPCS: CSRF OK. |
1082 | - echo '<div id="message" class="updated"><p>', esc_html( $this->strings['activated_successfully'] ), ' <strong>', esc_html( $this->plugins[ $slug ]['name'] ), '.</strong></p></div>'; |
|
1082 | + echo '<div id="message" class="updated"><p>', esc_html( $this->strings['activated_successfully'] ), ' <strong>', esc_html( $this->plugins[$slug]['name'] ), '.</strong></p></div>'; |
|
1083 | 1083 | } |
1084 | 1084 | } else { |
1085 | 1085 | // Simpler message layout for use on the plugin install page. |
@@ -1092,7 +1092,7 @@ discard block |
||
1092 | 1092 | echo '<div id="message" class="error"><p>', |
1093 | 1093 | sprintf( |
1094 | 1094 | esc_html( $this->strings['plugin_already_active'] ), |
1095 | - '<strong>' . esc_html( $this->plugins[ $slug ]['name'] ) . '</strong>' |
|
1095 | + '<strong>' . esc_html( $this->plugins[$slug]['name'] ) . '</strong>' |
|
1096 | 1096 | ), |
1097 | 1097 | '</p></div>'; |
1098 | 1098 | } elseif ( $this->does_plugin_require_update( $slug ) ) { |
@@ -1103,13 +1103,13 @@ discard block |
||
1103 | 1103 | echo '<div id="message" class="error"><p>', |
1104 | 1104 | sprintf( |
1105 | 1105 | esc_html( $this->strings['plugin_needs_higher_version'] ), |
1106 | - '<strong>' . esc_html( $this->plugins[ $slug ]['name'] ) . '</strong>' |
|
1106 | + '<strong>' . esc_html( $this->plugins[$slug]['name'] ) . '</strong>' |
|
1107 | 1107 | ), |
1108 | 1108 | '</p></div>'; |
1109 | 1109 | } |
1110 | 1110 | } else { |
1111 | 1111 | // Simpler message layout for use on the plugin install page. |
1112 | - echo '<p>', sprintf( esc_html( $this->strings['plugin_needs_higher_version'] ), esc_html( $this->plugins[ $slug ]['name'] ) ), '</p>'; |
|
1112 | + echo '<p>', sprintf( esc_html( $this->strings['plugin_needs_higher_version'] ), esc_html( $this->plugins[$slug]['name'] ) ), '</p>'; |
|
1113 | 1113 | } |
1114 | 1114 | } // End if(). |
1115 | 1115 | |
@@ -1236,7 +1236,7 @@ discard block |
||
1236 | 1236 | $rendered .= sprintf( |
1237 | 1237 | $line_template, |
1238 | 1238 | sprintf( |
1239 | - translate_nooped_plural( $this->strings[ $type ], $count, 'tgmpa' ), |
|
1239 | + translate_nooped_plural( $this->strings[$type], $count, 'tgmpa' ), |
|
1240 | 1240 | $imploded, |
1241 | 1241 | $count |
1242 | 1242 | ) |
@@ -1353,7 +1353,7 @@ discard block |
||
1353 | 1353 | |
1354 | 1354 | foreach ( (array) $wp_settings_errors as $key => $details ) { |
1355 | 1355 | if ( 'tgmpa' === $details['setting'] ) { |
1356 | - unset( $wp_settings_errors[ $key ] ); |
|
1356 | + unset( $wp_settings_errors[$key] ); |
|
1357 | 1357 | break; |
1358 | 1358 | } |
1359 | 1359 | } |
@@ -1389,20 +1389,20 @@ discard block |
||
1389 | 1389 | return; |
1390 | 1390 | } |
1391 | 1391 | |
1392 | - if ( empty( $plugin['slug'] ) || ! is_string( $plugin['slug'] ) || isset( $this->plugins[ $plugin['slug'] ] ) ) { |
|
1392 | + if ( empty( $plugin['slug'] ) || ! is_string( $plugin['slug'] ) || isset( $this->plugins[$plugin['slug']] ) ) { |
|
1393 | 1393 | return; |
1394 | 1394 | } |
1395 | 1395 | |
1396 | 1396 | $defaults = array( |
1397 | - 'name' => '', // String |
|
1398 | - 'slug' => '', // String |
|
1399 | - 'source' => 'repo', // String |
|
1400 | - 'required' => false, // Boolean |
|
1401 | - 'version' => '', // String |
|
1402 | - 'force_activation' => false, // Boolean |
|
1403 | - 'force_deactivation' => false, // Boolean |
|
1404 | - 'external_url' => '', // String |
|
1405 | - 'is_callable' => '', // String|Array. |
|
1397 | + 'name' => '', // String |
|
1398 | + 'slug' => '', // String |
|
1399 | + 'source' => 'repo', // String |
|
1400 | + 'required' => false, // Boolean |
|
1401 | + 'version' => '', // String |
|
1402 | + 'force_activation' => false, // Boolean |
|
1403 | + 'force_deactivation' => false, // Boolean |
|
1404 | + 'external_url' => '', // String |
|
1405 | + 'is_callable' => '', // String|Array. |
|
1406 | 1406 | ); |
1407 | 1407 | |
1408 | 1408 | // Prepare the received data. |
@@ -1423,8 +1423,8 @@ discard block |
||
1423 | 1423 | $plugin['source_type'] = $this->get_plugin_source_type( $plugin['source'] ); |
1424 | 1424 | |
1425 | 1425 | // Set the class properties. |
1426 | - $this->plugins[ $plugin['slug'] ] = $plugin; |
|
1427 | - $this->sort_order[ $plugin['slug'] ] = $plugin['name']; |
|
1426 | + $this->plugins[$plugin['slug']] = $plugin; |
|
1427 | + $this->sort_order[$plugin['slug']] = $plugin['name']; |
|
1428 | 1428 | |
1429 | 1429 | // Should we add the force activation hook ? |
1430 | 1430 | if ( true === $plugin['force_activation'] ) { |
@@ -1508,11 +1508,11 @@ discard block |
||
1508 | 1508 | ); |
1509 | 1509 | |
1510 | 1510 | foreach ( $keys as $key ) { |
1511 | - if ( isset( $config[ $key ] ) ) { |
|
1512 | - if ( is_array( $config[ $key ] ) ) { |
|
1513 | - $this->$key = array_merge( $this->$key, $config[ $key ] ); |
|
1511 | + if ( isset( $config[$key] ) ) { |
|
1512 | + if ( is_array( $config[$key] ) ) { |
|
1513 | + $this->$key = array_merge( $this->$key, $config[$key] ); |
|
1514 | 1514 | } else { |
1515 | - $this->$key = $config[ $key ]; |
|
1515 | + $this->$key = $config[$key]; |
|
1516 | 1516 | } |
1517 | 1517 | } |
1518 | 1518 | } |
@@ -1557,12 +1557,12 @@ discard block |
||
1557 | 1557 | * Parameter added in v2.5.0. |
1558 | 1558 | */ |
1559 | 1559 | public function populate_file_path( $plugin_slug = '' ) { |
1560 | - if ( ! empty( $plugin_slug ) && is_string( $plugin_slug ) && isset( $this->plugins[ $plugin_slug ] ) ) { |
|
1561 | - $this->plugins[ $plugin_slug ]['file_path'] = $this->_get_plugin_basename_from_slug( $plugin_slug ); |
|
1560 | + if ( ! empty( $plugin_slug ) && is_string( $plugin_slug ) && isset( $this->plugins[$plugin_slug] ) ) { |
|
1561 | + $this->plugins[$plugin_slug]['file_path'] = $this->_get_plugin_basename_from_slug( $plugin_slug ); |
|
1562 | 1562 | } else { |
1563 | 1563 | // Add file_path key for all plugins. |
1564 | 1564 | foreach ( $this->plugins as $slug => $values ) { |
1565 | - $this->plugins[ $slug ]['file_path'] = $this->_get_plugin_basename_from_slug( $slug ); |
|
1565 | + $this->plugins[$slug]['file_path'] = $this->_get_plugin_basename_from_slug( $slug ); |
|
1566 | 1566 | } |
1567 | 1567 | } |
1568 | 1568 | } |
@@ -1602,8 +1602,8 @@ discard block |
||
1602 | 1602 | */ |
1603 | 1603 | public function _get_plugin_data_from_name( $name, $data = 'slug' ) { |
1604 | 1604 | foreach ( $this->plugins as $values ) { |
1605 | - if ( $name === $values['name'] && isset( $values[ $data ] ) ) { |
|
1606 | - return $values[ $data ]; |
|
1605 | + if ( $name === $values['name'] && isset( $values[$data] ) ) { |
|
1606 | + return $values[$data]; |
|
1607 | 1607 | } |
1608 | 1608 | } |
1609 | 1609 | |
@@ -1621,13 +1621,13 @@ discard block |
||
1621 | 1621 | public function get_download_url( $slug ) { |
1622 | 1622 | $dl_source = ''; |
1623 | 1623 | |
1624 | - switch ( $this->plugins[ $slug ]['source_type'] ) { |
|
1624 | + switch ( $this->plugins[$slug]['source_type'] ) { |
|
1625 | 1625 | case 'repo': |
1626 | 1626 | return $this->get_wp_repo_download_url( $slug ); |
1627 | 1627 | case 'external': |
1628 | - return $this->plugins[ $slug ]['source']; |
|
1628 | + return $this->plugins[$slug]['source']; |
|
1629 | 1629 | case 'bundled': |
1630 | - return $this->default_path . $this->plugins[ $slug ]['source']; |
|
1630 | + return $this->default_path . $this->plugins[$slug]['source']; |
|
1631 | 1631 | } |
1632 | 1632 | |
1633 | 1633 | return $dl_source; // Should never happen. |
@@ -1663,7 +1663,7 @@ discard block |
||
1663 | 1663 | protected function get_plugins_api( $slug ) { |
1664 | 1664 | static $api = array(); // Cache received responses. |
1665 | 1665 | |
1666 | - if ( ! isset( $api[ $slug ] ) ) { |
|
1666 | + if ( ! isset( $api[$slug] ) ) { |
|
1667 | 1667 | if ( ! function_exists( 'plugins_api' ) ) { |
1668 | 1668 | require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; |
1669 | 1669 | } |
@@ -1678,16 +1678,16 @@ discard block |
||
1678 | 1678 | ) |
1679 | 1679 | ); |
1680 | 1680 | |
1681 | - $api[ $slug ] = false; |
|
1681 | + $api[$slug] = false; |
|
1682 | 1682 | |
1683 | 1683 | if ( is_wp_error( $response ) ) { |
1684 | 1684 | wp_die( esc_html( $this->strings['oops'] ) ); |
1685 | 1685 | } else { |
1686 | - $api[ $slug ] = $response; |
|
1686 | + $api[$slug] = $response; |
|
1687 | 1687 | } |
1688 | 1688 | } |
1689 | 1689 | |
1690 | - return $api[ $slug ]; |
|
1690 | + return $api[$slug]; |
|
1691 | 1691 | } |
1692 | 1692 | |
1693 | 1693 | /** |
@@ -1700,13 +1700,13 @@ discard block |
||
1700 | 1700 | * or the plugin name if not. |
1701 | 1701 | */ |
1702 | 1702 | public function get_info_link( $slug ) { |
1703 | - if ( ! empty( $this->plugins[ $slug ]['external_url'] ) && preg_match( self::IS_URL_REGEX, $this->plugins[ $slug ]['external_url'] ) ) { |
|
1703 | + if ( ! empty( $this->plugins[$slug]['external_url'] ) && preg_match( self::IS_URL_REGEX, $this->plugins[$slug]['external_url'] ) ) { |
|
1704 | 1704 | $link = sprintf( |
1705 | 1705 | '<a href="%1$s" target="_blank">%2$s</a>', |
1706 | - esc_url( $this->plugins[ $slug ]['external_url'] ), |
|
1707 | - esc_html( $this->plugins[ $slug ]['name'] ) |
|
1706 | + esc_url( $this->plugins[$slug]['external_url'] ), |
|
1707 | + esc_html( $this->plugins[$slug]['name'] ) |
|
1708 | 1708 | ); |
1709 | - } elseif ( 'repo' === $this->plugins[ $slug ]['source_type'] ) { |
|
1709 | + } elseif ( 'repo' === $this->plugins[$slug]['source_type'] ) { |
|
1710 | 1710 | $url = add_query_arg( |
1711 | 1711 | array( |
1712 | 1712 | 'tab' => 'plugin-information', |
@@ -1721,10 +1721,10 @@ discard block |
||
1721 | 1721 | $link = sprintf( |
1722 | 1722 | '<a href="%1$s" class="thickbox">%2$s</a>', |
1723 | 1723 | esc_url( $url ), |
1724 | - esc_html( $this->plugins[ $slug ]['name'] ) |
|
1724 | + esc_html( $this->plugins[$slug]['name'] ) |
|
1725 | 1725 | ); |
1726 | 1726 | } else { |
1727 | - $link = esc_html( $this->plugins[ $slug ]['name'] ); // No hyperlink. |
|
1727 | + $link = esc_html( $this->plugins[$slug]['name'] ); // No hyperlink. |
|
1728 | 1728 | } |
1729 | 1729 | |
1730 | 1730 | return $link; |
@@ -1849,7 +1849,7 @@ discard block |
||
1849 | 1849 | public function is_plugin_installed( $slug ) { |
1850 | 1850 | $installed_plugins = $this->get_plugins(); // Retrieve a list of all installed plugins (WP cached). |
1851 | 1851 | |
1852 | - return ( ! empty( $installed_plugins[ $this->plugins[ $slug ]['file_path'] ] ) ); |
|
1852 | + return ( ! empty( $installed_plugins[$this->plugins[$slug]['file_path']] ) ); |
|
1853 | 1853 | } |
1854 | 1854 | |
1855 | 1855 | /** |
@@ -1861,7 +1861,7 @@ discard block |
||
1861 | 1861 | * @return bool True if active, false otherwise. |
1862 | 1862 | */ |
1863 | 1863 | public function is_plugin_active( $slug ) { |
1864 | - return ( ( ! empty( $this->plugins[ $slug ]['is_callable'] ) && is_callable( $this->plugins[ $slug ]['is_callable'] ) ) || is_plugin_active( $this->plugins[ $slug ]['file_path'] ) ); |
|
1864 | + return ( ( ! empty( $this->plugins[$slug]['is_callable'] ) && is_callable( $this->plugins[$slug]['is_callable'] ) ) || is_plugin_active( $this->plugins[$slug]['file_path'] ) ); |
|
1865 | 1865 | } |
1866 | 1866 | |
1867 | 1867 | /** |
@@ -1875,7 +1875,7 @@ discard block |
||
1875 | 1875 | */ |
1876 | 1876 | public function can_plugin_update( $slug ) { |
1877 | 1877 | // We currently can't get reliable info on non-WP-repo plugins - issue #380. |
1878 | - if ( 'repo' !== $this->plugins[ $slug ]['source_type'] ) { |
|
1878 | + if ( 'repo' !== $this->plugins[$slug]['source_type'] ) { |
|
1879 | 1879 | return true; |
1880 | 1880 | } |
1881 | 1881 | |
@@ -1931,8 +1931,8 @@ discard block |
||
1931 | 1931 | public function get_installed_version( $slug ) { |
1932 | 1932 | $installed_plugins = $this->get_plugins(); // Retrieve a list of all installed plugins (WP cached). |
1933 | 1933 | |
1934 | - if ( ! empty( $installed_plugins[ $this->plugins[ $slug ]['file_path'] ]['Version'] ) ) { |
|
1935 | - return $installed_plugins[ $this->plugins[ $slug ]['file_path'] ]['Version']; |
|
1934 | + if ( ! empty( $installed_plugins[$this->plugins[$slug]['file_path']]['Version'] ) ) { |
|
1935 | + return $installed_plugins[$this->plugins[$slug]['file_path']]['Version']; |
|
1936 | 1936 | } |
1937 | 1937 | |
1938 | 1938 | return ''; |
@@ -1948,7 +1948,7 @@ discard block |
||
1948 | 1948 | */ |
1949 | 1949 | public function does_plugin_require_update( $slug ) { |
1950 | 1950 | $installed_version = $this->get_installed_version( $slug ); |
1951 | - $minimum_version = $this->plugins[ $slug ]['version']; |
|
1951 | + $minimum_version = $this->plugins[$slug]['version']; |
|
1952 | 1952 | |
1953 | 1953 | return version_compare( $minimum_version, $installed_version, '>' ); |
1954 | 1954 | } |
@@ -1963,9 +1963,9 @@ discard block |
||
1963 | 1963 | */ |
1964 | 1964 | public function does_plugin_have_update( $slug ) { |
1965 | 1965 | // Presume bundled and external plugins will point to a package which meets the minimum required version. |
1966 | - if ( 'repo' !== $this->plugins[ $slug ]['source_type'] ) { |
|
1966 | + if ( 'repo' !== $this->plugins[$slug]['source_type'] ) { |
|
1967 | 1967 | if ( $this->does_plugin_require_update( $slug ) ) { |
1968 | - return $this->plugins[ $slug ]['version']; |
|
1968 | + return $this->plugins[$slug]['version']; |
|
1969 | 1969 | } |
1970 | 1970 | |
1971 | 1971 | return false; |
@@ -1973,8 +1973,8 @@ discard block |
||
1973 | 1973 | |
1974 | 1974 | $repo_updates = get_site_transient( 'update_plugins' ); |
1975 | 1975 | |
1976 | - if ( isset( $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->new_version ) ) { |
|
1977 | - return $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->new_version; |
|
1976 | + if ( isset( $repo_updates->response[$this->plugins[$slug]['file_path']]->new_version ) ) { |
|
1977 | + return $repo_updates->response[$this->plugins[$slug]['file_path']]->new_version; |
|
1978 | 1978 | } |
1979 | 1979 | |
1980 | 1980 | return false; |
@@ -1990,14 +1990,14 @@ discard block |
||
1990 | 1990 | */ |
1991 | 1991 | public function get_upgrade_notice( $slug ) { |
1992 | 1992 | // We currently can't get reliable info on non-WP-repo plugins - issue #380. |
1993 | - if ( 'repo' !== $this->plugins[ $slug ]['source_type'] ) { |
|
1993 | + if ( 'repo' !== $this->plugins[$slug]['source_type'] ) { |
|
1994 | 1994 | return ''; |
1995 | 1995 | } |
1996 | 1996 | |
1997 | 1997 | $repo_updates = get_site_transient( 'update_plugins' ); |
1998 | 1998 | |
1999 | - if ( ! empty( $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->upgrade_notice ) ) { |
|
2000 | - return $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->upgrade_notice; |
|
1999 | + if ( ! empty( $repo_updates->response[$this->plugins[$slug]['file_path']]->upgrade_notice ) ) { |
|
2000 | + return $repo_updates->response[$this->plugins[$slug]['file_path']]->upgrade_notice; |
|
2001 | 2001 | } |
2002 | 2002 | |
2003 | 2003 | return ''; |
@@ -2081,7 +2081,7 @@ discard block |
||
2081 | 2081 | */ |
2082 | 2082 | if ( true === $plugin['force_deactivation'] && is_plugin_active( $plugin['file_path'] ) ) { |
2083 | 2083 | deactivate_plugins( $plugin['file_path'] ); |
2084 | - $deactivated[ $plugin['file_path'] ] = time(); |
|
2084 | + $deactivated[$plugin['file_path']] = time(); |
|
2085 | 2085 | } |
2086 | 2086 | } |
2087 | 2087 | |
@@ -2318,30 +2318,30 @@ discard block |
||
2318 | 2318 | $i = 0; |
2319 | 2319 | |
2320 | 2320 | // Redirect to the 'all' view if no plugins were found for the selected view context. |
2321 | - if ( empty( $plugins[ $this->view_context ] ) ) { |
|
2321 | + if ( empty( $plugins[$this->view_context] ) ) { |
|
2322 | 2322 | $this->view_context = 'all'; |
2323 | 2323 | } |
2324 | 2324 | |
2325 | - foreach ( $plugins[ $this->view_context ] as $slug => $plugin ) { |
|
2326 | - $table_data[ $i ]['sanitized_plugin'] = $plugin['name']; |
|
2327 | - $table_data[ $i ]['slug'] = $slug; |
|
2328 | - $table_data[ $i ]['plugin'] = '<strong>' . $this->tgmpa->get_info_link( $slug ) . '</strong>'; |
|
2329 | - $table_data[ $i ]['source'] = $this->get_plugin_source_type_text( $plugin['source_type'] ); |
|
2330 | - $table_data[ $i ]['type'] = $this->get_plugin_advise_type_text( $plugin['required'] ); |
|
2331 | - $table_data[ $i ]['status'] = $this->get_plugin_status_text( $slug ); |
|
2332 | - $table_data[ $i ]['installed_version'] = $this->tgmpa->get_installed_version( $slug ); |
|
2333 | - $table_data[ $i ]['minimum_version'] = $plugin['version']; |
|
2334 | - $table_data[ $i ]['available_version'] = $this->tgmpa->does_plugin_have_update( $slug ); |
|
2325 | + foreach ( $plugins[$this->view_context] as $slug => $plugin ) { |
|
2326 | + $table_data[$i]['sanitized_plugin'] = $plugin['name']; |
|
2327 | + $table_data[$i]['slug'] = $slug; |
|
2328 | + $table_data[$i]['plugin'] = '<strong>' . $this->tgmpa->get_info_link( $slug ) . '</strong>'; |
|
2329 | + $table_data[$i]['source'] = $this->get_plugin_source_type_text( $plugin['source_type'] ); |
|
2330 | + $table_data[$i]['type'] = $this->get_plugin_advise_type_text( $plugin['required'] ); |
|
2331 | + $table_data[$i]['status'] = $this->get_plugin_status_text( $slug ); |
|
2332 | + $table_data[$i]['installed_version'] = $this->tgmpa->get_installed_version( $slug ); |
|
2333 | + $table_data[$i]['minimum_version'] = $plugin['version']; |
|
2334 | + $table_data[$i]['available_version'] = $this->tgmpa->does_plugin_have_update( $slug ); |
|
2335 | 2335 | |
2336 | 2336 | // Prep the upgrade notice info. |
2337 | 2337 | $upgrade_notice = $this->tgmpa->get_upgrade_notice( $slug ); |
2338 | 2338 | if ( ! empty( $upgrade_notice ) ) { |
2339 | - $table_data[ $i ]['upgrade_notice'] = $upgrade_notice; |
|
2339 | + $table_data[$i]['upgrade_notice'] = $upgrade_notice; |
|
2340 | 2340 | |
2341 | 2341 | add_action( "tgmpa_after_plugin_row_{$slug}", array( $this, 'wp_plugin_update_row' ), 10, 2 ); |
2342 | 2342 | } |
2343 | 2343 | |
2344 | - $table_data[ $i ] = apply_filters( 'tgmpa_table_data_item', $table_data[ $i ], $plugin ); |
|
2344 | + $table_data[$i] = apply_filters( 'tgmpa_table_data_item', $table_data[$i], $plugin ); |
|
2345 | 2345 | |
2346 | 2346 | $i++; |
2347 | 2347 | } |
@@ -2367,17 +2367,17 @@ discard block |
||
2367 | 2367 | // No need to display plugins if they are installed, up-to-date and active. |
2368 | 2368 | continue; |
2369 | 2369 | } else { |
2370 | - $plugins['all'][ $slug ] = $plugin; |
|
2370 | + $plugins['all'][$slug] = $plugin; |
|
2371 | 2371 | |
2372 | 2372 | if ( ! $this->tgmpa->is_plugin_installed( $slug ) ) { |
2373 | - $plugins['install'][ $slug ] = $plugin; |
|
2373 | + $plugins['install'][$slug] = $plugin; |
|
2374 | 2374 | } else { |
2375 | 2375 | if ( false !== $this->tgmpa->does_plugin_have_update( $slug ) ) { |
2376 | - $plugins['update'][ $slug ] = $plugin; |
|
2376 | + $plugins['update'][$slug] = $plugin; |
|
2377 | 2377 | } |
2378 | 2378 | |
2379 | 2379 | if ( $this->tgmpa->can_plugin_activate( $slug ) ) { |
2380 | - $plugins['activate'][ $slug ] = $plugin; |
|
2380 | + $plugins['activate'][$slug] = $plugin; |
|
2381 | 2381 | } |
2382 | 2382 | } |
2383 | 2383 | } |
@@ -2395,7 +2395,7 @@ discard block |
||
2395 | 2395 | */ |
2396 | 2396 | protected function set_view_totals( $plugins ) { |
2397 | 2397 | foreach ( $plugins as $type => $list ) { |
2398 | - $this->view_totals[ $type ] = count( $list ); |
|
2398 | + $this->view_totals[$type] = count( $list ); |
|
2399 | 2399 | } |
2400 | 2400 | } |
2401 | 2401 | |
@@ -2497,8 +2497,8 @@ discard block |
||
2497 | 2497 | $name = array(); |
2498 | 2498 | |
2499 | 2499 | foreach ( $items as $i => $plugin ) { |
2500 | - $type[ $i ] = $plugin['type']; // Required / recommended. |
|
2501 | - $name[ $i ] = $plugin['sanitized_plugin']; |
|
2500 | + $type[$i] = $plugin['type']; // Required / recommended. |
|
2501 | + $name[$i] = $plugin['sanitized_plugin']; |
|
2502 | 2502 | } |
2503 | 2503 | |
2504 | 2504 | array_multisort( $type, SORT_DESC, $name, SORT_ASC, $items ); |
@@ -2545,7 +2545,7 @@ discard block |
||
2545 | 2545 | |
2546 | 2546 | if ( ! empty( $text ) ) { |
2547 | 2547 | |
2548 | - $status_links[ $type ] = sprintf( |
|
2548 | + $status_links[$type] = sprintf( |
|
2549 | 2549 | '<a href="%s"%s>%s</a>', |
2550 | 2550 | esc_url( $this->tgmpa->get_tgmpa_status_url( $type ) ), |
2551 | 2551 | ( $type === $this->view_context ) ? ' class="current"' : '', |
@@ -2568,7 +2568,7 @@ discard block |
||
2568 | 2568 | * @return string |
2569 | 2569 | */ |
2570 | 2570 | public function column_default( $item, $column_name ) { |
2571 | - return $item[ $column_name ]; |
|
2571 | + return $item[$column_name]; |
|
2572 | 2572 | } |
2573 | 2573 | |
2574 | 2574 | /** |
@@ -2768,7 +2768,7 @@ discard block |
||
2768 | 2768 | 'tgmpa-nonce' |
2769 | 2769 | ); |
2770 | 2770 | |
2771 | - $action_links[ $action ] = sprintf( |
|
2771 | + $action_links[$action] = sprintf( |
|
2772 | 2772 | '<a href="%1$s">' . esc_html( $text ) . '</a>', // $text contains the second placeholder. |
2773 | 2773 | esc_url( $nonce_url ), |
2774 | 2774 | '<span class="screen-reader-text">' . esc_html( $item['sanitized_plugin'] ) . '</span>' |
@@ -2919,19 +2919,19 @@ discard block |
||
2919 | 2919 | // Validate the received input. |
2920 | 2920 | foreach ( $plugins_to_install as $key => $slug ) { |
2921 | 2921 | // Check if the plugin was registered with TGMPA and remove if not. |
2922 | - if ( ! isset( $this->tgmpa->plugins[ $slug ] ) ) { |
|
2923 | - unset( $plugins_to_install[ $key ] ); |
|
2922 | + if ( ! isset( $this->tgmpa->plugins[$slug] ) ) { |
|
2923 | + unset( $plugins_to_install[$key] ); |
|
2924 | 2924 | continue; |
2925 | 2925 | } |
2926 | 2926 | |
2927 | 2927 | // For install: make sure this is a plugin we *can* install and not one already installed. |
2928 | 2928 | if ( 'install' === $install_type && true === $this->tgmpa->is_plugin_installed( $slug ) ) { |
2929 | - unset( $plugins_to_install[ $key ] ); |
|
2929 | + unset( $plugins_to_install[$key] ); |
|
2930 | 2930 | } |
2931 | 2931 | |
2932 | 2932 | // For updates: make sure this is a plugin we *can* update (update available and WP version ok). |
2933 | 2933 | if ( 'update' === $install_type && false === $this->tgmpa->is_plugin_updatetable( $slug ) ) { |
2934 | - unset( $plugins_to_install[ $key ] ); |
|
2934 | + unset( $plugins_to_install[$key] ); |
|
2935 | 2935 | } |
2936 | 2936 | } |
2937 | 2937 | |
@@ -2983,7 +2983,7 @@ discard block |
||
2983 | 2983 | |
2984 | 2984 | // Prepare the data for validated plugins for the install/upgrade. |
2985 | 2985 | foreach ( $plugins_to_install as $slug ) { |
2986 | - $name = $this->tgmpa->plugins[ $slug ]['name']; |
|
2986 | + $name = $this->tgmpa->plugins[$slug]['name']; |
|
2987 | 2987 | $source = $this->tgmpa->get_download_url( $slug ); |
2988 | 2988 | |
2989 | 2989 | if ( ! empty( $name ) && ! empty( $source ) ) { |
@@ -2996,9 +2996,9 @@ discard block |
||
2996 | 2996 | break; |
2997 | 2997 | |
2998 | 2998 | case 'update': |
2999 | - $file_paths[] = $this->tgmpa->plugins[ $slug ]['file_path']; |
|
3000 | - $to_inject[ $slug ] = $this->tgmpa->plugins[ $slug ]; |
|
3001 | - $to_inject[ $slug ]['source'] = $source; |
|
2999 | + $file_paths[] = $this->tgmpa->plugins[$slug]['file_path']; |
|
3000 | + $to_inject[$slug] = $this->tgmpa->plugins[$slug]; |
|
3001 | + $to_inject[$slug]['source'] = $source; |
|
3002 | 3002 | break; |
3003 | 3003 | } |
3004 | 3004 | } |
@@ -3065,8 +3065,8 @@ discard block |
||
3065 | 3065 | // Grab the file paths for the selected & inactive plugins from the registration array. |
3066 | 3066 | foreach ( $plugins as $slug ) { |
3067 | 3067 | if ( $this->tgmpa->can_plugin_activate( $slug ) ) { |
3068 | - $plugins_to_activate[] = $this->tgmpa->plugins[ $slug ]['file_path']; |
|
3069 | - $plugin_names[] = $this->tgmpa->plugins[ $slug ]['name']; |
|
3068 | + $plugins_to_activate[] = $this->tgmpa->plugins[$slug]['file_path']; |
|
3069 | + $plugin_names[] = $this->tgmpa->plugins[$slug]['name']; |
|
3070 | 3070 | } |
3071 | 3071 | } |
3072 | 3072 | unset( $slug ); |
@@ -3098,8 +3098,8 @@ discard block |
||
3098 | 3098 | // Update recently activated plugins option. |
3099 | 3099 | $recent = (array) get_option( 'recently_activated' ); |
3100 | 3100 | foreach ( $plugins_to_activate as $plugin => $time ) { |
3101 | - if ( isset( $recent[ $plugin ] ) ) { |
|
3102 | - unset( $recent[ $plugin ] ); |
|
3101 | + if ( isset( $recent[$plugin] ) ) { |
|
3102 | + unset( $recent[$plugin] ); |
|
3103 | 3103 | } |
3104 | 3104 | } |
3105 | 3105 | update_option( 'recently_activated', $recent ); |
@@ -3430,7 +3430,7 @@ discard block |
||
3430 | 3430 | ) |
3431 | 3431 | ); |
3432 | 3432 | |
3433 | - $results[ $plugin ] = $this->result; |
|
3433 | + $results[$plugin] = $this->result; |
|
3434 | 3434 | |
3435 | 3435 | // Prevent credentials auth screen from displaying multiple times. |
3436 | 3436 | if ( false === $result ) { |
@@ -3616,7 +3616,7 @@ discard block |
||
3616 | 3616 | 'names' => array(), |
3617 | 3617 | 'install_type' => 'install', |
3618 | 3618 | ); |
3619 | - $args = wp_parse_args( $args, $defaults ); |
|
3619 | + $args = wp_parse_args( $args, $defaults ); |
|
3620 | 3620 | |
3621 | 3621 | // Set plugin names to $this->plugin_names property. |
3622 | 3622 | $this->plugin_names = $args['names']; |
@@ -3673,7 +3673,7 @@ discard block |
||
3673 | 3673 | */ |
3674 | 3674 | public function before( $title = '' ) { |
3675 | 3675 | if ( empty( $title ) ) { |
3676 | - $title = esc_html( $this->plugin_names[ $this->i ] ); |
|
3676 | + $title = esc_html( $this->plugin_names[$this->i] ); |
|
3677 | 3677 | } |
3678 | 3678 | parent::before( $title ); |
3679 | 3679 | } |
@@ -3690,7 +3690,7 @@ discard block |
||
3690 | 3690 | */ |
3691 | 3691 | public function after( $title = '' ) { |
3692 | 3692 | if ( empty( $title ) ) { |
3693 | - $title = esc_html( $this->plugin_names[ $this->i ] ); |
|
3693 | + $title = esc_html( $this->plugin_names[$this->i] ); |
|
3694 | 3694 | } |
3695 | 3695 | parent::after( $title ); |
3696 | 3696 | |
@@ -3863,7 +3863,7 @@ discard block |
||
3863 | 3863 | */ |
3864 | 3864 | protected static function emulate_filter_bool( $value ) { |
3865 | 3865 | // @codingStandardsIgnoreStart |
3866 | - static $true = array( |
|
3866 | + static $true = array( |
|
3867 | 3867 | '1', |
3868 | 3868 | 'true', 'True', 'TRUE', |
3869 | 3869 | 'y', 'Y', |
@@ -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( |