WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

Custom_Image_Header::ajax_header_remove() public WP 3.9.0

Given an attachment ID for a header image, unsets it as a user-uploaded header image for the current theme.

Triggered when the user clicks the overlay "X" button next to each image choice in the Customizer's Header tool.

Это метод класса: Custom_Image_Header{}

Хуков нет.

Возвращает

Null. Ничего.

Использование

$Custom_Image_Header = new Custom_Image_Header();
$Custom_Image_Header->ajax_header_remove();

Список изменений

С версии 3.9.0 Введена.

Код Custom_Image_Header::ajax_header_remove() WP 5.5.1

wp-admin/includes/class-custom-image-header.php
<?php
public function ajax_header_remove() {
	check_ajax_referer( 'header-remove', 'nonce' );

	if ( ! current_user_can( 'edit_theme_options' ) ) {
		wp_send_json_error();
	}

	$attachment_id = absint( $_POST['attachment_id'] );
	if ( $attachment_id < 1 ) {
		wp_send_json_error();
	}

	$key = '_wp_attachment_custom_header_last_used_' . get_stylesheet();
	delete_post_meta( $attachment_id, $key );
	delete_post_meta( $attachment_id, '_wp_attachment_is_custom_header', get_stylesheet() );

	wp_send_json_success();
}