Site Health: Add support for required WordPress and PHP versions to themes.

Follow-up to [45546] for plugins.

Props flixos90, afragen.
Fixes #44592. See #40934, #meta3718.
Built from https://develop.svn.wordpress.org/trunk@47145


git-svn-id: http://core.svn.wordpress.org/trunk@46945 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2020-01-31 01:17:04 +00:00
parent eafc40be6d
commit d0a0825809
2 changed files with 10 additions and 2 deletions

View File

@ -21,6 +21,8 @@ final class WP_Theme implements ArrayAccess {
/**
* Headers for style.css files.
*
* @since 3.4.0
* @since 5.4.0 Added `Requires at least` and `Requires PHP` headers.
* @var array
*/
private static $file_headers = array(
@ -35,6 +37,8 @@ final class WP_Theme implements ArrayAccess {
'Tags' => 'Tags',
'TextDomain' => 'Text Domain',
'DomainPath' => 'Domain Path',
'RequiresWP' => 'Requires at least',
'RequiresPHP' => 'Requires PHP',
);
/**
@ -801,11 +805,13 @@ final class WP_Theme implements ArrayAccess {
* Sanitize a theme header.
*
* @since 3.4.0
* @since 5.4.0 Added support for `Requires at least` and `Requires PHP` headers.
*
* @staticvar array $header_tags
* @staticvar array $header_tags_with_a
*
* @param string $header Theme header. Name, Description, Author, Version, ThemeURI, AuthorURI, Status, Tags.
* @param string $header Theme header. Accepts 'Name', 'Description', 'Author', 'Version',
* 'ThemeURI', 'AuthorURI', 'Status', 'Tags', 'RequiresWP', 'RequiresPHP'.
* @param string $value Value to sanitize.
* @return string|array An array for Tags header, string otherwise.
*/
@ -853,6 +859,8 @@ final class WP_Theme implements ArrayAccess {
$value = array_filter( array_map( 'trim', explode( ',', strip_tags( $value ) ) ) );
break;
case 'Version':
case 'RequiresWP':
case 'RequiresPHP':
$value = strip_tags( $value );
break;
}

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.4-alpha-47144';
$wp_version = '5.4-alpha-47145';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.