Make WordPress Core

Ticket #50662: 50662.2.diff

File 50662.2.diff, 6.6 KB (added by desrosj, 5 years ago)
  • src/wp-admin/includes/class-wp-site-health.php

     
    17351735        }
    17361736
    17371737        /**
     1738         * Test if plugin an theme auto-updates appear to be configured correctly.
     1739         *
     1740         * @since 5.5.0
     1741         *
     1742         * @return array The test results.
     1743         */
     1744        public function get_test_plugin_theme_auto_updates() {
     1745                $result = array(
     1746                        'label'       => __( 'Plugin and Theme auto-updates appear to be configured correctly' ),
     1747                        'status'      => 'good',
     1748                        'badge'       => array(
     1749                                'label' => __( 'Security' ),
     1750                                'color' => 'blue',
     1751                        ),
     1752                        'description' => sprintf(
     1753                                '<p>%s</p>',
     1754                                __( 'Plugin and theme auto updates ensure that the latest versions are always installed.' )
     1755                        ),
     1756                        'actions'     => '',
     1757                        'test'        => 'plugin_theme_auto_updates',
     1758                );
     1759
     1760                $check_plugin_theme_updates = $this->detect_plugin_theme_auto_update_issues();
     1761
     1762                $result['status'] = $check_plugin_theme_updates->status;
     1763
     1764                if ( 'good' !== $check_plugin_theme_updates->status ) {
     1765                        $result['label'] = __( 'Your site may have problems auto-updating plugins and themes' );
     1766
     1767                        $result['description'] .= sprintf(
     1768                                '<p>%s</p>',
     1769                                $check_plugin_theme_updates->message
     1770                        );
     1771                }
     1772
     1773                return $result;
     1774        }
     1775
     1776        /**
    17381777         * Test if loopbacks work as expected.
    17391778         *
    17401779         * A loopback is when WordPress queries itself, for example to start a new WP_Cron instance,
     
    19692008        public static function get_tests() {
    19702009                $tests = array(
    19712010                        'direct' => array(
    1972                                 'wordpress_version'    => array(
     2011                                'wordpress_version'         => array(
    19732012                                        'label' => __( 'WordPress Version' ),
    19742013                                        'test'  => 'wordpress_version',
    19752014                                ),
    1976                                 'plugin_version'       => array(
     2015                                'plugin_version'            => array(
    19772016                                        'label' => __( 'Plugin Versions' ),
    19782017                                        'test'  => 'plugin_version',
    19792018                                ),
    1980                                 'theme_version'        => array(
     2019                                'theme_version'             => array(
    19812020                                        'label' => __( 'Theme Versions' ),
    19822021                                        'test'  => 'theme_version',
    19832022                                ),
    1984                                 'php_version'          => array(
     2023                                'php_version'               => array(
    19852024                                        'label' => __( 'PHP Version' ),
    19862025                                        'test'  => 'php_version',
    19872026                                ),
    1988                                 'php_extensions'       => array(
     2027                                'php_extensions'            => array(
    19892028                                        'label' => __( 'PHP Extensions' ),
    19902029                                        'test'  => 'php_extensions',
    19912030                                ),
    1992                                 'php_default_timezone' => array(
     2031                                'php_default_timezone'      => array(
    19932032                                        'label' => __( 'PHP Default Timezone' ),
    19942033                                        'test'  => 'php_default_timezone',
    19952034                                ),
    1996                                 'php_sessions'         => array(
     2035                                'php_sessions'              => array(
    19972036                                        'label' => __( 'PHP Sessions' ),
    19982037                                        'test'  => 'php_sessions',
    19992038                                ),
    2000                                 'sql_server'           => array(
     2039                                'sql_server'                => array(
    20012040                                        'label' => __( 'Database Server version' ),
    20022041                                        'test'  => 'sql_server',
    20032042                                ),
    2004                                 'utf8mb4_support'      => array(
     2043                                'utf8mb4_support'           => array(
    20052044                                        'label' => __( 'MySQL utf8mb4 support' ),
    20062045                                        'test'  => 'utf8mb4_support',
    20072046                                ),
    2008                                 'https_status'         => array(
     2047                                'https_status'              => array(
    20092048                                        'label' => __( 'HTTPS status' ),
    20102049                                        'test'  => 'https_status',
    20112050                                ),
    2012                                 'ssl_support'          => array(
     2051                                'ssl_support'               => array(
    20132052                                        'label' => __( 'Secure communication' ),
    20142053                                        'test'  => 'ssl_support',
    20152054                                ),
    2016                                 'scheduled_events'     => array(
     2055                                'scheduled_events'          => array(
    20172056                                        'label' => __( 'Scheduled events' ),
    20182057                                        'test'  => 'scheduled_events',
    20192058                                ),
    2020                                 'http_requests'        => array(
     2059                                'http_requests'             => array(
    20212060                                        'label' => __( 'HTTP Requests' ),
    20222061                                        'test'  => 'http_requests',
    20232062                                ),
    2024                                 'debug_enabled'        => array(
     2063                                'debug_enabled'             => array(
    20252064                                        'label' => __( 'Debugging enabled' ),
    20262065                                        'test'  => 'is_in_debug_mode',
    20272066                                ),
     2067                                'plugin_theme_auto_updates' => array(
     2068                                        'label' => __( 'Plugin & Theme auto-updates' ),
     2069                                        'test'  => 'plugin_theme_auto_updates',
     2070                                ),
    20282071                        ),
    20292072                        'async'  => array(
    20302073                                'dotorg_communication' => array(
     
    22062249        }
    22072250
    22082251        /**
     2252         * Check for potential issues with plugin and theme auto-updates.
     2253         *
     2254         * Though there is no way to 100% determine if plugin and theme auto-updates are configured
     2255         * correctly, a few educated guesses could be made to flag any conditions that would
     2256         * potentially cause unexpected behaviors.
     2257         *
     2258         * @since 5.5.0
     2259         *
     2260         * @return object The test results.
     2261         */
     2262        function detect_plugin_theme_auto_update_issues() {
     2263                $test_plugins_enabled = apply_filters( 'auto_update_plugin', true );
     2264                $test_themes_enabled  = apply_filters( 'auto_update_theme', true );
     2265                $ui_enabled_for_plugins          = wp_is_auto_update_enabled_for_type( 'plugin' );
     2266                $ui_enabled_for_themes           = wp_is_auto_update_enabled_for_type( 'theme' );
     2267                $plugin_filter_present           = has_filter( 'auto_update_plugin' );
     2268                $theme_filter_present            = has_filter( 'auto_update_theme' );
     2269
     2270                if ( ( ! $test_plugins_enabled && $ui_enabled_for_plugins ) || ( $test_themes_enabled && $ui_enabled_for_themes ) ) {
     2271                        return (object) array(
     2272                                'status'  => 'critical',
     2273                                'message' => __( 'Auto-updates for plugins and/or themes appear to be disabled, but settings are still set to be displayed. This could cause auto-updates to not work as expected.' ),
     2274                        );
     2275                }
     2276
     2277                if ( ( ! $test_plugins_enabled && $plugin_filter_present ) && ( ! $test_themes_enabled && $theme_filter_present ) ) {
     2278                        return (object) array(
     2279                                'status'  => 'recommended',
     2280                                'message' => __( 'Auto-updates for plugins and themes appear to be disabled. This will prevent your sites from receiving new versions automatically when available.' ),
     2281                        );
     2282                } elseif ( ! $test_plugins_enabled && $plugin_filter_present ) {
     2283                        return (object) array(
     2284                                'status'  => 'recommended',
     2285                                'message' => __( 'Auto-updates for plugins appear to be disabled. This will prevent your sites from receiving new versions automatically when available.' ),
     2286                        );
     2287                } elseif ( ! $test_themes_enabled && $test_themes_enabled ) {
     2288                        return (object) array(
     2289                                'status'  => 'recommended',
     2290                                'message' => __( 'Auto-updates for themes appear to be disabled. This will prevent your sites from receiving new versions automatically when available.' ),
     2291                        );
     2292                }
     2293
     2294                return (object) array(
     2295                        'status'  => 'good',
     2296                        'message' => __( 'There appears to be no issues with plugin and theme auto-updates.' ),
     2297                );
     2298        }
     2299
     2300        /**
    22092301         * Run a loopback test on our site.
    22102302         *
    22112303         * Loopbacks are what WordPress uses to communicate with itself to start up WP_Cron, scheduled posts,