files_manager ) ) { \Elementor\Plugin::$instance->files_manager->clear_cache(); } } public static function defaults() { return array( // Empty = keep the built-in purple (#7c3aed). 'primary' => '', 'input_bg' => '#ffffff', 'input_color' => '#000000', 'btn_bg' => '#000000', 'btn_color' => '#ffffff', 'card_bg' => '#ffffff', 'radius' => 8, ); } public static function get_settings(): array { if ( null !== self::$settings_cache ) return self::$settings_cache; $saved = get_theme_mod( 'eppro_customizer', array() ); self::$settings_cache = wp_parse_args( is_array( $saved ) ? $saved : array(), self::defaults() ); return self::$settings_cache; } /** * CSS variables for the brand colour: the colour itself, a darker hover * shade, a light tint and the "r, g, b" triplet used by focus rings and * coloured shadows. Empty array when no valid colour is set. */ public static function primary_vars( string $hex ): array { $hex = sanitize_hex_color( $hex ); if ( ! $hex ) return array(); $h = ltrim( $hex, '#' ); if ( 3 === strlen( $h ) ) { $h = $h[0] . $h[0] . $h[1] . $h[1] . $h[2] . $h[2]; } $rgb = array( hexdec( substr( $h, 0, 2 ) ), hexdec( substr( $h, 2, 2 ) ), hexdec( substr( $h, 4, 2 ) ) ); $mix = static function ( array $c, int $target, float $amount ): string { $out = '#'; foreach ( $c as $v ) { $out .= str_pad( dechex( (int) round( $v + ( $target - $v ) * $amount ) ), 2, '0', STR_PAD_LEFT ); } return $out; }; return array( '--eppro-primary' => $hex, '--eppro-primary-dark' => $mix( $rgb, 0, 0.15 ), '--eppro-primary-light' => $mix( $rgb, 255, 0.88 ), '--eppro-primary-rgb' => implode( ', ', $rgb ), ); } public static function register( $wp_customize ) { $defaults = self::defaults(); $wp_customize->add_section( 'eppro_section', array( 'title' => __( 'Essential Pro Pack', 'admore-widgets-suite' ), 'description' => __( 'Global defaults for Essential Pro Pack widgets. Colours set in a widget\'s own Style tab always take priority.', 'admore-widgets-suite' ), 'priority' => 160, ) ); $colors = array( 'primary' => array( __( 'Brand Color', 'admore-widgets-suite' ), __( 'Replaces the default purple: focus rings, active states, step indicator, popup close hover and other accents. Leave empty to keep the default.', 'admore-widgets-suite' ), ), 'input_bg' => array( __( 'Input Background', 'admore-widgets-suite' ), '' ), 'input_color' => array( __( 'Input Text Color', 'admore-widgets-suite' ), '' ), 'btn_bg' => array( __( 'Button Background', 'admore-widgets-suite' ), '' ), 'btn_color' => array( __( 'Button Icon Color', 'admore-widgets-suite' ), '' ), 'card_bg' => array( __( 'Results Card Background', 'admore-widgets-suite' ), '' ), ); foreach ( $colors as $key => $info ) { $wp_customize->add_setting( 'eppro_customizer[' . $key . ']', array( 'default' => $defaults[ $key ], 'transport' => 'refresh', 'sanitize_callback' => 'sanitize_hex_color', ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'eppro_' . $key, array( 'label' => $info[0], 'description' => $info[1], 'section' => 'eppro_section', 'settings' => 'eppro_customizer[' . $key . ']', ) ) ); } $wp_customize->add_setting( 'eppro_customizer[radius]', array( 'default' => $defaults['radius'], 'transport' => 'refresh', 'sanitize_callback' => 'absint', ) ); $wp_customize->add_control( 'eppro_radius', array( 'label' => __( 'Global Border Radius (px)', 'admore-widgets-suite' ), 'section' => 'eppro_section', 'settings' => 'eppro_customizer[radius]', 'type' => 'number', 'input_attrs' => array( 'min' => 0, 'max' => 60 ), ) ); } }