| | 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 | */ |
| | 1690 | function _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 | |
| | 1702 | add_action( 'delete_attachment', '_delete_attachment_theme_mod' ); |
| | 1703 | |