From b73bbd8139d3e3ee1ad91328b2502e3582e37010 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 18 May 2020 12:32:10 +0000 Subject: [PATCH] Themes: Prevent activation and live preview of themes that require a higher version of PHP or WordPress. Props afragen, jorbin, TimothyBlynJacobs, SergeyBiryukov. See #48491. Built from https://develop.svn.wordpress.org/trunk@47816 git-svn-id: http://core.svn.wordpress.org/trunk@47592 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/customize.php | 21 +++++-- wp-admin/includes/ajax-actions.php | 6 +- wp-admin/includes/theme.php | 37 +++++++----- wp-admin/theme-install.php | 36 ++++++++---- wp-admin/themes.php | 57 ++++++++++++++----- .../class-wp-customize-theme-control.php | 6 +- wp-includes/version.php | 2 +- 7 files changed, 117 insertions(+), 48 deletions(-) diff --git a/wp-admin/customize.php b/wp-admin/customize.php index a8b62f4195..375804d568 100644 --- a/wp-admin/customize.php +++ b/wp-admin/customize.php @@ -177,11 +177,22 @@ do_action( 'customize_controls_print_scripts' );
- is_theme_active() ? __( 'Publish' ) : __( 'Activate & Publish' ); ?> -
- - -
+ theme()->get( 'RequiresWP' ) ); + $compatible_php = is_php_version_compatible( $wp_customize->theme()->get( 'RequiresPHP' ) ); + ?> + + is_theme_active() ? __( 'Publish' ) : __( 'Activate & Publish' ); ?> +
+ + +
+ + +
+ +
+ + + <# if ( data.compatibleWP && data.compatiblePHP ) { #> + + <# } else { #> + + <# } #> <# } else { #> diff --git a/wp-admin/theme-install.php b/wp-admin/theme-install.php index 2519ed01ae..6d8ea54542 100644 --- a/wp-admin/theme-install.php +++ b/wp-admin/theme-install.php @@ -282,18 +282,34 @@ if ( $tab ) {

{{ data.name }}

+ <# console.log( data ); #> <# if ( data.installed ) { #> - - <# if ( data.activate_url ) { #> - - <# } #> - <# if ( data.customize_url ) { #> - + <# if ( data.compatible_wp && data.compatible_php ) { #> + + <# if ( data.activate_url ) { #> + + <# } #> + <# if ( data.customize_url ) { #> + + <# } else { #> + + <# } #> <# } else { #> - + + <# if ( data.activate_url ) { #> + + <# } #> + <# if ( data.customize_url ) { #> + + <# } else { #> + + <# } #> <# } #> <# } else { #> - + + + + + + +
@@ -518,12 +527,21 @@ if ( ! is_multisite() && $broken_themes ) { <# } #> <# } else { #> - - - + <# if ( data.compatibleWP && data.compatiblePHP ) { #> + + + + <# } else { #> + + + + <# } #> <# } #>
@@ -592,14 +610,25 @@ if ( ! is_multisite() && $broken_themes ) {
- - <# if ( data.actions.activate ) { #> - + <# if ( data.compatibleWP && data.compatiblePHP ) { #> + + <# if ( data.actions.activate ) { #> + + <# } #> + + <# } else { #> + + <# if ( data.actions.activate ) { #> + + <# } #> + <# } #> -
<# if ( ! data.active && data.actions['delete'] ) { #> diff --git a/wp-includes/customize/class-wp-customize-theme-control.php b/wp-includes/customize/class-wp-customize-theme-control.php index 10f09d180b..9c5e7602cf 100644 --- a/wp-includes/customize/class-wp-customize-theme-control.php +++ b/wp-includes/customize/class-wp-customize-theme-control.php @@ -121,7 +121,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 1dc5c04c8a..b8add0c608 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.5-alpha-47815'; +$wp_version = '5.5-alpha-47816'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.