From 140ff5cb9bff16d35f3ab1012ad428ca880dd316 Mon Sep 17 00:00:00 2001 From: Konstantin Obenland Date: Wed, 15 Jul 2015 16:27:17 +0000 Subject: [PATCH] Properly clean up header image data when the attachment is deleted. Props CreativeInfusion. Fixes #33005. git-svn-id: https://develop.svn.wordpress.org/trunk@33278 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/theme.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/wp-includes/theme.php b/src/wp-includes/theme.php index f8cf1688ac..d35a337ebf 100644 --- a/src/wp-includes/theme.php +++ b/src/wp-includes/theme.php @@ -1931,22 +1931,27 @@ function require_if_theme_supports( $feature, $include ) { * Checks an attachment being deleted to see if it's a header or background image. * * If true it removes the theme modification which would be pointing at the deleted - * attachment + * attachment. * * @access private * @since 3.0.0 - * @param int $id the attachment id + * @since 4.3.0 Also removes `header_image_data`. + * + * @param int $id The attachment id. */ function _delete_attachment_theme_mod( $id ) { $attachment_image = wp_get_attachment_url( $id ); - $header_image = get_header_image(); + $header_image = get_header_image(); $background_image = get_background_image(); - if ( $header_image && $header_image == $attachment_image ) + if ( $header_image && $header_image == $attachment_image ) { remove_theme_mod( 'header_image' ); + remove_theme_mod( 'header_image_data' ); + } - if ( $background_image && $background_image == $attachment_image ) + if ( $background_image && $background_image == $attachment_image ) { remove_theme_mod( 'background_image' ); + } } /**