|
20 | 20 | function wp_dashboard_setup() { |
21 | 21 | global $wp_registered_widgets, $wp_registered_widget_controls, $wp_dashboard_control_callbacks; |
22 | 22 |
|
23 | | - $wp_dashboard_control_callbacks = array(); |
24 | | - $screen = get_current_screen(); |
| 23 | + $screen = get_current_screen(); |
25 | 24 |
|
26 | 25 | /* Register Widgets and Controls */ |
| 26 | + $wp_dashboard_control_callbacks = array(); |
27 | 27 |
|
28 | | - $response = wp_check_browser_version(); |
| 28 | + // Browser version |
| 29 | + $check_browser = wp_check_browser_version(); |
29 | 30 |
|
30 | | - if ( $response && $response['upgrade'] ) { |
| 31 | + if ( $check_browser && $check_browser['upgrade'] ) { |
31 | 32 | add_filter( 'postbox_classes_dashboard_dashboard_browser_nag', 'dashboard_browser_nag_class' ); |
32 | 33 |
|
33 | | - if ( $response['insecure'] ) { |
| 34 | + if ( $check_browser['insecure'] ) { |
34 | 35 | wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'You are using an insecure browser!' ), 'wp_dashboard_browser_nag' ); |
35 | 36 | } else { |
36 | 37 | wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'Your browser is out of date!' ), 'wp_dashboard_browser_nag' ); |
37 | 38 | } |
38 | 39 | } |
39 | 40 |
|
40 | 41 | // PHP Version. |
41 | | - $response = wp_check_php_version(); |
| 42 | + $check_php = wp_check_php_version(); |
42 | 43 |
|
43 | | - if ( $response && isset( $response['is_acceptable'] ) && ! $response['is_acceptable'] |
44 | | - && current_user_can( 'update_php' ) |
45 | | - ) { |
46 | | - add_filter( 'postbox_classes_dashboard_dashboard_php_nag', 'dashboard_php_nag_class' ); |
| 44 | + if ( $check_php && current_user_can( 'update_php' ) ) { |
| 45 | + // If "not acceptable" the widget will be shown. |
| 46 | + if ( isset( $check_php['is_acceptable'] ) && ! $check_php['is_acceptable'] ) { |
| 47 | + add_filter( 'postbox_classes_dashboard_dashboard_php_nag', 'dashboard_php_nag_class' ); |
47 | 48 |
|
48 | | - wp_add_dashboard_widget( 'dashboard_php_nag', __( 'PHP Update Recommended' ), 'wp_dashboard_php_nag' ); |
| 49 | + if ( $check_php['is_lower_than_future_minimum'] ) { |
| 50 | + wp_add_dashboard_widget( 'dashboard_php_nag', __( 'PHP Update Required' ), 'wp_dashboard_php_nag' ); |
| 51 | + } else { |
| 52 | + wp_add_dashboard_widget( 'dashboard_php_nag', __( 'PHP Update Recommended' ), 'wp_dashboard_php_nag' ); |
| 53 | + } |
| 54 | + } |
49 | 55 | } |
50 | 56 |
|
51 | 57 | // Site Health. |
@@ -1825,29 +1831,48 @@ function wp_dashboard_php_nag() { |
1825 | 1831 | } |
1826 | 1832 |
|
1827 | 1833 | if ( isset( $response['is_secure'] ) && ! $response['is_secure'] ) { |
1828 | | - $msg = sprintf( |
| 1834 | + // The `is_secure` array key name doesn't actually imply this is a secure version of PHP. It only means it receives security updates. |
| 1835 | + |
| 1836 | + if ( $response['is_lower_than_future_minimum'] ) { |
| 1837 | + $message = sprintf( |
| 1838 | + /* translators: %s: The server PHP version. */ |
| 1839 | + __( 'Your site is running on an outdated version of PHP (%s), which does not receive security updates and soon will not be supported by WordPress. Ensure that PHP is updated on your server as soon as possible. Otherwise you will not be able to upgrade WordPress.' ), |
| 1840 | + PHP_VERSION |
| 1841 | + ); |
| 1842 | + } else { |
| 1843 | + $message = sprintf( |
| 1844 | + /* translators: %s: The server PHP version. */ |
| 1845 | + __( 'Your site is running on an outdated version of PHP (%s), which does not receive security updates. It should be updated.' ), |
| 1846 | + PHP_VERSION |
| 1847 | + ); |
| 1848 | + } |
| 1849 | + } elseif ( $response['is_lower_than_future_minimum'] ) { |
| 1850 | + $message = sprintf( |
1829 | 1851 | /* translators: %s: The server PHP version. */ |
1830 | | - __( 'Your site is running an insecure version of PHP (%s), which should be updated.' ), |
| 1852 | + __( 'Your site is running on an outdated version of PHP (%s), which soon will not be supported by WordPress. Ensure that PHP is updated on your server as soon as possible. Otherwise you will not be able to upgrade WordPress.' ), |
1831 | 1853 | PHP_VERSION |
1832 | 1854 | ); |
1833 | 1855 | } else { |
1834 | | - $msg = sprintf( |
| 1856 | + $message = sprintf( |
1835 | 1857 | /* translators: %s: The server PHP version. */ |
1836 | | - __( 'Your site is running an outdated version of PHP (%s), which should be updated.' ), |
| 1858 | + __( 'Your site is running on an outdated version of PHP (%s), which should be updated.' ), |
1837 | 1859 | PHP_VERSION |
1838 | 1860 | ); |
1839 | 1861 | } |
1840 | 1862 | ?> |
1841 | | - <p><?php echo $msg; ?></p> |
| 1863 | + <p class="bigger-bolder-text"><?php echo $message; ?></p> |
1842 | 1864 |
|
1843 | | - <h3><?php _e( 'What is PHP and how does it affect my site?' ); ?></h3> |
| 1865 | + <p><?php _e( 'What is PHP and how does it affect my site?' ); ?></p> |
1844 | 1866 | <p> |
| 1867 | + <?php _e( 'PHP is one of the programming languages used to build WordPress. Newer versions of PHP receive regular security updates and may increase your site’s performance.' ); ?> |
1845 | 1868 | <?php |
1846 | | - printf( |
1847 | | - /* translators: %s: The minimum recommended PHP version. */ |
1848 | | - __( 'PHP is the programming language used to build and maintain WordPress. Newer versions of PHP are created with increased performance in mind, so you may see a positive effect on your site’s performance. The minimum recommended version of PHP is %s.' ), |
1849 | | - $response ? $response['recommended_version'] : '' |
1850 | | - ); |
| 1869 | + if ( ! empty( $response['recommended_version'] ) ) { |
| 1870 | + printf( |
| 1871 | + /* translators: %s: The minimum recommended PHP version. */ |
| 1872 | + __( 'The minimum recommended version of PHP is %s.' ), |
| 1873 | + $response['recommended_version'] |
| 1874 | + ); |
| 1875 | + } |
1851 | 1876 | ?> |
1852 | 1877 | </p> |
1853 | 1878 |
|
@@ -1879,8 +1904,14 @@ function wp_dashboard_php_nag() { |
1879 | 1904 | function dashboard_php_nag_class( $classes ) { |
1880 | 1905 | $response = wp_check_php_version(); |
1881 | 1906 |
|
1882 | | - if ( $response && isset( $response['is_secure'] ) && ! $response['is_secure'] ) { |
1883 | | - $classes[] = 'php-insecure'; |
| 1907 | + if ( ! $response ) { |
| 1908 | + return $classes; |
| 1909 | + } |
| 1910 | + |
| 1911 | + if ( isset( $response['is_secure'] ) && ! $response['is_secure'] ) { |
| 1912 | + $classes[] = 'php-no-security-updates'; |
| 1913 | + } elseif ( $response['is_lower_than_future_minimum'] ) { |
| 1914 | + $classes[] = 'php-version-lower-than-future-minimum'; |
1884 | 1915 | } |
1885 | 1916 |
|
1886 | 1917 | return $classes; |
|
0 commit comments