@@ -717,11 +717,11 @@ discard block |
||
717 | 717 | $args = apply_filters( |
718 | 718 | 'tgmpa_admin_menu_args', |
719 | 719 | array( |
720 | - 'parent_slug' => $this->parent_slug, // Parent Menu slug. |
|
721 | - 'page_title' => $this->strings['page_title'], // Page title. |
|
722 | - 'menu_title' => $this->strings['menu_title'], // Menu title. |
|
723 | - 'capability' => $this->capability, // Capability. |
|
724 | - 'menu_slug' => $this->menu, // Menu slug. |
|
720 | + 'parent_slug' => $this->parent_slug, // Parent Menu slug. |
|
721 | + 'page_title' => $this->strings['page_title'], // Page title. |
|
722 | + 'menu_title' => $this->strings['menu_title'], // Menu title. |
|
723 | + 'capability' => $this->capability, // Capability. |
|
724 | + 'menu_slug' => $this->menu, // Menu slug. |
|
725 | 725 | 'function' => array( $this, 'install_plugins_page' ), // Callback. |
726 | 726 | ) |
727 | 727 | ); |
@@ -823,7 +823,7 @@ discard block |
||
823 | 823 | // All plugin information will be stored in an array for processing. |
824 | 824 | $slug = $this->sanitize_key( urldecode( $_GET['plugin'] ) ); |
825 | 825 | |
826 | - if ( ! isset( $this->plugins[ $slug ] ) ) { |
|
826 | + if ( ! isset( $this->plugins[$slug] ) ) { |
|
827 | 827 | return false; |
828 | 828 | } |
829 | 829 | |
@@ -868,7 +868,7 @@ discard block |
||
868 | 868 | $extra = array(); |
869 | 869 | $extra['slug'] = $slug; // Needed for potentially renaming of directory name. |
870 | 870 | $source = $this->get_download_url( $slug ); |
871 | - $api = ( 'repo' === $this->plugins[ $slug ]['source_type'] ) ? $this->get_plugins_api( $slug ) : null; |
|
871 | + $api = ( 'repo' === $this->plugins[$slug]['source_type'] ) ? $this->get_plugins_api( $slug ) : null; |
|
872 | 872 | $api = ( false !== $api ) ? $api : null; |
873 | 873 | |
874 | 874 | $url = add_query_arg( |
@@ -885,8 +885,8 @@ discard block |
||
885 | 885 | |
886 | 886 | $title = ( 'update' === $install_type ) ? $this->strings['updating'] : $this->strings['installing']; |
887 | 887 | $skin_args = array( |
888 | - 'type' => ( 'bundled' !== $this->plugins[ $slug ]['source_type'] ) ? 'web' : 'upload', |
|
889 | - 'title' => sprintf( $title, $this->plugins[ $slug ]['name'] ), |
|
888 | + 'type' => ( 'bundled' !== $this->plugins[$slug]['source_type'] ) ? 'web' : 'upload', |
|
889 | + 'title' => sprintf( $title, $this->plugins[$slug]['name'] ), |
|
890 | 890 | 'url' => esc_url_raw( $url ), |
891 | 891 | 'nonce' => $install_type . '-plugin_' . $slug, |
892 | 892 | 'plugin' => '', |
@@ -896,12 +896,12 @@ discard block |
||
896 | 896 | unset( $title ); |
897 | 897 | |
898 | 898 | if ( 'update' === $install_type ) { |
899 | - $skin_args['plugin'] = $this->plugins[ $slug ]['file_path']; |
|
899 | + $skin_args['plugin'] = $this->plugins[$slug]['file_path']; |
|
900 | 900 | $skin = new Plugin_Upgrader_Skin( $skin_args ); |
901 | 901 | } else { |
902 | 902 | |
903 | - if( $this->strict_versions === true && isset($this->plugins[ $slug ]['version']) && array_key_exists($this->plugins[ $slug ]['version'], $skin_args['api']->versions) ) { |
|
904 | - $skin_args['api']->version = $this->plugins[ $slug ]['version']; |
|
903 | + if ( $this->strict_versions === true && isset( $this->plugins[$slug]['version'] ) && array_key_exists( $this->plugins[$slug]['version'], $skin_args['api']->versions ) ) { |
|
904 | + $skin_args['api']->version = $this->plugins[$slug]['version']; |
|
905 | 905 | } |
906 | 906 | |
907 | 907 | $skin = new Plugin_Installer_Skin( $skin_args ); |
@@ -916,12 +916,12 @@ discard block |
||
916 | 916 | if ( 'update' === $install_type ) { |
917 | 917 | // Inject our info into the update transient. |
918 | 918 | $to_inject = array( |
919 | - $slug => $this->plugins[ $slug ], |
|
919 | + $slug => $this->plugins[$slug], |
|
920 | 920 | ); |
921 | - $to_inject[ $slug ]['source'] = $source; |
|
921 | + $to_inject[$slug]['source'] = $source; |
|
922 | 922 | $this->inject_update_info( $to_inject ); |
923 | 923 | |
924 | - $upgrader->upgrade( $this->plugins[ $slug ]['file_path'] ); |
|
924 | + $upgrader->upgrade( $this->plugins[$slug]['file_path'] ); |
|
925 | 925 | } else { |
926 | 926 | $upgrader->install( $source ); |
927 | 927 | } |
@@ -951,11 +951,11 @@ discard block |
||
951 | 951 | } |
952 | 952 | |
953 | 953 | return true; |
954 | - } elseif ( isset( $this->plugins[ $slug ]['file_path'], $_GET['tgmpa-activate'] ) && 'activate-plugin' === $_GET['tgmpa-activate'] ) { |
|
954 | + } elseif ( isset( $this->plugins[$slug]['file_path'], $_GET['tgmpa-activate'] ) && 'activate-plugin' === $_GET['tgmpa-activate'] ) { |
|
955 | 955 | // Activate action link was clicked. |
956 | 956 | check_admin_referer( 'tgmpa-activate', 'tgmpa-nonce' ); |
957 | 957 | |
958 | - if ( false === $this->activate_single_plugin( $this->plugins[ $slug ]['file_path'], $slug ) ) { |
|
958 | + if ( false === $this->activate_single_plugin( $this->plugins[$slug]['file_path'], $slug ) ) { |
|
959 | 959 | return true; // Finish execution of the function early as we encountered an error. |
960 | 960 | } |
961 | 961 | } |
@@ -980,17 +980,17 @@ discard block |
||
980 | 980 | foreach ( $plugins as $slug => $plugin ) { |
981 | 981 | $file_path = $plugin['file_path']; |
982 | 982 | |
983 | - if ( empty( $repo_updates->response[ $file_path ] ) ) { |
|
984 | - $repo_updates->response[ $file_path ] = new stdClass(); |
|
983 | + if ( empty( $repo_updates->response[$file_path] ) ) { |
|
984 | + $repo_updates->response[$file_path] = new stdClass(); |
|
985 | 985 | } |
986 | 986 | |
987 | 987 | // We only really need to set package, but let's do all we can in case WP changes something. |
988 | - $repo_updates->response[ $file_path ]->slug = $slug; |
|
989 | - $repo_updates->response[ $file_path ]->plugin = $file_path; |
|
990 | - $repo_updates->response[ $file_path ]->new_version = $plugin['version']; |
|
991 | - $repo_updates->response[ $file_path ]->package = $plugin['source']; |
|
992 | - if ( empty( $repo_updates->response[ $file_path ]->url ) && ! empty( $plugin['external_url'] ) ) { |
|
993 | - $repo_updates->response[ $file_path ]->url = $plugin['external_url']; |
|
988 | + $repo_updates->response[$file_path]->slug = $slug; |
|
989 | + $repo_updates->response[$file_path]->plugin = $file_path; |
|
990 | + $repo_updates->response[$file_path]->new_version = $plugin['version']; |
|
991 | + $repo_updates->response[$file_path]->package = $plugin['source']; |
|
992 | + if ( empty( $repo_updates->response[$file_path]->url ) && ! empty( $plugin['external_url'] ) ) { |
|
993 | + $repo_updates->response[$file_path]->url = $plugin['external_url']; |
|
994 | 994 | } |
995 | 995 | } |
996 | 996 | |
@@ -1033,7 +1033,7 @@ discard block |
||
1033 | 1033 | } else { |
1034 | 1034 | // Bulk installer contains less info, so fall back on the info registered here. |
1035 | 1035 | foreach ( $this->plugins as $slug => $plugin ) { |
1036 | - if ( ! empty( $upgrader->skin->plugin_names[ $upgrader->skin->i ] ) && $plugin['name'] === $upgrader->skin->plugin_names[ $upgrader->skin->i ] ) { |
|
1036 | + if ( ! empty( $upgrader->skin->plugin_names[$upgrader->skin->i] ) && $plugin['name'] === $upgrader->skin->plugin_names[$upgrader->skin->i] ) { |
|
1037 | 1037 | $desired_slug = $slug; |
1038 | 1038 | break; |
1039 | 1039 | } |
@@ -1101,7 +1101,7 @@ discard block |
||
1101 | 1101 | // immediately after a single activation. |
1102 | 1102 | // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Not using the superglobal. |
1103 | 1103 | if ( ! isset( $_POST['action'] ) ) { |
1104 | - echo '<div id="message" class="updated"><p>', esc_html( $this->strings['activated_successfully'] ), ' <strong>', esc_html( $this->plugins[ $slug ]['name'] ), '.</strong></p></div>'; |
|
1104 | + echo '<div id="message" class="updated"><p>', esc_html( $this->strings['activated_successfully'] ), ' <strong>', esc_html( $this->plugins[$slug]['name'] ), '.</strong></p></div>'; |
|
1105 | 1105 | } |
1106 | 1106 | } else { |
1107 | 1107 | // Simpler message layout for use on the plugin install page. |
@@ -1114,7 +1114,7 @@ discard block |
||
1114 | 1114 | echo '<div id="message" class="error"><p>', |
1115 | 1115 | sprintf( |
1116 | 1116 | esc_html( $this->strings['plugin_already_active'] ), |
1117 | - '<strong>' . esc_html( $this->plugins[ $slug ]['name'] ) . '</strong>' |
|
1117 | + '<strong>' . esc_html( $this->plugins[$slug]['name'] ) . '</strong>' |
|
1118 | 1118 | ), |
1119 | 1119 | '</p></div>'; |
1120 | 1120 | } elseif ( $this->does_plugin_require_update( $slug ) ) { |
@@ -1126,13 +1126,13 @@ discard block |
||
1126 | 1126 | echo '<div id="message" class="error"><p>', |
1127 | 1127 | sprintf( |
1128 | 1128 | esc_html( $this->strings['plugin_needs_higher_version'] ), |
1129 | - '<strong>' . esc_html( $this->plugins[ $slug ]['name'] ) . '</strong>' |
|
1129 | + '<strong>' . esc_html( $this->plugins[$slug]['name'] ) . '</strong>' |
|
1130 | 1130 | ), |
1131 | 1131 | '</p></div>'; |
1132 | 1132 | } |
1133 | 1133 | } else { |
1134 | 1134 | // Simpler message layout for use on the plugin install page. |
1135 | - echo '<p>', sprintf( esc_html( $this->strings['plugin_needs_higher_version'] ), esc_html( $this->plugins[ $slug ]['name'] ) ), '</p>'; |
|
1135 | + echo '<p>', sprintf( esc_html( $this->strings['plugin_needs_higher_version'] ), esc_html( $this->plugins[$slug]['name'] ) ), '</p>'; |
|
1136 | 1136 | } |
1137 | 1137 | } |
1138 | 1138 | |
@@ -1259,7 +1259,7 @@ discard block |
||
1259 | 1259 | $rendered .= sprintf( |
1260 | 1260 | $line_template, |
1261 | 1261 | sprintf( |
1262 | - translate_nooped_plural( $this->strings[ $type ], $count, 'tgmpa' ), |
|
1262 | + translate_nooped_plural( $this->strings[$type], $count, 'tgmpa' ), |
|
1263 | 1263 | $imploded, |
1264 | 1264 | $count |
1265 | 1265 | ) |
@@ -1376,7 +1376,7 @@ discard block |
||
1376 | 1376 | |
1377 | 1377 | foreach ( (array) $wp_settings_errors as $key => $details ) { |
1378 | 1378 | if ( 'tgmpa' === $details['setting'] ) { |
1379 | - unset( $wp_settings_errors[ $key ] ); |
|
1379 | + unset( $wp_settings_errors[$key] ); |
|
1380 | 1380 | break; |
1381 | 1381 | } |
1382 | 1382 | } |
@@ -1412,20 +1412,20 @@ discard block |
||
1412 | 1412 | return; |
1413 | 1413 | } |
1414 | 1414 | |
1415 | - if ( empty( $plugin['slug'] ) || ! is_string( $plugin['slug'] ) || isset( $this->plugins[ $plugin['slug'] ] ) ) { |
|
1415 | + if ( empty( $plugin['slug'] ) || ! is_string( $plugin['slug'] ) || isset( $this->plugins[$plugin['slug']] ) ) { |
|
1416 | 1416 | return; |
1417 | 1417 | } |
1418 | 1418 | |
1419 | 1419 | $defaults = array( |
1420 | - 'name' => '', // String. |
|
1421 | - 'slug' => '', // String. |
|
1422 | - 'source' => 'repo', // String. |
|
1423 | - 'required' => false, // Boolean. |
|
1424 | - 'version' => '', // String. |
|
1425 | - 'force_activation' => false, // Boolean. |
|
1426 | - 'force_deactivation' => false, // Boolean. |
|
1427 | - 'external_url' => '', // String. |
|
1428 | - 'is_callable' => '', // String or array. |
|
1420 | + 'name' => '', // String. |
|
1421 | + 'slug' => '', // String. |
|
1422 | + 'source' => 'repo', // String. |
|
1423 | + 'required' => false, // Boolean. |
|
1424 | + 'version' => '', // String. |
|
1425 | + 'force_activation' => false, // Boolean. |
|
1426 | + 'force_deactivation' => false, // Boolean. |
|
1427 | + 'external_url' => '', // String. |
|
1428 | + 'is_callable' => '', // String or array. |
|
1429 | 1429 | ); |
1430 | 1430 | |
1431 | 1431 | // Prepare the received data. |
@@ -1446,8 +1446,8 @@ discard block |
||
1446 | 1446 | $plugin['source_type'] = $this->get_plugin_source_type( $plugin['source'] ); |
1447 | 1447 | |
1448 | 1448 | // Set the class properties. |
1449 | - $this->plugins[ $plugin['slug'] ] = $plugin; |
|
1450 | - $this->sort_order[ $plugin['slug'] ] = $plugin['name']; |
|
1449 | + $this->plugins[$plugin['slug']] = $plugin; |
|
1450 | + $this->sort_order[$plugin['slug']] = $plugin['name']; |
|
1451 | 1451 | |
1452 | 1452 | // Should we add the force activation hook ? |
1453 | 1453 | if ( true === $plugin['force_activation'] ) { |
@@ -1532,11 +1532,11 @@ discard block |
||
1532 | 1532 | ); |
1533 | 1533 | |
1534 | 1534 | foreach ( $keys as $key ) { |
1535 | - if ( isset( $config[ $key ] ) ) { |
|
1536 | - if ( is_array( $config[ $key ] ) ) { |
|
1537 | - $this->$key = array_merge( $this->$key, $config[ $key ] ); |
|
1535 | + if ( isset( $config[$key] ) ) { |
|
1536 | + if ( is_array( $config[$key] ) ) { |
|
1537 | + $this->$key = array_merge( $this->$key, $config[$key] ); |
|
1538 | 1538 | } else { |
1539 | - $this->$key = $config[ $key ]; |
|
1539 | + $this->$key = $config[$key]; |
|
1540 | 1540 | } |
1541 | 1541 | } |
1542 | 1542 | } |
@@ -1581,12 +1581,12 @@ discard block |
||
1581 | 1581 | * Parameter added in v2.5.0. |
1582 | 1582 | */ |
1583 | 1583 | public function populate_file_path( $plugin_slug = '' ) { |
1584 | - if ( ! empty( $plugin_slug ) && is_string( $plugin_slug ) && isset( $this->plugins[ $plugin_slug ] ) ) { |
|
1585 | - $this->plugins[ $plugin_slug ]['file_path'] = $this->_get_plugin_basename_from_slug( $plugin_slug ); |
|
1584 | + if ( ! empty( $plugin_slug ) && is_string( $plugin_slug ) && isset( $this->plugins[$plugin_slug] ) ) { |
|
1585 | + $this->plugins[$plugin_slug]['file_path'] = $this->_get_plugin_basename_from_slug( $plugin_slug ); |
|
1586 | 1586 | } else { |
1587 | 1587 | // Add file_path key for all plugins. |
1588 | 1588 | foreach ( $this->plugins as $slug => $values ) { |
1589 | - $this->plugins[ $slug ]['file_path'] = $this->_get_plugin_basename_from_slug( $slug ); |
|
1589 | + $this->plugins[$slug]['file_path'] = $this->_get_plugin_basename_from_slug( $slug ); |
|
1590 | 1590 | } |
1591 | 1591 | } |
1592 | 1592 | } |
@@ -1626,8 +1626,8 @@ discard block |
||
1626 | 1626 | */ |
1627 | 1627 | public function _get_plugin_data_from_name( $name, $data = 'slug' ) { |
1628 | 1628 | foreach ( $this->plugins as $values ) { |
1629 | - if ( $name === $values['name'] && isset( $values[ $data ] ) ) { |
|
1630 | - return $values[ $data ]; |
|
1629 | + if ( $name === $values['name'] && isset( $values[$data] ) ) { |
|
1630 | + return $values[$data]; |
|
1631 | 1631 | } |
1632 | 1632 | } |
1633 | 1633 | |
@@ -1645,13 +1645,13 @@ discard block |
||
1645 | 1645 | public function get_download_url( $slug ) { |
1646 | 1646 | $dl_source = ''; |
1647 | 1647 | |
1648 | - switch ( $this->plugins[ $slug ]['source_type'] ) { |
|
1648 | + switch ( $this->plugins[$slug]['source_type'] ) { |
|
1649 | 1649 | case 'repo': |
1650 | 1650 | return $this->get_wp_repo_download_url( $slug ); |
1651 | 1651 | case 'external': |
1652 | - return $this->plugins[ $slug ]['source']; |
|
1652 | + return $this->plugins[$slug]['source']; |
|
1653 | 1653 | case 'bundled': |
1654 | - return $this->default_path . $this->plugins[ $slug ]['source']; |
|
1654 | + return $this->default_path . $this->plugins[$slug]['source']; |
|
1655 | 1655 | } |
1656 | 1656 | |
1657 | 1657 | return $dl_source; // Should never happen. |
@@ -1671,12 +1671,12 @@ discard block |
||
1671 | 1671 | |
1672 | 1672 | if ( false !== $api && isset( $api->download_link ) ) { |
1673 | 1673 | |
1674 | - if($this->strict_versions === true){ |
|
1675 | - $version = isset($this->plugins[$slug]['version']) ? $this->plugins[$slug]['version'] : ''; |
|
1674 | + if ( $this->strict_versions === true ) { |
|
1675 | + $version = isset( $this->plugins[$slug]['version'] ) ? $this->plugins[$slug]['version'] : ''; |
|
1676 | 1676 | $versions = $api->versions; |
1677 | - $source = isset($versions[$version]) ? $versions[$version] : $api->download_link; |
|
1677 | + $source = isset( $versions[$version] ) ? $versions[$version] : $api->download_link; |
|
1678 | 1678 | } |
1679 | - else{ |
|
1679 | + else { |
|
1680 | 1680 | $source = $api->download_link; |
1681 | 1681 | } |
1682 | 1682 | |
@@ -1696,7 +1696,7 @@ discard block |
||
1696 | 1696 | protected function get_plugins_api( $slug ) { |
1697 | 1697 | static $api = array(); // Cache received responses. |
1698 | 1698 | |
1699 | - if ( ! isset( $api[ $slug ] ) ) { |
|
1699 | + if ( ! isset( $api[$slug] ) ) { |
|
1700 | 1700 | if ( ! function_exists( 'plugins_api' ) ) { |
1701 | 1701 | require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; |
1702 | 1702 | } |
@@ -1711,16 +1711,16 @@ discard block |
||
1711 | 1711 | ) |
1712 | 1712 | ); |
1713 | 1713 | |
1714 | - $api[ $slug ] = false; |
|
1714 | + $api[$slug] = false; |
|
1715 | 1715 | |
1716 | 1716 | if ( is_wp_error( $response ) ) { |
1717 | 1717 | wp_die( esc_html( $this->strings['oops'] ) ); |
1718 | 1718 | } else { |
1719 | - $api[ $slug ] = $response; |
|
1719 | + $api[$slug] = $response; |
|
1720 | 1720 | } |
1721 | 1721 | } |
1722 | 1722 | |
1723 | - return $api[ $slug ]; |
|
1723 | + return $api[$slug]; |
|
1724 | 1724 | } |
1725 | 1725 | |
1726 | 1726 | /** |
@@ -1733,13 +1733,13 @@ discard block |
||
1733 | 1733 | * or the plugin name if not. |
1734 | 1734 | */ |
1735 | 1735 | public function get_info_link( $slug ) { |
1736 | - if ( ! empty( $this->plugins[ $slug ]['external_url'] ) && preg_match( self::IS_URL_REGEX, $this->plugins[ $slug ]['external_url'] ) ) { |
|
1736 | + if ( ! empty( $this->plugins[$slug]['external_url'] ) && preg_match( self::IS_URL_REGEX, $this->plugins[$slug]['external_url'] ) ) { |
|
1737 | 1737 | $link = sprintf( |
1738 | 1738 | '<a href="%1$s" target="_blank">%2$s</a>', |
1739 | - esc_url( $this->plugins[ $slug ]['external_url'] ), |
|
1740 | - esc_html( $this->plugins[ $slug ]['name'] ) |
|
1739 | + esc_url( $this->plugins[$slug]['external_url'] ), |
|
1740 | + esc_html( $this->plugins[$slug]['name'] ) |
|
1741 | 1741 | ); |
1742 | - } elseif ( 'repo' === $this->plugins[ $slug ]['source_type'] ) { |
|
1742 | + } elseif ( 'repo' === $this->plugins[$slug]['source_type'] ) { |
|
1743 | 1743 | $url = add_query_arg( |
1744 | 1744 | array( |
1745 | 1745 | 'tab' => 'plugin-information', |
@@ -1754,10 +1754,10 @@ discard block |
||
1754 | 1754 | $link = sprintf( |
1755 | 1755 | '<a href="%1$s" class="thickbox">%2$s</a>', |
1756 | 1756 | esc_url( $url ), |
1757 | - esc_html( $this->plugins[ $slug ]['name'] ) |
|
1757 | + esc_html( $this->plugins[$slug]['name'] ) |
|
1758 | 1758 | ); |
1759 | 1759 | } else { |
1760 | - $link = esc_html( $this->plugins[ $slug ]['name'] ); // No hyperlink. |
|
1760 | + $link = esc_html( $this->plugins[$slug]['name'] ); // No hyperlink. |
|
1761 | 1761 | } |
1762 | 1762 | |
1763 | 1763 | return $link; |
@@ -1882,7 +1882,7 @@ discard block |
||
1882 | 1882 | public function is_plugin_installed( $slug ) { |
1883 | 1883 | $installed_plugins = $this->get_plugins(); // Retrieve a list of all installed plugins (WP cached). |
1884 | 1884 | |
1885 | - return ( ! empty( $installed_plugins[ $this->plugins[ $slug ]['file_path'] ] ) ); |
|
1885 | + return ( ! empty( $installed_plugins[$this->plugins[$slug]['file_path']] ) ); |
|
1886 | 1886 | } |
1887 | 1887 | |
1888 | 1888 | /** |
@@ -1894,7 +1894,7 @@ discard block |
||
1894 | 1894 | * @return bool True if active, false otherwise. |
1895 | 1895 | */ |
1896 | 1896 | public function is_plugin_active( $slug ) { |
1897 | - return ( ( ! empty( $this->plugins[ $slug ]['is_callable'] ) && is_callable( $this->plugins[ $slug ]['is_callable'] ) ) || is_plugin_active( $this->plugins[ $slug ]['file_path'] ) ); |
|
1897 | + return ( ( ! empty( $this->plugins[$slug]['is_callable'] ) && is_callable( $this->plugins[$slug]['is_callable'] ) ) || is_plugin_active( $this->plugins[$slug]['file_path'] ) ); |
|
1898 | 1898 | } |
1899 | 1899 | |
1900 | 1900 | /** |
@@ -1908,7 +1908,7 @@ discard block |
||
1908 | 1908 | */ |
1909 | 1909 | public function can_plugin_update( $slug ) { |
1910 | 1910 | // We currently can't get reliable info on non-WP-repo plugins - issue #380. |
1911 | - if ( 'repo' !== $this->plugins[ $slug ]['source_type'] ) { |
|
1911 | + if ( 'repo' !== $this->plugins[$slug]['source_type'] ) { |
|
1912 | 1912 | return true; |
1913 | 1913 | } |
1914 | 1914 | |
@@ -1964,8 +1964,8 @@ discard block |
||
1964 | 1964 | public function get_installed_version( $slug ) { |
1965 | 1965 | $installed_plugins = $this->get_plugins(); // Retrieve a list of all installed plugins (WP cached). |
1966 | 1966 | |
1967 | - if ( ! empty( $installed_plugins[ $this->plugins[ $slug ]['file_path'] ]['Version'] ) ) { |
|
1968 | - return $installed_plugins[ $this->plugins[ $slug ]['file_path'] ]['Version']; |
|
1967 | + if ( ! empty( $installed_plugins[$this->plugins[$slug]['file_path']]['Version'] ) ) { |
|
1968 | + return $installed_plugins[$this->plugins[$slug]['file_path']]['Version']; |
|
1969 | 1969 | } |
1970 | 1970 | |
1971 | 1971 | return ''; |
@@ -1981,7 +1981,7 @@ discard block |
||
1981 | 1981 | */ |
1982 | 1982 | public function does_plugin_require_update( $slug ) { |
1983 | 1983 | $installed_version = $this->get_installed_version( $slug ); |
1984 | - $minimum_version = $this->plugins[ $slug ]['version']; |
|
1984 | + $minimum_version = $this->plugins[$slug]['version']; |
|
1985 | 1985 | |
1986 | 1986 | return version_compare( $minimum_version, $installed_version, '>' ); |
1987 | 1987 | } |
@@ -1996,9 +1996,9 @@ discard block |
||
1996 | 1996 | */ |
1997 | 1997 | public function does_plugin_have_update( $slug ) { |
1998 | 1998 | // Presume bundled and external plugins will point to a package which meets the minimum required version. |
1999 | - if ( 'repo' !== $this->plugins[ $slug ]['source_type'] ) { |
|
1999 | + if ( 'repo' !== $this->plugins[$slug]['source_type'] ) { |
|
2000 | 2000 | if ( $this->does_plugin_require_update( $slug ) ) { |
2001 | - return $this->plugins[ $slug ]['version']; |
|
2001 | + return $this->plugins[$slug]['version']; |
|
2002 | 2002 | } |
2003 | 2003 | |
2004 | 2004 | return false; |
@@ -2006,8 +2006,8 @@ discard block |
||
2006 | 2006 | |
2007 | 2007 | $repo_updates = get_site_transient( 'update_plugins' ); |
2008 | 2008 | |
2009 | - if ( isset( $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->new_version ) ) { |
|
2010 | - return $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->new_version; |
|
2009 | + if ( isset( $repo_updates->response[$this->plugins[$slug]['file_path']]->new_version ) ) { |
|
2010 | + return $repo_updates->response[$this->plugins[$slug]['file_path']]->new_version; |
|
2011 | 2011 | } |
2012 | 2012 | |
2013 | 2013 | return false; |
@@ -2023,14 +2023,14 @@ discard block |
||
2023 | 2023 | */ |
2024 | 2024 | public function get_upgrade_notice( $slug ) { |
2025 | 2025 | // We currently can't get reliable info on non-WP-repo plugins - issue #380. |
2026 | - if ( 'repo' !== $this->plugins[ $slug ]['source_type'] ) { |
|
2026 | + if ( 'repo' !== $this->plugins[$slug]['source_type'] ) { |
|
2027 | 2027 | return ''; |
2028 | 2028 | } |
2029 | 2029 | |
2030 | 2030 | $repo_updates = get_site_transient( 'update_plugins' ); |
2031 | 2031 | |
2032 | - if ( ! empty( $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->upgrade_notice ) ) { |
|
2033 | - return $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->upgrade_notice; |
|
2032 | + if ( ! empty( $repo_updates->response[$this->plugins[$slug]['file_path']]->upgrade_notice ) ) { |
|
2033 | + return $repo_updates->response[$this->plugins[$slug]['file_path']]->upgrade_notice; |
|
2034 | 2034 | } |
2035 | 2035 | |
2036 | 2036 | return ''; |
@@ -2114,7 +2114,7 @@ discard block |
||
2114 | 2114 | */ |
2115 | 2115 | if ( true === $plugin['force_deactivation'] && is_plugin_active( $plugin['file_path'] ) ) { |
2116 | 2116 | deactivate_plugins( $plugin['file_path'] ); |
2117 | - $deactivated[ $plugin['file_path'] ] = time(); |
|
2117 | + $deactivated[$plugin['file_path']] = time(); |
|
2118 | 2118 | } |
2119 | 2119 | } |
2120 | 2120 | |
@@ -2351,30 +2351,30 @@ discard block |
||
2351 | 2351 | $i = 0; |
2352 | 2352 | |
2353 | 2353 | // Redirect to the 'all' view if no plugins were found for the selected view context. |
2354 | - if ( empty( $plugins[ $this->view_context ] ) ) { |
|
2354 | + if ( empty( $plugins[$this->view_context] ) ) { |
|
2355 | 2355 | $this->view_context = 'all'; |
2356 | 2356 | } |
2357 | 2357 | |
2358 | - foreach ( $plugins[ $this->view_context ] as $slug => $plugin ) { |
|
2359 | - $table_data[ $i ]['sanitized_plugin'] = $plugin['name']; |
|
2360 | - $table_data[ $i ]['slug'] = $slug; |
|
2361 | - $table_data[ $i ]['plugin'] = '<strong>' . $this->tgmpa->get_info_link( $slug ) . '</strong>'; |
|
2362 | - $table_data[ $i ]['source'] = $this->get_plugin_source_type_text( $plugin['source_type'] ); |
|
2363 | - $table_data[ $i ]['type'] = $this->get_plugin_advise_type_text( $plugin['required'] ); |
|
2364 | - $table_data[ $i ]['status'] = $this->get_plugin_status_text( $slug ); |
|
2365 | - $table_data[ $i ]['installed_version'] = $this->tgmpa->get_installed_version( $slug ); |
|
2366 | - $table_data[ $i ]['minimum_version'] = $plugin['version']; |
|
2367 | - $table_data[ $i ]['available_version'] = $this->tgmpa->does_plugin_have_update( $slug ); |
|
2358 | + foreach ( $plugins[$this->view_context] as $slug => $plugin ) { |
|
2359 | + $table_data[$i]['sanitized_plugin'] = $plugin['name']; |
|
2360 | + $table_data[$i]['slug'] = $slug; |
|
2361 | + $table_data[$i]['plugin'] = '<strong>' . $this->tgmpa->get_info_link( $slug ) . '</strong>'; |
|
2362 | + $table_data[$i]['source'] = $this->get_plugin_source_type_text( $plugin['source_type'] ); |
|
2363 | + $table_data[$i]['type'] = $this->get_plugin_advise_type_text( $plugin['required'] ); |
|
2364 | + $table_data[$i]['status'] = $this->get_plugin_status_text( $slug ); |
|
2365 | + $table_data[$i]['installed_version'] = $this->tgmpa->get_installed_version( $slug ); |
|
2366 | + $table_data[$i]['minimum_version'] = $plugin['version']; |
|
2367 | + $table_data[$i]['available_version'] = $this->tgmpa->does_plugin_have_update( $slug ); |
|
2368 | 2368 | |
2369 | 2369 | // Prep the upgrade notice info. |
2370 | 2370 | $upgrade_notice = $this->tgmpa->get_upgrade_notice( $slug ); |
2371 | 2371 | if ( ! empty( $upgrade_notice ) ) { |
2372 | - $table_data[ $i ]['upgrade_notice'] = $upgrade_notice; |
|
2372 | + $table_data[$i]['upgrade_notice'] = $upgrade_notice; |
|
2373 | 2373 | |
2374 | 2374 | add_action( "tgmpa_after_plugin_row_{$slug}", array( $this, 'wp_plugin_update_row' ), 10, 2 ); |
2375 | 2375 | } |
2376 | 2376 | |
2377 | - $table_data[ $i ] = apply_filters( 'tgmpa_table_data_item', $table_data[ $i ], $plugin ); |
|
2377 | + $table_data[$i] = apply_filters( 'tgmpa_table_data_item', $table_data[$i], $plugin ); |
|
2378 | 2378 | |
2379 | 2379 | $i++; |
2380 | 2380 | } |
@@ -2400,17 +2400,17 @@ discard block |
||
2400 | 2400 | // No need to display plugins if they are installed, up-to-date and active. |
2401 | 2401 | continue; |
2402 | 2402 | } else { |
2403 | - $plugins['all'][ $slug ] = $plugin; |
|
2403 | + $plugins['all'][$slug] = $plugin; |
|
2404 | 2404 | |
2405 | 2405 | if ( ! $this->tgmpa->is_plugin_installed( $slug ) ) { |
2406 | - $plugins['install'][ $slug ] = $plugin; |
|
2406 | + $plugins['install'][$slug] = $plugin; |
|
2407 | 2407 | } else { |
2408 | 2408 | if ( false !== $this->tgmpa->does_plugin_have_update( $slug ) ) { |
2409 | - $plugins['update'][ $slug ] = $plugin; |
|
2409 | + $plugins['update'][$slug] = $plugin; |
|
2410 | 2410 | } |
2411 | 2411 | |
2412 | 2412 | if ( $this->tgmpa->can_plugin_activate( $slug ) ) { |
2413 | - $plugins['activate'][ $slug ] = $plugin; |
|
2413 | + $plugins['activate'][$slug] = $plugin; |
|
2414 | 2414 | } |
2415 | 2415 | } |
2416 | 2416 | } |
@@ -2428,7 +2428,7 @@ discard block |
||
2428 | 2428 | */ |
2429 | 2429 | protected function set_view_totals( $plugins ) { |
2430 | 2430 | foreach ( $plugins as $type => $list ) { |
2431 | - $this->view_totals[ $type ] = count( $list ); |
|
2431 | + $this->view_totals[$type] = count( $list ); |
|
2432 | 2432 | } |
2433 | 2433 | } |
2434 | 2434 | |
@@ -2530,8 +2530,8 @@ discard block |
||
2530 | 2530 | $name = array(); |
2531 | 2531 | |
2532 | 2532 | foreach ( $items as $i => $plugin ) { |
2533 | - $type[ $i ] = $plugin['type']; // Required / recommended. |
|
2534 | - $name[ $i ] = $plugin['sanitized_plugin']; |
|
2533 | + $type[$i] = $plugin['type']; // Required / recommended. |
|
2534 | + $name[$i] = $plugin['sanitized_plugin']; |
|
2535 | 2535 | } |
2536 | 2536 | |
2537 | 2537 | array_multisort( $type, SORT_DESC, $name, SORT_ASC, $items ); |
@@ -2578,7 +2578,7 @@ discard block |
||
2578 | 2578 | |
2579 | 2579 | if ( ! empty( $text ) ) { |
2580 | 2580 | |
2581 | - $status_links[ $type ] = sprintf( |
|
2581 | + $status_links[$type] = sprintf( |
|
2582 | 2582 | '<a href="%s"%s>%s</a>', |
2583 | 2583 | esc_url( $this->tgmpa->get_tgmpa_status_url( $type ) ), |
2584 | 2584 | ( $type === $this->view_context ) ? ' class="current"' : '', |
@@ -2601,7 +2601,7 @@ discard block |
||
2601 | 2601 | * @return string |
2602 | 2602 | */ |
2603 | 2603 | public function column_default( $item, $column_name ) { |
2604 | - return $item[ $column_name ]; |
|
2604 | + return $item[$column_name]; |
|
2605 | 2605 | } |
2606 | 2606 | |
2607 | 2607 | /** |
@@ -2801,7 +2801,7 @@ discard block |
||
2801 | 2801 | 'tgmpa-nonce' |
2802 | 2802 | ); |
2803 | 2803 | |
2804 | - $action_links[ $action ] = sprintf( |
|
2804 | + $action_links[$action] = sprintf( |
|
2805 | 2805 | '<a href="%1$s">' . esc_html( $text ) . '</a>', // $text contains the second placeholder. |
2806 | 2806 | esc_url( $nonce_url ), |
2807 | 2807 | '<span class="screen-reader-text">' . esc_html( $item['sanitized_plugin'] ) . '</span>' |
@@ -2952,19 +2952,19 @@ discard block |
||
2952 | 2952 | // Validate the received input. |
2953 | 2953 | foreach ( $plugins_to_install as $key => $slug ) { |
2954 | 2954 | // Check if the plugin was registered with TGMPA and remove if not. |
2955 | - if ( ! isset( $this->tgmpa->plugins[ $slug ] ) ) { |
|
2956 | - unset( $plugins_to_install[ $key ] ); |
|
2955 | + if ( ! isset( $this->tgmpa->plugins[$slug] ) ) { |
|
2956 | + unset( $plugins_to_install[$key] ); |
|
2957 | 2957 | continue; |
2958 | 2958 | } |
2959 | 2959 | |
2960 | 2960 | // For install: make sure this is a plugin we *can* install and not one already installed. |
2961 | 2961 | if ( 'install' === $install_type && true === $this->tgmpa->is_plugin_installed( $slug ) ) { |
2962 | - unset( $plugins_to_install[ $key ] ); |
|
2962 | + unset( $plugins_to_install[$key] ); |
|
2963 | 2963 | } |
2964 | 2964 | |
2965 | 2965 | // For updates: make sure this is a plugin we *can* update (update available and WP version ok). |
2966 | 2966 | if ( 'update' === $install_type && false === $this->tgmpa->is_plugin_updatetable( $slug ) ) { |
2967 | - unset( $plugins_to_install[ $key ] ); |
|
2967 | + unset( $plugins_to_install[$key] ); |
|
2968 | 2968 | } |
2969 | 2969 | } |
2970 | 2970 | |
@@ -3016,7 +3016,7 @@ discard block |
||
3016 | 3016 | |
3017 | 3017 | // Prepare the data for validated plugins for the install/upgrade. |
3018 | 3018 | foreach ( $plugins_to_install as $slug ) { |
3019 | - $name = $this->tgmpa->plugins[ $slug ]['name']; |
|
3019 | + $name = $this->tgmpa->plugins[$slug]['name']; |
|
3020 | 3020 | $source = $this->tgmpa->get_download_url( $slug ); |
3021 | 3021 | |
3022 | 3022 | if ( ! empty( $name ) && ! empty( $source ) ) { |
@@ -3029,9 +3029,9 @@ discard block |
||
3029 | 3029 | break; |
3030 | 3030 | |
3031 | 3031 | case 'update': |
3032 | - $file_paths[] = $this->tgmpa->plugins[ $slug ]['file_path']; |
|
3033 | - $to_inject[ $slug ] = $this->tgmpa->plugins[ $slug ]; |
|
3034 | - $to_inject[ $slug ]['source'] = $source; |
|
3032 | + $file_paths[] = $this->tgmpa->plugins[$slug]['file_path']; |
|
3033 | + $to_inject[$slug] = $this->tgmpa->plugins[$slug]; |
|
3034 | + $to_inject[$slug]['source'] = $source; |
|
3035 | 3035 | break; |
3036 | 3036 | } |
3037 | 3037 | } |
@@ -3098,8 +3098,8 @@ discard block |
||
3098 | 3098 | // Grab the file paths for the selected & inactive plugins from the registration array. |
3099 | 3099 | foreach ( $plugins as $slug ) { |
3100 | 3100 | if ( $this->tgmpa->can_plugin_activate( $slug ) ) { |
3101 | - $plugins_to_activate[] = $this->tgmpa->plugins[ $slug ]['file_path']; |
|
3102 | - $plugin_names[] = $this->tgmpa->plugins[ $slug ]['name']; |
|
3101 | + $plugins_to_activate[] = $this->tgmpa->plugins[$slug]['file_path']; |
|
3102 | + $plugin_names[] = $this->tgmpa->plugins[$slug]['name']; |
|
3103 | 3103 | } |
3104 | 3104 | } |
3105 | 3105 | unset( $slug ); |
@@ -3132,8 +3132,8 @@ discard block |
||
3132 | 3132 | // Update recently activated plugins option. |
3133 | 3133 | $recent = (array) get_option( 'recently_activated' ); |
3134 | 3134 | foreach ( $plugins_to_activate as $plugin => $time ) { |
3135 | - if ( isset( $recent[ $plugin ] ) ) { |
|
3136 | - unset( $recent[ $plugin ] ); |
|
3135 | + if ( isset( $recent[$plugin] ) ) { |
|
3136 | + unset( $recent[$plugin] ); |
|
3137 | 3137 | } |
3138 | 3138 | } |
3139 | 3139 | update_option( 'recently_activated', $recent ); |
@@ -3464,7 +3464,7 @@ discard block |
||
3464 | 3464 | ) |
3465 | 3465 | ); |
3466 | 3466 | |
3467 | - $results[ $plugin ] = $this->result; |
|
3467 | + $results[$plugin] = $this->result; |
|
3468 | 3468 | |
3469 | 3469 | // Prevent credentials auth screen from displaying multiple times. |
3470 | 3470 | if ( false === $result ) { |
@@ -3655,7 +3655,7 @@ discard block |
||
3655 | 3655 | 'names' => array(), |
3656 | 3656 | 'install_type' => 'install', |
3657 | 3657 | ); |
3658 | - $args = wp_parse_args( $args, $defaults ); |
|
3658 | + $args = wp_parse_args( $args, $defaults ); |
|
3659 | 3659 | |
3660 | 3660 | // Set plugin names to $this->plugin_names property. |
3661 | 3661 | $this->plugin_names = $args['names']; |
@@ -3717,7 +3717,7 @@ discard block |
||
3717 | 3717 | */ |
3718 | 3718 | public function before( $title = '' ) { |
3719 | 3719 | if ( empty( $title ) ) { |
3720 | - $title = esc_html( $this->plugin_names[ $this->i ] ); |
|
3720 | + $title = esc_html( $this->plugin_names[$this->i] ); |
|
3721 | 3721 | } |
3722 | 3722 | parent::before( $title ); |
3723 | 3723 | } |
@@ -3734,7 +3734,7 @@ discard block |
||
3734 | 3734 | */ |
3735 | 3735 | public function after( $title = '' ) { |
3736 | 3736 | if ( empty( $title ) ) { |
3737 | - $title = esc_html( $this->plugin_names[ $this->i ] ); |
|
3737 | + $title = esc_html( $this->plugin_names[$this->i] ); |
|
3738 | 3738 | } |
3739 | 3739 | parent::after( $title ); |
3740 | 3740 | |
@@ -3907,7 +3907,7 @@ discard block |
||
3907 | 3907 | */ |
3908 | 3908 | protected static function emulate_filter_bool( $value ) { |
3909 | 3909 | // phpcs:disable WordPress.Arrays.ArrayDeclarationSpacing.ArrayItemNoNewLine |
3910 | - static $true = array( |
|
3910 | + static $true = array( |
|
3911 | 3911 | '1', |
3912 | 3912 | 'true', 'True', 'TRUE', |
3913 | 3913 | 'y', 'Y', |
@@ -1671,12 +1671,11 @@ discard block |
||
1671 | 1671 | |
1672 | 1672 | if ( false !== $api && isset( $api->download_link ) ) { |
1673 | 1673 | |
1674 | - if($this->strict_versions === true){ |
|
1674 | + if($this->strict_versions === true) { |
|
1675 | 1675 | $version = isset($this->plugins[$slug]['version']) ? $this->plugins[$slug]['version'] : ''; |
1676 | 1676 | $versions = $api->versions; |
1677 | 1677 | $source = isset($versions[$version]) ? $versions[$version] : $api->download_link; |
1678 | - } |
|
1679 | - else{ |
|
1678 | + } else { |
|
1680 | 1679 | $source = $api->download_link; |
1681 | 1680 | } |
1682 | 1681 | |
@@ -1792,10 +1791,12 @@ discard block |
||
1792 | 1791 | if ( 'update-core' === $screen->base ) { |
1793 | 1792 | // Core update screen. |
1794 | 1793 | return true; |
1795 | - } elseif ( 'plugins' === $screen->base && ! empty( $_POST['action'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing |
|
1794 | + } elseif ( 'plugins' === $screen->base && ! empty( $_POST['action'] ) ) { |
|
1795 | +// phpcs:ignore WordPress.Security.NonceVerification.Missing |
|
1796 | 1796 | // Plugins bulk update screen. |
1797 | 1797 | return true; |
1798 | - } elseif ( 'update' === $screen->base && ! empty( $_POST['action'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing |
|
1798 | + } elseif ( 'update' === $screen->base && ! empty( $_POST['action'] ) ) { |
|
1799 | +// phpcs:ignore WordPress.Security.NonceVerification.Missing |
|
1799 | 1800 | // Individual updates (ajax call). |
1800 | 1801 | return true; |
1801 | 1802 | } |
@@ -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 | 'strict_versions' => false // Download of plugins will download the exactly version specified in version field |
135 | 135 | |
136 | 136 | /* |