_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

  1. if ( !function_exists( '_delete_attachment_theme_mod' ) ) { 
  2. require_once ABSPATH . WPINC . '/theme.php'; 
  3.  
  4. // The attachment id. 
  5. $id = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = _delete_attachment_theme_mod($id); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/theme.php  
  1. function _delete_attachment_theme_mod( $id ) { 
  2. $attachment_image = wp_get_attachment_url( $id ); 
  3. $header_image = get_header_image(); 
  4. $background_image = get_background_image(); 
  5. $custom_logo_id = get_theme_mod( 'custom_logo' ); 
  6.  
  7. if ( $custom_logo_id && $custom_logo_id == $id ) { 
  8. remove_theme_mod( 'custom_logo' ); 
  9. remove_theme_mod( 'header_text' ); 
  10.  
  11. if ( $header_image && $header_image == $attachment_image ) { 
  12. remove_theme_mod( 'header_image_data' ); 
  13.  
  14. if ( $background_image && $background_image == $attachment_image ) {