Changeset 42832 for trunk/src/wp-admin/includes/dashboard.php
- Timestamp:
- 03/12/2018 04:42:11 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/dashboard.php
r42781 r42832 34 34 wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'Your browser is out of date!' ), 'wp_dashboard_browser_nag' ); 35 35 } 36 } 37 38 // PHP Version 39 $response = wp_check_php_version(); 40 if ( $response && ! $response['is_acceptable'] && current_user_can( 'upgrade_php' ) ) { 41 $title = $response['is_secure'] ? __( 'Your site could be much faster!' ) : __( 'Your site could be much faster and more secure!' ); 42 wp_add_dashboard_widget( 'dashboard_php_nag', $title, 'wp_dashboard_php_nag' ); 36 43 } 37 44 … … 179 186 } 180 187 188 $high_priority_widgets = array( 'dashboard_browser_nag', 'dashboard_php_nag' ); 189 181 190 $priority = 'core'; 182 if ( 'dashboard_browser_nag' === $widget_id) {191 if ( in_array( $widget_id, $high_priority_widgets, true ) ) { 183 192 $priority = 'high'; 184 193 } … … 1595 1604 1596 1605 set_site_transient( 'browser_' . $key, $response, WEEK_IN_SECONDS ); 1606 } 1607 1608 return $response; 1609 } 1610 1611 /** 1612 * Displays the PHP upgrade nag. 1613 * 1614 * @since 5.0.0 1615 */ 1616 function wp_dashboard_php_nag() { 1617 $response = wp_check_php_version(); 1618 1619 if ( ! $response ) { 1620 return; 1621 } 1622 1623 $information_url = _x( 'https://wordpress.org/support/upgrade-php/', 'localized PHP upgrade information page' ); 1624 1625 $msg = __( 'Hi, it’s your friends at WordPress here.' ); 1626 if ( ! $response['is_secure'] ) { 1627 $msg .= ' ' . __( 'We noticed that your site is running on an insecure version of PHP, which is why we’re showing you this notice.' ); 1628 } else { 1629 $msg .= ' ' . __( 'We noticed that your site is running on an outdated version of PHP, which is why we’re showing you this notice.' ); 1630 } 1631 1632 ?> 1633 <p><?php echo $msg; ?></p> 1634 1635 <h3><?php _e( 'What is PHP and why should I care?' ); ?></h3> 1636 <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> 1637 <p><?php _e( 'If you want to know exactly how PHP works and why it is important, continue reading.' ); ?></p> 1638 1639 <h3><?php _e( 'Okay, how do I update?' ); ?></h3> 1640 <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’t.' ); ?></p> 1641 <p> 1642 <a class="button button-primary button-hero" href="<?php echo esc_url( $information_url ); ?>"><?php _e( 'Show me how to upgrade my PHP' ); ?></a> 1643 </p> 1644 1645 <h3><?php _e( 'Thank you for taking the time to read this!' ); ?></h3> 1646 <p><?php _e( 'If you carefully follow the instructions we’ve provided, upgrading shouldn’t take more than a few minutes, and it is generally very safe to do.' ); ?></p> 1647 <p><?php _e( 'Good luck and happy blogging!' ); ?></p> 1648 <?php 1649 } 1650 1651 /** 1652 * Checks if the user needs to upgrade PHP. 1653 * 1654 * @since 5.0.0 1655 * 1656 * @return array Array of PHP version data. 1657 */ 1658 function wp_check_php_version() { 1659 $version = phpversion(); 1660 $key = md5( $version ); 1661 1662 $response = get_site_transient( 'php_check_' . $key ); 1663 if ( false === $response ) { 1664 $url = 'http://api.wordpress.org/core/serve-happy/1.0/'; 1665 if ( wp_http_supports( array( 'ssl' ) ) ) { 1666 $url = set_url_scheme( $url, 'https' ); 1667 } 1668 1669 $url = add_query_arg( 'php_version', $version, $url ); 1670 1671 $response = wp_remote_get( $url ); 1672 1673 if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) { 1674 return false; 1675 } 1676 1677 /** 1678 * Response should be an array with: 1679 * 'recommended_version' - string - The PHP version recommended by WordPress 1680 * 'is_supported' - boolean - Whether the PHP version is actively supported 1681 * 'is_secure' - boolean - Whether the PHP version receives security updates 1682 * 'is_acceptable' - boolean - Whether the PHP version is still acceptable for WordPress 1683 */ 1684 $response = json_decode( wp_remote_retrieve_body( $response ), true ); 1685 1686 if ( ! is_array( $response ) ) { 1687 return false; 1688 } 1689 1690 set_site_transient( 'php_check_' . $key, $response, WEEK_IN_SECONDS ); 1597 1691 } 1598 1692
Note: See TracChangeset
for help on using the changeset viewer.