{$value_to_check}; $types = [ 'visible' => $theme->visibility === 'visible', 'hidden' => $theme->visibility === 'hidden', 'available' => $theme->behavior === 'available', 'not_available' => $theme->behavior === 'not_available', ]; return wu_get_isset($types, $type, false); } /** * Adds a magic getter for themes. * * @since 2.0.0 * * @param string $theme_name The theme name. * @return object */ public function __get($theme_name) { $theme = (object) wu_get_isset($this->get_limit(), $theme_name, $this->get_default_permissions($theme_name)); return (object) wp_parse_args($theme, $this->get_default_permissions($theme_name)); } /** * Returns default permissions. * * @since 2.0.0 * * @param string $type Type for sub-checking. * @return array */ public function get_default_permissions($type) { return [ 'visibility' => 'visible', 'behavior' => 'available', ]; } /** * Checks if a theme exists on the current module. * * @since 2.0.0 * * @param string $theme_name The theme name. * @return bool */ public function exists($theme_name) { $results = wu_get_isset($this->get_limit(), $theme_name, []); return wu_get_isset($results, 'visibility', 'not-set') !== 'not-set' || wu_get_isset($results, 'behavior', 'not-set') !== 'not-set'; } /** * Get all themes. * * @since 2.0.0 * @return array List of theme stylesheets. */ public function get_all_themes() { $themes = (array) $this->get_limit(); return array_keys($themes); } /** * Get available themes. * * @since 2.0.0 * @return array */ public function get_available_themes() { $limits = $this->get_limit(); $available = []; foreach ($limits as $theme_slug => $theme_settings) { $theme_settings = (object) $theme_settings; if ($theme_settings->behavior === 'available') { $available[] = $theme_slug; } } return $available; } /** * Get the forced active theme for the current limitations. * * @since 2.0.0 * @return string */ public function get_forced_active_theme() { $active_theme = false; $limits = $this->get_limit(); if (empty($limits)) { return $active_theme; } if ($this->forced_active_theme !== null) { return $this->forced_active_theme; } foreach ($limits as $theme_slug => $theme_settings) { $theme_settings = (object) $theme_settings; if ($theme_settings->behavior === 'force_active') { $active_theme = $theme_slug; } } $this->forced_active_theme = $active_theme; return $this->forced_active_theme; } /** * Checks if the module is enabled. * * @since 2.0.0 * * @param string $type Type for sub-checking. * @return boolean */ public function is_enabled($type = '') { return true; } }