Make WordPress Core

Changeset 14850


Ignore:
Timestamp:
05/24/2010 07:42:43 PM (15 years ago)
Author:
nacin
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/theme.php

    r14684 r14850  
    17151715}
    17161716
     1717/**
     1718 * Checks an attachment, if it's a header or background image. If true remove the theme modification.
     1719 *
     1720 * @since 3.0.0
     1721 * @param int $id the attachment id
     1722 */
     1723function _delete_attachment_theme_mod( $id ) {
     1724    $attachment_image = wp_get_attachment_url( $id );
     1725    $header_image = get_header_image();
     1726    $background_image = get_background_image();
     1727   
     1728    if ( $header_image && $header_image == $attachment_image )
     1729        remove_theme_mod( 'header_image' );
     1730
     1731    if ( $background_image && $background_image == $attachment_image )
     1732        remove_theme_mod( 'background_image' );
     1733}
     1734
     1735add_action( 'delete_attachment', '_delete_attachment_theme_mod' );
     1736
    17171737?>
Note: See TracChangeset for help on using the changeset viewer.