Skip to content

Commit

Permalink
Merge branch 'release/1.5.0-rc2'
Browse files Browse the repository at this point in the history
  • Loading branch information
nylen committed Dec 20, 2022
2 parents 8631ab2 + c1a6835 commit 280acbf
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 58 deletions.
2 changes: 1 addition & 1 deletion wp-admin/includes/ajax-actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -3317,7 +3317,7 @@ function wp_ajax_query_themes() {
}

$theme->name = wp_kses( $theme->name, $themes_allowedtags );
$theme->author = wp_kses( $theme->author, $themes_allowedtags );
$theme->author = wp_kses( $theme->author['display_name'], $themes_allowedtags );
$theme->version = wp_kses( $theme->version, $themes_allowedtags );
$theme->description = wp_kses( $theme->description, $themes_allowedtags );
$theme->stars = wp_star_rating(
Expand Down
20 changes: 11 additions & 9 deletions wp-admin/includes/class-theme-upgrader.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,18 @@ public function install_strings() {
/* translators: %s: Theme error. */
$this->strings['current_theme_has_errors'] = __( 'The current theme has the following error: "%s".' );

if ( 'update-theme' === $this->skin->overwrite ) {
$this->strings['installing_package'] = __( 'Updating the theme…' );
$this->strings['process_failed'] = __( 'Theme update failed.' );
$this->strings['process_success'] = __( 'Theme updated successfully.' );
}
if ( ! empty( $this->skin->overwrite ) ) {
if ( 'update-theme' === $this->skin->overwrite ) {
$this->strings['installing_package'] = __( 'Updating the theme…' );
$this->strings['process_failed'] = __( 'Theme update failed.' );
$this->strings['process_success'] = __( 'Theme updated successfully.' );
}

if ( 'downgrade-theme' === $this->skin->overwrite ) {
$this->strings['installing_package'] = __( 'Downgrading the theme…' );
$this->strings['process_failed'] = __( 'Theme downgrade failed.' );
$this->strings['process_success'] = __( 'Theme downgraded successfully.' );
if ( 'downgrade-theme' === $this->skin->overwrite ) {
$this->strings['installing_package'] = __( 'Downgrading the theme…' );
$this->strings['process_failed'] = __( 'Theme downgrade failed.' );
$this->strings['process_success'] = __( 'Theme downgraded successfully.' );
}
}
}

Expand Down
61 changes: 45 additions & 16 deletions wp-admin/includes/theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -423,19 +423,27 @@ function get_theme_feature_list( $api = true ) {
* for more information on the make-up of possible return objects depending on the value of `$action`.
*/
function themes_api( $action, $args = array() ) {
// include an unmodified $wp_version
include( ABSPATH . WPINC . '/version.php' );

if ( is_array( $args ) ) {
$args = (object) $args;
}

if ( ! isset( $args->per_page ) ) {
$args->per_page = 24;
if ( 'query_themes' == $action ) {
if ( ! isset( $args->per_page ) ) {
$args->per_page = 24;
}
}

if ( ! isset( $args->locale ) ) {
$args->locale = get_user_locale();
}

if ( ! isset( $args->wp_version ) ) {
$args->wp_version = substr( $wp_version, 0, 3 ); // X.y
}

/**
* Filters arguments used to query for installer pages from the ClassicPress.net Themes API.
*
Expand Down Expand Up @@ -467,19 +475,24 @@ function themes_api( $action, $args = array() ) {
$res = apply_filters( 'themes_api', false, $action, $args );

if ( ! $res ) {
// include an unmodified $wp_version
include ABSPATH . WPINC . '/version.php';
$url = 'http://api.wordpress.org/themes/info/1.2/';
$url = add_query_arg(
array(
'action' => $action,
'request' => $args,
),
$url
);

$url = 'https://api.wordpress.org/themes/info/1.0/';
$http_url = $url;
if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) {
$url = set_url_scheme( $url, 'https' );
}

$http_args = array(
'user-agent' => classicpress_user_agent(),
'body' => array(
'action' => $action,
'request' => serialize( $args ),
),
'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ),
);
$request = wp_remote_post( $url, $http_args );
$request = wp_remote_get( $url, $http_args );

if ( is_wp_error( $request ) ) {
if ( ! wp_doing_ajax() ) {
Expand All @@ -492,9 +505,7 @@ function themes_api( $action, $args = array() ) {
headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE
);
}

// Retry request
$request = wp_remote_post( $url, $http_args );
$request = wp_remote_get( $http_url, $http_args );
}

if ( is_wp_error( $request ) ) {
Expand All @@ -508,8 +519,11 @@ function themes_api( $action, $args = array() ) {
$request->get_error_message()
);
} else {
$res = maybe_unserialize( wp_remote_retrieve_body( $request ) );
if ( ! is_object( $res ) && ! is_array( $res ) ) {
$res = json_decode( wp_remote_retrieve_body( $request ), true );
if ( is_array( $res ) ) {
// Object casting is required in order to match the info/1.0 format.
$res = (object) $res;
} elseif ( null === $res ) {
$res = new WP_Error(
'themes_api_failed',
sprintf(
Expand All @@ -520,6 +534,21 @@ function themes_api( $action, $args = array() ) {
wp_remote_retrieve_body( $request )
);
}

if ( isset( $res->error ) ) {
$res = new WP_Error( 'themes_api_failed', $res->error );
}
}

// Back-compat for info/1.2 API, upgrade the theme objects in query_themes to objects.
if ( 'query_themes' == $action ) {
foreach ( $res->themes as $i => $theme ) {
$res->themes[ $i ] = (object) $theme;
}
}
// Back-compat for info/1.2 API, downgrade the feature_list result back to an array.
if ( 'feature_list' == $action ) {
$res = (array) $res;
}
}

Expand Down
13 changes: 1 addition & 12 deletions wp-admin/js/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,18 +334,7 @@ themes.Collection = Backbone.Collection.extend({
data: {
// Request data
request: _.extend({
per_page: 100,
fields: {
description: true,
tested: true,
requires: true,
rating: true,
downloaded: true,
downloadLink: true,
last_updated: true,
homepage: true,
num_ratings: true
}
per_page: 100
}, request)
},

Expand Down
2 changes: 1 addition & 1 deletion wp-admin/js/theme.min.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion wp-admin/theme-install.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@
<h3 class="theme-name">{{ data.name }}</h3>

<div class="theme-actions">
<# console.log( data ); #>
<# if ( data.installed ) { #>
<# if ( data.compatible_wp && data.compatible_php ) { #>
<?php
Expand Down
17 changes: 1 addition & 16 deletions wp-includes/class-wp-customize-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -5751,19 +5751,6 @@ public function handle_load_themes_request() {
// Arguments for all queries.
$wporg_args = array(
'per_page' => 100,
'fields' => array(
'screenshot_url' => true,
'description' => true,
'rating' => true,
'downloaded' => true,
'downloadlink' => true,
'last_updated' => true,
'homepage' => true,
'num_ratings' => true,
'tags' => true,
'parent' => true,
// 'extended_author' => true, @todo: WordPress.org throws a 500 server error when this is here.
),
);

$args = array_merge( $wporg_args, $args );
Expand Down Expand Up @@ -5807,10 +5794,8 @@ public function handle_load_themes_request() {
);

$theme->name = wp_kses( $theme->name, $themes_allowedtags );
$theme->author = wp_kses( $theme->author, $themes_allowedtags );
$theme->version = wp_kses( $theme->version, $themes_allowedtags );
$theme->description = wp_kses( $theme->description, $themes_allowedtags );
$theme->tags = implode( ', ', $theme->tags );
$theme->stars = wp_star_rating(
array(
'rating' => $theme->rating,
Expand All @@ -5835,7 +5820,7 @@ public function handle_load_themes_request() {
// Map available theme properties to installed theme properties.
$theme->id = $theme->slug;
$theme->screenshot = array( $theme->screenshot_url );
$theme->authorAndUri = $theme->author;
$theme->authorAndUri = wp_kses( $theme->author['display_name'], $themes_allowedtags );
$theme->compatibleWP = is_wp_version_compatible( $theme->requires ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName
$theme->compatiblePHP = is_php_version_compatible( $theme->requires_php ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName

Expand Down
2 changes: 1 addition & 1 deletion wp-includes/script-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function classicpress_asset_version( $type = 'script', $handle = null ) {
static $default_version;

if ( empty( $default_version ) ) {
$default_version = 'cp_4cbf988f';
$default_version = 'cp_d9f5b255';
}

/**
Expand Down
2 changes: 1 addition & 1 deletion wp-includes/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*
* @global string $cp_version
*/
$cp_version = '1.5.0-rc1';
$cp_version = '1.5.0-rc2';

/**
* The WordPress version string
Expand Down

0 comments on commit 280acbf

Please sign in to comment.