From 27ddc687c4aaa66e8aa5321194b9ed78e48f58c0 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 13 Apr 2021 17:59:45 +0000 Subject: [PATCH] Coding Standards: Use strict comparison in `wp-admin/includes/class-custom-background.php`. Includes minor code layout fixes for better readability. See #52627. git-svn-id: https://develop.svn.wordpress.org/trunk@50706 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/class-custom-background.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/wp-admin/includes/class-custom-background.php b/src/wp-admin/includes/class-custom-background.php index bc3c082bc3..5c65c6b282 100644 --- a/src/wp-admin/includes/class-custom-background.php +++ b/src/wp-admin/includes/class-custom-background.php @@ -117,8 +117,10 @@ class Custom_Background { if ( isset( $_POST['reset-background'] ) ) { check_admin_referer( 'custom-background-reset', '_wpnonce-custom-background-reset' ); + remove_theme_mod( 'background_image' ); remove_theme_mod( 'background_image_thumb' ); + $this->updated = true; return; } @@ -126,8 +128,10 @@ class Custom_Background { if ( isset( $_POST['remove-background'] ) ) { // @todo Uploaded files are not removed here. check_admin_referer( 'custom-background-remove', '_wpnonce-custom-background-remove' ); + set_theme_mod( 'background_image', '' ); set_theme_mod( 'background_image_thumb', '' ); + $this->updated = true; wp_safe_redirect( $_POST['_wp_http_referer'] ); return; @@ -204,8 +208,10 @@ class Custom_Background { if ( isset( $_POST['background-color'] ) ) { check_admin_referer( 'custom-background' ); + $color = preg_replace( '/[^0-9a-fA-F]/', '', $_POST['background-color'] ); - if ( strlen( $color ) == 6 || strlen( $color ) == 3 ) { + + if ( strlen( $color ) === 6 || strlen( $color ) === 3 ) { set_theme_mod( 'background_color', $color ); } else { set_theme_mod( 'background_color', '' ); @@ -308,7 +314,7 @@ class Custom_Background { - + @@ -484,6 +490,7 @@ class Custom_Background { } check_admin_referer( 'custom-background-upload', '_wpnonce-custom-background-upload' ); + $overrides = array( 'test_form' => false ); $uploaded_file = $_FILES['import'];