WordPress.org

Make WordPress Core

Ticket #12467: 12467.patch

File 12467.patch, 890 bytes (added by ocean90, 8 years ago)
  • wp-includes/theme.php

     
    16811681                require ( $include );
    16821682}
    16831683
     1684/**
     1685 * Checks an attachment, if it's a header or background image. If true remove the theme modification.
     1686 *
     1687 * @since 3.0.0
     1688 * @param int $id the attachment id
     1689 */
     1690function _delete_attachment_theme_mod( $id ) {
     1691        $attachment_image = wp_get_attachment_url( $id );
     1692        $header_image = get_header_image();
     1693        $background_image = get_background_image();
     1694       
     1695        if ( $header_image && $header_image == $attachment_image )
     1696                remove_theme_mod( 'header_image' );
     1697
     1698        if ( $background_image && $background_image == $attachment_image )
     1699                remove_theme_mod( 'background_image' );
     1700}
     1701
     1702add_action( 'delete_attachment', '_delete_attachment_theme_mod' );
     1703
    16841704?>