From 307725883a1783123051fef0650f1e4990dce0b0 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 18 May 2020 16:03:09 +0000 Subject: [PATCH] Themes: Prevent installation of themes that require a higher version of PHP or WordPress. Props afragen. Fixes #49653. See #48491. Built from https://develop.svn.wordpress.org/trunk@47819 git-svn-id: http://core.svn.wordpress.org/trunk@47595 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/theme.php | 9 +++-- wp-admin/theme-install.php | 33 ++++++++++++++----- wp-includes/class-wp-customize-manager.php | 8 +++-- .../class-wp-customize-theme-control.php | 6 +++- wp-includes/version.php | 2 +- 5 files changed, 43 insertions(+), 15 deletions(-) diff --git a/wp-admin/includes/theme.php b/wp-admin/includes/theme.php index 09473c1a50..5c5afee52a 100644 --- a/wp-admin/includes/theme.php +++ b/wp-admin/includes/theme.php @@ -827,8 +827,13 @@ function customize_themes_print_templates() { <# } #> <# } else { #> - - + <# if ( data.compatibleWP && data.compatiblePHP ) { #> + + + <# } else { #> + + + <# } #> <# } #> diff --git a/wp-admin/theme-install.php b/wp-admin/theme-install.php index 6e890f5da1..b1b1eaf4fc 100644 --- a/wp-admin/theme-install.php +++ b/wp-admin/theme-install.php @@ -311,12 +311,21 @@ if ( $tab ) { <# } #> <# } #> <# } else { #> - - - + <# if ( data.compatible_wp && data.compatible_php ) { #> + + + + <# } else { #> + + + + <# } #> <# } #> @@ -333,9 +342,17 @@ if ( $tab ) { <# if ( data.installed ) { #> - + <# if ( data.compatible_wp && data.compatible_php ) { #> + + <# } else { #> + + <# } #> <# } else { #> - + <# if ( data.compatible_wp && data.compatible_php ) { #> + + <# } else { #> + + <# } #> <# } #>
diff --git a/wp-includes/class-wp-customize-manager.php b/wp-includes/class-wp-customize-manager.php index 2342089302..ce325118f5 100644 --- a/wp-includes/class-wp-customize-manager.php +++ b/wp-includes/class-wp-customize-manager.php @@ -5853,9 +5853,11 @@ final class WP_Customize_Manager { $theme->active = ( isset( $_POST['customized_theme'] ) && $_POST['customized_theme'] === $theme->slug ); // Map available theme properties to installed theme properties. - $theme->id = $theme->slug; - $theme->screenshot = array( $theme->screenshot_url ); - $theme->authorAndUri = wp_kses( $theme->author['display_name'], $themes_allowedtags ); + $theme->id = $theme->slug; + $theme->screenshot = array( $theme->screenshot_url ); + $theme->authorAndUri = wp_kses( $theme->author['display_name'], $themes_allowedtags ); + $theme->compatibleWP = is_wp_version_compatible( $theme->requires ); + $theme->compatiblePHP = is_php_version_compatible( $theme->requires_php ); if ( isset( $theme->parent ) ) { $theme->parent = $theme->parent['slug']; diff --git a/wp-includes/customize/class-wp-customize-theme-control.php b/wp-includes/customize/class-wp-customize-theme-control.php index 9c5e7602cf..270547baaf 100644 --- a/wp-includes/customize/class-wp-customize-theme-control.php +++ b/wp-includes/customize/class-wp-customize-theme-control.php @@ -133,7 +133,11 @@ class WP_Customize_Theme_Control extends WP_Customize_Control {

{{ data.theme.name }}

- + <# if ( data.theme.compatibleWP && data.theme.compatiblePHP ) { #> + + <# } else { #> + + <# } #>
<# } #> diff --git a/wp-includes/version.php b/wp-includes/version.php index 506440e860..886582e409 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.5-alpha-47818'; +$wp_version = '5.5-alpha-47819'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.