// Construct the attachment array.
$attachment = array
( 'post_title' =>
$filename,
'post_content' =>
$url,
'post_mime_type' =>
$type,
'guid' =>
$url,
'context' => 'custom-header',
);
// Save the data.
$attachment_id =
wp_insert_attachment( $attachment,
$file );
return compact( 'attachment_id', 'file', 'filename', 'url', 'type'
);
} /**
* Displays third step of custom header image page.
*
* @since 2.1.0
* @since 4.4.0 Switched to using wp_get_attachment_url() instead of the guid
* for retrieving the header image URL.
*/