'', 'right' => '', 'bottom' => '', 'left' => '' ); $default = wp_parse_args( $default, $default_values ); $json_value = get_theme_mod( $setting_name, wp_json_encode( $default ) ); $values = json_decode( $json_value, true ); // Ensure we have an array if ( !is_array( $values ) ) { $values = $default; } return wp_parse_args( $values, $default ); } protected function get_dimension_css( $setting_name, $property = 'padding', $default = [] ) { $default_values = wp_parse_args( $default, [ 'top' => '0', 'right' => '0', 'bottom' => '0', 'left' => '0', ] ); $json_value = get_theme_mod( $setting_name, wp_json_encode( $default_values ) ); $values = json_decode( $json_value, true ); if ( !is_array( $values ) ) { $values = $default_values; } $css_rules = []; foreach ( ['top', 'right', 'bottom', 'left'] as $side ) { $val = trim( $values[$side] ?? '' ); // Skip empty or zero-length values if ( $val === '' || $val === '0' || $val === '0px' || $val === '0em' || $val === '0%' ) { continue; } // If value already has unit (px, em, %, rem, etc.), use as is if ( preg_match( '/[a-z%]+$/i', $val ) ) { $css_rules[] = "{$property}-{$side}: {$val} !important;"; } else { // Append px unit by default if missing $css_rules[] = "{$property}-{$side}: {$val}px !important;"; } } return implode( ' ', $css_rules ); } protected function get_radius_css( $setting_name, $default = [] ) { $default_values = wp_parse_args( $default, [ 'top' => '0', 'right' => '0', 'bottom' => '0', 'left' => '0', ] ); $json_value = get_theme_mod( $setting_name, wp_json_encode( $default_values ) ); $values = json_decode( $json_value, true ); if ( !is_array( $values ) ) { $values = $default_values; } $map = [ 'top' => 'border-top-left-radius', 'right' => 'border-top-right-radius', 'bottom' => 'border-bottom-right-radius', 'left' => 'border-bottom-left-radius', ]; $css_rules = []; foreach ( $map as $key => $css_prop ) { $val = trim( $values[$key] ?? '' ); if ( $val === '' || $val === '0' || $val === '0px' || $val === '0em' || $val === '0%' ) { continue; } if ( preg_match( '/[a-z%]+$/i', $val ) ) { $css_rules[] = "{$css_prop}: {$val} !important;"; } else { $css_rules[] = "{$css_prop}: {$val}px !important;"; } } return implode( ' ', $css_rules ); } public function render_style() { $header_options = get_option( 'dnxte_header_navigation_options', array() ); $is_custom_dropdown = isset( $header_options['custom_dropdown'] ) ? $header_options['custom_dropdown'] : 0; $is_primary_menu_style = isset( $header_options['hover_animation'] ) ? $header_options['hover_animation'] : 0; $is_cta_button = isset( $header_options['cta_menu_button'] ) ? $header_options['cta_menu_button'] : 0; $is_onscroll_logo = isset( $header_options['on_scroll_logo'] ) ? $header_options['on_scroll_logo'] : 0; $is_onscroll_enabled = isset( $header_options['change_logo_onscroll'] ) ? $header_options['change_logo_onscroll'] : 0; $btn_icon_position = !empty( get_option( 'dnxte_icon_position' ) ) ? get_option( 'dnxte_icon_position' ) : 'row'; $is_cta_btn_sahdow_enabled = get_option( 'dnxte_cta_btn_shadow', 0 ); $show_shadow = get_theme_mod( 'dnxte_header_shadow' ); $shadow_color = get_option( 'dnxte_header_shadow_color' ); $hs_offset_x = get_option( 'dnxte_header_shadow_offset_x', 0 ); $hs_offset_y = get_option( 'dnxte_header_shadow_offset_y', 0 ); $hs_blur = get_option( 'dnxte_header_shadow_blur', 10 ); $hs_spread = get_option( 'dnxte_header_shadow_spread', 2 ); // fixed heade shadow $fixed_header_shadow = get_option( 'dnxte_header_shadow_fixed' ); $fixed_header_shadow_color = get_option( 'dnxte_header_shadow_color_fixed' ); $hsf_offset_x = get_option( 'dnxte_header_fixed_shadow_offset_x', 0 ); $hsf_offset_y = get_option( 'dnxte_header_fixed_shadow_offset_y', 0 ); $hsf_blur = get_option( 'dnxte_header_fixed_shadow_blur', 10 ); $hsf_spread = get_option( 'dnxte_header_fixed_shadow_spread', 2 ); $menu_padding = get_theme_mod('dnxte_padding'); if(! empty($menu_padding)) { $menu_padding_top = json_decode($menu_padding, true); $menu_padding_top = isset($menu_padding_top['top']) ? $menu_padding_top['top'] : '10'; } else { $menu_padding_top = '10'; } $cta_btn_padding = $this->get_dimension_css( 'dnxte_cta_button_padding', 'padding' ); $nav_padding = $this->get_dimension_css( 'dnxte_padding', 'padding', [ 'top' => '10', 'bottom' => '10', 'left' => '20', 'right' => '20', ] ); $cta_padding = $this->get_dimension_css('dnxte_cta_button_padding', 'padding', [ 'top' => '10', 'bottom' => '10', 'left' => '20', 'right' => '20', ] ); $hover_animated_color = get_option( 'dnxte_hover_animated_color' ); $hover_animated_color = !empty( $hover_animated_color ) ? $hover_animated_color : '#7A5AF8'; $hover_button_radius = $this->get_radius_css( 'dnxte_radius', [ 'top' => '5', 'right' => '5', 'bottom' => '5', 'left' => '5', ] ); $current_menu_hover_effect = get_theme_mod( 'dnxte_hover_active_menu' ); ?>