/**
  * @param WP_Theme $theme
  *
  * @return bool
  */
 public function isValidTheme(WP_Theme $theme)
 {
     return $this->checkCapability() && $theme->exists() && !$theme->parent();
 }
Ejemplo n.º 2
0
/**
 * 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;
}