Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

_delete_attachment_theme_mod( int $id )

Checks an attachment being deleted to see if it’s a header or background image.


Description Description

If true it removes the theme modification which would be pointing at the deleted attachment.


Parameters Parameters

$id

(int) (Required) The attachment id.


Top ↑

Source Source

File: 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 ) {
		remove_theme_mod( 'background_image' );
	}
}

Top ↑

Changelog Changelog

Changelog
Version Description
4.5.0 Also removes custom logo theme mods.
4.3.0 Also removes header_image_data.
3.0.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.