_delete_attachment_theme_mod()
Checks an attachment being deleted to see if it's a header or background image.
If true it removes the theme modification which would be pointing at the deleted attachment.
Внутренняя функция — эта функция рассчитана на использование самим ядром. Не рекомендуется использовать эту функцию в своем коде.
Хуков нет.
Возвращает
null. Ничего (null).
Использование
_delete_attachment_theme_mod( $id );
- $id(int) (обязательный)
- The attachment ID.
Список изменений
| С версии 3.0.0 | Введена. |
| С версии 4.3.0 | Also removes header_image_data. |
| С версии 4.5.0 | Also removes custom logo theme mods. |
| С версии 6.6.0 | Also removes site_logo option set by the site logo block. |
Код _delete_attachment_theme_mod() delete attachment theme mod WP 7.1
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 = (int) get_theme_mod( 'custom_logo' );
$site_logo_id = (int) get_option( 'site_logo' );
if ( $custom_logo_id && $custom_logo_id === $id ) {
remove_theme_mod( 'custom_logo' );
remove_theme_mod( 'header_text' );
}
if ( $site_logo_id && $site_logo_id === $id ) {
delete_option( 'site_logo' );
}
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' );
}
}