Themes: Display a message in theme grid and Theme Details modal if a theme update requires a higher version of PHP or WordPress.
This applies to the Themes screen and the Customizer theme browser. Props afragen, SergeyBiryukov. See #48491. Built from https://develop.svn.wordpress.org/trunk@48652 git-svn-id: http://core.svn.wordpress.org/trunk@48414 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
6307a7c41c
commit
0122e035b0
|
@ -684,6 +684,9 @@ function wp_prepare_themes_for_js( $themes = null ) {
|
|||
);
|
||||
}
|
||||
|
||||
$update_requires_wp = isset( $updates[ $slug ]['requires'] ) ? $updates[ $slug ]['requires'] : null;
|
||||
$update_requires_php = isset( $updates[ $slug ]['requires_php'] ) ? $updates[ $slug ]['requires_php'] : null;
|
||||
|
||||
$auto_update = in_array( $slug, $auto_updates, true );
|
||||
$auto_update_action = $auto_update ? 'disable-auto-update' : 'enable-auto-update';
|
||||
|
||||
|
@ -698,6 +701,10 @@ function wp_prepare_themes_for_js( $themes = null ) {
|
|||
'version' => $theme->get( 'Version' ),
|
||||
'compatibleWP' => is_wp_version_compatible( $theme->get( 'RequiresWP' ) ),
|
||||
'compatiblePHP' => is_php_version_compatible( $theme->get( 'RequiresPHP' ) ),
|
||||
'updateResponse' => array(
|
||||
'compatibleWP' => is_wp_version_compatible( $update_requires_wp ),
|
||||
'compatiblePHP' => is_php_version_compatible( $update_requires_php ),
|
||||
),
|
||||
'parent' => $parent,
|
||||
'active' => $slug === $current_theme,
|
||||
'hasUpdate' => isset( $updates[ $slug ] ),
|
||||
|
@ -793,10 +800,68 @@ function customize_themes_print_templates() {
|
|||
<# } #>
|
||||
|
||||
<# if ( data.hasUpdate ) { #>
|
||||
<# if ( data.updateResponse.compatibleWP && data.updateResponse.compatiblePHP ) { #>
|
||||
<div class="notice notice-warning notice-alt notice-large" data-slug="{{ data.id }}">
|
||||
<h3 class="notice-title"><?php _e( 'Update Available' ); ?></h3>
|
||||
{{{ data.update }}}
|
||||
</div>
|
||||
<# } else { #>
|
||||
<div class="notice notice-error notice-alt notice-large" data-slug="{{ data.id }}">
|
||||
<h3 class="notice-title"><?php _e( 'Update Incompatible' ); ?></h3>
|
||||
<p>
|
||||
<# if ( ! data.updateResponse.compatibleWP && ! data.updateResponse.compatiblePHP ) { #>
|
||||
<?php
|
||||
_e( 'There is a new version available, but it doesn’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.updateResponse.compatibleWP ) { #>
|
||||
<?php
|
||||
_e( 'There is a new version available, but it doesn’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.updateResponse.compatiblePHP ) { #>
|
||||
<?php
|
||||
_e( 'There is a new version available, but it doesn’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.parent ) { #>
|
||||
|
|
|
@ -389,13 +389,64 @@ foreach ( $themes as $theme ) :
|
|||
<?php } ?>
|
||||
|
||||
<?php if ( $theme['hasUpdate'] ) : ?>
|
||||
<div class="update-message notice inline notice-warning notice-alt">
|
||||
<?php if ( $theme['updateResponse']['compatibleWP'] && $theme['updateResponse']['compatiblePHP'] ) : ?>
|
||||
<div class="update-message notice inline notice-warning notice-alt"><p>
|
||||
<?php if ( $theme['hasPackage'] ) : ?>
|
||||
<p><?php _e( 'New version available. <button class="button-link" type="button">Update now</button>' ); ?></p>
|
||||
<?php _e( 'New version available. <button class="button-link" type="button">Update now</button>' ); ?>
|
||||
<?php else : ?>
|
||||
<p><?php _e( 'New version available.' ); ?></p>
|
||||
<?php _e( 'New version available.' ); ?>
|
||||
<?php endif; ?>
|
||||
</p></div>
|
||||
<?php else : ?>
|
||||
<div class="notice inline notice-error notice-alt"><p>
|
||||
<?php
|
||||
if ( $theme['updateResponse']['compatibleWP'] && $theme['updateResponse']['compatiblePHP'] ) {
|
||||
_e( 'There is a new version available, but it doesn’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>' );
|
||||
}
|
||||
} elseif ( ! $theme['updateResponse']['compatibleWP'] ) {
|
||||
_e( 'There is a new version available, but it doesn’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' )
|
||||
);
|
||||
}
|
||||
} elseif ( ! $theme['updateResponse']['compatiblePHP'] ) {
|
||||
_e( 'There is a new version available, but it doesn’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>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php
|
||||
|
@ -659,10 +710,67 @@ function wp_theme_auto_update_setting_template() {
|
|||
<# } #>
|
||||
|
||||
<# if ( data.hasUpdate ) { #>
|
||||
<# if ( data.updateResponse.compatibleWP && data.updateResponse.compatiblePHP ) { #>
|
||||
<div class="update-message notice inline notice-warning notice-alt"><p>
|
||||
<# if ( data.hasPackage ) { #>
|
||||
<div class="update-message notice inline notice-warning notice-alt"><p><?php _e( 'New version available. <button class="button-link" type="button">Update now</button>' ); ?></p></div>
|
||||
<?php _e( 'New version available. <button class="button-link" type="button">Update now</button>' ); ?>
|
||||
<# } else { #>
|
||||
<div class="update-message notice inline notice-warning notice-alt"><p><?php _e( 'New version available.' ); ?></p></div>
|
||||
<?php _e( 'New version available.' ); ?>
|
||||
<# } #>
|
||||
</p></div>
|
||||
<# } else { #>
|
||||
<div class="notice inline notice-error notice-alt"><p>
|
||||
<# if ( ! data.updateResponse.compatibleWP && ! data.updateResponse.compatiblePHP ) { #>
|
||||
<?php
|
||||
_e( 'There is a new version available, but it doesn’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.updateResponse.compatibleWP ) { #>
|
||||
<?php
|
||||
_e( 'There is a new version available, but it doesn’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.updateResponse.compatiblePHP ) { #>
|
||||
<?php
|
||||
_e( 'There is a new version available, but it doesn’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>
|
||||
<# } #>
|
||||
<# } #>
|
||||
|
||||
|
@ -853,15 +961,73 @@ function wp_theme_auto_update_setting_template() {
|
|||
</p></div>
|
||||
<# } #>
|
||||
|
||||
<# if ( data.actions.autoupdate ) { #>
|
||||
<?php echo wp_theme_auto_update_setting_template(); ?>
|
||||
<# } #>
|
||||
|
||||
<# if ( data.hasUpdate ) { #>
|
||||
<# if ( data.updateResponse.compatibleWP && data.updateResponse.compatiblePHP ) { #>
|
||||
<div class="notice notice-warning notice-alt notice-large">
|
||||
<h3 class="notice-title"><?php _e( 'Update Available' ); ?></h3>
|
||||
{{{ data.update }}}
|
||||
</div>
|
||||
<# } else { #>
|
||||
<div class="notice notice-error notice-alt notice-large">
|
||||
<h3 class="notice-title"><?php _e( 'Update Incompatible' ); ?></h3>
|
||||
<p>
|
||||
<# if ( ! data.updateResponse.compatibleWP && ! data.updateResponse.compatiblePHP ) { #>
|
||||
<?php
|
||||
_e( 'There is a new version available, but it doesn’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.updateResponse.compatibleWP ) { #>
|
||||
<?php
|
||||
_e( 'There is a new version available, but it doesn’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.updateResponse.compatiblePHP ) { #>
|
||||
<?php
|
||||
_e( 'There is a new version available, but it doesn’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.actions.autoupdate ) { #>
|
||||
<?php echo wp_theme_auto_update_setting_template(); ?>
|
||||
<# } #>
|
||||
|
||||
<p class="theme-description">{{{ data.description }}}</p>
|
||||
|
|
|
@ -90,6 +90,7 @@ class WP_Customize_Theme_Control extends WP_Customize_Control {
|
|||
</div>
|
||||
|
||||
<# if ( 'installed' === data.theme.type && data.theme.hasUpdate ) { #>
|
||||
<# if ( data.theme.updateResponse.compatibleWP && data.theme.updateResponse.compatiblePHP ) { #>
|
||||
<div class="update-message notice inline notice-warning notice-alt" data-slug="{{ data.theme.id }}">
|
||||
<p>
|
||||
<?php
|
||||
|
@ -105,6 +106,62 @@ class WP_Customize_Theme_Control extends WP_Customize_Control {
|
|||
?>
|
||||
</p>
|
||||
</div>
|
||||
<# } else { #>
|
||||
<div class="update-message notice inline notice-warning notice-alt" data-slug="{{ data.theme.id }}">
|
||||
<p>
|
||||
<# if ( ! data.theme.updateResponse.compatibleWP && ! data.theme.updateResponse.compatiblePHP ) { #>
|
||||
<?php
|
||||
_e( 'There is a new version available, but it doesn’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.updateResponse.compatibleWP ) { #>
|
||||
<?php
|
||||
_e( 'There is a new version available, but it doesn’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.updateResponse.compatiblePHP ) { #>
|
||||
<?php
|
||||
_e( 'There is a new version available, but it doesn’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.compatibleWP || ! data.theme.compatiblePHP ) { #>
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.5-beta4-48651';
|
||||
$wp_version = '5.5-beta4-48652';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue