本文整理匯總了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;
}