General: Implement editorial, design and accessibility feedback for the PHP version nag.

The updated version of the nag is shorter, more on point and less aggressive than the previous one. It integrates better with the other dashboard widgets and fixes several accessibility concerns. A yellow warning color is used when the current PHP version is outdated, a red error color is used when it is also insecure.

Props afercia, birgire, danieltj, flixos90, johnjamesjacoby, karmatosed, Luciano Croce, nerrad, pento, schlessera, SergeyBiryukov, sonjaleix.

Fixes #41191.

Built from https://develop.svn.wordpress.org/trunk@43006


git-svn-id: http://core.svn.wordpress.org/trunk@42835 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Felix Arntz 2018-04-26 14:31:24 +00:00
parent 603c91b3bc
commit 6b2e34f703
7 changed files with 81 additions and 40 deletions

View File

@ -1117,17 +1117,25 @@ a.rsswidget {
}
/* PHP Nag */
#dashboard_php_nag h2.hndle {
border-right: 4px solid #dc3232;
#dashboard_php_nag .dashicons-warning {
color: #ffb900;
padding-left: 6px;
}
#dashboard_php_nag.php-insecure .dashicons-warning {
color: #df3232;
}
#dashboard_php_nag p {
margin: 12px 0;
}
#dashboard_php_nag h3 {
font-weight: 600;
}
#dashboard_php_nag .button.button-hero {
display: block;
text-align: center;
#dashboard_php_nag .button .dashicons-external {
line-height: 25px;
}
/* =Media Queries

File diff suppressed because one or more lines are too long

View File

@ -1117,17 +1117,25 @@ a.rsswidget {
}
/* PHP Nag */
#dashboard_php_nag h2.hndle {
border-left: 4px solid #dc3232;
#dashboard_php_nag .dashicons-warning {
color: #ffb900;
padding-right: 6px;
}
#dashboard_php_nag.php-insecure .dashicons-warning {
color: #df3232;
}
#dashboard_php_nag p {
margin: 12px 0;
}
#dashboard_php_nag h3 {
font-weight: 600;
}
#dashboard_php_nag .button.button-hero {
display: block;
text-align: center;
#dashboard_php_nag .button .dashicons-external {
line-height: 25px;
}
/* =Media Queries

File diff suppressed because one or more lines are too long

View File

@ -35,11 +35,11 @@ function wp_dashboard_setup() {
}
}
// PHP Version
// PHP Version.
$response = wp_check_php_version();
if ( $response && ! $response['is_acceptable'] && current_user_can( 'upgrade_php' ) ) {
$title = $response['is_secure'] ? __( 'Your site could be much faster!' ) : __( 'Your site could be much faster and more secure!' );
wp_add_dashboard_widget( 'dashboard_php_nag', $title, 'wp_dashboard_php_nag' );
if ( $response && isset( $response['is_acceptable'] ) && ! $response['is_acceptable'] && current_user_can( 'upgrade_php' ) ) {
add_filter( 'postbox_classes_dashboard_dashboard_php_nag', 'dashboard_php_nag_class' );
wp_add_dashboard_widget( 'dashboard_php_nag', __( 'PHP Update Required' ), 'wp_dashboard_php_nag' );
}
// Right Now
@ -1618,37 +1618,56 @@ function wp_dashboard_php_nag() {
return;
}
$information_url = _x( 'https://wordpress.org/support/upgrade-php/', 'localized PHP upgrade information page' );
if ( ! $response['is_secure'] ) {
$msg = __( 'WordPress has detected that your site is running on an insecure version of PHP, which is why we’re showing you this notice.' );
if ( isset( $response['is_secure'] ) && ! $response['is_secure'] ) {
$msg = __( 'WordPress has detected that your site is running on an insecure version of PHP.' );
} else {
$msg = __( 'WordPress has detected that your site is running on an outdated version of PHP, which is why we’re showing you this notice.' );
$msg = __( 'WordPress has detected that your site is running on an outdated version of PHP.' );
}
?>
<p><?php echo $msg; ?></p>
<h3><?php _e( 'What is PHP and why should I care?' ); ?></h3>
<p><?php _e( 'PHP is the programming language that WordPress is built on. Newer versions of PHP are both faster and more secure, so upgrading is better for your site, and better for the people who are building WordPress.' ); ?></p>
<p><?php _e( 'If you want to know exactly how PHP works and why it is important, continue reading.' ); ?></p>
<h3><?php _e( 'What is PHP and how does it affect my site?' ); ?></h3>
<p><?php _e( 'PHP is the programming language we use to build and maintain WordPress. Newer versions of PHP are both faster and more secure, so updating will have a positive effect on your sites performance.' ); ?></p>
<h3><?php _e( 'How can I upgrade my PHP version?' ); ?></h3>
<p><?php _e( 'The button below will take you to a page with more details on what PHP is, how to upgrade your PHP version, and what to do if it turns out you can&#8217;t.' ); ?></p>
<p>
<a class="button button-primary button-hero" href="<?php echo esc_url( $information_url ); ?>"><?php _e( 'Show me how to upgrade my PHP' ); ?></a>
<p class="button-container">
<?php
printf(
'<a class="button button-primary" href="%1$s" target="_blank" rel="noopener noreferrer">%2$s <span class="screen-reader-text">%3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>',
esc_url( _x( 'https://wordpress.org/support/upgrade-php/', 'localized PHP upgrade information page' ) ),
__( 'Learn more about updating PHP' ),
/* translators: accessibility text */
__( '(opens in a new tab)' )
);
?>
</p>
<p><?php _e( 'Upgrading usually takes only a few minutes and should be safe if you follow the provided instructions.' ); ?></p>
<?php
}
/**
* Adds an additional class to the PHP nag if the current version is insecure.
*
* @since 5.0.0
*
* @param array $classes Metabox classes.
* @return array Modified metabox classes.
*/
function dashboard_php_nag_class( $classes ) {
$response = wp_check_php_version();
if ( $response && isset( $response['is_secure'] ) && ! $response['is_secure'] ) {
$classes[] = 'php-insecure';
}
return $classes;
}
/**
* Checks if the user needs to upgrade PHP.
*
* @since 5.0.0
*
* @return array Array of PHP version data.
* @return array|false $response Array of PHP version data. False on failure.
*/
function wp_check_php_version() {
$version = phpversion();
@ -1665,16 +1684,16 @@ function wp_check_php_version() {
$response = wp_remote_get( $url );
if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) {
if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
return false;
}
/**
* Response should be an array with:
* 'recommended_version' - string - The PHP version recommended by WordPress
* 'is_supported' - boolean - Whether the PHP version is actively supported
* 'is_secure' - boolean - Whether the PHP version receives security updates
* 'is_acceptable' - boolean - Whether the PHP version is still acceptable for WordPress
* 'recommended_version' - string - The PHP version recommended by WordPress.
* 'is_supported' - boolean - Whether the PHP version is actively supported.
* 'is_secure' - boolean - Whether the PHP version receives security updates.
* 'is_acceptable' - boolean - Whether the PHP version is still acceptable for WordPress.
*/
$response = json_decode( wp_remote_retrieve_body( $response ), true );

View File

@ -1140,7 +1140,13 @@ function do_meta_boxes( $screen, $context, $object ) {
echo '<span class="toggle-indicator" aria-hidden="true"></span>';
echo '</button>';
}
echo "<h2 class='hndle'><span>{$box['title']}</span></h2>\n";
echo '<h2 class="hndle">';
if ( 'dashboard_php_nag' === $box['id'] ) {
echo '<span aria-hidden="true" class="dashicons dashicons-warning"></span>';
echo '<span class="screen-reader-text">' . __( 'Warning:' ) . ' </span>';
}
echo "<span>{$box['title']}</span>";
echo "</h2>\n";
echo '<div class="inside">' . "\n";
call_user_func( $box['callback'], $object, $box );
echo "</div>\n";
@ -2166,7 +2172,7 @@ function _wp_admin_html_begin() {
?>
<!DOCTYPE html>
<!--[if IE 8]>
<html xmlns="http://www.w3.org/1999/xhtml" class="ie8 <?php echo $admin_html_class; ?>"
<html xmlns="http://www.w3.org/1999/xhtml" class="ie8 <?php echo $admin_html_class; ?>"
<?php
/**
* Fires inside the HTML tag in the admin header.
@ -2178,7 +2184,7 @@ function _wp_admin_html_begin() {
<?php language_attributes(); ?>>
<![endif]-->
<!--[if !(IE 8) ]><!-->
<html xmlns="http://www.w3.org/1999/xhtml" class="<?php echo $admin_html_class; ?>"
<html xmlns="http://www.w3.org/1999/xhtml" class="<?php echo $admin_html_class; ?>"
<?php
/** This action is documented in wp-admin/includes/template.php */
do_action( 'admin_xml_ns' );

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.0-alpha-43005';
$wp_version = '5.0-alpha-43006';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.