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
This commit is contained in:
parent
d528d7a044
commit
b73bbd8139
|
@ -177,11 +177,22 @@ do_action( 'customize_controls_print_scripts' );
|
|||
<div class="wp-full-overlay expanded">
|
||||
<form id="customize-controls" class="wrap wp-full-overlay-sidebar">
|
||||
<div id="customize-header-actions" class="wp-full-overlay-header">
|
||||
<?php
|
||||
$compatible_wp = is_wp_version_compatible( $wp_customize->theme()->get( 'RequiresWP' ) );
|
||||
$compatible_php = is_php_version_compatible( $wp_customize->theme()->get( 'RequiresPHP' ) );
|
||||
?>
|
||||
<?php if ( $compatible_wp && $compatible_php ) : ?>
|
||||
<?php $save_text = $wp_customize->is_theme_active() ? __( 'Publish' ) : __( 'Activate & Publish' ); ?>
|
||||
<div id="customize-save-button-wrapper" class="customize-save-button-wrapper" >
|
||||
<?php submit_button( $save_text, 'primary save', 'save', false ); ?>
|
||||
<button id="publish-settings" class="publish-settings button-primary button dashicons dashicons-admin-generic" aria-label="<?php esc_attr_e( 'Publish Settings' ); ?>" aria-expanded="false" disabled></button>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<?php $save_text = _x( 'Cannot Activate', 'theme' ); ?>
|
||||
<div id="customize-save-button-wrapper" class="customize-save-button-wrapper disabled" >
|
||||
<button class="button button-primary disabled" aria-label="<?php esc_attr_e( 'Publish Settings' ); ?>" aria-expanded="false" disabled><?php echo $save_text; ?></button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<span class="spinner"></span>
|
||||
<button type="button" class="customize-controls-preview-toggle">
|
||||
<span class="controls"><?php _e( 'Customize' ); ?></span>
|
||||
|
|
|
@ -3573,6 +3573,8 @@ function wp_ajax_query_themes() {
|
|||
|
||||
$theme->num_ratings = number_format_i18n( $theme->num_ratings );
|
||||
$theme->preview_url = set_url_scheme( $theme->preview_url );
|
||||
$theme->compatible_wp = is_wp_version_compatible( $theme->requires );
|
||||
$theme->compatible_php = is_php_version_compatible( $theme->requires_php );
|
||||
}
|
||||
|
||||
wp_send_json_success( $api );
|
||||
|
|
|
@ -690,8 +690,10 @@ function wp_prepare_themes_for_js( $themes = null ) {
|
|||
'description' => $theme->display( 'Description' ),
|
||||
'author' => $theme->display( 'Author', false, true ),
|
||||
'authorAndUri' => $theme->display( 'Author' ),
|
||||
'version' => $theme->display( 'Version' ),
|
||||
'tags' => $theme->display( 'Tags' ),
|
||||
'version' => $theme->get( 'Version' ),
|
||||
'compatibleWP' => is_wp_version_compatible( $theme->get( 'RequiresWP' ) ),
|
||||
'compatiblePHP' => is_php_version_compatible( $theme->get( 'RequiresPHP' ) ),
|
||||
'parent' => $parent,
|
||||
'active' => $slug === $current_theme,
|
||||
'hasUpdate' => isset( $updates[ $slug ] ),
|
||||
|
@ -818,7 +820,12 @@ function customize_themes_print_templates() {
|
|||
<a href="{{{ data.actions['delete'] }}}" data-slug="{{ data.id }}" class="button button-secondary delete-theme"><?php _e( 'Delete' ); ?></a>
|
||||
<# } #>
|
||||
<?php } ?>
|
||||
|
||||
<# if ( data.compatibleWP && data.compatiblePHP ) { #>
|
||||
<button type="button" class="button button-primary preview-theme" data-slug="{{ data.id }}"><?php _e( 'Live Preview' ); ?></button>
|
||||
<# } else { #>
|
||||
<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 & Preview' ); ?></button>
|
||||
|
|
|
@ -282,7 +282,9 @@ if ( $tab ) {
|
|||
<h3 class="theme-name">{{ data.name }}</h3>
|
||||
|
||||
<div class="theme-actions">
|
||||
<# console.log( data ); #>
|
||||
<# if ( data.installed ) { #>
|
||||
<# if ( data.compatible_wp && data.compatible_php ) { #>
|
||||
<?php
|
||||
/* translators: %s: Theme name. */
|
||||
$aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' );
|
||||
|
@ -295,6 +297,20 @@ if ( $tab ) {
|
|||
<# } else { #>
|
||||
<button class="button preview install-theme-preview"><?php _e( 'Preview' ); ?></button>
|
||||
<# } #>
|
||||
<# } else { #>
|
||||
<?php
|
||||
/* translators: %s: Theme name. */
|
||||
$aria_label = sprintf( _x( 'Cannot Activate %s', 'theme' ), '{{ data.name }}' );
|
||||
?>
|
||||
<# if ( data.activate_url ) { #>
|
||||
<a class="button button-primary disabled" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _ex( 'Cannot Activate', 'theme' ); ?></a>
|
||||
<# } #>
|
||||
<# if ( data.customize_url ) { #>
|
||||
<a class="button disabled"><?php _e( 'Live Preview' ); ?></a>
|
||||
<# } else { #>
|
||||
<button class="button disabled"><?php _e( 'Preview' ); ?></button>
|
||||
<# } #>
|
||||
<# } #>
|
||||
<# } else { #>
|
||||
<?php
|
||||
/* translators: %s: Theme name. */
|
||||
|
|
|
@ -353,7 +353,7 @@ foreach ( $themes as $theme ) :
|
|||
<?php if ( $theme['actions']['customize'] && current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { ?>
|
||||
<a class="button button-primary customize load-customize hide-if-no-customize" href="<?php echo $theme['actions']['customize']; ?>"><?php _e( 'Customize' ); ?></a>
|
||||
<?php } ?>
|
||||
<?php } else { ?>
|
||||
<?php } elseif ( $theme['compatibleWP'] && $theme['compatiblePHP'] ) { ?>
|
||||
<?php
|
||||
/* translators: %s: Theme name. */
|
||||
$aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' );
|
||||
|
@ -362,6 +362,15 @@ foreach ( $themes as $theme ) :
|
|||
<?php if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { ?>
|
||||
<a class="button button-primary load-customize hide-if-no-customize" href="<?php echo $theme['actions']['customize']; ?>"><?php _e( 'Live Preview' ); ?></a>
|
||||
<?php } ?>
|
||||
<?php } else { ?>
|
||||
<?php
|
||||
/* translators: %s: Theme name. */
|
||||
$aria_label = sprintf( _x( 'Cannot Activate %s', 'theme' ), '{{ data.name }}' );
|
||||
?>
|
||||
<a class="button disabled" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _ex( 'Cannot Activate', 'theme' ); ?></a>
|
||||
<?php if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { ?>
|
||||
<a class="button button-primary hide-if-no-customize disabled"><?php _e( 'Live Preview' ); ?></a>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
|
||||
</div>
|
||||
|
@ -518,12 +527,21 @@ if ( ! is_multisite() && $broken_themes ) {
|
|||
<a class="button button-primary customize load-customize hide-if-no-customize" href="{{{ data.actions.customize }}}"><?php _e( 'Customize' ); ?></a>
|
||||
<# } #>
|
||||
<# } else { #>
|
||||
<# if ( data.compatibleWP && data.compatiblePHP ) { #>
|
||||
<?php
|
||||
/* translators: %s: Theme name. */
|
||||
$aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' );
|
||||
?>
|
||||
<a class="button activate" href="{{{ data.actions.activate }}}" aria-label="<?php echo $aria_label; ?>"><?php _e( 'Activate' ); ?></a>
|
||||
<a class="button button-primary load-customize hide-if-no-customize" href="{{{ data.actions.customize }}}"><?php _e( 'Live Preview' ); ?></a>
|
||||
<# } else { #>
|
||||
<?php
|
||||
/* translators: %s: Theme name. */
|
||||
$aria_label = sprintf( _x( 'Cannot Activate %s', 'theme' ), '{{ data.name }}' );
|
||||
?>
|
||||
<a class="button disabled" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _ex( 'Cannot Activate', 'theme' ); ?></a>
|
||||
<a class="button button-primary hide-if-no-customize disabled"><?php _e( 'Live Preview' ); ?></a>
|
||||
<# } #>
|
||||
<# } #>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -592,6 +610,7 @@ if ( ! is_multisite() && $broken_themes ) {
|
|||
<?php echo implode( ' ', $current_theme_actions ); ?>
|
||||
</div>
|
||||
<div class="inactive-theme">
|
||||
<# if ( data.compatibleWP && data.compatiblePHP ) { #>
|
||||
<?php
|
||||
/* translators: %s: Theme name. */
|
||||
$aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' );
|
||||
|
@ -600,6 +619,16 @@ if ( ! is_multisite() && $broken_themes ) {
|
|||
<a href="{{{ data.actions.activate }}}" class="button activate" aria-label="<?php echo $aria_label; ?>"><?php _e( 'Activate' ); ?></a>
|
||||
<# } #>
|
||||
<a href="{{{ data.actions.customize }}}" class="button button-primary load-customize hide-if-no-customize"><?php _e( 'Live Preview' ); ?></a>
|
||||
<# } else { #>
|
||||
<?php
|
||||
/* translators: %s: Theme name. */
|
||||
$aria_label = sprintf( _x( 'Cannot Activate %s', 'theme' ), '{{ data.name }}' );
|
||||
?>
|
||||
<# if ( data.actions.activate ) { #>
|
||||
<a class="button disabled" aria-label="<?php echo $aria_label; ?>"><?php _ex( 'Cannot Activate', 'theme' ); ?></a>
|
||||
<# } #>
|
||||
<a class="button button-primary hide-if-no-customize disabled"><?php _e( 'Live Preview' ); ?></a>
|
||||
<# } #>
|
||||
</div>
|
||||
|
||||
<# if ( ! data.active && data.actions['delete'] ) { #>
|
||||
|
|
|
@ -121,7 +121,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">
|
||||
<# if ( data.theme.compatibleWP && data.theme.compatiblePHP ) { #>
|
||||
<button type="button" class="button button-primary preview-theme" aria-label="<?php echo esc_attr( $preview_label ); ?>" data-slug="{{ data.theme.id }}"><?php _e( 'Live Preview' ); ?></button>
|
||||
<# } else { #>
|
||||
<button type="button" class="button button-primary disabled" aria-label="<?php echo esc_attr( $preview_label ); ?>"><?php _e( 'Live Preview' ); ?></button>
|
||||
<# } #>
|
||||
</div>
|
||||
</div>
|
||||
<div class="notice notice-success notice-alt"><p><?php _ex( 'Installed', 'theme' ); ?></p></div>
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue