_delete_attachment_theme_mod
Checks an attachment being deleted to see if it's a header or background image.
Description
_delete_attachment_theme_mod( (int) $id );
If true it removes the theme modification which would be pointing at the deleted attachment.
Parameters (1)
- 0. $id (int)
- The attachment id.
Usage
if ( !function_exists( '_delete_attachment_theme_mod' ) ) { require_once ABSPATH . WPINC . '/theme.php'; } // The attachment id. $id = -1; // NOTICE! Understand what this does before running. $result = _delete_attachment_theme_mod($id);
Defined (1)
The function is defined in the following location(s).
- /wp-includes/theme.php
- function _delete_attachment_theme_mod( $id ) {
- $attachment_image = wp_get_attachment_url( $id );
- $header_image = get_header_image();
- $background_image = get_background_image();
- $custom_logo_id = get_theme_mod( 'custom_logo' );
- if ( $custom_logo_id && $custom_logo_id == $id ) {
- remove_theme_mod( 'custom_logo' );
- remove_theme_mod( 'header_text' );
- }
- 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 ) {
- }
- }