Invalidate header/background images for the current theme when the attachment is deleted. props ocean90, fixes #12467.

git-svn-id: https://develop.svn.wordpress.org/trunk@14850 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin 2010-05-24 19:42:43 +00:00
parent 5e0a7abf5c
commit b074c7be02
1 changed files with 20 additions and 0 deletions

View File

@ -1714,4 +1714,24 @@ function require_if_theme_supports( $feature, $include) {
require ( $include );
}
/**
* Checks an attachment, if it's a header or background image. If true remove the theme modification.
*
* @since 3.0.0
* @param int $id the attachment id
*/
function _delete_attachment_theme_mod( $id ) {
$attachment_image = wp_get_attachment_url( $id );
$header_image = get_header_image();
$background_image = get_background_image();
if ( $header_image && $header_image == $attachment_image )
remove_theme_mod( 'header_image' );
if ( $background_image && $background_image == $attachment_image )
remove_theme_mod( 'background_image' );
}
add_action( 'delete_attachment', '_delete_attachment_theme_mod' );
?>