/**
  * Loads cookie and sets up theme filters.
  */
 public static function setup_theme()
 {
     global $pagenow;
     if (is_admin() && 'themes.php' == $pagenow || !self::can_switch_themes()) {
         return;
     }
     self::check_reset();
     self::load_cookie();
     if (empty(self::$theme)) {
         return;
     }
     add_filter('pre_option_template', array(self::$theme, 'get_template'));
     add_filter('pre_option_stylesheet', array(self::$theme, 'get_stylesheet'));
     add_filter('pre_option_stylesheet_root', array(self::$theme, 'get_theme_root'));
     $parent = self::$theme->parent();
     add_filter('pre_option_template_root', array(empty($parent) ? self::$theme : $parent, 'get_theme_root'));
     add_filter('pre_option_current_theme', '__return_false');
 }
 /**
  * @param WP_Theme $theme
  *
  * @return bool
  */
 public function isValidTheme(WP_Theme $theme)
 {
     return $this->checkCapability() && $theme->exists() && !$theme->parent();
 }
 /**
  * Check, the current theme have a parent value and is a child theme.
  *
  * @param array|\WP_Theme $theme_data An array of theme data.
  *
  * @return bool
  */
 public function is_child(\WP_Theme $theme_data)
 {
     return (bool) $theme_data->parent();
 }
 /**
  * Loads recursively the config file from a theme and its parents
  *
  * @param $theme WP_Theme Current theme
  * @return array
  */
 private function loadConfigs(\WP_Theme $theme)
 {
     if (false !== $theme->parent()) {
         $this->loadConfigs($theme->parent());
     }
     $theme_dir = $theme->get_stylesheet_directory();
     $path = "{$theme_dir}/config/" . $this->name;
     if (is_dir($path)) {
         $this->loadDir($path, $theme);
     }
     if (is_file("{$path}.yml")) {
         $this->loadFile("{$path}.yml", $theme);
     }
 }