| | 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 | /** |
| | 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 | /** |