Custom_Image_Header::reset_header_image() WordPress Method

The Custom_Image_Header::reset_header_image() method is used to reset the header image for a WordPress site. This method can be used when the current header image is no longer desired, or when a new header image is desired. This method will remove the current header image from the WordPress site and set the default header image for the site.

Custom_Image_Header::reset_header_image() #

Reset a header image to the default image for the theme.


Description

This method does not do anything if the theme does not have a default header image.


Top ↑

Source

File: wp-admin/includes/class-custom-image-header.php

	final public function reset_header_image() {
		$this->process_default_headers();
		$default = get_theme_support( 'custom-header', 'default-image' );

		if ( ! $default ) {
			$this->remove_header_image();
			return;
		}

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

		$default_data = array();
		foreach ( $this->default_headers as $header => $details ) {
			if ( $details['url'] === $default ) {
				$default_data = $details;
				break;
			}
		}

		set_theme_mod( 'header_image', $default );
		set_theme_mod( 'header_image_data', (object) $default_data );
	}


Top ↑

Changelog

Changelog
VersionDescription
3.4.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.