Themes: Display a message in theme grid if a theme requires a higher version of PHP or WordPress.

This applies to the Themes screen, Add Themes screen, and the Customizer theme browser.

Props afragen, desrosj, SergeyBiryukov.
See #48491.
Built from https://develop.svn.wordpress.org/trunk@48638


git-svn-id: http://core.svn.wordpress.org/trunk@48400 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2020-07-27 15:04:03 +00:00
parent 39147698d9
commit 4336a2b9a7
4 changed files with 171 additions and 5 deletions

View File

@ -271,6 +271,66 @@ if ( $tab ) {
<# } else { #>
<div class="theme-screenshot blank"></div>
<# } #>
<# if ( data.installed ) { #>
<div class="notice notice-success notice-alt"><p><?php _ex( 'Installed', 'theme' ); ?></p></div>
<# } #>
<# if ( ! data.compatible_wp || ! data.compatible_php ) { #>
<div class="notice notice-error notice-alt"><p>
<# if ( ! data.compatible_wp && ! data.compatible_php ) { #>
<?php
_e( 'This theme doesn&#8217;t work with your versions of WordPress and PHP.' );
if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
printf(
/* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
self_admin_url( 'update-core.php' ),
esc_url( wp_get_update_php_url() )
);
wp_update_php_annotation( '</p><p><em>', '</em>' );
} elseif ( current_user_can( 'update_core' ) ) {
printf(
/* translators: %s: URL to WordPress Updates screen. */
' ' . __( '<a href="%s">Please update WordPress</a>.' ),
self_admin_url( 'update-core.php' )
);
} elseif ( current_user_can( 'update_php' ) ) {
printf(
/* translators: %s: URL to Update PHP page. */
' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
esc_url( wp_get_update_php_url() )
);
wp_update_php_annotation( '</p><p><em>', '</em>' );
}
?>
<# } else if ( ! data.compatible_wp ) { #>
<?php
_e( 'This theme doesn&#8217;t work with your version of WordPress.' );
if ( current_user_can( 'update_core' ) ) {
printf(
/* translators: %s: URL to WordPress Updates screen. */
' ' . __( '<a href="%s">Please update WordPress</a>.' ),
self_admin_url( 'update-core.php' )
);
}
?>
<# } else if ( ! data.compatible_php ) { #>
<?php
_e( 'This theme doesn&#8217;t work with your version of PHP.' );
if ( current_user_can( 'update_php' ) ) {
printf(
/* translators: %s: URL to Update PHP page. */
' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
esc_url( wp_get_update_php_url() )
);
wp_update_php_annotation( '</p><p><em>', '</em>' );
}
?>
<# } #>
</p></div>
<# } #>
<span class="more-details"><?php _ex( 'Details &amp; Preview', 'theme' ); ?></span>
<div class="theme-author">
<?php
@ -338,10 +398,6 @@ if ( $tab ) {
<# } #>
</div>
</div>
<# if ( data.installed ) { #>
<div class="notice notice-success notice-alt"><p><?php _ex( 'Installed', 'theme' ); ?></p></div>
<# } #>
</script>
<script id="tmpl-theme-preview" type="text/template">

View File

@ -615,6 +615,61 @@ function wp_theme_auto_update_setting_template() {
<# } #>
<# } #>
<# if ( ! data.compatibleWP || ! data.compatiblePHP ) { #>
<div class="notice notice-error notice-alt"><p>
<# if ( ! data.compatibleWP && ! data.compatiblePHP ) { #>
<?php
_e( 'This theme doesn&#8217;t work with your versions of WordPress and PHP.' );
if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
printf(
/* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
self_admin_url( 'update-core.php' ),
esc_url( wp_get_update_php_url() )
);
wp_update_php_annotation( '</p><p><em>', '</em>' );
} elseif ( current_user_can( 'update_core' ) ) {
printf(
/* translators: %s: URL to WordPress Updates screen. */
' ' . __( '<a href="%s">Please update WordPress</a>.' ),
self_admin_url( 'update-core.php' )
);
} elseif ( current_user_can( 'update_php' ) ) {
printf(
/* translators: %s: URL to Update PHP page. */
' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
esc_url( wp_get_update_php_url() )
);
wp_update_php_annotation( '</p><p><em>', '</em>' );
}
?>
<# } else if ( ! data.compatibleWP ) { #>
<?php
_e( 'This theme doesn&#8217;t work with your version of WordPress.' );
if ( current_user_can( 'update_core' ) ) {
printf(
/* translators: %s: URL to WordPress Updates screen. */
' ' . __( '<a href="%s">Please update WordPress</a>.' ),
self_admin_url( 'update-core.php' )
);
}
?>
<# } else if ( ! data.compatiblePHP ) { #>
<?php
_e( 'This theme doesn&#8217;t work with your version of PHP.' );
if ( current_user_can( 'update_php' ) ) {
printf(
/* translators: %s: URL to Update PHP page. */
' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
esc_url( wp_get_update_php_url() )
);
wp_update_php_annotation( '</p><p><em>', '</em>' );
}
?>
<# } #>
</p></div>
<# } #>
<span class="more-details" id="{{ data.id }}-action"><?php _e( 'Theme Details' ); ?></span>
<div class="theme-author">
<?php

View File

@ -107,6 +107,61 @@ class WP_Customize_Theme_Control extends WP_Customize_Control {
</div>
<# } #>
<# if ( ! data.theme.compatibleWP || ! data.theme.compatiblePHP ) { #>
<div class="notice notice-error notice-alt"><p>
<# if ( ! data.theme.compatibleWP && ! data.theme.compatiblePHP ) { #>
<?php
_e( 'This theme doesn&#8217;t work with your versions of WordPress and PHP.' );
if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
printf(
/* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
self_admin_url( 'update-core.php' ),
esc_url( wp_get_update_php_url() )
);
wp_update_php_annotation( '</p><p><em>', '</em>' );
} elseif ( current_user_can( 'update_core' ) ) {
printf(
/* translators: %s: URL to WordPress Updates screen. */
' ' . __( '<a href="%s">Please update WordPress</a>.' ),
self_admin_url( 'update-core.php' )
);
} elseif ( current_user_can( 'update_php' ) ) {
printf(
/* translators: %s: URL to Update PHP page. */
' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
esc_url( wp_get_update_php_url() )
);
wp_update_php_annotation( '</p><p><em>', '</em>' );
}
?>
<# } else if ( ! data.theme.compatibleWP ) { #>
<?php
_e( 'This theme doesn&#8217;t work with your version of WordPress.' );
if ( current_user_can( 'update_core' ) ) {
printf(
/* translators: %s: URL to WordPress Updates screen. */
' ' . __( '<a href="%s">Please update WordPress</a>.' ),
self_admin_url( 'update-core.php' )
);
}
?>
<# } else if ( ! data.theme.compatiblePHP ) { #>
<?php
_e( 'This theme doesn&#8217;t work with your version of PHP.' );
if ( current_user_can( 'update_php' ) ) {
printf(
/* translators: %s: URL to Update PHP page. */
' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
esc_url( wp_get_update_php_url() )
);
wp_update_php_annotation( '</p><p><em>', '</em>' );
}
?>
<# } #>
</p></div>
<# } #>
<# if ( data.theme.active ) { #>
<div class="theme-id-container">
<h3 class="theme-name" id="{{ data.section }}-{{ data.theme.id }}-name">

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.5-beta3-48637';
$wp_version = '5.5-beta3-48638';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.