diff -r 3d4e9c994f10 -r a86126ab1dd4 wp/wp-admin/includes/plugin-install.php --- a/wp/wp-admin/includes/plugin-install.php Tue Oct 22 16:11:46 2019 +0200 +++ b/wp/wp-admin/includes/plugin-install.php Tue Dec 15 13:49:49 2020 +0100 @@ -73,6 +73,7 @@ * FAQ, screenshots, other notes, and changelog. Default false. * @type bool $tested Whether to return the 'Compatible up to' value. Default true. * @type bool $requires Whether to return the required WordPress version. Default true. + * @type bool $requires_php Whether to return the required PHP version. Default true. * @type bool $rating Whether to return the rating in percent and total number of ratings. * Default true. * @type bool $ratings Whether to return the number of rating for each star (1-5). Default true. @@ -99,14 +100,14 @@ * for more information on the make-up of possible return values depending on the value of `$action`. */ function plugins_api( $action, $args = array() ) { - // include an unmodified $wp_version - include( ABSPATH . WPINC . '/version.php' ); + // Include an unmodified $wp_version. + require ABSPATH . WPINC . '/version.php'; if ( is_array( $args ) ) { $args = (object) $args; } - if ( 'query_plugins' == $action ) { + if ( 'query_plugins' === $action ) { if ( ! isset( $args->per_page ) ) { $args->per_page = 24; } @@ -117,7 +118,7 @@ } if ( ! isset( $args->wp_version ) ) { - $args->wp_version = substr( $wp_version, 0, 3 ); // X.y + $args->wp_version = substr( $wp_version, 0, 3 ); // x.y } /** @@ -160,7 +161,8 @@ ); $http_url = $url; - if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) { + $ssl = wp_http_supports( array( 'ssl' ) ); + if ( $ssl ) { $url = set_url_scheme( $url, 'https' ); } @@ -171,14 +173,17 @@ $request = wp_remote_get( $url, $http_args ); if ( $ssl && is_wp_error( $request ) ) { - trigger_error( - sprintf( - /* translators: %s: support forums URL */ - __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the support forums.' ), - __( 'https://wordpress.org/support/' ) - ) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ), - headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE - ); + if ( ! wp_is_json_request() ) { + trigger_error( + sprintf( + /* translators: %s: Support forums URL. */ + __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the support forums.' ), + __( 'https://wordpress.org/support/forums/' ) + ) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ), + headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE + ); + } + $request = wp_remote_get( $http_url, $http_args ); } @@ -186,9 +191,9 @@ $res = new WP_Error( 'plugins_api_failed', sprintf( - /* translators: %s: support forums URL */ + /* translators: %s: Support forums URL. */ __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the support forums.' ), - __( 'https://wordpress.org/support/' ) + __( 'https://wordpress.org/support/forums/' ) ), $request->get_error_message() ); @@ -201,9 +206,9 @@ $res = new WP_Error( 'plugins_api_failed', sprintf( - /* translators: %s: support forums URL */ + /* translators: %s: Support forums URL. */ __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the support forums.' ), - __( 'https://wordpress.org/support/' ) + __( 'https://wordpress.org/support/forums/' ) ), wp_remote_retrieve_body( $request ) ); @@ -238,8 +243,9 @@ * @return array */ function install_popular_tags( $args = array() ) { - $key = md5( serialize( $args ) ); - if ( false !== ( $tags = get_site_transient( 'poptags_' . $key ) ) ) { + $key = md5( serialize( $args ) ); + $tags = get_site_transient( 'poptags_' . $key ); + if ( false !== $tags ) { return $tags; } @@ -259,7 +265,15 @@ */ function install_dashboard() { ?> -
WordPress Plugin Directory or upload a plugin in .zip format by clicking the button at the top of this page.' ), __( 'https://wordpress.org/plugins/' ) ); ?>
++ WordPress Plugin Directory or upload a plugin in .zip format by clicking the button at the top of this page.' ), + __( 'https://wordpress.org/plugins/' ) + ); + ?> +
@@ -274,7 +288,7 @@ if ( is_wp_error( $api_tags ) ) { echo $api_tags->get_error_message(); } else { - //Set up the tags in a way which can be interpreted by wp_generate_tag_cloud() + // Set up the tags in a way which can be interpreted by wp_generate_tag_cloud(). $tags = array(); foreach ( (array) $api_tags as $tag ) { $url = self_admin_url( 'plugin-install.php?tab=search&type=tag&s=' . urlencode( $tag['name'] ) ); @@ -290,7 +304,9 @@ echo wp_generate_tag_cloud( $tags, array( + /* translators: %s: Number of plugins. */ 'single_text' => __( '%s plugin' ), + /* translators: %s: Number of plugins. */ 'multiple_text' => __( '%s plugins' ), ) ); @@ -318,9 +334,8 @@ - + + 'search-submit' ) ); ?>