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'; } ?>
>
$items ) : ?>
get_header_items( $items, $options ); ?>
get_header_items_option() ); $template_file = $item['item']; switch ( $item['item'] ) { case 'hamburger': \Razzi\Theme::instance()->set_prop( 'modals', $item['item'] ); break; case 'cart': if ( ! class_exists( 'WooCommerce' ) ) { $template_file = ''; break; } if ( 'panel' == Helper::get_option( 'header_cart_behaviour' ) ) { \Razzi\Theme::instance()->set_prop( 'modals', $item['item'] ); } break; case 'search': $args = $this->search_options( $options ); break; case 'account': if ( 'panel' == Helper::get_option( 'header_account_behaviour' ) ) { \Razzi\Theme::instance()->set_prop( 'modals', $item['item'] ); } break; } if ( $template_file ) { get_template_part( 'template-parts/headers/' . $template_file, '', $args ); } } } /** * Options of header items * * @since 1.0.0 * * @return array */ protected function get_header_items_option() { return apply_filters( 'razzi_header_items_option', array( '0' => esc_html__('Select a item', 'razzi'), 'logo' => esc_html__('Logo', 'razzi'), 'menu-primary' => esc_html__('Primary Menu', 'razzi'), 'menu-secondary' => esc_html__('Secondary Menu', 'razzi'), 'hamburger' => esc_html__('Hamburger Icon', 'razzi'), 'search' => esc_html__('Search Icon', 'razzi'), 'cart' => esc_html__('Cart Icon', 'razzi'), 'wishlist' => esc_html__('Wishlist Icon', 'razzi'), 'account' => esc_html__('Account Icon', 'razzi'), 'languages' => esc_html__('Languages', 'razzi'), 'currencies' => esc_html__('Currencies', 'razzi'), 'department' => esc_html__('Department', 'razzi'), 'socials' => esc_html__('Socials', 'razzi'), 'text' => esc_html__( 'Custom Text', 'razzi' ), ) ); } /** * Options of header items * * @since 1.0.0 * * @return array */ protected function get_mobile_header_icons_option() { return apply_filters( 'razzi_mobile_header_icons_option', array( 'cart' => esc_html__( 'Cart Icon', 'razzi' ), 'wishlist' => esc_html__( 'Wishlist Icon', 'razzi' ), 'account' => esc_html__( 'Account Icon', 'razzi' ), 'menu' => esc_html__( 'Menu Icon', 'razzi' ), 'search' => esc_html__( 'Search Icon', 'razzi' ), 'text' => esc_html__('Custom Text', 'razzi'), ) ); } /** * Get nav menu * * @since 1.0.0 * * @return void */ public function primary_menu( $mega_menu = true ) { $class = array( 'nav-menu', Helper::get_option( 'hamburger_click_item' ) ); $classes = implode( ' ', $class ); $primary_menu = get_post_meta( \Razzi\Helper::get_post_ID(), 'rz_header_primary_menu', true ); $theme_location = $primary_menu ? '__no_such_location' : 'primary'; if( empty($primary_menu ) && ! has_nav_menu( $theme_location ) ) { return; } if ( $mega_menu == true && Helper::get_header_layout() != 'v6' && class_exists( '\Razzi\Addons\Modules\Mega_Menu\Walker' ) ) { wp_nav_menu( apply_filters( 'razzi_navigation_primary_content', array( 'theme_location' => $theme_location, 'container' => false, 'menu_class' => $classes, 'menu' => $primary_menu, 'walker' => new \Razzi\Addons\Modules\Mega_Menu\Walker() ) ) ); } else { wp_nav_menu( apply_filters( 'razzi_navigation_primary_content', array( 'theme_location' => $theme_location, 'container' => false, 'menu_class' => $classes, 'menu' => $primary_menu, ) ) ); } } /** * Display header extra class * * @since 1.0.0 * * @return string */ public static function classes( $classes ) { if ( intval( Helper::get_option( 'header_sticky' ) ) && Helper::get_header_layout() != 'v6' ) { $header_sticky_el = (array) Helper::get_option( 'header_sticky_el' ); if( Helper::get_option('header_type') == 'custom' ) { if ( ! in_array( 'header_main', $header_sticky_el ) ) { $classes .= ' header-main-no-sticky'; } if ( ! in_array( 'header_bottom', $header_sticky_el ) ) { $classes .= ' header-bottom-no-sticky'; } } else { if( in_array( Helper::get_option('header_layout'), array( 'v3', 'v4', 'v9' ) ) ) { if ( ! in_array( 'header_main', $header_sticky_el ) ) { $classes .= ' header-main-no-sticky'; } if ( ! in_array( 'header_bottom', $header_sticky_el ) ) { $classes .= ' header-bottom-no-sticky'; } } else { $classes .= ' header-bottom-no-sticky'; } } } if ( ! get_post_meta( \Razzi\Helper::get_post_ID(), 'rz_hide_header_border', true ) ) { $classes .= ' site-header__border'; } echo esc_attr( apply_filters( 'razzi_site_header_class', $classes ) ); } /** * Mobile header. * * @since 1.0.0 * * @return void */ public function mobile_header() { if ( ! apply_filters( 'razzi_get_header_mobile', true ) ) { return; } $show_header = ! get_post_meta( \Razzi\Helper::get_post_ID(), 'rz_hide_header_section', true ); if ( ! $show_header ) { return; } ?> '; foreach ( $icons as $icon ) { $icon['item'] = $icon['item'] ? $icon['item'] : key( $this->get_mobile_header_icons_option() ); switch ( $icon['item'] ) { case 'cart': \Razzi\Theme::instance()->set_prop( 'modals', 'cart' ); get_template_part( 'template-parts/headers/cart' ); break; case 'wishlist': get_template_part( 'template-parts/headers/wishlist' ); break; case 'account': \Razzi\Theme::instance()->set_prop( 'modals', 'account' ); get_template_part( 'template-parts/headers/account' ); break; case 'menu': get_template_part( 'template-parts/mobile/header-menu' ); break; case 'search': \Razzi\Theme::instance()->set_prop( 'modals', 'search' ); get_template_part( 'template-parts/mobile/header-search' ); break; case 'text': get_template_part( 'template-parts/headers/text' ); break; default: do_action( 'razzi_mobile_header_icon', $icon['item'] ); break; } } echo ''; } /** * Add menu mobile modal * * @since 1.0.0 * * @return void */ public function menu_mobile_modal() { ?>
get_prop( 'modals' ); if ( ! in_array( 'hamburger', $modals ) ) { return; } ?> set_prop( 'modals', 'search' ); } if ( $args['search_style'] == 'form' || $args['search_style'] == 'form-cat' ) { $args['search_class'] .= ' search-form-type'; $args['search_class'] .= ' form-type-' . $args['search_style']; } if ( $args['search_style'] == 'form' ) { $args['search_class'] .= ' form-type-' . $args['search_form_style']; } if( Helper::get_option('header_layout') == 'v3' ) { $args['search_class'] .= ' form-skin-dark'; } return $args; } /** * Get search form * * @since 1.0.0 * * @return void */ public function razzi_mobile_panel_search() { get_template_part( 'template-parts/mobile/header-panel-search' ); } }