本文整理汇总了PHP中WP_Theme::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_Theme::exists方法的具体用法?PHP WP_Theme::exists怎么用?PHP WP_Theme::exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WP_Theme
的用法示例。
在下文中一共展示了WP_Theme::exists方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isValidTheme
/**
* @param WP_Theme $theme
*
* @return bool
*/
public function isValidTheme(WP_Theme $theme)
{
return $this->checkCapability() && $theme->exists() && !$theme->parent();
}
示例2: wp_get_theme
/**
* Gets a WP_Theme object for a theme.
*
* @since 3.4.0
*
* @param string $stylesheet Directory name for the theme. Optional. Defaults to current theme.
* @param string $theme_root Absolute path of the theme root to look in. Optional. If not specified, get_raw_theme_root()
* is used to calculate the theme root for the $stylesheet provided (or current theme).
* @return WP_Theme|bool WP_Theme object. False if the theme is not found.
*/
function wp_get_theme($stylesheet = null, $theme_root = null)
{
global $wp_theme_directories;
if (empty($stylesheet)) {
$stylesheet = get_stylesheet();
}
if (empty($theme_root)) {
$theme_root = get_raw_theme_root($stylesheet);
if (false === $theme_root) {
return false;
}
if (!in_array($theme_root, (array) $wp_theme_directories)) {
$theme_root = WP_CONTENT_DIR . $theme_root;
}
}
$theme = new WP_Theme($stylesheet, $theme_root);
if ($theme->exists()) {
return $theme;
}
return false;
}