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
This commit is contained in:
Sergey Biryukov 2020-05-18 16:03:09 +00:00
parent 54cdfaef59
commit 307725883a
5 changed files with 43 additions and 15 deletions

View File

@ -827,8 +827,13 @@ function customize_themes_print_templates() {
<button class="button button-primary disabled"><?php _e( 'Live Preview' ); ?></button>
<# } #>
<# } else { #>
<button type="button" class="button theme-install" data-slug="{{ data.id }}"><?php _e( 'Install' ); ?></button>
<button type="button" class="button button-primary theme-install preview" data-slug="{{ data.id }}"><?php _e( 'Install &amp; Preview' ); ?></button>
<# if ( data.compatibleWP && data.compatiblePHP ) { #>
<button type="button" class="button theme-install" data-slug="{{ data.id }}"><?php _e( 'Install' ); ?></button>
<button type="button" class="button button-primary theme-install preview" data-slug="{{ data.id }}"><?php _e( 'Install &amp; Preview' ); ?></button>
<# } else { #>
<button type="button" class="button disabled"><?php _ex( 'Cannot Install', 'theme' ); ?></button>
<button type="button" class="button button-primary disabled"><?php _e( 'Install &amp; Preview' ); ?></button>
<# } #>
<# } #>
</div>
</div>

View File

@ -311,12 +311,21 @@ if ( $tab ) {
<# } #>
<# } #>
<# } else { #>
<?php
/* translators: %s: Theme name. */
$aria_label = sprintf( __( 'Install %s' ), '{{ data.name }}' );
?>
<a class="button button-primary theme-install" data-name="{{ data.name }}" data-slug="{{ data.id }}" href="{{ data.install_url }}" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Install' ); ?></a>
<button class="button preview install-theme-preview"><?php _e( 'Preview' ); ?></button>
<# if ( data.compatible_wp && data.compatible_php ) { #>
<?php
/* translators: %s: Theme name. */
$aria_label = sprintf( __( 'Install %s' ), '{{ data.name }}' );
?>
<a class="button button-primary theme-install" data-name="{{ data.name }}" data-slug="{{ data.id }}" href="{{ data.install_url }}" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Install' ); ?></a>
<button class="button preview install-theme-preview"><?php _e( 'Preview' ); ?></button>
<# } else { #>
<?php
/* translators: %s: Theme name. */
$aria_label = sprintf( __( 'Cannot Install %s' ), '{{ data.name }}' );
?>
<a class="button button-primary disabled" data-name="{{ data.name }}" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _ex( 'Cannot Install', 'theme' ); ?></a>
<button class="button disabled"><?php _e( 'Preview' ); ?></button>
<# } #>
<# } #>
</div>
</div>
@ -333,9 +342,17 @@ if ( $tab ) {
<button class="previous-theme"><span class="screen-reader-text"><?php _e( 'Previous theme' ); ?></span></button>
<button class="next-theme"><span class="screen-reader-text"><?php _e( 'Next theme' ); ?></span></button>
<# if ( data.installed ) { #>
<a class="button button-primary activate" href="{{ data.activate_url }}"><?php _e( 'Activate' ); ?></a>
<# if ( data.compatible_wp && data.compatible_php ) { #>
<a class="button button-primary activate" href="{{ data.activate_url }}"><?php _e( 'Activate' ); ?></a>
<# } else { #>
<a class="button button-primary disabled" ><?php _ex( 'Cannot Activate', 'theme' ); ?></a>
<# } #>
<# } else { #>
<a href="{{ data.install_url }}" class="button button-primary theme-install" data-name="{{ data.name }}" data-slug="{{ data.id }}"><?php _e( 'Install' ); ?></a>
<# if ( data.compatible_wp && data.compatible_php ) { #>
<a href="{{ data.install_url }}" class="button button-primary theme-install" data-name="{{ data.name }}" data-slug="{{ data.id }}"><?php _e( 'Install' ); ?></a>
<# } else { #>
<a class="button button-primary disabled" ><?php _ex( 'Cannot Install', 'theme' ); ?></a>
<# } #>
<# } #>
</div>
<div class="wp-full-overlay-sidebar-content">

View File

@ -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'];

View File

@ -133,7 +133,11 @@ class WP_Customize_Theme_Control extends WP_Customize_Control {
<div class="theme-id-container">
<h3 class="theme-name" id="{{ data.section }}-{{ data.theme.id }}-name">{{ data.theme.name }}</h3>
<div class="theme-actions">
<button type="button" class="button button-primary theme-install preview" aria-label="<?php echo esc_attr( $install_label ); ?>" data-slug="{{ data.theme.id }}" data-name="{{ data.theme.name }}"><?php _e( 'Install &amp; Preview' ); ?></button>
<# if ( data.theme.compatibleWP && data.theme.compatiblePHP ) { #>
<button type="button" class="button button-primary theme-install preview" aria-label="<?php echo esc_attr( $install_label ); ?>" data-slug="{{ data.theme.id }}" data-name="{{ data.theme.name }}"><?php _e( 'Install &amp; Preview' ); ?></button>
<# } else { #>
<button type="button" class="button button-primary disabled" aria-label="<?php echo esc_attr( $install_label ); ?>" disabled><?php _e( 'Install &amp; Preview' ); ?></button>
<# } #>
</div>
</div>
<# } #>

View File

@ -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.