WordPress函数require_if_theme_supports()

描述:

加载主题支持的所有函数

用法:

<?php require_if_theme_supports( $feature, $include ) ?>

参数:

$feature

(string) (必填) 要检查的功能

默认值: None

$include

(string) (必填) 包含实现功能的函数的文件

默认值: None

源文件:

/**
 * Checks a theme's support for a given feature before loading the functions which implement it.
 *
 * @since 2.9.0
 *
 * @param string $feature The feature being checked.
 * @param string $include Path to the file.
 * @return bool True if the current theme supports the supplied feature, false otherwise.
 */
function require_if_theme_supports( $feature, $include ) {
	if ( current_theme_supports( $feature ) ) {
		require ( $include );
		return true;
	}
	return false;
}