Custom_Image_Header::customize_set_last_used( WP_Customize_Manager $wp_customize )

In this article

Updates the last-used postmeta on a header image attachment after saving a new header image via the Customizer.

Parameters

$wp_customizeWP_Customize_Managerrequired
Customize manager.

Source

public function customize_set_last_used( $wp_customize ) {

	$header_image_data_setting = $wp_customize->get_setting( 'header_image_data' );

	if ( ! $header_image_data_setting ) {
		return;
	}

	$data = $header_image_data_setting->post_value();

	if ( ! isset( $data['attachment_id'] ) ) {
		return;
	}

	$attachment_id = $data['attachment_id'];
	$key           = '_wp_attachment_custom_header_last_used_' . get_stylesheet();
	update_post_meta( $attachment_id, $key, time() );
}

Changelog

VersionDescription
3.9.0Introduced.

User Contributed Notes

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