Custom_Image_Header::ajax_header_remove()

最后更新于:2021-11-25 19:42:17

Custom_Image_Header::ajax_header_remove()

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

源文件

文件: gc-admin/includes/class-custom-image-header.php

	public function ajax_header_remove() {
		check_ajax_referer( 'header-remove', 'nonce' );

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

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

		$key = '_gc_attachment_custom_header_last_used_' . get_stylesheet();
		delete_post_meta( $attachment_id, $key );
		delete_post_meta( $attachment_id, '_gc_attachment_is_custom_header', get_stylesheet() );

		gc_send_json_success();
	}