'; /** * Path to icon SVG files * * @var string */ public static $path_to_icons = BRANDY_TEMPLATE_DIR . '/template-parts/icons/darkmode/'; protected function __construct() { if ( function_exists( 'brandy_niche_supports' ) && brandy_niche_supports( 'dark-mode' ) ) { parent::__construct(); } } /** * Register customizer components for element settings * * @return array Component definitions */ protected function register_components() { return array( 'introduction' => array( 'type' => 'FlexibleContent', 'content' => __( 'This element is still in beta. It may not work as expected.', 'brandy' ), ), 'icon_reset' => array( 'title' => array( 'text' => __( 'Icon', 'brandy' ), 'type' => 'bold', 'show_devices' => true, ), 'type' => 'Reset', 'reset_paths' => array( array( 'icon' ), ), ), 'icon_color' => array( 'title' => array( 'text' => __( 'Color', 'brandy' ), 'type' => 'normal', ), 'type' => 'ColorGroup', 'value_path' => array( 'icon', 'color' ), 'default_value' => array( 'normal' => array( 'desktop' => 'var(--wp--preset--color--brandy-foreground)', 'tablet' => null, 'mobile' => null, ), 'hover' => array( 'desktop' => 'var(--wp--preset--color--brandy-foreground)', 'tablet' => null, 'mobile' => null, ), ), 'render_options' => array( 'type' => 'variable', 'data' => array( array( 'type' => 'color', 'name' => '--icon-color', 'value_path' => array( 'icon', 'color' ), ), ), ), ), 'icon_size' => array( 'title' => array( 'text' => __( 'Icon size', 'brandy' ), 'type' => 'normal', ), 'type' => 'Dimension', 'value_path' => array( 'icon', 'size' ), 'units' => array( 'px' ), 'default_value' => array( 'desktop' => ElementsLoader::get_default_icon_size(), 'tablet' => null, 'mobile' => null, ), 'render_options' => array( 'type' => 'variable', 'data' => array( array( 'type' => 'dimension', 'name' => '--icon-size', 'value_path' => array( 'icon', 'size' ), ), ), ), ), 'margin' => array( 'title' => array( 'text' => __( 'Margin', 'brandy' ), 'type' => 'bold', 'show_devices' => true, ), 'default_value' => array( 'desktop' => array( 'unit' => 'px', 'top' => 0, 'right' => 0, 'bottom' => 0, 'left' => 0, 'is_constraints' => false, ), 'tablet' => null, 'mobile' => null, ), 'value_path' => array( 'margin' ), 'type' => 'Spacing', 'render_options' => array( 'type' => 'variable', 'data' => array( array( 'type' => 'spacing', 'name' => '--margin', 'value_path' => array( 'margin' ), ), ), ), ), ); } /** * Define layout structure for customizer UI * * @param array $layouts Existing layouts * @return array Updated layouts */ public function add_layout( $layouts = array() ) { $layout = array( 'general' => array( 'sections' => array( array( 'components' => array( 'introduction', ), ), ), ), 'designs' => array( 'sections' => array( array( 'components' => array( 'icon_reset', 'icon_color', 'icon_size', ), ), array( 'components' => array( 'margin' ), ), ), ), ); $mapped_layout = $this->map_layout( $layout ); $layouts[ $this->element_id ] = $mapped_layout; return $layouts; } /** * Get icon SVG by type (sun or moon) * * @param string $icon_type Icon type (sun|moon) * @return string SVG markup */ public static function get_icon( $icon_type ) { $file_path = self::$path_to_icons . "$icon_type.php"; if ( file_exists( $file_path ) ) { ob_start(); require $file_path; $icon_data = ob_get_contents(); ob_end_clean(); return $icon_data; } return ''; } }