From a60b30444fa1e626fa1362873fc0f8ae63c6eb81 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 18 May 2020 16:01:38 +0000 Subject: [PATCH] Themes: Prevent installation of themes that require a higher version of PHP or WordPress. Props afragen. Fixes #49653. See #48491. git-svn-id: https://develop.svn.wordpress.org/trunk@47819 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/theme.php | 9 +++-- src/wp-admin/theme-install.php | 33 ++++++++++++++----- .../class-wp-customize-manager.php | 8 +++-- .../class-wp-customize-theme-control.php | 6 +++- 4 files changed, 42 insertions(+), 14 deletions(-) diff --git a/src/wp-admin/includes/theme.php b/src/wp-admin/includes/theme.php index 09473c1a50..5c5afee52a 100644 --- a/src/wp-admin/includes/theme.php +++ b/src/wp-admin/includes/theme.php @@ -827,8 +827,13 @@ function customize_themes_print_templates() { <# } #> <# } else { #> - - + <# if ( data.compatibleWP && data.compatiblePHP ) { #> + + + <# } else { #> + + + <# } #> <# } #> diff --git a/src/wp-admin/theme-install.php b/src/wp-admin/theme-install.php index 6e890f5da1..b1b1eaf4fc 100644 --- a/src/wp-admin/theme-install.php +++ b/src/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/src/wp-includes/class-wp-customize-manager.php b/src/wp-includes/class-wp-customize-manager.php index 2342089302..ce325118f5 100644 --- a/src/wp-includes/class-wp-customize-manager.php +++ b/src/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/src/wp-includes/customize/class-wp-customize-theme-control.php b/src/wp-includes/customize/class-wp-customize-theme-control.php index 9c5e7602cf..270547baaf 100644 --- a/src/wp-includes/customize/class-wp-customize-theme-control.php +++ b/src/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 { #> + + <# } #>
<# } #>