<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[43006] trunk/src/wp-admin: General: Implement editorial, design and accessibility feedback for the PHP version nag.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/43006">43006</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/43006","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>flixos90</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2018-04-26 14:30:24 +0000 (Thu, 26 Apr 2018)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>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 <a href="https://core.trac.wordpress.org/ticket/41191">#41191</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadmincssdashboardcss">trunk/src/wp-admin/css/dashboard.css</a></li>
<li><a href="#trunksrcwpadminincludesdashboardphp">trunk/src/wp-admin/includes/dashboard.php</a></li>
<li><a href="#trunksrcwpadminincludestemplatephp">trunk/src/wp-admin/includes/template.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadmincssdashboardcss"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/css/dashboard.css</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/css/dashboard.css      2018-04-25 22:37:08 UTC (rev 43005)
+++ trunk/src/wp-admin/css/dashboard.css        2018-04-26 14:30:24 UTC (rev 43006)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1117,17 +1117,25 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> /* PHP Nag */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-#dashboard_php_nag h2.hndle {
-       border-left: 4px solid #dc3232;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+#dashboard_php_nag .dashicons-warning {
+       color: #ffb900;
+       padding-right: 6px;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+#dashboard_php_nag.php-insecure .dashicons-warning {
+       color: #df3232;
+}
+
+#dashboard_php_nag p {
+       margin: 12px 0;
+}
+
</ins><span class="cx" style="display: block; padding: 0 10px"> #dashboard_php_nag h3 {
</span><span class="cx" style="display: block; padding: 0 10px">        font-weight: 600;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-#dashboard_php_nag .button.button-hero {
-       display: block;
-       text-align: center;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+#dashboard_php_nag .button .dashicons-external {
+       line-height: 25px;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> /* =Media Queries
</span></span></pre></div>
<a id="trunksrcwpadminincludesdashboardphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/dashboard.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/dashboard.php 2018-04-25 22:37:08 UTC (rev 43005)
+++ trunk/src/wp-admin/includes/dashboard.php   2018-04-26 14:30:24 UTC (rev 43006)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -35,11 +35,11 @@
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        // PHP Version
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // PHP Version.
</ins><span class="cx" style="display: block; padding: 0 10px">         $response = wp_check_php_version();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        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' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 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' );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        // Right Now
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1618,37 +1618,56 @@
</span><span class="cx" style="display: block; padding: 0 10px">                return;
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        $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&#8217;re showing you this notice.' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( isset( $response['is_secure'] ) && ! $response['is_secure'] ) {
+               $msg = __( 'WordPress has detected that your site is running on an insecure version of PHP.' );
</ins><span class="cx" style="display: block; padding: 0 10px">         } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $msg = __( 'WordPress has detected that your site is running on an outdated version of PHP, which is why we&#8217;re showing you this notice.' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $msg = __( 'WordPress has detected that your site is running on an outdated version of PHP.' );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        ?>
</span><span class="cx" style="display: block; padding: 0 10px">        <p><?php echo $msg; ?></p>
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        <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>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <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 site’s performance.' ); ?></p>
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        <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>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <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)' )
+                       );
+               ?>
</ins><span class="cx" style="display: block; padding: 0 10px">         </p>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-       <p><?php _e( 'Upgrading usually takes only a few minutes and should be safe if you follow the provided instructions.' ); ?></p>
</del><span class="cx" style="display: block; padding: 0 10px">         <?php
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * 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;
+}
+
+/**
</ins><span class="cx" style="display: block; padding: 0 10px">  * Checks if the user needs to upgrade PHP.
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * @since 5.0.0
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return array Array of PHP version data.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return array|false $response Array of PHP version data. False on failure.
</ins><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_check_php_version() {
</span><span class="cx" style="display: block; padding: 0 10px">        $version = phpversion();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1665,16 +1684,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $response = wp_remote_get( $url );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                         return false;
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                /**
</span><span class="cx" style="display: block; padding: 0 10px">                 * Response should be an array with:
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                 *  '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
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+          *  '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.
</ins><span class="cx" style="display: block; padding: 0 10px">                  */
</span><span class="cx" style="display: block; padding: 0 10px">                $response = json_decode( wp_remote_retrieve_body( $response ), true );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span></span></pre></div>
<a id="trunksrcwpadminincludestemplatephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/template.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/template.php  2018-04-25 22:37:08 UTC (rev 43005)
+++ trunk/src/wp-admin/includes/template.php    2018-04-26 14:30:24 UTC (rev 43006)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1140,7 +1140,13 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                                echo '<span class="toggle-indicator" aria-hidden="true"></span>';
</span><span class="cx" style="display: block; padding: 0 10px">                                                echo '</button>';
</span><span class="cx" style="display: block; padding: 0 10px">                                        }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        echo "<h2 class='hndle'><span>{$box['title']}</span></h2>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                 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";
</ins><span class="cx" style="display: block; padding: 0 10px">                                         echo '<div class="inside">' . "\n";
</span><span class="cx" style="display: block; padding: 0 10px">                                        call_user_func( $box['callback'], $object, $box );
</span><span class="cx" style="display: block; padding: 0 10px">                                        echo "</div>\n";
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2166,7 +2172,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><span class="cx" style="display: block; padding: 0 10px"> <!DOCTYPE html>
</span><span class="cx" style="display: block; padding: 0 10px"> <!--[if IE 8]>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<html xmlns="http://www.w3.org/1999/xhtml" class="ie8 <?php echo $admin_html_class; ?>" 
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<html xmlns="http://www.w3.org/1999/xhtml" class="ie8 <?php echo $admin_html_class; ?>"
</ins><span class="cx" style="display: block; padding: 0 10px">                                                                                                                                         <?php
</span><span class="cx" style="display: block; padding: 0 10px">                                                                                                                                        /**
</span><span class="cx" style="display: block; padding: 0 10px">                                                                                                                                         * Fires inside the HTML tag in the admin header.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2178,7 +2184,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        <?php language_attributes(); ?>>
</span><span class="cx" style="display: block; padding: 0 10px"> <![endif]-->
</span><span class="cx" style="display: block; padding: 0 10px"> <!--[if !(IE 8) ]><!-->
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<html xmlns="http://www.w3.org/1999/xhtml" class="<?php echo $admin_html_class; ?>" 
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<html xmlns="http://www.w3.org/1999/xhtml" class="<?php echo $admin_html_class; ?>"
</ins><span class="cx" style="display: block; padding: 0 10px">                                                                                                                                 <?php
</span><span class="cx" style="display: block; padding: 0 10px">                                                                                                                                /** This action is documented in wp-admin/includes/template.php */
</span><span class="cx" style="display: block; padding: 0 10px">                                                                                                                                do_action( 'admin_xml_ns' );
</span></span></pre>
</div>
</div>

</body>
</html>