diff -r 7b1b88e27a20 -r 48c4eec2b7e6 wp/wp-admin/includes/class-custom-background.php --- a/wp/wp-admin/includes/class-custom-background.php Thu Sep 29 08:06:27 2022 +0200 +++ b/wp/wp-admin/includes/class-custom-background.php Fri Sep 05 18:40:08 2025 +0200 @@ -11,6 +11,7 @@ * * @since 3.0.0 */ +#[AllowDynamicProperties] class Custom_Background { /** @@ -38,11 +39,14 @@ private $updated; /** - * Constructor - Register administration header callback. + * Constructor - Registers administration header callback. * * @since 3.0.0 - * @param callable $admin_header_callback - * @param callable $admin_image_div_callback Optional custom image div output callback. + * + * @param callable $admin_header_callback Optional. Administration header callback. + * Default empty string. + * @param callable $admin_image_div_callback Optional. Custom image div output callback. + * Default empty string. */ public function __construct( $admin_header_callback = '', $admin_image_div_callback = '' ) { $this->admin_header_callback = $admin_header_callback; @@ -57,12 +61,19 @@ } /** - * Set up the hooks for the Custom Background admin page. + * Sets up the hooks for the Custom Background admin page. * * @since 3.0.0 */ public function init() { - $page = add_theme_page( __( 'Background' ), __( 'Background' ), 'edit_theme_options', 'custom-background', array( $this, 'admin_page' ) ); + $page = add_theme_page( + _x( 'Background', 'custom background' ), + _x( 'Background', 'custom background' ), + 'edit_theme_options', + 'custom-background', + array( $this, 'admin_page' ) + ); + if ( ! $page ) { return; } @@ -77,7 +88,7 @@ } /** - * Set up the enqueue for the CSS & JavaScript files. + * Sets up the enqueue for the CSS & JavaScript files. * * @since 3.0.0 */ @@ -97,7 +108,7 @@ get_current_screen()->set_help_sidebar( '

' . __( 'For more information:' ) . '

' . '

' . __( 'Documentation on Custom Background' ) . '

' . - '

' . __( 'Support' ) . '

' + '

' . __( 'Support forums' ) . '

' ); wp_enqueue_media(); @@ -106,7 +117,7 @@ } /** - * Execute custom background modification. + * Executes custom background modification. * * @since 3.0.0 */ @@ -222,7 +233,7 @@ } /** - * Display the custom background page. + * Displays the custom background page. * * @since 3.0.0 */ @@ -231,30 +242,37 @@

- -
-

- Customizer.' ), admin_url( 'customize.php?autofocus[control]=background_image' ) ); - ?> -

-
- + wp_admin_notice( + $message, + array( + 'type' => 'info', + 'additional_classes' => array( 'hide-if-no-customize' ), + ) + ); + } - updated ) ) { ?> -
-

- Visit your site to see how it looks.' ), home_url( '/' ) ); - ?> -

-
- + if ( ! empty( $this->updated ) ) { + $updated_message = sprintf( + /* translators: %s: Home URL. */ + __( 'Background updated. Visit your site to see how it looks.' ), + esc_url( home_url( '/' ) ) + ); + wp_admin_notice( + $updated_message, + array( + 'id' => 'message', + 'additional_classes' => array( 'updated' ), + ) + ); + } + ?>

@@ -306,7 +324,7 @@
-
+
@@ -320,7 +338,7 @@
-
+
@@ -412,7 +430,12 @@ ?> -
+
+ +
@@ -431,7 +454,12 @@ -
+
+ +
@@ -450,7 +483,12 @@ -
+
+ +
@@ -458,7 +496,12 @@ -
+
+ + updated = true; } /** - * Ajax handler for adding custom background context to an attachment. + * Handles Ajax request for adding custom background context to an attachment. * * Triggers when the user adds a new background image from the * Media Manager. @@ -618,8 +662,8 @@ $url = wp_get_attachment_image_src( $attachment_id, $size ); $thumbnail = wp_get_attachment_image_src( $attachment_id, 'thumbnail' ); - set_theme_mod( 'background_image', esc_url_raw( $url[0] ) ); - set_theme_mod( 'background_image_thumb', esc_url_raw( $thumbnail[0] ) ); + set_theme_mod( 'background_image', sanitize_url( $url[0] ) ); + set_theme_mod( 'background_image_thumb', sanitize_url( $thumbnail[0] ) ); exit; } }