Custom_Image_Header::get_default_header_images()publicWP 3.9.0

Gets the details of default header images if defined.

Method of the class: Custom_Image_Header{}

No Hooks.

Return

Array. Default header images.

Usage

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

Changelog

Since 3.9.0 Introduced.

Custom_Image_Header::get_default_header_images() code WP 6.5.2

public function get_default_header_images() {
	$this->process_default_headers();

	// Get the default image if there is one.
	$default = get_theme_support( 'custom-header', 'default-image' );

	if ( ! $default ) { // If not, easy peasy.
		return $this->default_headers;
	}

	$default = sprintf( $default, get_template_directory_uri(), get_stylesheet_directory_uri() );

	$already_has_default = false;

	foreach ( $this->default_headers as $k => $h ) {
		if ( $h['url'] === $default ) {
			$already_has_default = true;
			break;
		}
	}

	if ( $already_has_default ) {
		return $this->default_headers;
	}

	// If the one true image isn't included in the default set, prepend it.
	$header_images            = array();
	$header_images['default'] = array(
		'url'           => $default,
		'thumbnail_url' => $default,
		'description'   => 'Default',
	);

	// The rest of the set comes after.
	return array_merge( $header_images, $this->default_headers );
}