From 1390edda647be489d659b3fa885b2ab85e924e00 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Mon, 16 Feb 2026 18:28:30 -0800 Subject: [PATCH 1/3] Fix return types for Customizer setting subclasses --- .../class-wp-customize-background-image-setting.php | 2 ++ .../customize/class-wp-customize-filter-setting.php | 5 ++++- .../customize/class-wp-customize-header-image-setting.php | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/customize/class-wp-customize-background-image-setting.php b/src/wp-includes/customize/class-wp-customize-background-image-setting.php index f56810e6aab4b..20685dad2bbfe 100644 --- a/src/wp-includes/customize/class-wp-customize-background-image-setting.php +++ b/src/wp-includes/customize/class-wp-customize-background-image-setting.php @@ -28,8 +28,10 @@ final class WP_Customize_Background_Image_Setting extends WP_Customize_Setting { * @since 3.4.0 * * @param mixed $value The value to update. Not used. + * @return bool Always returns true. */ public function update( $value ) { remove_theme_mod( 'background_image_thumb' ); + return true; } } diff --git a/src/wp-includes/customize/class-wp-customize-filter-setting.php b/src/wp-includes/customize/class-wp-customize-filter-setting.php index ad70f4f853288..e916aca04d350 100644 --- a/src/wp-includes/customize/class-wp-customize-filter-setting.php +++ b/src/wp-includes/customize/class-wp-customize-filter-setting.php @@ -24,6 +24,9 @@ class WP_Customize_Filter_Setting extends WP_Customize_Setting { * @since 3.4.0 * * @param mixed $value The value to update. + * @return bool Always returns true. */ - public function update( $value ) {} + public function update( $value ) { + return true; + } } diff --git a/src/wp-includes/customize/class-wp-customize-header-image-setting.php b/src/wp-includes/customize/class-wp-customize-header-image-setting.php index 0834b378d3a6e..9c51ed5778e2a 100644 --- a/src/wp-includes/customize/class-wp-customize-header-image-setting.php +++ b/src/wp-includes/customize/class-wp-customize-header-image-setting.php @@ -32,6 +32,7 @@ final class WP_Customize_Header_Image_Setting extends WP_Customize_Setting { * @global Custom_Image_Header $custom_image_header * * @param mixed $value The value to update. + * @return bool Always returns true. */ public function update( $value ) { global $custom_image_header; @@ -58,5 +59,6 @@ public function update( $value ) { } else { $custom_image_header->set_header_image( $value ); } + return true; } } From 4aea65e1fdd66d5f3af1aabc0d5a9c339d4f5865 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Mon, 16 Feb 2026 21:09:31 -0800 Subject: [PATCH 2/3] Ensure remaining Customizer setting update methods return booleans --- src/wp-includes/class-wp-customize-setting.php | 2 +- ...lass-wp-customize-nav-menu-item-setting.php | 18 ++++++++++-------- .../class-wp-customize-nav-menu-setting.php | 6 ++++-- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/wp-includes/class-wp-customize-setting.php b/src/wp-includes/class-wp-customize-setting.php index 7f2ea62c4e5c6..0efcb7fee6a9b 100644 --- a/src/wp-includes/class-wp-customize-setting.php +++ b/src/wp-includes/class-wp-customize-setting.php @@ -708,7 +708,7 @@ protected function update( $value ) { */ do_action( "customize_update_{$this->type}", $value, $this ); - return has_action( "customize_update_{$this->type}" ); + return (bool) has_action( "customize_update_{$this->type}" ); } } diff --git a/src/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php b/src/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php index 1d4c8610a7db2..767c602d23250 100644 --- a/src/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php +++ b/src/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php @@ -765,11 +765,11 @@ public function sanitize( $value ) { * @param array|false $value The menu item array to update. If false, then the menu item will be deleted * entirely. See WP_Customize_Nav_Menu_Item_Setting::$default for what the value * should consist of. - * @return null|void + * @return bool Whether updated. */ protected function update( $value ) { if ( $this->is_updated ) { - return; + return ( 'error' !== $this->update_status ); } $this->is_updated = true; @@ -806,19 +806,19 @@ protected function update( $value ) { if ( ! $nav_menu_setting || ! ( $nav_menu_setting instanceof WP_Customize_Nav_Menu_Setting ) ) { $this->update_status = 'error'; $this->update_error = new WP_Error( 'unexpected_nav_menu_setting' ); - return; + return false; } if ( false === $nav_menu_setting->save() ) { $this->update_status = 'error'; $this->update_error = new WP_Error( 'nav_menu_setting_failure' ); - return; + return false; } if ( (int) $value['nav_menu_term_id'] !== $nav_menu_setting->previous_term_id ) { $this->update_status = 'error'; $this->update_error = new WP_Error( 'unexpected_previous_term_id' ); - return; + return false; } $value['nav_menu_term_id'] = $nav_menu_setting->term_id; @@ -832,19 +832,19 @@ protected function update( $value ) { if ( ! $parent_nav_menu_item_setting || ! ( $parent_nav_menu_item_setting instanceof WP_Customize_Nav_Menu_Item_Setting ) ) { $this->update_status = 'error'; $this->update_error = new WP_Error( 'unexpected_nav_menu_item_setting' ); - return; + return false; } if ( false === $parent_nav_menu_item_setting->save() ) { $this->update_status = 'error'; $this->update_error = new WP_Error( 'nav_menu_item_setting_failure' ); - return; + return false; } if ( (int) $value['menu_item_parent'] !== $parent_nav_menu_item_setting->previous_post_id ) { $this->update_status = 'error'; $this->update_error = new WP_Error( 'unexpected_previous_post_id' ); - return; + return false; } $value['menu_item_parent'] = $parent_nav_menu_item_setting->post_id; @@ -886,6 +886,8 @@ protected function update( $value ) { } } } + + return ( 'error' !== $this->update_status ); } /** diff --git a/src/wp-includes/customize/class-wp-customize-nav-menu-setting.php b/src/wp-includes/customize/class-wp-customize-nav-menu-setting.php index f01906c81884c..e317b8c1742d5 100644 --- a/src/wp-includes/customize/class-wp-customize-nav-menu-setting.php +++ b/src/wp-includes/customize/class-wp-customize-nav-menu-setting.php @@ -478,11 +478,11 @@ public function sanitize( $value ) { * @type int $parent The id of the parent term. Default 0. * @type bool $auto_add Whether pages will auto_add to this menu. Default false. * } - * @return null|void + * @return bool Whether updated. */ protected function update( $value ) { if ( $this->is_updated ) { - return; + return ( 'error' !== $this->update_status ); } $this->is_updated = true; @@ -582,6 +582,8 @@ protected function update( $value ) { $this->_widget_nav_menu_updates[ $nav_menu_widget_setting->id ] = $updated_widget_instance; } } + + return ( 'error' !== $this->update_status ); } /** From 1112a31c29eb32262d830f5f45e7a3a800135889 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Mon, 16 Feb 2026 21:16:16 -0800 Subject: [PATCH 3/3] Add since tags and increase specificity of return types --- .../customize/class-wp-customize-background-image-setting.php | 3 ++- .../customize/class-wp-customize-filter-setting.php | 3 ++- .../customize/class-wp-customize-header-image-setting.php | 3 ++- .../customize/class-wp-customize-nav-menu-item-setting.php | 1 + .../customize/class-wp-customize-nav-menu-setting.php | 1 + 5 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/wp-includes/customize/class-wp-customize-background-image-setting.php b/src/wp-includes/customize/class-wp-customize-background-image-setting.php index 20685dad2bbfe..0103dc1658eed 100644 --- a/src/wp-includes/customize/class-wp-customize-background-image-setting.php +++ b/src/wp-includes/customize/class-wp-customize-background-image-setting.php @@ -26,9 +26,10 @@ final class WP_Customize_Background_Image_Setting extends WP_Customize_Setting { /** * @since 3.4.0 + * @since 7.0.0 Return type updated from void to true for compatibility with base class. * * @param mixed $value The value to update. Not used. - * @return bool Always returns true. + * @return true Always returns true. */ public function update( $value ) { remove_theme_mod( 'background_image_thumb' ); diff --git a/src/wp-includes/customize/class-wp-customize-filter-setting.php b/src/wp-includes/customize/class-wp-customize-filter-setting.php index e916aca04d350..0263f693312aa 100644 --- a/src/wp-includes/customize/class-wp-customize-filter-setting.php +++ b/src/wp-includes/customize/class-wp-customize-filter-setting.php @@ -22,9 +22,10 @@ class WP_Customize_Filter_Setting extends WP_Customize_Setting { * Saves the value of the setting, using the related API. * * @since 3.4.0 + * @since 7.0.0 Return type updated from void to true for compatibility with base class. * * @param mixed $value The value to update. - * @return bool Always returns true. + * @return true Always returns true. */ public function update( $value ) { return true; diff --git a/src/wp-includes/customize/class-wp-customize-header-image-setting.php b/src/wp-includes/customize/class-wp-customize-header-image-setting.php index 9c51ed5778e2a..009e2e606f7ff 100644 --- a/src/wp-includes/customize/class-wp-customize-header-image-setting.php +++ b/src/wp-includes/customize/class-wp-customize-header-image-setting.php @@ -28,11 +28,12 @@ final class WP_Customize_Header_Image_Setting extends WP_Customize_Setting { /** * @since 3.4.0 + * @since 7.0.0 Return type updated from void to true for compatibility with base class. * * @global Custom_Image_Header $custom_image_header * * @param mixed $value The value to update. - * @return bool Always returns true. + * @return true Always returns true. */ public function update( $value ) { global $custom_image_header; diff --git a/src/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php b/src/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php index 767c602d23250..1de7bfdc20581 100644 --- a/src/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php +++ b/src/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php @@ -759,6 +759,7 @@ public function sanitize( $value ) { * To delete a menu, the client can send false as the value. * * @since 4.3.0 + * @since 7.0.0 Return type updated from null|void to bool for compatibility with base class. * * @see wp_update_nav_menu_item() * diff --git a/src/wp-includes/customize/class-wp-customize-nav-menu-setting.php b/src/wp-includes/customize/class-wp-customize-nav-menu-setting.php index e317b8c1742d5..138ab8806e719 100644 --- a/src/wp-includes/customize/class-wp-customize-nav-menu-setting.php +++ b/src/wp-includes/customize/class-wp-customize-nav-menu-setting.php @@ -466,6 +466,7 @@ public function sanitize( $value ) { * To delete a menu, the client can send false as the value. * * @since 4.3.0 + * @since 7.0.0 Return type updated from null|void to bool for compatibility with base class. * * @see wp_update_nav_menu_object() *