From 88c4b0c9a7d2e2d5b0fcbd297cd8b5790a6546f7 Mon Sep 17 00:00:00 2001
From: Paul Biron <paul@sparrowhawkcomputing.com>
Date: Tue, 28 Jul 2020 10:03:21 -0600
Subject: [PATCH] disable the plugin/theme auto-updates UI if
 AUTOMATIC_UPDATER_DISABLED is defined & true.

---
 src/wp-admin/includes/update.php | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/wp-admin/includes/update.php b/src/wp-admin/includes/update.php
index 7570905548..0641b1e898 100644
--- a/src/wp-admin/includes/update.php
+++ b/src/wp-admin/includes/update.php
@@ -1014,6 +1014,13 @@ function wp_recovery_mode_nag() {
  * @return bool True if auto-updates are enabled for `$type`, false otherwise.
  */
 function wp_is_auto_update_enabled_for_type( $type ) {
+	if ( ! class_exists( 'WP_Automatic_Updater' ) ) {
+		require_once ABSPATH . 'wp-admin/includes/class-wp-automatic-updater.php';
+	}
+
+	$updater = new WP_Automatic_Updater();
+	$enabled = ! $updater->is_disabled();
+
 	switch ( $type ) {
 		case 'plugin':
 			/**
@@ -1023,7 +1030,7 @@ function wp_is_auto_update_enabled_for_type( $type ) {
 			 *
 			 * @param bool $enabled True if plugins auto-update is enabled, false otherwise.
 			 */
-			return apply_filters( 'plugins_auto_update_enabled', true );
+			return apply_filters( 'plugins_auto_update_enabled', $enabled );
 		case 'theme':
 			/**
 			 * Filters whether themes auto-update is enabled.
@@ -1032,7 +1039,7 @@ function wp_is_auto_update_enabled_for_type( $type ) {
 			 *
 			 * @param bool $enabled True if themes auto-update is enabled, false otherwise.
 			 */
-			return apply_filters( 'themes_auto_update_enabled', true );
+			return apply_filters( 'themes_auto_update_enabled', $enabled );
 	}
 
 	return false;
-- 
2.26.2.windows.1

