wp/wp-includes/theme.php
changeset 19 3d72ae0968f4
parent 18 be944660c56a
child 21 48c4eec2b7e6
equal deleted inserted replaced
18:be944660c56a 19:3d72ae0968f4
    43 	$args     = wp_parse_args( $args, $defaults );
    43 	$args     = wp_parse_args( $args, $defaults );
    44 
    44 
    45 	$theme_directories = search_theme_directories();
    45 	$theme_directories = search_theme_directories();
    46 
    46 
    47 	if ( is_array( $wp_theme_directories ) && count( $wp_theme_directories ) > 1 ) {
    47 	if ( is_array( $wp_theme_directories ) && count( $wp_theme_directories ) > 1 ) {
    48 		// Make sure the current theme wins out, in case search_theme_directories() picks the wrong
    48 		// Make sure the active theme wins out, in case search_theme_directories() picks the wrong
    49 		// one in the case of a conflict. (Normally, last registered theme root wins.)
    49 		// one in the case of a conflict. (Normally, last registered theme root wins.)
    50 		$current_theme = get_stylesheet();
    50 		$current_theme = get_stylesheet();
    51 		if ( isset( $theme_directories[ $current_theme ] ) ) {
    51 		if ( isset( $theme_directories[ $current_theme ] ) ) {
    52 			$root_of_current_theme = get_raw_theme_root( $current_theme );
    52 			$root_of_current_theme = get_raw_theme_root( $current_theme );
    53 			if ( ! in_array( $root_of_current_theme, $wp_theme_directories, true ) ) {
    53 			if ( ! in_array( $root_of_current_theme, $wp_theme_directories, true ) ) {
   103  *
   103  *
   104  * @since 3.4.0
   104  * @since 3.4.0
   105  *
   105  *
   106  * @global array $wp_theme_directories
   106  * @global array $wp_theme_directories
   107  *
   107  *
   108  * @param string $stylesheet Optional. Directory name for the theme. Defaults to current theme.
   108  * @param string $stylesheet Optional. Directory name for the theme. Defaults to active theme.
   109  * @param string $theme_root Optional. Absolute path of the theme root to look in.
   109  * @param string $theme_root Optional. Absolute path of the theme root to look in.
   110  *                           If not specified, get_raw_theme_root() is used to calculate
   110  *                           If not specified, get_raw_theme_root() is used to calculate
   111  *                           the theme root for the $stylesheet provided (or current theme).
   111  *                           the theme root for the $stylesheet provided (or active theme).
   112  * @return WP_Theme Theme object. Be sure to check the object's exists() method
   112  * @return WP_Theme Theme object. Be sure to check the object's exists() method
   113  *                  if you need to confirm the theme's existence.
   113  *                  if you need to confirm the theme's existence.
   114  */
   114  */
   115 function wp_get_theme( $stylesheet = '', $theme_root = '' ) {
   115 function wp_get_theme( $stylesheet = '', $theme_root = '' ) {
   116 	global $wp_theme_directories;
   116 	global $wp_theme_directories;
   180 	 */
   180 	 */
   181 	return apply_filters( 'stylesheet', get_option( 'stylesheet' ) );
   181 	return apply_filters( 'stylesheet', get_option( 'stylesheet' ) );
   182 }
   182 }
   183 
   183 
   184 /**
   184 /**
   185  * Retrieves stylesheet directory path for current theme.
   185  * Retrieves stylesheet directory path for the active theme.
   186  *
   186  *
   187  * @since 1.5.0
   187  * @since 1.5.0
   188  *
   188  *
   189  * @return string Path to current theme's stylesheet directory.
   189  * @return string Path to active theme's stylesheet directory.
   190  */
   190  */
   191 function get_stylesheet_directory() {
   191 function get_stylesheet_directory() {
   192 	$stylesheet     = get_stylesheet();
   192 	$stylesheet     = get_stylesheet();
   193 	$theme_root     = get_theme_root( $stylesheet );
   193 	$theme_root     = get_theme_root( $stylesheet );
   194 	$stylesheet_dir = "$theme_root/$stylesheet";
   194 	$stylesheet_dir = "$theme_root/$stylesheet";
   195 
   195 
   196 	/**
   196 	/**
   197 	 * Filters the stylesheet directory path for current theme.
   197 	 * Filters the stylesheet directory path for the active theme.
   198 	 *
   198 	 *
   199 	 * @since 1.5.0
   199 	 * @since 1.5.0
   200 	 *
   200 	 *
   201 	 * @param string $stylesheet_dir Absolute path to the current theme.
   201 	 * @param string $stylesheet_dir Absolute path to the active theme.
   202 	 * @param string $stylesheet     Directory name of the current theme.
   202 	 * @param string $stylesheet     Directory name of the active theme.
   203 	 * @param string $theme_root     Absolute path to themes directory.
   203 	 * @param string $theme_root     Absolute path to themes directory.
   204 	 */
   204 	 */
   205 	return apply_filters( 'stylesheet_directory', $stylesheet_dir, $stylesheet, $theme_root );
   205 	return apply_filters( 'stylesheet_directory', $stylesheet_dir, $stylesheet, $theme_root );
   206 }
   206 }
   207 
   207 
   208 /**
   208 /**
   209  * Retrieves stylesheet directory URI for current theme.
   209  * Retrieves stylesheet directory URI for the active theme.
   210  *
   210  *
   211  * @since 1.5.0
   211  * @since 1.5.0
   212  *
   212  *
   213  * @return string URI to current theme's stylesheet directory.
   213  * @return string URI to active theme's stylesheet directory.
   214  */
   214  */
   215 function get_stylesheet_directory_uri() {
   215 function get_stylesheet_directory_uri() {
   216 	$stylesheet         = str_replace( '%2F', '/', rawurlencode( get_stylesheet() ) );
   216 	$stylesheet         = str_replace( '%2F', '/', rawurlencode( get_stylesheet() ) );
   217 	$theme_root_uri     = get_theme_root_uri( $stylesheet );
   217 	$theme_root_uri     = get_theme_root_uri( $stylesheet );
   218 	$stylesheet_dir_uri = "$theme_root_uri/$stylesheet";
   218 	$stylesheet_dir_uri = "$theme_root_uri/$stylesheet";
   228 	 */
   228 	 */
   229 	return apply_filters( 'stylesheet_directory_uri', $stylesheet_dir_uri, $stylesheet, $theme_root_uri );
   229 	return apply_filters( 'stylesheet_directory_uri', $stylesheet_dir_uri, $stylesheet, $theme_root_uri );
   230 }
   230 }
   231 
   231 
   232 /**
   232 /**
   233  * Retrieves stylesheet URI for current theme.
   233  * Retrieves stylesheet URI for the active theme.
   234  *
   234  *
   235  * The stylesheet file name is 'style.css' which is appended to the stylesheet directory URI path.
   235  * The stylesheet file name is 'style.css' which is appended to the stylesheet directory URI path.
   236  * See get_stylesheet_directory_uri().
   236  * See get_stylesheet_directory_uri().
   237  *
   237  *
   238  * @since 1.5.0
   238  * @since 1.5.0
   239  *
   239  *
   240  * @return string URI to current theme's stylesheet.
   240  * @return string URI to active theme's stylesheet.
   241  */
   241  */
   242 function get_stylesheet_uri() {
   242 function get_stylesheet_uri() {
   243 	$stylesheet_dir_uri = get_stylesheet_directory_uri();
   243 	$stylesheet_dir_uri = get_stylesheet_directory_uri();
   244 	$stylesheet_uri     = $stylesheet_dir_uri . '/style.css';
   244 	$stylesheet_uri     = $stylesheet_dir_uri . '/style.css';
   245 	/**
   245 	/**
   246 	 * Filters the URI of the current theme stylesheet.
   246 	 * Filters the URI of the active theme stylesheet.
   247 	 *
   247 	 *
   248 	 * @since 1.5.0
   248 	 * @since 1.5.0
   249 	 *
   249 	 *
   250 	 * @param string $stylesheet_uri     Stylesheet URI for the current theme/child theme.
   250 	 * @param string $stylesheet_uri     Stylesheet URI for the active theme/child theme.
   251 	 * @param string $stylesheet_dir_uri Stylesheet directory URI for the current theme/child theme.
   251 	 * @param string $stylesheet_dir_uri Stylesheet directory URI for the active theme/child theme.
   252 	 */
   252 	 */
   253 	return apply_filters( 'stylesheet_uri', $stylesheet_uri, $stylesheet_dir_uri );
   253 	return apply_filters( 'stylesheet_uri', $stylesheet_uri, $stylesheet_dir_uri );
   254 }
   254 }
   255 
   255 
   256 /**
   256 /**
   270  *
   270  *
   271  * @since 2.1.0
   271  * @since 2.1.0
   272  *
   272  *
   273  * @global WP_Locale $wp_locale WordPress date and time locale object.
   273  * @global WP_Locale $wp_locale WordPress date and time locale object.
   274  *
   274  *
   275  * @return string URI to current theme's localized stylesheet.
   275  * @return string URI to active theme's localized stylesheet.
   276  */
   276  */
   277 function get_locale_stylesheet_uri() {
   277 function get_locale_stylesheet_uri() {
   278 	global $wp_locale;
   278 	global $wp_locale;
   279 	$stylesheet_dir_uri = get_stylesheet_directory_uri();
   279 	$stylesheet_dir_uri = get_stylesheet_directory_uri();
   280 	$dir                = get_stylesheet_directory();
   280 	$dir                = get_stylesheet_directory();
   296 	 */
   296 	 */
   297 	return apply_filters( 'locale_stylesheet_uri', $stylesheet_uri, $stylesheet_dir_uri );
   297 	return apply_filters( 'locale_stylesheet_uri', $stylesheet_uri, $stylesheet_dir_uri );
   298 }
   298 }
   299 
   299 
   300 /**
   300 /**
   301  * Retrieves name of the current theme.
   301  * Retrieves name of the active theme.
   302  *
   302  *
   303  * @since 1.5.0
   303  * @since 1.5.0
   304  *
   304  *
   305  * @return string Template name.
   305  * @return string Template name.
   306  */
   306  */
   307 function get_template() {
   307 function get_template() {
   308 	/**
   308 	/**
   309 	 * Filters the name of the current theme.
   309 	 * Filters the name of the active theme.
   310 	 *
   310 	 *
   311 	 * @since 1.5.0
   311 	 * @since 1.5.0
   312 	 *
   312 	 *
   313 	 * @param string $template Current theme's directory name.
   313 	 * @param string $template active theme's directory name.
   314 	 */
   314 	 */
   315 	return apply_filters( 'template', get_option( 'template' ) );
   315 	return apply_filters( 'template', get_option( 'template' ) );
   316 }
   316 }
   317 
   317 
   318 /**
   318 /**
   319  * Retrieves template directory path for current theme.
   319  * Retrieves template directory path for the active theme.
   320  *
   320  *
   321  * @since 1.5.0
   321  * @since 1.5.0
   322  *
   322  *
   323  * @return string Path to current theme's template directory.
   323  * @return string Path to active theme's template directory.
   324  */
   324  */
   325 function get_template_directory() {
   325 function get_template_directory() {
   326 	$template     = get_template();
   326 	$template     = get_template();
   327 	$theme_root   = get_theme_root( $template );
   327 	$theme_root   = get_theme_root( $template );
   328 	$template_dir = "$theme_root/$template";
   328 	$template_dir = "$theme_root/$template";
   329 
   329 
   330 	/**
   330 	/**
   331 	 * Filters the current theme directory path.
   331 	 * Filters the active theme directory path.
   332 	 *
   332 	 *
   333 	 * @since 1.5.0
   333 	 * @since 1.5.0
   334 	 *
   334 	 *
   335 	 * @param string $template_dir The path of the current theme directory.
   335 	 * @param string $template_dir The path of the active theme directory.
   336 	 * @param string $template     Directory name of the current theme.
   336 	 * @param string $template     Directory name of the active theme.
   337 	 * @param string $theme_root   Absolute path to the themes directory.
   337 	 * @param string $theme_root   Absolute path to the themes directory.
   338 	 */
   338 	 */
   339 	return apply_filters( 'template_directory', $template_dir, $template, $theme_root );
   339 	return apply_filters( 'template_directory', $template_dir, $template, $theme_root );
   340 }
   340 }
   341 
   341 
   342 /**
   342 /**
   343  * Retrieves template directory URI for current theme.
   343  * Retrieves template directory URI for the active theme.
   344  *
   344  *
   345  * @since 1.5.0
   345  * @since 1.5.0
   346  *
   346  *
   347  * @return string URI to current theme's template directory.
   347  * @return string URI to active theme's template directory.
   348  */
   348  */
   349 function get_template_directory_uri() {
   349 function get_template_directory_uri() {
   350 	$template         = str_replace( '%2F', '/', rawurlencode( get_template() ) );
   350 	$template         = str_replace( '%2F', '/', rawurlencode( get_template() ) );
   351 	$theme_root_uri   = get_theme_root_uri( $template );
   351 	$theme_root_uri   = get_theme_root_uri( $template );
   352 	$template_dir_uri = "$theme_root_uri/$template";
   352 	$template_dir_uri = "$theme_root_uri/$template";
   353 
   353 
   354 	/**
   354 	/**
   355 	 * Filters the current theme directory URI.
   355 	 * Filters the active theme directory URI.
   356 	 *
   356 	 *
   357 	 * @since 1.5.0
   357 	 * @since 1.5.0
   358 	 *
   358 	 *
   359 	 * @param string $template_dir_uri The URI of the current theme directory.
   359 	 * @param string $template_dir_uri The URI of the active theme directory.
   360 	 * @param string $template         Directory name of the current theme.
   360 	 * @param string $template         Directory name of the active theme.
   361 	 * @param string $theme_root_uri   The themes root URI.
   361 	 * @param string $theme_root_uri   The themes root URI.
   362 	 */
   362 	 */
   363 	return apply_filters( 'template_directory_uri', $template_dir_uri, $template, $theme_root_uri );
   363 	return apply_filters( 'template_directory_uri', $template_dir_uri, $template, $theme_root_uri );
   364 }
   364 }
   365 
   365 
   497 	}
   497 	}
   498 
   498 
   499 	/* Loop the registered theme directories and extract all themes */
   499 	/* Loop the registered theme directories and extract all themes */
   500 	foreach ( $wp_theme_directories as $theme_root ) {
   500 	foreach ( $wp_theme_directories as $theme_root ) {
   501 
   501 
   502 		// Start with directories in the root of the current theme directory.
   502 		// Start with directories in the root of the active theme directory.
   503 		$dirs = @ scandir( $theme_root );
   503 		$dirs = @ scandir( $theme_root );
   504 		if ( ! $dirs ) {
   504 		if ( ! $dirs ) {
   505 			trigger_error( "$theme_root is not readable", E_USER_NOTICE );
   505 			trigger_error( "$theme_root is not readable", E_USER_NOTICE );
   506 			continue;
   506 			continue;
   507 		}
   507 		}
   681 		return '/themes';
   681 		return '/themes';
   682 	}
   682 	}
   683 
   683 
   684 	$theme_root = false;
   684 	$theme_root = false;
   685 
   685 
   686 	// If requesting the root for the current theme, consult options to avoid calling get_theme_roots().
   686 	// If requesting the root for the active theme, consult options to avoid calling get_theme_roots().
   687 	if ( ! $skip_cache ) {
   687 	if ( ! $skip_cache ) {
   688 		if ( get_option( 'stylesheet' ) == $stylesheet_or_template ) {
   688 		if ( get_option( 'stylesheet' ) == $stylesheet_or_template ) {
   689 			$theme_root = get_option( 'stylesheet_root' );
   689 			$theme_root = get_option( 'stylesheet_root' );
   690 		} elseif ( get_option( 'template' ) == $stylesheet_or_template ) {
   690 		} elseif ( get_option( 'template' ) == $stylesheet_or_template ) {
   691 			$theme_root = get_option( 'template_root' );
   691 			$theme_root = get_option( 'template_root' );
   828 	 */
   828 	 */
   829 	do_action( 'switch_theme', $new_name, $new_theme, $old_theme );
   829 	do_action( 'switch_theme', $new_name, $new_theme, $old_theme );
   830 }
   830 }
   831 
   831 
   832 /**
   832 /**
   833  * Checks that the current theme has 'index.php' and 'style.css' files.
   833  * Checks that the active theme has the required files.
       
   834  *
       
   835  * Standalone themes need to have a `templates/index.html` or `index.php` template file.
       
   836  * Child themes need to have a `Template` header in the `style.css` stylesheet.
   834  *
   837  *
   835  * Does not initially check the default theme, which is the fallback and should always exist.
   838  * Does not initially check the default theme, which is the fallback and should always exist.
   836  * But if it doesn't exist, it'll fall back to the latest core default theme that does exist.
   839  * But if it doesn't exist, it'll fall back to the latest core default theme that does exist.
   837  * Will switch theme to the fallback theme if current theme does not validate.
   840  * Will switch theme to the fallback theme if active theme does not validate.
   838  *
   841  *
   839  * You can use the {@see 'validate_current_theme'} filter to return false to disable
   842  * You can use the {@see 'validate_current_theme'} filter to return false to disable
   840  * this functionality.
   843  * this functionality.
   841  *
   844  *
   842  * @since 1.5.0
   845  * @since 1.5.0
       
   846  * @since 6.0.0 Removed the requirement for block themes to have an `index.php` template.
   843  *
   847  *
   844  * @see WP_DEFAULT_THEME
   848  * @see WP_DEFAULT_THEME
   845  *
   849  *
   846  * @return bool
   850  * @return bool
   847  */
   851  */
   848 function validate_current_theme() {
   852 function validate_current_theme() {
   849 	/**
   853 	/**
   850 	 * Filters whether to validate the current theme.
   854 	 * Filters whether to validate the active theme.
   851 	 *
   855 	 *
   852 	 * @since 2.7.0
   856 	 * @since 2.7.0
   853 	 *
   857 	 *
   854 	 * @param bool $validate Whether to validate the current theme. Default true.
   858 	 * @param bool $validate Whether to validate the active theme. Default true.
   855 	 */
   859 	 */
   856 	if ( wp_installing() || ! apply_filters( 'validate_current_theme', true ) ) {
   860 	if ( wp_installing() || ! apply_filters( 'validate_current_theme', true ) ) {
   857 		return true;
   861 		return true;
   858 	}
   862 	}
   859 
   863 
   860 	if ( ! file_exists( get_template_directory() . '/index.php' ) ) {
   864 	if (
       
   865 		! file_exists( get_template_directory() . '/templates/index.html' )
       
   866 		&& ! file_exists( get_template_directory() . '/block-templates/index.html' ) // Deprecated path support since 5.9.0.
       
   867 		&& ! file_exists( get_template_directory() . '/index.php' )
       
   868 	) {
   861 		// Invalid.
   869 		// Invalid.
   862 	} elseif ( ! file_exists( get_template_directory() . '/style.css' ) ) {
   870 	} elseif ( ! file_exists( get_template_directory() . '/style.css' ) ) {
   863 		// Invalid.
   871 		// Invalid.
   864 	} elseif ( is_child_theme() && ! file_exists( get_stylesheet_directory() . '/style.css' ) ) {
   872 	} elseif ( is_child_theme() && ! file_exists( get_stylesheet_directory() . '/style.css' ) ) {
   865 		// Invalid.
   873 		// Invalid.
   905  * @param string $stylesheet Directory name for the theme.
   913  * @param string $stylesheet Directory name for the theme.
   906  * @return true|WP_Error True if requirements are met, WP_Error on failure.
   914  * @return true|WP_Error True if requirements are met, WP_Error on failure.
   907  */
   915  */
   908 function validate_theme_requirements( $stylesheet ) {
   916 function validate_theme_requirements( $stylesheet ) {
   909 	$theme = wp_get_theme( $stylesheet );
   917 	$theme = wp_get_theme( $stylesheet );
   910 
       
   911 	// If the theme is a Full Site Editing theme, check for the presence of the Gutenberg plugin.
       
   912 	$theme_tags = $theme->get( 'Tags' );
       
   913 
       
   914 	if ( ! empty( $theme_tags ) && in_array( 'full-site-editing', $theme_tags, true ) && ! function_exists( 'gutenberg_is_fse_theme' ) ) {
       
   915 		return new WP_Error(
       
   916 			'theme_requires_gutenberg_plugin',
       
   917 			sprintf(
       
   918 					/* translators: %s: Theme name. */
       
   919 				_x( '<strong>Error:</strong> This theme (%s) uses Full Site Editing, which requires the Gutenberg plugin to be activated.', 'theme' ),
       
   920 				$theme->display( 'Name' )
       
   921 			)
       
   922 		);
       
   923 	}
       
   924 
   918 
   925 	$requirements = array(
   919 	$requirements = array(
   926 		'requires'     => ! empty( $theme->get( 'RequiresWP' ) ) ? $theme->get( 'RequiresWP' ) : '',
   920 		'requires'     => ! empty( $theme->get( 'RequiresWP' ) ) ? $theme->get( 'RequiresWP' ) : '',
   927 		'requires_php' => ! empty( $theme->get( 'RequiresPHP' ) ) ? $theme->get( 'RequiresPHP' ) : '',
   921 		'requires_php' => ! empty( $theme->get( 'RequiresPHP' ) ) ? $theme->get( 'RequiresPHP' ) : '',
   928 	);
   922 	);
   964 
   958 
   965 /**
   959 /**
   966  * Retrieves all theme modifications.
   960  * Retrieves all theme modifications.
   967  *
   961  *
   968  * @since 3.1.0
   962  * @since 3.1.0
   969  *
   963  * @since 5.9.0 The return value is always an array.
   970  * @return array|void Theme modifications.
   964  *
       
   965  * @return array Theme modifications.
   971  */
   966  */
   972 function get_theme_mods() {
   967 function get_theme_mods() {
   973 	$theme_slug = get_option( 'stylesheet' );
   968 	$theme_slug = get_option( 'stylesheet' );
   974 	$mods       = get_option( "theme_mods_$theme_slug" );
   969 	$mods       = get_option( "theme_mods_$theme_slug" );
       
   970 
   975 	if ( false === $mods ) {
   971 	if ( false === $mods ) {
   976 		$theme_name = get_option( 'current_theme' );
   972 		$theme_name = get_option( 'current_theme' );
   977 		if ( false === $theme_name ) {
   973 		if ( false === $theme_name ) {
   978 			$theme_name = wp_get_theme()->get( 'Name' );
   974 			$theme_name = wp_get_theme()->get( 'Name' );
   979 		}
   975 		}
       
   976 
   980 		$mods = get_option( "mods_$theme_name" ); // Deprecated location.
   977 		$mods = get_option( "mods_$theme_name" ); // Deprecated location.
   981 		if ( is_admin() && false !== $mods ) {
   978 		if ( is_admin() && false !== $mods ) {
   982 			update_option( "theme_mods_$theme_slug", $mods );
   979 			update_option( "theme_mods_$theme_slug", $mods );
   983 			delete_option( "mods_$theme_name" );
   980 			delete_option( "mods_$theme_name" );
   984 		}
   981 		}
   985 	}
   982 	}
       
   983 
       
   984 	if ( ! is_array( $mods ) ) {
       
   985 		$mods = array();
       
   986 	}
       
   987 
   986 	return $mods;
   988 	return $mods;
   987 }
   989 }
   988 
   990 
   989 /**
   991 /**
   990  * Retrieves theme modification value for the current theme.
   992  * Retrieves theme modification value for the active theme.
   991  *
   993  *
   992  * If the modification name does not exist, then the $default will be passed
   994  * If the modification name does not exist and `$default` is a string, then the
   993  * through {@link https://www.php.net/sprintf sprintf()} PHP function with
   995  * default will be passed through the {@link https://www.php.net/sprintf sprintf()}
   994  * the template directory URI as the first string and the stylesheet directory URI
   996  * PHP function with the template directory URI as the first value and the
   995  * as the second string.
   997  * stylesheet directory URI as the second value.
   996  *
   998  *
   997  * @since 2.1.0
   999  * @since 2.1.0
   998  *
  1000  *
   999  * @param string       $name    Theme modification name.
  1001  * @param string $name    Theme modification name.
  1000  * @param string|false $default Optional. Theme modification default value. Default false.
  1002  * @param mixed  $default Optional. Theme modification default value. Default false.
  1001  * @return mixed Theme modification value.
  1003  * @return mixed Theme modification value.
  1002  */
  1004  */
  1003 function get_theme_mod( $name, $default = false ) {
  1005 function get_theme_mod( $name, $default = false ) {
  1004 	$mods = get_theme_mods();
  1006 	$mods = get_theme_mods();
  1005 
  1007 
  1011 		 * of the modification array. For example, 'header_textcolor', 'header_image',
  1013 		 * of the modification array. For example, 'header_textcolor', 'header_image',
  1012 		 * and so on depending on the theme options.
  1014 		 * and so on depending on the theme options.
  1013 		 *
  1015 		 *
  1014 		 * @since 2.2.0
  1016 		 * @since 2.2.0
  1015 		 *
  1017 		 *
  1016 		 * @param string $current_mod The value of the current theme modification.
  1018 		 * @param mixed $current_mod The value of the active theme modification.
  1017 		 */
  1019 		 */
  1018 		return apply_filters( "theme_mod_{$name}", $mods[ $name ] );
  1020 		return apply_filters( "theme_mod_{$name}", $mods[ $name ] );
  1019 	}
  1021 	}
  1020 
  1022 
  1021 	if ( is_string( $default ) ) {
  1023 	if ( is_string( $default ) ) {
  1030 	/** This filter is documented in wp-includes/theme.php */
  1032 	/** This filter is documented in wp-includes/theme.php */
  1031 	return apply_filters( "theme_mod_{$name}", $default );
  1033 	return apply_filters( "theme_mod_{$name}", $default );
  1032 }
  1034 }
  1033 
  1035 
  1034 /**
  1036 /**
  1035  * Updates theme modification value for the current theme.
  1037  * Updates theme modification value for the active theme.
  1036  *
  1038  *
  1037  * @since 2.1.0
  1039  * @since 2.1.0
  1038  * @since 5.6.0 A return value was added.
  1040  * @since 5.6.0 A return value was added.
  1039  *
  1041  *
  1040  * @param string $name  Theme modification name.
  1042  * @param string $name  Theme modification name.
  1052 	 * of the modification array. For example, 'header_textcolor', 'header_image',
  1054 	 * of the modification array. For example, 'header_textcolor', 'header_image',
  1053 	 * and so on depending on the theme options.
  1055 	 * and so on depending on the theme options.
  1054 	 *
  1056 	 *
  1055 	 * @since 3.9.0
  1057 	 * @since 3.9.0
  1056 	 *
  1058 	 *
  1057 	 * @param string $value     The new value of the theme modification.
  1059 	 * @param mixed $value     The new value of the theme modification.
  1058 	 * @param string $old_value The current value of the theme modification.
  1060 	 * @param mixed $old_value The current value of the theme modification.
  1059 	 */
  1061 	 */
  1060 	$mods[ $name ] = apply_filters( "pre_set_theme_mod_{$name}", $value, $old_value );
  1062 	$mods[ $name ] = apply_filters( "pre_set_theme_mod_{$name}", $value, $old_value );
  1061 
  1063 
  1062 	$theme = get_option( 'stylesheet' );
  1064 	$theme = get_option( 'stylesheet' );
  1063 
  1065 
  1064 	return update_option( "theme_mods_$theme", $mods );
  1066 	return update_option( "theme_mods_$theme", $mods );
  1065 }
  1067 }
  1066 
  1068 
  1067 /**
  1069 /**
  1068  * Removes theme modification name from current theme list.
  1070  * Removes theme modification name from active theme list.
  1069  *
  1071  *
  1070  * If removing the name also removes all elements, then the entire option
  1072  * If removing the name also removes all elements, then the entire option
  1071  * will be removed.
  1073  * will be removed.
  1072  *
  1074  *
  1073  * @since 2.1.0
  1075  * @since 2.1.0
  1092 
  1094 
  1093 	update_option( "theme_mods_$theme", $mods );
  1095 	update_option( "theme_mods_$theme", $mods );
  1094 }
  1096 }
  1095 
  1097 
  1096 /**
  1098 /**
  1097  * Removes theme modifications option for current theme.
  1099  * Removes theme modifications option for the active theme.
  1098  *
  1100  *
  1099  * @since 2.1.0
  1101  * @since 2.1.0
  1100  */
  1102  */
  1101 function remove_theme_mods() {
  1103 function remove_theme_mods() {
  1102 	delete_option( 'theme_mods_' . get_option( 'stylesheet' ) );
  1104 	delete_option( 'theme_mods_' . get_option( 'stylesheet' ) );
  1197 		return '';
  1199 		return '';
  1198 	}
  1200 	}
  1199 
  1201 
  1200 	$width  = absint( $header->width );
  1202 	$width  = absint( $header->width );
  1201 	$height = absint( $header->height );
  1203 	$height = absint( $header->height );
       
  1204 	$alt    = '';
       
  1205 
       
  1206 	// Use alternative text assigned to the image, if available. Otherwise, leave it empty.
       
  1207 	if ( ! empty( $header->attachment_id ) ) {
       
  1208 		$image_alt = get_post_meta( $header->attachment_id, '_wp_attachment_image_alt', true );
       
  1209 
       
  1210 		if ( is_string( $image_alt ) ) {
       
  1211 			$alt = $image_alt;
       
  1212 		}
       
  1213 	}
  1202 
  1214 
  1203 	$attr = wp_parse_args(
  1215 	$attr = wp_parse_args(
  1204 		$attr,
  1216 		$attr,
  1205 		array(
  1217 		array(
  1206 			'src'    => $header->url,
  1218 			'src'    => $header->url,
  1207 			'width'  => $width,
  1219 			'width'  => $width,
  1208 			'height' => $height,
  1220 			'height' => $height,
  1209 			'alt'    => get_bloginfo( 'name' ),
  1221 			'alt'    => $alt,
  1210 		)
  1222 		)
  1211 	);
  1223 	);
  1212 
  1224 
  1213 	// Generate 'srcset' and 'sizes' if not already present.
  1225 	// Generate 'srcset' and 'sizes' if not already present.
  1214 	if ( empty( $attr['srcset'] ) && ! empty( $header->attachment_id ) ) {
  1226 	if ( empty( $attr['srcset'] ) && ! empty( $header->attachment_id ) ) {
  1215 		$image_meta = get_post_meta( $header->attachment_id, '_wp_attachment_metadata', true );
  1227 		$image_meta = get_post_meta( $header->attachment_id, '_wp_attachment_metadata', true );
  1216 		$size_array = array( $width, $height );
  1228 		$size_array = array( $width, $height );
  1217 
  1229 
  1218 		if ( is_array( $image_meta ) ) {
  1230 		if ( is_array( $image_meta ) ) {
  1219 			$srcset = wp_calculate_image_srcset( $size_array, $header->url, $image_meta, $header->attachment_id );
  1231 			$srcset = wp_calculate_image_srcset( $size_array, $header->url, $image_meta, $header->attachment_id );
  1220 			$sizes  = ! empty( $attr['sizes'] ) ? $attr['sizes'] : wp_calculate_image_sizes( $size_array, $header->url, $image_meta, $header->attachment_id );
  1232 
       
  1233 			if ( ! empty( $attr['sizes'] ) ) {
       
  1234 				$sizes = $attr['sizes'];
       
  1235 			} else {
       
  1236 				$sizes = wp_calculate_image_sizes( $size_array, $header->url, $image_meta, $header->attachment_id );
       
  1237 			}
  1221 
  1238 
  1222 			if ( $srcset && $sizes ) {
  1239 			if ( $srcset && $sizes ) {
  1223 				$attr['srcset'] = $srcset;
  1240 				$attr['srcset'] = $srcset;
  1224 				$attr['sizes']  = $sizes;
  1241 				$attr['sizes']  = $sizes;
  1225 			}
  1242 			}
  1226 		}
  1243 		}
  1227 	}
  1244 	}
       
  1245 
       
  1246 	/**
       
  1247 	 * Filters the list of header image attributes.
       
  1248 	 *
       
  1249 	 * @since 5.9.0
       
  1250 	 *
       
  1251 	 * @param array  $attr   Array of the attributes for the image tag.
       
  1252 	 * @param object $header The custom header object returned by 'get_custom_header()'.
       
  1253 	 */
       
  1254 	$attr = apply_filters( 'get_header_image_tag_attributes', $attr, $header );
  1228 
  1255 
  1229 	$attr = array_map( 'esc_attr', $attr );
  1256 	$attr = array_map( 'esc_attr', $attr );
  1230 	$html = '<img';
  1257 	$html = '<img';
  1231 
  1258 
  1232 	foreach ( $attr as $name => $value ) {
  1259 	foreach ( $attr as $name => $value ) {
  1268  * @global array $_wp_default_headers
  1295  * @global array $_wp_default_headers
  1269  *
  1296  *
  1270  * @return object
  1297  * @return object
  1271  */
  1298  */
  1272 function _get_random_header_data() {
  1299 function _get_random_header_data() {
       
  1300 	global $_wp_default_headers;
  1273 	static $_wp_random_header = null;
  1301 	static $_wp_random_header = null;
  1274 
  1302 
  1275 	if ( empty( $_wp_random_header ) ) {
  1303 	if ( empty( $_wp_random_header ) ) {
  1276 		global $_wp_default_headers;
       
  1277 		$header_image_mod = get_theme_mod( 'header_image', '' );
  1304 		$header_image_mod = get_theme_mod( 'header_image', '' );
  1278 		$headers          = array();
  1305 		$headers          = array();
  1279 
  1306 
  1280 		if ( 'random-uploaded-image' === $header_image_mod ) {
  1307 		if ( 'random-uploaded-image' === $header_image_mod ) {
  1281 			$headers = get_uploaded_header_images();
  1308 			$headers = get_uploaded_header_images();
  1293 			return new stdClass;
  1320 			return new stdClass;
  1294 		}
  1321 		}
  1295 
  1322 
  1296 		$_wp_random_header = (object) $headers[ array_rand( $headers ) ];
  1323 		$_wp_random_header = (object) $headers[ array_rand( $headers ) ];
  1297 
  1324 
  1298 		$_wp_random_header->url           = sprintf( $_wp_random_header->url, get_template_directory_uri(), get_stylesheet_directory_uri() );
  1325 		$_wp_random_header->url = sprintf(
  1299 		$_wp_random_header->thumbnail_url = sprintf( $_wp_random_header->thumbnail_url, get_template_directory_uri(), get_stylesheet_directory_uri() );
  1326 			$_wp_random_header->url,
       
  1327 			get_template_directory_uri(),
       
  1328 			get_stylesheet_directory_uri()
       
  1329 		);
       
  1330 
       
  1331 		$_wp_random_header->thumbnail_url = sprintf(
       
  1332 			$_wp_random_header->thumbnail_url,
       
  1333 			get_template_directory_uri(),
       
  1334 			get_stylesheet_directory_uri()
       
  1335 		);
  1300 	}
  1336 	}
  1301 
  1337 
  1302 	return $_wp_random_header;
  1338 	return $_wp_random_header;
  1303 }
  1339 }
  1304 
  1340 
  1365 		echo esc_url( $image );
  1401 		echo esc_url( $image );
  1366 	}
  1402 	}
  1367 }
  1403 }
  1368 
  1404 
  1369 /**
  1405 /**
  1370  * Gets the header images uploaded for the current theme.
  1406  * Gets the header images uploaded for the active theme.
  1371  *
  1407  *
  1372  * @since 3.2.0
  1408  * @since 3.2.0
  1373  *
  1409  *
  1374  * @return array
  1410  * @return array
  1375  */
  1411  */
  1394 	foreach ( (array) $headers as $header ) {
  1430 	foreach ( (array) $headers as $header ) {
  1395 		$url          = esc_url_raw( wp_get_attachment_url( $header->ID ) );
  1431 		$url          = esc_url_raw( wp_get_attachment_url( $header->ID ) );
  1396 		$header_data  = wp_get_attachment_metadata( $header->ID );
  1432 		$header_data  = wp_get_attachment_metadata( $header->ID );
  1397 		$header_index = $header->ID;
  1433 		$header_index = $header->ID;
  1398 
  1434 
  1399 		$header_images[ $header_index ]                      = array();
  1435 		$header_images[ $header_index ]                  = array();
  1400 		$header_images[ $header_index ]['attachment_id']     = $header->ID;
  1436 		$header_images[ $header_index ]['attachment_id'] = $header->ID;
  1401 		$header_images[ $header_index ]['url']               = $url;
  1437 		$header_images[ $header_index ]['url']           = $url;
  1402 		$header_images[ $header_index ]['thumbnail_url']     = $url;
  1438 		$header_images[ $header_index ]['thumbnail_url'] = $url;
  1403 		$header_images[ $header_index ]['alt_text']          = get_post_meta( $header->ID, '_wp_attachment_image_alt', true );
  1439 		$header_images[ $header_index ]['alt_text']      = get_post_meta( $header->ID, '_wp_attachment_image_alt', true );
  1404 		$header_images[ $header_index ]['attachment_parent'] = isset( $header_data['attachment_parent'] ) ? $header_data['attachment_parent'] : '';
  1440 
       
  1441 		if ( isset( $header_data['attachment_parent'] ) ) {
       
  1442 			$header_images[ $header_index ]['attachment_parent'] = $header_data['attachment_parent'];
       
  1443 		} else {
       
  1444 			$header_images[ $header_index ]['attachment_parent'] = '';
       
  1445 		}
  1405 
  1446 
  1406 		if ( isset( $header_data['width'] ) ) {
  1447 		if ( isset( $header_data['width'] ) ) {
  1407 			$header_images[ $header_index ]['width'] = $header_data['width'];
  1448 			$header_images[ $header_index ]['width'] = $header_data['width'];
  1408 		}
  1449 		}
  1409 		if ( isset( $header_data['height'] ) ) {
  1450 		if ( isset( $header_data['height'] ) ) {
  1490  * @return bool|void A single header returns true on success, false on failure.
  1531  * @return bool|void A single header returns true on success, false on failure.
  1491  *                   There is currently no return value for multiple headers.
  1532  *                   There is currently no return value for multiple headers.
  1492  */
  1533  */
  1493 function unregister_default_headers( $header ) {
  1534 function unregister_default_headers( $header ) {
  1494 	global $_wp_default_headers;
  1535 	global $_wp_default_headers;
       
  1536 
  1495 	if ( is_array( $header ) ) {
  1537 	if ( is_array( $header ) ) {
  1496 		array_map( 'unregister_default_headers', $header );
  1538 		array_map( 'unregister_default_headers', $header );
  1497 	} elseif ( isset( $_wp_default_headers[ $header ] ) ) {
  1539 	} elseif ( isset( $_wp_default_headers[ $header ] ) ) {
  1498 		unset( $_wp_default_headers[ $header ] );
  1540 		unset( $_wp_default_headers[ $header ] );
  1499 		return true;
  1541 		return true;
  1825 	$styles = wp_get_custom_css();
  1867 	$styles = wp_get_custom_css();
  1826 	if ( $styles || is_customize_preview() ) :
  1868 	if ( $styles || is_customize_preview() ) :
  1827 		$type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"';
  1869 		$type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"';
  1828 		?>
  1870 		?>
  1829 		<style<?php echo $type_attr; ?> id="wp-custom-css">
  1871 		<style<?php echo $type_attr; ?> id="wp-custom-css">
  1830 			<?php echo strip_tags( $styles ); // Note that esc_html() cannot be used because `div &gt; span` is not interpreted properly. ?>
  1872 			<?php
       
  1873 			// Note that esc_html() cannot be used because `div &gt; span` is not interpreted properly.
       
  1874 			echo strip_tags( $styles );
       
  1875 			?>
  1831 		</style>
  1876 		</style>
  1832 		<?php
  1877 		<?php
  1833 	endif;
  1878 	endif;
  1834 }
  1879 }
  1835 
  1880 
  1836 /**
  1881 /**
  1837  * Fetches the `custom_css` post for a given theme.
  1882  * Fetches the `custom_css` post for a given theme.
  1838  *
  1883  *
  1839  * @since 4.7.0
  1884  * @since 4.7.0
  1840  *
  1885  *
  1841  * @param string $stylesheet Optional. A theme object stylesheet name. Defaults to the current theme.
  1886  * @param string $stylesheet Optional. A theme object stylesheet name. Defaults to the active theme.
  1842  * @return WP_Post|null The custom_css post or null if none exists.
  1887  * @return WP_Post|null The custom_css post or null if none exists.
  1843  */
  1888  */
  1844 function wp_get_custom_css_post( $stylesheet = '' ) {
  1889 function wp_get_custom_css_post( $stylesheet = '' ) {
  1845 	if ( empty( $stylesheet ) ) {
  1890 	if ( empty( $stylesheet ) ) {
  1846 		$stylesheet = get_stylesheet();
  1891 		$stylesheet = get_stylesheet();
  1887 /**
  1932 /**
  1888  * Fetches the saved Custom CSS content for rendering.
  1933  * Fetches the saved Custom CSS content for rendering.
  1889  *
  1934  *
  1890  * @since 4.7.0
  1935  * @since 4.7.0
  1891  *
  1936  *
  1892  * @param string $stylesheet Optional. A theme object stylesheet name. Defaults to the current theme.
  1937  * @param string $stylesheet Optional. A theme object stylesheet name. Defaults to the active theme.
  1893  * @return string The Custom CSS Post content.
  1938  * @return string The Custom CSS Post content.
  1894  */
  1939  */
  1895 function wp_get_custom_css( $stylesheet = '' ) {
  1940 function wp_get_custom_css( $stylesheet = '' ) {
  1896 	$css = '';
  1941 	$css = '';
  1897 
  1942 
  1903 	if ( $post ) {
  1948 	if ( $post ) {
  1904 		$css = $post->post_content;
  1949 		$css = $post->post_content;
  1905 	}
  1950 	}
  1906 
  1951 
  1907 	/**
  1952 	/**
  1908 	 * Filters the Custom CSS Output into the <head>.
  1953 	 * Filters the custom CSS output into the head element.
  1909 	 *
  1954 	 *
  1910 	 * @since 4.7.0
  1955 	 * @since 4.7.0
  1911 	 *
  1956 	 *
  1912 	 * @param string $css        CSS pulled in from the Custom CSS CPT.
  1957 	 * @param string $css        CSS pulled in from the Custom CSS post type.
  1913 	 * @param string $stylesheet The theme stylesheet name.
  1958 	 * @param string $stylesheet The theme stylesheet name.
  1914 	 */
  1959 	 */
  1915 	$css = apply_filters( 'wp_get_custom_css', $css, $stylesheet );
  1960 	$css = apply_filters( 'wp_get_custom_css', $css, $stylesheet );
  1916 
  1961 
  1917 	return $css;
  1962 	return $css;
  1926  *
  1971  *
  1927  * @param string $css CSS, stored in `post_content`.
  1972  * @param string $css CSS, stored in `post_content`.
  1928  * @param array  $args {
  1973  * @param array  $args {
  1929  *     Args.
  1974  *     Args.
  1930  *
  1975  *
  1931  *     @type string $preprocessed Pre-processed CSS, stored in `post_content_filtered`. Normally empty string. Optional.
  1976  *     @type string $preprocessed Optional. Pre-processed CSS, stored in `post_content_filtered`.
  1932  *     @type string $stylesheet   Stylesheet (child theme) to update. Optional, defaults to current theme/stylesheet.
  1977  *                                Normally empty string.
       
  1978  *     @type string $stylesheet   Optional. Stylesheet (child theme) to update.
       
  1979  *                                Defaults to active theme/stylesheet.
  1933  * }
  1980  * }
  1934  * @return WP_Post|WP_Error Post on success, error on failure.
  1981  * @return WP_Post|WP_Error Post on success, error on failure.
  1935  */
  1982  */
  1936 function wp_update_custom_css_post( $css, $args = array() ) {
  1983 function wp_update_custom_css_post( $css, $args = array() ) {
  1937 	$args = wp_parse_args(
  1984 	$args = wp_parse_args(
  1946 		'css'          => $css,
  1993 		'css'          => $css,
  1947 		'preprocessed' => $args['preprocessed'],
  1994 		'preprocessed' => $args['preprocessed'],
  1948 	);
  1995 	);
  1949 
  1996 
  1950 	/**
  1997 	/**
  1951 	 * Filters the `css` (`post_content`) and `preprocessed` (`post_content_filtered`) args for a `custom_css` post being updated.
  1998 	 * Filters the `css` (`post_content`) and `preprocessed` (`post_content_filtered`) args
       
  1999 	 * for a `custom_css` post being updated.
  1952 	 *
  2000 	 *
  1953 	 * This filter can be used by plugin that offer CSS pre-processors, to store the original
  2001 	 * This filter can be used by plugin that offer CSS pre-processors, to store the original
  1954 	 * pre-processed CSS in `post_content_filtered` and then store processed CSS in `post_content`.
  2002 	 * pre-processed CSS in `post_content_filtered` and then store processed CSS in `post_content`.
  1955 	 * When used in this way, the `post_content_filtered` should be supplied as the setting value
  2003 	 * When used in this way, the `post_content_filtered` should be supplied as the setting value
  1956 	 * instead of `post_content` via a the `customize_value_custom_css` filter, for example:
  2004 	 * instead of `post_content` via a the `customize_value_custom_css` filter, for example:
  1968 	 * @since 4.7.0
  2016 	 * @since 4.7.0
  1969 	 * @param array $data {
  2017 	 * @param array $data {
  1970 	 *     Custom CSS data.
  2018 	 *     Custom CSS data.
  1971 	 *
  2019 	 *
  1972 	 *     @type string $css          CSS stored in `post_content`.
  2020 	 *     @type string $css          CSS stored in `post_content`.
  1973 	 *     @type string $preprocessed Pre-processed CSS stored in `post_content_filtered`. Normally empty string.
  2021 	 *     @type string $preprocessed Pre-processed CSS stored in `post_content_filtered`.
       
  2022 	 *                                Normally empty string.
  1974 	 * }
  2023 	 * }
  1975 	 * @param array $args {
  2024 	 * @param array $args {
  1976 	 *     The args passed into `wp_update_custom_css_post()` merged with defaults.
  2025 	 *     The args passed into `wp_update_custom_css_post()` merged with defaults.
  1977 	 *
  2026 	 *
  1978 	 *     @type string $css          The original CSS passed in to be updated.
  2027 	 *     @type string $css          The original CSS passed in to be updated.
  2084  *
  2133  *
  2085  * @return string[] If registered, a list of editor stylesheet URLs.
  2134  * @return string[] If registered, a list of editor stylesheet URLs.
  2086  */
  2135  */
  2087 function get_editor_stylesheets() {
  2136 function get_editor_stylesheets() {
  2088 	$stylesheets = array();
  2137 	$stylesheets = array();
  2089 	// Load editor_style.css if the current theme supports it.
  2138 	// Load editor_style.css if the active theme supports it.
  2090 	if ( ! empty( $GLOBALS['editor_styles'] ) && is_array( $GLOBALS['editor_styles'] ) ) {
  2139 	if ( ! empty( $GLOBALS['editor_styles'] ) && is_array( $GLOBALS['editor_styles'] ) ) {
  2091 		$editor_styles = $GLOBALS['editor_styles'];
  2140 		$editor_styles = $GLOBALS['editor_styles'];
  2092 
  2141 
  2093 		$editor_styles = array_unique( array_filter( $editor_styles ) );
  2142 		$editor_styles = array_unique( array_filter( $editor_styles ) );
  2094 		$style_uri     = get_stylesheet_directory_uri();
  2143 		$style_uri     = get_stylesheet_directory_uri();
  2154 					'title'  => _x( 'Find Us', 'Theme starter content' ),
  2203 					'title'  => _x( 'Find Us', 'Theme starter content' ),
  2155 					'text'   => implode(
  2204 					'text'   => implode(
  2156 						'',
  2205 						'',
  2157 						array(
  2206 						array(
  2158 							'<strong>' . _x( 'Address', 'Theme starter content' ) . "</strong>\n",
  2207 							'<strong>' . _x( 'Address', 'Theme starter content' ) . "</strong>\n",
  2159 							_x( '123 Main Street', 'Theme starter content' ) . "\n" . _x( 'New York, NY 10001', 'Theme starter content' ) . "\n\n",
  2208 							_x( '123 Main Street', 'Theme starter content' ) . "\n",
       
  2209 							_x( 'New York, NY 10001', 'Theme starter content' ) . "\n\n",
  2160 							'<strong>' . _x( 'Hours', 'Theme starter content' ) . "</strong>\n",
  2210 							'<strong>' . _x( 'Hours', 'Theme starter content' ) . "</strong>\n",
  2161 							_x( 'Monday&ndash;Friday: 9:00AM&ndash;5:00PM', 'Theme starter content' ) . "\n" . _x( 'Saturday &amp; Sunday: 11:00AM&ndash;3:00PM', 'Theme starter content' ),
  2211 							_x( 'Monday&ndash;Friday: 9:00AM&ndash;5:00PM', 'Theme starter content' ) . "\n",
       
  2212 							_x( 'Saturday &amp; Sunday: 11:00AM&ndash;3:00PM', 'Theme starter content' ),
  2162 						)
  2213 						)
  2163 					),
  2214 					),
  2164 					'filter' => true,
  2215 					'filter' => true,
  2165 					'visual' => true,
  2216 					'visual' => true,
  2166 				),
  2217 				),
  2358 									array_merge( $core_content[ $type ][ $id ][1], $widget ),
  2409 									array_merge( $core_content[ $type ][ $id ][1], $widget ),
  2359 								);
  2410 								);
  2360 							}
  2411 							}
  2361 
  2412 
  2362 							$content[ $type ][ $sidebar_id ][] = $widget;
  2413 							$content[ $type ][ $sidebar_id ][] = $widget;
  2363 						} elseif ( is_string( $widget ) && ! empty( $core_content[ $type ] ) && ! empty( $core_content[ $type ][ $widget ] ) ) {
  2414 						} elseif ( is_string( $widget )
       
  2415 							&& ! empty( $core_content[ $type ] )
       
  2416 							&& ! empty( $core_content[ $type ][ $widget ] )
       
  2417 						) {
  2364 							$content[ $type ][ $sidebar_id ][] = $core_content[ $type ][ $widget ];
  2418 							$content[ $type ][ $sidebar_id ][] = $core_content[ $type ][ $widget ];
  2365 						}
  2419 						}
  2366 					}
  2420 					}
  2367 				}
  2421 				}
  2368 				break;
  2422 				break;
  2385 							if ( ! empty( $core_content[ $type ][ $id ] ) ) {
  2439 							if ( ! empty( $core_content[ $type ][ $id ] ) ) {
  2386 								$nav_menu_item = array_merge( $core_content[ $type ][ $id ], $nav_menu_item );
  2440 								$nav_menu_item = array_merge( $core_content[ $type ][ $id ], $nav_menu_item );
  2387 							}
  2441 							}
  2388 
  2442 
  2389 							$content[ $type ][ $nav_menu_location ]['items'][] = $nav_menu_item;
  2443 							$content[ $type ][ $nav_menu_location ]['items'][] = $nav_menu_item;
  2390 						} elseif ( is_string( $nav_menu_item ) && ! empty( $core_content[ $type ] ) && ! empty( $core_content[ $type ][ $nav_menu_item ] ) ) {
  2444 						} elseif ( is_string( $nav_menu_item )
       
  2445 							&& ! empty( $core_content[ $type ] )
       
  2446 							&& ! empty( $core_content[ $type ][ $nav_menu_item ] )
       
  2447 						) {
  2391 							$content[ $type ][ $nav_menu_location ]['items'][] = $core_content[ $type ][ $nav_menu_item ];
  2448 							$content[ $type ][ $nav_menu_location ]['items'][] = $core_content[ $type ][ $nav_menu_item ];
  2392 						}
  2449 						}
  2393 					}
  2450 					}
  2394 				}
  2451 				}
  2395 				break;
  2452 				break;
  2545 				$post_formats = get_post_format_slugs();
  2602 				$post_formats = get_post_format_slugs();
  2546 				unset( $post_formats['standard'] );
  2603 				unset( $post_formats['standard'] );
  2547 
  2604 
  2548 				$args[0] = array_intersect( $args[0], array_keys( $post_formats ) );
  2605 				$args[0] = array_intersect( $args[0], array_keys( $post_formats ) );
  2549 			} else {
  2606 			} else {
  2550 				_doing_it_wrong( "add_theme_support( 'post-formats' )", __( 'You need to pass an array of post formats.' ), '5.6.0' );
  2607 				_doing_it_wrong(
       
  2608 					"add_theme_support( 'post-formats' )",
       
  2609 					__( 'You need to pass an array of post formats.' ),
       
  2610 					'5.6.0'
       
  2611 				);
  2551 				return false;
  2612 				return false;
  2552 			}
  2613 			}
  2553 			break;
  2614 			break;
  2554 
  2615 
  2555 		case 'html5':
  2616 		case 'html5':
  2556 			// You can't just pass 'html5', you need to pass an array of types.
  2617 			// You can't just pass 'html5', you need to pass an array of types.
  2557 			if ( empty( $args[0] ) ) {
  2618 			if ( empty( $args[0] ) || ! is_array( $args[0] ) ) {
       
  2619 				_doing_it_wrong(
       
  2620 					"add_theme_support( 'html5' )",
       
  2621 					__( 'You need to pass an array of types.' ),
       
  2622 					'3.6.1'
       
  2623 				);
       
  2624 
       
  2625 				if ( ! empty( $args[0] ) && ! is_array( $args[0] ) ) {
       
  2626 					return false;
       
  2627 				}
       
  2628 
  2558 				// Build an array of types for back-compat.
  2629 				// Build an array of types for back-compat.
  2559 				$args = array( 0 => array( 'comment-list', 'comment-form', 'search-form' ) );
  2630 				$args = array( 0 => array( 'comment-list', 'comment-form', 'search-form' ) );
  2560 			} elseif ( ! isset( $args[0] ) || ! is_array( $args[0] ) ) {
       
  2561 				_doing_it_wrong( "add_theme_support( 'html5' )", __( 'You need to pass an array of types.' ), '3.6.1' );
       
  2562 				return false;
       
  2563 			}
  2631 			}
  2564 
  2632 
  2565 			// Calling 'html5' again merges, rather than overwrites.
  2633 			// Calling 'html5' again merges, rather than overwrites.
  2566 			if ( isset( $_wp_theme_features['html5'] ) ) {
  2634 			if ( isset( $_wp_theme_features['html5'] ) ) {
  2567 				$args[0] = array_merge( $_wp_theme_features['html5'][0], $args[0] );
  2635 				$args[0] = array_merge( $_wp_theme_features['html5'][0], $args[0] );
  2797  *
  2865  *
  2798  * @since 4.5.0
  2866  * @since 4.5.0
  2799  * @access private
  2867  * @access private
  2800  */
  2868  */
  2801 function _custom_logo_header_styles() {
  2869 function _custom_logo_header_styles() {
  2802 	if ( ! current_theme_supports( 'custom-header', 'header-text' ) && get_theme_support( 'custom-logo', 'header-text' ) && ! get_theme_mod( 'header_text', true ) ) {
  2870 	if ( ! current_theme_supports( 'custom-header', 'header-text' )
       
  2871 		&& get_theme_support( 'custom-logo', 'header-text' )
       
  2872 		&& ! get_theme_mod( 'header_text', true )
       
  2873 	) {
  2803 		$classes = (array) get_theme_support( 'custom-logo', 'header-text' );
  2874 		$classes = (array) get_theme_support( 'custom-logo', 'header-text' );
  2804 		$classes = array_map( 'sanitize_html_class', $classes );
  2875 		$classes = array_map( 'sanitize_html_class', $classes );
  2805 		$classes = '.' . implode( ', .', $classes );
  2876 		$classes = '.' . implode( ', .', $classes );
  2806 
  2877 
  2807 		$type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"';
  2878 		$type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"';
  2836  * @param mixed  ...$args Optional extra arguments to be checked against certain features.
  2907  * @param mixed  ...$args Optional extra arguments to be checked against certain features.
  2837  * @return mixed The array of extra arguments or the value for the registered feature.
  2908  * @return mixed The array of extra arguments or the value for the registered feature.
  2838  */
  2909  */
  2839 function get_theme_support( $feature, ...$args ) {
  2910 function get_theme_support( $feature, ...$args ) {
  2840 	global $_wp_theme_features;
  2911 	global $_wp_theme_features;
       
  2912 
  2841 	if ( ! isset( $_wp_theme_features[ $feature ] ) ) {
  2913 	if ( ! isset( $_wp_theme_features[ $feature ] ) ) {
  2842 		return false;
  2914 		return false;
  2843 	}
  2915 	}
  2844 
  2916 
  2845 	if ( ! $args ) {
  2917 	if ( ! $args ) {
  2961  * @global array $_wp_theme_features
  3033  * @global array $_wp_theme_features
  2962  *
  3034  *
  2963  * @param string $feature The feature being checked. See add_theme_support() for the list
  3035  * @param string $feature The feature being checked. See add_theme_support() for the list
  2964  *                        of possible values.
  3036  *                        of possible values.
  2965  * @param mixed  ...$args Optional extra arguments to be checked against certain features.
  3037  * @param mixed  ...$args Optional extra arguments to be checked against certain features.
  2966  * @return bool True if the current theme supports the feature, false otherwise.
  3038  * @return bool True if the active theme supports the feature, false otherwise.
  2967  */
  3039  */
  2968 function current_theme_supports( $feature, ...$args ) {
  3040 function current_theme_supports( $feature, ...$args ) {
  2969 	global $_wp_theme_features;
  3041 	global $_wp_theme_features;
  2970 
  3042 
  2971 	if ( 'custom-header-uploads' === $feature ) {
  3043 	if ( 'custom-header-uploads' === $feature ) {
  2974 
  3046 
  2975 	if ( ! isset( $_wp_theme_features[ $feature ] ) ) {
  3047 	if ( ! isset( $_wp_theme_features[ $feature ] ) ) {
  2976 		return false;
  3048 		return false;
  2977 	}
  3049 	}
  2978 
  3050 
  2979 	// If no args passed then no extra checks need be performed.
  3051 	// If no args passed then no extra checks need to be performed.
  2980 	if ( ! $args ) {
  3052 	if ( ! $args ) {
  2981 		return true;
  3053 		/** This filter is documented in wp-includes/theme.php */
       
  3054 		return apply_filters( "current_theme_supports-{$feature}", true, $args, $_wp_theme_features[ $feature ] ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
  2982 	}
  3055 	}
  2983 
  3056 
  2984 	switch ( $feature ) {
  3057 	switch ( $feature ) {
  2985 		case 'post-thumbnails':
  3058 		case 'post-thumbnails':
  2986 			/*
  3059 			/*
  3011 			// Specific capabilities can be registered by passing an array to add_theme_support().
  3084 			// Specific capabilities can be registered by passing an array to add_theme_support().
  3012 			return ( isset( $_wp_theme_features[ $feature ][0][ $args[0] ] ) && $_wp_theme_features[ $feature ][0][ $args[0] ] );
  3085 			return ( isset( $_wp_theme_features[ $feature ][0][ $args[0] ] ) && $_wp_theme_features[ $feature ][0][ $args[0] ] );
  3013 	}
  3086 	}
  3014 
  3087 
  3015 	/**
  3088 	/**
  3016 	 * Filters whether the current theme supports a specific feature.
  3089 	 * Filters whether the active theme supports a specific feature.
  3017 	 *
  3090 	 *
  3018 	 * The dynamic portion of the hook name, `$feature`, refers to the specific
  3091 	 * The dynamic portion of the hook name, `$feature`, refers to the specific
  3019 	 * theme feature. See add_theme_support() for the list of possible values.
  3092 	 * theme feature. See add_theme_support() for the list of possible values.
  3020 	 *
  3093 	 *
  3021 	 * @since 3.4.0
  3094 	 * @since 3.4.0
  3022 	 *
  3095 	 *
  3023 	 * @param bool   $supports Whether the current theme supports the given feature. Default true.
  3096 	 * @param bool   $supports Whether the active theme supports the given feature. Default true.
  3024 	 * @param array  $args     Array of arguments for the feature.
  3097 	 * @param array  $args     Array of arguments for the feature.
  3025 	 * @param string $feature  The theme feature.
  3098 	 * @param string $feature  The theme feature.
  3026 	 */
  3099 	 */
  3027 	return apply_filters( "current_theme_supports-{$feature}", true, $args, $_wp_theme_features[ $feature ] ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
  3100 	return apply_filters( "current_theme_supports-{$feature}", true, $args, $_wp_theme_features[ $feature ] ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
  3028 }
  3101 }
  3033  * @since 2.9.0
  3106  * @since 2.9.0
  3034  *
  3107  *
  3035  * @param string $feature The feature being checked. See add_theme_support() for the list
  3108  * @param string $feature The feature being checked. See add_theme_support() for the list
  3036  *                        of possible values.
  3109  *                        of possible values.
  3037  * @param string $include Path to the file.
  3110  * @param string $include Path to the file.
  3038  * @return bool True if the current theme supports the supplied feature, false otherwise.
  3111  * @return bool True if the active theme supports the supplied feature, false otherwise.
  3039  */
  3112  */
  3040 function require_if_theme_supports( $feature, $include ) {
  3113 function require_if_theme_supports( $feature, $include ) {
  3041 	if ( current_theme_supports( $feature ) ) {
  3114 	if ( current_theme_supports( $feature ) ) {
  3042 		require $include;
  3115 		require $include;
  3043 		return true;
  3116 		return true;
  3046 }
  3119 }
  3047 
  3120 
  3048 /**
  3121 /**
  3049  * Registers a theme feature for use in add_theme_support().
  3122  * Registers a theme feature for use in add_theme_support().
  3050  *
  3123  *
  3051  * This does not indicate that the current theme supports the feature, it only describes
  3124  * This does not indicate that the active theme supports the feature, it only describes
  3052  * the feature's supported options.
  3125  * the feature's supported options.
  3053  *
  3126  *
  3054  * @since 5.5.0
  3127  * @since 5.5.0
  3055  *
  3128  *
  3056  * @see add_theme_support()
  3129  * @see add_theme_support()
  3063  *     Data used to describe the theme.
  3136  *     Data used to describe the theme.
  3064  *
  3137  *
  3065  *     @type string     $type         The type of data associated with this feature.
  3138  *     @type string     $type         The type of data associated with this feature.
  3066  *                                    Valid values are 'string', 'boolean', 'integer',
  3139  *                                    Valid values are 'string', 'boolean', 'integer',
  3067  *                                    'number', 'array', and 'object'. Defaults to 'boolean'.
  3140  *                                    'number', 'array', and 'object'. Defaults to 'boolean'.
  3068  *     @type boolean    $variadic     Does this feature utilize the variadic support
  3141  *     @type bool       $variadic     Does this feature utilize the variadic support
  3069  *                                    of add_theme_support(), or are all arguments specified
  3142  *                                    of add_theme_support(), or are all arguments specified
  3070  *                                    as the second parameter. Must be used with the "array" type.
  3143  *                                    as the second parameter. Must be used with the "array" type.
  3071  *     @type string     $description  A short description of the feature. Included in
  3144  *     @type string     $description  A short description of the feature. Included in
  3072  *                                    the Themes REST API schema. Intended for developers.
  3145  *                                    the Themes REST API schema. Intended for developers.
  3073  *     @type bool|array $show_in_rest {
  3146  *     @type bool|array $show_in_rest {
  3153 			);
  3226 			);
  3154 		}
  3227 		}
  3155 	}
  3228 	}
  3156 
  3229 
  3157 	if ( is_array( $args['show_in_rest'] ) ) {
  3230 	if ( is_array( $args['show_in_rest'] ) ) {
  3158 		if ( isset( $args['show_in_rest']['prepare_callback'] ) && ! is_callable( $args['show_in_rest']['prepare_callback'] ) ) {
  3231 		if ( isset( $args['show_in_rest']['prepare_callback'] )
       
  3232 			&& ! is_callable( $args['show_in_rest']['prepare_callback'] )
       
  3233 		) {
  3159 			return new WP_Error(
  3234 			return new WP_Error(
  3160 				'invalid_rest_prepare_callback',
  3235 				'invalid_rest_prepare_callback',
  3161 				sprintf(
  3236 				sprintf(
  3162 					/* translators: %s: prepare_callback */
  3237 					/* translators: %s: prepare_callback */
  3163 					__( 'The "%s" must be a callable function.' ),
  3238 					__( 'The "%s" must be a callable function.' ),
  3272  *
  3347  *
  3273  * @since 3.3.0
  3348  * @since 3.3.0
  3274  */
  3349  */
  3275 function check_theme_switched() {
  3350 function check_theme_switched() {
  3276 	$stylesheet = get_option( 'theme_switched' );
  3351 	$stylesheet = get_option( 'theme_switched' );
       
  3352 
  3277 	if ( $stylesheet ) {
  3353 	if ( $stylesheet ) {
  3278 		$old_theme = wp_get_theme( $stylesheet );
  3354 		$old_theme = wp_get_theme( $stylesheet );
  3279 
  3355 
  3280 		// Prevent widget & menu mapping from running since Customizer already called it up front.
  3356 		// Prevent widget & menu mapping from running since Customizer already called it up front.
  3281 		if ( get_option( 'theme_switched_via_customizer' ) ) {
  3357 		if ( get_option( 'theme_switched_via_customizer' ) ) {
  3301 			do_action( 'after_switch_theme', $old_theme->get( 'Name' ), $old_theme );
  3377 			do_action( 'after_switch_theme', $old_theme->get( 'Name' ), $old_theme );
  3302 		} else {
  3378 		} else {
  3303 			/** This action is documented in wp-includes/theme.php */
  3379 			/** This action is documented in wp-includes/theme.php */
  3304 			do_action( 'after_switch_theme', $stylesheet, $old_theme );
  3380 			do_action( 'after_switch_theme', $stylesheet, $old_theme );
  3305 		}
  3381 		}
       
  3382 
  3306 		flush_rewrite_rules();
  3383 		flush_rewrite_rules();
  3307 
  3384 
  3308 		update_option( 'theme_switched', false );
  3385 		update_option( 'theme_switched', false );
  3309 	}
  3386 	}
  3310 }
  3387 }
  3340 	/*
  3417 	/*
  3341 	 * Note that wp_unslash() is not being used on the input vars because it is
  3418 	 * Note that wp_unslash() is not being used on the input vars because it is
  3342 	 * called before wp_magic_quotes() gets called. Besides this fact, none of
  3419 	 * called before wp_magic_quotes() gets called. Besides this fact, none of
  3343 	 * the values should contain any characters needing slashes anyway.
  3420 	 * the values should contain any characters needing slashes anyway.
  3344 	 */
  3421 	 */
  3345 	$keys       = array( 'changeset_uuid', 'customize_changeset_uuid', 'customize_theme', 'theme', 'customize_messenger_channel', 'customize_autosaved' );
  3422 	$keys       = array(
       
  3423 		'changeset_uuid',
       
  3424 		'customize_changeset_uuid',
       
  3425 		'customize_theme',
       
  3426 		'theme',
       
  3427 		'customize_messenger_channel',
       
  3428 		'customize_autosaved',
       
  3429 	);
  3346 	$input_vars = array_merge(
  3430 	$input_vars = array_merge(
  3347 		wp_array_slice_assoc( $_GET, $keys ),
  3431 		wp_array_slice_assoc( $_GET, $keys ),
  3348 		wp_array_slice_assoc( $_POST, $keys )
  3432 		wp_array_slice_assoc( $_POST, $keys )
  3349 	);
  3433 	);
  3350 
  3434 
  3396 		'customize_save' === wp_unslash( $_REQUEST['action'] )
  3480 		'customize_save' === wp_unslash( $_REQUEST['action'] )
  3397 	);
  3481 	);
  3398 	$settings_previewed       = ! $is_customize_save_action;
  3482 	$settings_previewed       = ! $is_customize_save_action;
  3399 
  3483 
  3400 	require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
  3484 	require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
  3401 	$GLOBALS['wp_customize'] = new WP_Customize_Manager( compact( 'changeset_uuid', 'theme', 'messenger_channel', 'settings_previewed', 'autosaved', 'branching' ) );
  3485 	$GLOBALS['wp_customize'] = new WP_Customize_Manager(
       
  3486 		compact(
       
  3487 			'changeset_uuid',
       
  3488 			'theme',
       
  3489 			'messenger_channel',
       
  3490 			'settings_previewed',
       
  3491 			'autosaved',
       
  3492 			'branching'
       
  3493 		)
       
  3494 	);
  3402 }
  3495 }
  3403 
  3496 
  3404 /**
  3497 /**
  3405  * Publishes a snapshot's changes.
  3498  * Publishes a snapshot's changes.
  3406  *
  3499  *
  3539 /**
  3632 /**
  3540  * Returns a URL to load the Customizer.
  3633  * Returns a URL to load the Customizer.
  3541  *
  3634  *
  3542  * @since 3.4.0
  3635  * @since 3.4.0
  3543  *
  3636  *
  3544  * @param string $stylesheet Optional. Theme to customize. Defaults to current theme.
  3637  * @param string $stylesheet Optional. Theme to customize. Defaults to active theme.
  3545  *                           The theme's stylesheet will be urlencoded if necessary.
  3638  *                           The theme's stylesheet will be urlencoded if necessary.
  3546  * @return string
  3639  * @return string
  3547  */
  3640  */
  3548 function wp_customize_url( $stylesheet = '' ) {
  3641 function wp_customize_url( $stylesheet = '' ) {
  3549 	$url = admin_url( 'customize.php' );
  3642 	$url = admin_url( 'customize.php' );
  3608 
  3701 
  3609 	return ( $wp_customize instanceof WP_Customize_Manager ) && $wp_customize->is_preview();
  3702 	return ( $wp_customize instanceof WP_Customize_Manager ) && $wp_customize->is_preview();
  3610 }
  3703 }
  3611 
  3704 
  3612 /**
  3705 /**
  3613  * Makes sure that auto-draft posts get their post_date bumped or status changed to draft to prevent premature garbage-collection.
  3706  * Makes sure that auto-draft posts get their post_date bumped or status changed
       
  3707  * to draft to prevent premature garbage-collection.
  3614  *
  3708  *
  3615  * When a changeset is updated but remains an auto-draft, ensure the post_date
  3709  * When a changeset is updated but remains an auto-draft, ensure the post_date
  3616  * for the auto-draft posts remains the same so that it will be
  3710  * for the auto-draft posts remains the same so that it will be
  3617  * garbage-collected at the same time by `wp_delete_auto_drafts()`. Otherwise,
  3711  * garbage-collected at the same time by `wp_delete_auto_drafts()`. Otherwise,
  3618  * if the changeset is updated to be a draft then update the posts
  3712  * if the changeset is updated to be a draft then update the posts
  3705  * Creates the initial theme features when the 'setup_theme' action is fired.
  3799  * Creates the initial theme features when the 'setup_theme' action is fired.
  3706  *
  3800  *
  3707  * See {@see 'setup_theme'}.
  3801  * See {@see 'setup_theme'}.
  3708  *
  3802  *
  3709  * @since 5.5.0
  3803  * @since 5.5.0
       
  3804  * @since 6.0.1 The `block-templates` feature was added.
  3710  */
  3805  */
  3711 function create_initial_theme_features() {
  3806 function create_initial_theme_features() {
  3712 	register_theme_feature(
  3807 	register_theme_feature(
  3713 		'align-wide',
  3808 		'align-wide',
  3714 		array(
  3809 		array(
  3718 	);
  3813 	);
  3719 	register_theme_feature(
  3814 	register_theme_feature(
  3720 		'automatic-feed-links',
  3815 		'automatic-feed-links',
  3721 		array(
  3816 		array(
  3722 			'description'  => __( 'Whether posts and comments RSS feed links are added to head.' ),
  3817 			'description'  => __( 'Whether posts and comments RSS feed links are added to head.' ),
       
  3818 			'show_in_rest' => true,
       
  3819 		)
       
  3820 	);
       
  3821 	register_theme_feature(
       
  3822 		'block-templates',
       
  3823 		array(
       
  3824 			'description'  => __( 'Whether a theme uses block-based templates.' ),
  3723 			'show_in_rest' => true,
  3825 			'show_in_rest' => true,
  3724 		)
  3826 		)
  3725 	);
  3827 	);
  3726 	register_theme_feature(
  3828 	register_theme_feature(
  3727 		'custom-background',
  3829 		'custom-background',
  4069 			'description'  => __( 'Whether theme opts in to default WordPress block styles for viewing.' ),
  4171 			'description'  => __( 'Whether theme opts in to default WordPress block styles for viewing.' ),
  4070 			'show_in_rest' => true,
  4172 			'show_in_rest' => true,
  4071 		)
  4173 		)
  4072 	);
  4174 	);
  4073 }
  4175 }
       
  4176 
       
  4177 /**
       
  4178  * Returns whether the active theme is a block-based theme or not.
       
  4179  *
       
  4180  * @since 5.9.0
       
  4181  *
       
  4182  * @return boolean Whether the active theme is a block-based theme or not.
       
  4183  */
       
  4184 function wp_is_block_theme() {
       
  4185 	return wp_get_theme()->is_block_theme();
       
  4186 }
       
  4187 
       
  4188 /**
       
  4189  * Adds default theme supports for block themes when the 'setup_theme' action fires.
       
  4190  *
       
  4191  * See {@see 'setup_theme'}.
       
  4192  *
       
  4193  * @since 5.9.0
       
  4194  * @access private
       
  4195  */
       
  4196 function _add_default_theme_supports() {
       
  4197 	if ( ! wp_is_block_theme() ) {
       
  4198 		return;
       
  4199 	}
       
  4200 
       
  4201 	add_theme_support( 'post-thumbnails' );
       
  4202 	add_theme_support( 'responsive-embeds' );
       
  4203 	add_theme_support( 'editor-styles' );
       
  4204 	/*
       
  4205 	 * Makes block themes support HTML5 by default for the comment block and search form
       
  4206 	 * (which use default template functions) and `[caption]` and `[gallery]` shortcodes.
       
  4207 	 * Other blocks contain their own HTML5 markup.
       
  4208 	 */
       
  4209 	add_theme_support( 'html5', array( 'comment-form', 'comment-list', 'search-form', 'gallery', 'caption', 'style', 'script' ) );
       
  4210 	add_theme_support( 'automatic-feed-links' );
       
  4211 
       
  4212 	add_filter( 'should_load_separate_core_block_assets', '__return_true' );
       
  4213 }