is_rtl() ? 'true' : 'false', 'ajax_url' => class_exists( 'WC_AJAX' ) ? \WC_AJAX::get_endpoint( '%%endpoint%%' ) : '', 'nonce' => wp_create_nonce( '_razzi_nonce' ), 'search_content_type' => Helper::get_option( 'header_search_type' ), 'header_search_number' => Helper::get_option( 'header_search_number' ), 'header_ajax_search' => intval( Helper::get_option( 'header_search_ajax' ) ), 'sticky_header' => intval( Helper::get_option( 'header_sticky' ) ), 'mobile_landscape' => Helper::get_option( 'mobile_landscape_product_columns' ), 'mobile_portrait' => Helper::get_option( 'mobile_portrait_product_columns' ), 'popup' => Helper::get_option( 'newsletter_popup_enable' ), 'popup_frequency' => Helper::get_option( 'newsletter_popup_frequency' ), 'popup_visible' => Helper::get_option( 'newsletter_popup_visible' ), 'popup_visible_delay' => Helper::get_option( 'newsletter_popup_visible_delay' ), 'recently_viewed_navigation' => Helper::get_option( 'recently_viewed_navigation' ), ); $razzi_data = apply_filters( 'razzi_wp_script_data', $razzi_data ); wp_localize_script( 'razzi', 'razziData', $razzi_data ); } /** * Display the site header sticky minimized * * @since 1.0.0 * * @return void */ public function show_header_sticky_minimized() { $show_header = ! get_post_meta( \Razzi\Helper::get_post_ID(), 'rz_hide_header_section', true ); if ( ! apply_filters( 'razzi_get_header', $show_header ) ) { return; } if ( ! intval(Helper::get_option( 'header_sticky' ) ) ) { return; } if ( get_post_meta( Helper::get_post_ID(), 'rz_header_background', true ) == 'transparent' ) { return; } echo '
'; } /** * Display the site header * * @since 1.0.0 * * @return void */ public function show_header() { $show_header = ! get_post_meta( \Razzi\Helper::get_post_ID(), 'rz_hide_header_section', true ); if ( ! apply_filters( 'razzi_get_header', $show_header ) ) { return; } $custom_header_layout = get_post_meta( Helper::get_post_ID(), 'rz_header_layout', true ); if( ! empty($custom_header_layout) && 'default' != $custom_header_layout ) { $this->prebuild_header( $custom_header_layout ); } else { if ( 'default' == Helper::get_option( 'header_type' ) ) { $this->prebuild_header( Helper::get_option( 'header_layout' ) ); } else { $options = array(); // Header main. $sections = array( 'left' => Helper::get_option( 'header_main_left' ), 'center' => Helper::get_option( 'header_main_center' ), 'right' => Helper::get_option( 'header_main_right' ), ); $classes = array( 'header-main', 'header-contents', 'hidden-xs hidden-sm' ); $this->get_header_contents( $sections, $options, array( 'class' => $classes ) ); // Header bottom. $sections = array( 'left' => Helper::get_option( 'header_bottom_left' ), 'center' => Helper::get_option( 'header_bottom_center' ), 'right' => Helper::get_option( 'header_bottom_right' ), ); $border = Helper::get_option( 'header_bottom_border_top' ); $border = $border ? 'has-border' : ''; $sticky_bottom = in_array( 'header_main', (array) Helper::get_option( 'header_sticky_el' ) ) ? 'rz-sticky-main' : ''; $classes = array( 'header-bottom', 'header-contents', 'hidden-xs hidden-sm', $border, $sticky_bottom ); $this->get_header_contents( $sections, $options, array( 'class' => $classes ) ); } } } /** * Display pre-build header * * @since 1.0.0 * * @return void */ protected function prebuild_header( $version = 'v1' ) { switch ( $version ) { case 'v1': $main_sections = array( 'left' => array( array( 'item' => 'logo' ), ), 'center' => array( array( 'item' => 'menu-primary' ), ), 'right' => $this->get_header_attributes(array('search', 'account', 'wishlist', 'cart')) ); $main_options = array( 'search' => array( 'search_style' => 'icon' ) ); $bottom_sections = array(); $bottom_options = array(); break; case 'v2': $main_sections = array( 'left' => array( array( 'item' => 'menu-primary' ), ), 'center' => array( array( 'item' => 'logo' ), ), 'right' => array_merge( array( array( 'item' => 'currencies' ), array( 'item' => 'languages' ), ), $this->get_header_attributes(array('search', 'account', 'wishlist', 'cart')) ) ); $main_options = array( 'search' => array( 'search_style' => 'icon' ) ); $bottom_sections = array(); $bottom_options = array(); break; case 'v3': $main_sections = array( 'left' => array( array( 'item' => 'menu-secondary' ), ), 'center' => array( array( 'item' => 'logo' ), ), 'right' => $this->get_header_attributes(array('account', 'wishlist', 'cart')) ); $main_options = array(); $bottom_sections = array( 'left' => array( array( 'item' => 'menu-primary' ), ), 'center' => array(), 'right' => $this->get_header_attributes(array('search')) ); $bottom_options = array( 'search' => array( 'search_style' => 'form', 'search_form_style' => 'boxed' ) ); break; case 'v4': $main_sections = array( 'left' => array( array( 'item' => 'logo' ), ), 'center' => array( array( 'item' => 'menu-primary' ), ), 'right' => $this->get_header_attributes(array('account', 'wishlist', 'cart')) ); $main_options = array(); $bottom_sections = array( 'left' => array(), 'center' => array( array( 'item' => 'department' ), array( 'item' => 'search' ), ), 'right' => array() ); $bottom_options = array( 'search' => array( 'search_style' => 'form-cat', ) ); break; case 'v5': $main_sections = array( 'left' => array( array( 'item' => 'logo' ), ), 'center' => array(), 'right' => array_merge( $this->get_header_attributes(array('search', 'account', 'wishlist', 'cart')), array( array( 'item' => 'hamburger' ), ) ) ); $main_options = array( 'search' => array( 'search_style' => 'icon' ) ); $bottom_sections = array(); $bottom_options = array(); break; case 'v6': $main_sections = array( 'left' => array( array( 'item' => 'logo' ), ), 'center' => array( array( 'item' => 'menu-primary' ), ), 'right' => array( array( 'item' => 'socials' ), ) ); $main_options = array(); $bottom_sections = array( 'left' => $this->get_header_attributes(array('search')), 'center' => array(), 'right' => $this->get_header_attributes(array('account', 'wishlist', 'cart')) ); $bottom_options = array( 'search' => array( 'search_style' => 'form', 'search_form_style' => 'full-width' ) ); break; case 'v7': $main_sections = array( 'left' => array( array( 'item' => 'logo' ), ), 'center' => array(), 'right' => array_merge( array( array( 'item' => 'menu-primary' ), ), $this->get_header_attributes(array('cart')) ) ); $main_options = array(); $bottom_sections = array(); $bottom_options = array(); break; case 'v8': $main_sections = array( 'left' => array( array( 'item' => 'menu-primary' ), ), 'center' => array( array( 'item' => 'logo' ), ), 'right' => $this->get_header_attributes(array('search', 'account', 'wishlist', 'cart')) ); $main_options = array( 'search' => array( 'search_style' => 'icon' ) ); $bottom_sections = array(); $bottom_options = array(); break; case 'v9': $main_sections = array( 'left' => array( array( 'item' => 'logo' ), ), 'center' => $this->get_header_attributes(array('search')), 'right' => $this->get_header_attributes(array('account', 'wishlist', 'cart')) ); $main_options = array( 'search' => array( 'search_style' => 'form', 'search_form_style' => 'boxed' ) ); $bottom_sections = array( 'left' => array( array( 'item' => 'menu-primary' ), ), 'center' => array(), 'right' => array() ); $bottom_options = array(); break; case 'v10': $main_sections = array( 'left' => array( array( 'item' => 'logo' ), ), 'center' => array( array( 'item' => 'department' ), array( 'item' => 'search' ), ), 'right' => array( array( 'item' => 'account' ), array( 'item' => 'wishlist' ), array( 'item' => 'cart' ), ), ); $main_options = array( 'search' => array( 'search_style' => 'form', 'search_form_style' => 'full-width' ) ); $bottom_sections = array(); $bottom_options = array(); break; case 'v11': $main_sections = array( 'left' => array( array( 'item' => 'logo' ), array( 'item' => 'search' ), ), 'center' => array(), 'right' => array( array( 'item' => 'account' ), array( 'item' => 'wishlist' ), array( 'item' => 'cart' ), array( 'item' => 'hamburger' ), ), ); $main_options = array( 'search' => array( 'search_style' => 'form-cat', ) ); $bottom_sections = array(); $bottom_options = array(); break; default: $main_sections = array(); $main_options = array(); $bottom_sections = array(); $bottom_options = array(); break; } $classes = array( 'header-main', 'header-contents', 'hidden-xs hidden-sm' ); $this->get_header_contents( $main_sections, $options['main_options'] = $main_options, array( 'class' => $classes ) ); $classes = array( 'header-bottom', 'header-contents', 'hidden-xs hidden-sm' ); $this->get_header_contents( $bottom_sections, $options['bottom_options'] = $bottom_options, array( 'class' => $classes ) ); } /** * Display header attributes * * @since 1.0.0 * * @return void */ function get_header_attributes( $atts = array('search') ) { $attributes = array(); if( Helper::get_option('header_search_icon') && in_array( 'search', $atts ) ) { $attributes[] = array( 'item' => 'search' ); } if( Helper::get_option('header_account_icon') && in_array( 'account', $atts ) ) { $attributes[] = array( 'item' => 'account' ); } if( Helper::get_option('header_wishlist_icon') && in_array( 'wishlist', $atts ) ) { $attributes[] = array( 'item' => 'wishlist' ); } if( Helper::get_option('header_cart_icon') && in_array( 'cart', $atts ) ) { $attributes[] = array( 'item' => 'cart' ); } return $attributes; } /** * Display header items * * @since 1.0.0 * * @return void */ protected function get_header_contents( $sections, $options, $atts = array() ) { if ( false == array_filter( $sections ) ) { return; } $classes = array(); if ( isset( $atts['class'] ) ) { $classes = (array) $atts['class']; unset( $atts['class'] ); } if ( empty( $sections['left'] ) && empty( $sections['right'] ) ) { unset( $sections['left'] ); unset( $sections['right'] ); } if ( ! empty( $sections['center'] ) ) { $classes[] = 'has-center'; $center_items = wp_list_pluck( $sections['center'], 'item' ); if ( in_array( 'logo', $center_items ) ) { $classes[] = 'logo-center'; } if ( in_array( 'menu-primary', $center_items ) ) { $classes[] = 'menu-center'; } if ( empty( $sections['left'] ) && empty( $sections['right'] ) ) { $classes[] = 'no-sides'; } } else { $classes[] = 'no-center'; unset( $sections['center'] ); if ( empty( $sections['left'] ) ) { unset( $sections['left'] ); } if ( empty( $sections['right'] ) ) { unset( $sections['right'] ); } } $attr = ''; foreach ( $atts as $name => $value ) { $attr .= ' ' . $name . '=' . esc_attr( $value ) . ''; } $container_width = 'container'; if ( Helper::get_header_layout() == 'v6' ) { $container_width = 'header-container'; } elseif ( Helper::get_option( 'header_width' ) == 'large' ) { $container_width = 'razzi-container'; }elseif ( Helper::get_option( 'header_width' ) == 'wide' ) { $container_width = 'razzi-container-wide'; } ?>