Upgrade/Install: Allow WordPress sites to opt-in to beta & RC releases.

The `WP_AUTO_UPDATE_CORE` constant now supports `beta` and `rc` values.

This makes it possible for sites to opt-in to updating to RC (or beta) releases without having to install a plugin, or run on a development version.

Props dd32, knutsp.
Fixes #51319.

git-svn-id: https://develop.svn.wordpress.org/trunk@49245 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2020-10-20 17:54:50 +00:00
parent 643754dc67
commit 194d32b970
2 changed files with 11 additions and 2 deletions

View File

@ -283,14 +283,18 @@ class Core_Upgrader extends WP_Upgrader {
$upgrade_minor = true; $upgrade_minor = true;
$upgrade_major = false; $upgrade_major = false;
// WP_AUTO_UPDATE_CORE = true (all), 'minor', false. // WP_AUTO_UPDATE_CORE = true (all), 'beta', 'rc', 'minor', false.
if ( defined( 'WP_AUTO_UPDATE_CORE' ) ) { if ( defined( 'WP_AUTO_UPDATE_CORE' ) ) {
if ( false === WP_AUTO_UPDATE_CORE ) { if ( false === WP_AUTO_UPDATE_CORE ) {
// Defaults to turned off, unless a filter allows it. // Defaults to turned off, unless a filter allows it.
$upgrade_dev = false; $upgrade_dev = false;
$upgrade_minor = false; $upgrade_minor = false;
$upgrade_major = false; $upgrade_major = false;
} elseif ( true === WP_AUTO_UPDATE_CORE ) { } elseif (
true === WP_AUTO_UPDATE_CORE
|| 'beta' === WP_AUTO_UPDATE_CORE
|| 'rc' === WP_AUTO_UPDATE_CORE
) {
// ALL updates for core. // ALL updates for core.
$upgrade_dev = true; $upgrade_dev = true;
$upgrade_minor = true; $upgrade_minor = true;

View File

@ -136,6 +136,11 @@ function wp_version_check( $extra_stats = array(), $force_check = false ) {
$post_body = array_merge( $post_body, $extra_stats ); $post_body = array_merge( $post_body, $extra_stats );
} }
// Allow for WP_AUTO_UPDATE_CORE to specify beta/RC releases.
if ( defined( 'WP_AUTO_UPDATE_CORE' ) && in_array( WP_AUTO_UPDATE_CORE, array( 'beta', 'rc' ), true ) ) {
$query['channel'] = WP_AUTO_UPDATE_CORE;
}
$url = 'http://api.wordpress.org/core/version-check/1.7/?' . http_build_query( $query, null, '&' ); $url = 'http://api.wordpress.org/core/version-check/1.7/?' . http_build_query( $query, null, '&' );
$http_url = $url; $http_url = $url;
$ssl = wp_http_supports( array( 'ssl' ) ); $ssl = wp_http_supports( array( 'ssl' ) );