visible ) ) { $visibility = $this->visible; if ( ( $visibility == 'logged' && ! ( get_query_var( 'et_is-loggedin', false) ) ) || ( $visibility == 'unlogged' && get_query_var( 'et_is-loggedin', false) ) ) { if ( $depth > 0 ) { // $output .= "\n$indent
\n"; $output .= ''; } } else { if ( $depth > 0 ) { $output .= "\n$indent
\n"; } $output .= "\n$indent\n"; if ( $depth > 0 ) { $output .= "\n$indent
\n"; } } } else { $output .= "$indent\n"; if ( $depth > 0 ) { $output .= "\n$indent
\n"; } } } function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { global $wp_query; $item_id = $item->ID; $visibility = get_post_meta( $item_id, '_menu-item-item_visibility', true ); $this->visible = $visibility; if ( ( $visibility == 'logged' && ! ( get_query_var( 'et_is-loggedin', false) ) ) || ( $visibility == 'unlogged' && get_query_var( 'et_is-loggedin', false) ) ) { return; } $indent = ( $depth ) ? str_repeat( "\t", $depth ) : ''; $value = $label_text = ''; $anchor = get_post_meta( $item_id, '_menu-item-anchor', true ); if ( ! empty( $anchor ) ) { $item->url = $item->url . '#' . $anchor; if ( ( $key = array_search( 'current_page_item', $item->classes ) ) !== false ) { unset( $item->classes[ $key ] ); } if ( ( $key = array_search( 'current-menu-item', $item->classes ) ) !== false ) { unset( $item->classes[ $key ] ); } } $classes = empty( $item->classes ) ? array() : (array) $item->classes; $classes[] = 'menu-item-' . $item->ID; $classes[] = 'item-level-' . $depth; $arrow = ''; $design = get_post_meta( $item_id, '_menu-item-design', true ); $design2 = get_post_meta( $item_id, '_menu-item-design2', true ); $columns = get_post_meta( $item_id, '_menu-item-columns', true ); $icon_type = get_post_meta( $item_id, '_menu-item-icon_type', true ); $icon = get_post_meta( $item_id, '_menu-item-icon', true ); $label = get_post_meta( $item_id, '_menu-item-label', true ); $disable_titles = get_post_meta( $item_id, '_menu-item-disable_titles', true ); $widget_area = get_post_meta( $item_id, '_menu-item-widget_area', true ); $static_block = get_post_meta( $item_id, '_menu-item-static_block', true ); $open_by_click = get_post_meta( $item_id, '_menu-item-open_by_click', true ); // $block = get_post_meta($item_id, '_menu-item-block', true); $widgets_content = $block_html = $postCategories = ''; if ( $depth == 0 ) { if ( $design != '' ) { $classes[] = apply_filters( 'menu_item_design', 'item-design-' . $design ); } else { $classes[] = apply_filters( 'menu_item_design', 'item-design-dropdown' ); } if ( $columns != '' ) { $classes[] = 'columns-' . $columns; } if ( $open_by_click == 1 ) { $classes[] = 'menu-open-by-click'; wp_enqueue_script('menu_item_on_click'); } if ( apply_filters( 'menu_item_with_sublists', true ) ) { if ( apply_filters('menu_item_dropdown_full_width', false) ) { $classes[] = 'mega-menu-full-width'; } if ( $static_block != '' ) { $classes[] = 'item-with-block'; $classes[] = 'menu-item-has-children'; $classes[] = 'menu-parent-item'; ob_start(); if ( ! apply_filters('menu_dropdown_ajax', etheme_get_option( 'menu_dropdown_ajax', true ) ) ) { etheme_static_block( $static_block, true ); } else { echo et_ajax_element_holder( 'block', array( 'id' => $static_block, 'ajax' => true ), '', false, 'menu_static_block_dropdown' ); $classes[] = 'menu-item-ajax-dropdown'; } $block_html = ob_get_contents(); ob_end_clean(); if ( $block_html == '' ) { $block_html = '

' . esc_html__( 'Oops, looks that mega-menu was not imported correctly. Go to Appearance > Menus > edit menu and use the 8theme menu options to select the Static Block for this menu item and show the mega-menu content', 'xstore' ) . '

'; } $block_html = ''; } } if ( $design == 'posts-subcategories' && apply_filters( 'menu_item_with_sublists', true ) ) { wp_enqueue_script( 'menu_posts' ); // force load style in cases when Menu displayed from Elementor etheme_enqueue_style('mega-menu'); $postCategories = ''; } } else { if ( $design2 != '' ) { $classes[] = 'item-design2-' . $design2; } if ( $widget_area != '' ) { $classes[] = 'item-with-widgets'; ob_start(); dynamic_sidebar( $widget_area ); $widgets = ob_get_contents(); ob_end_clean(); $widgets_content = ''; } if ( ! empty( $block ) ) { $classes[] = 'item-with-block'; ob_start(); if ( ! apply_filters('menu_dropdown_ajax', etheme_get_option( 'menu_dropdown_ajax', true ) ) ) { etheme_static_block( $block, true ); } else { echo et_ajax_element_holder( 'block', array( 'id' => $block, 'ajax' => true ), '', false, 'menu_static_block_dropdown' ); $classes[] = 'menu-item-ajax-dropdown'; } $block_html = ob_get_contents(); ob_end_clean(); if ( $block_html == '' ) { $block_html = '

' . esc_html__( 'Oops, looks that mega-menu was not imported correctly. Go to Appearance > Menus > edit menu and use the 8theme menu options to select the Static Block for this menu item and show the mega-menu content', 'xstore' ) . '

'; } $block_html = ''; } } if ( $depth < 3 ) { if ( $disable_titles == 1 ) { $classes[] = 'menu-disable_title'; } } if ( $icon != '' ) { switch ( $icon_type ) { case 'xstore-icons': $icon = ''; break; case 'fontawesome-5': $icon = ''; break; default: $icon = ''; break; } } if ( $label != '' ) { $classes[] = 'menu-label-' . $label; $label_text .= ''; switch ( $label ) { case 'sale': $label_text .= __( 'Sale', 'xstore' ); break; case 'hot': $label_text .= __( 'Hot', 'xstore' ); break; default: $label_text .= __( 'New', 'xstore' ); break; } $label_text .= ''; } if ( $design != '' ) { $design = apply_filters( 'menu_item_design', 'item-design-' . $design ); $should_load_mega_menu_assets = in_array($design, array('item-design-mega-menu', 'item-design-posts-subcategories')); if ( $should_load_mega_menu_assets ) { do_action('menu_item_mega_menu_assets_load'); } if ( apply_filters( 'menu_item_mega_menu', $should_load_mega_menu_assets ) ) { wp_enqueue_script('mega_menu'); etheme_enqueue_style('mega-menu'); } elseif ( $design2 == 'image-no-borders' ) { etheme_enqueue_style('mega-menu'); } } if ( ! apply_filters( 'menu_item_with_sublists', true ) ) { unset( $classes[ array_search( 'menu-item-has-children', $classes ) ] ); unset( $classes[ array_search( 'menu-parent-item', $classes ) ] ); } if ( $depth == 0 ) { if ( in_array( 'menu-item-has-children', $classes ) ) { if ( get_query_var('is_mobile', false) ) { wp_enqueue_script( 'menu_item_on_touch' ); } if ( apply_filters( 'menu_item_with_svg_arrow', false ) ) { $arrow .= ''; } } } elseif ( ! apply_filters( 'menu_subitem_with_arrow', true ) ) { unset( $classes[ array_search( 'menu-item-has-children', $classes ) ] ); unset( $classes[ array_search( 'menu-parent-item', $classes ) ] ); } $nav_menu_css_classes = apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args, $depth); $class_names = join( ' ', $nav_menu_css_classes); $class_names = ' class="' . esc_attr( $class_names ) . '"'; $use_img = get_post_meta( $item_id, '_menu-item-use_img', true ); // $id = 'menu-item-' . $item->ID; // $id = strlen( $id ) ? ' id="' . esc_attr( $id ) . '"' : ''; $output .= $indent . '\n"; if ( has_action('etheme_after_menu_item') ) : ob_start(); do_action( 'etheme_after_menu_item', $depth ); $output .= ob_get_clean(); endif; } function et_enque_styles( $item_id, $depth, $has_tooltip = false ) { $visibility = get_post_meta( $item_id, '_menu-item-item_visibility', true ); if ( ( $visibility == 'logged' && ! ( get_query_var( 'et_is-loggedin', false) ) ) || ( $visibility == 'unlogged' && get_query_var( 'et_is-loggedin', false) ) ) { return; } $use_img = get_post_meta( $item_id, '_menu-item-use_img', true ); $post_thumbnail = get_post_thumbnail_id( $item_id, 'thumb' ); $post_thumbnail_url = wp_get_attachment_url( $post_thumbnail ); $bg_position = get_post_meta( $item_id, '_menu-item-background_position', true ); $bg_repeat = get_post_meta( $item_id, '_menu-item-background_repeat', true ); $column_width = get_post_meta( $item_id, '_menu-item-column_width', true ); $column_height = get_post_meta( $item_id, '_menu-item-column_height', true ); $sublist_width = get_post_meta( $item_id, '_menu-item-sublist_width', true ); $bg_pos = $bg_rep = $styles = $styles_sublist = $submenu_width = ''; if ( $use_img != 'img' && apply_filters('menu_item_load_background_style', true, $has_tooltip) ) { if ( $bg_position != '' ) { $bg_pos = "background-position: " . $bg_position . ";"; } if ( $bg_repeat != '' ) { $bg_rep = "background-repeat: " . $bg_repeat . ";"; } if ( ! empty( $post_thumbnail_url ) ) { $styles_sublist .= $bg_pos . $bg_rep . " background-image: url(" . $post_thumbnail_url . ");"; } if ( ! empty( $post_thumbnail_url ) && ! empty( $column_height ) ) { $styles_sublist .= " background-image: url(" . $post_thumbnail_url . ");"; } } if ( $depth == 1 && ! empty( $column_width ) ) { $styles .= 'width:' . $column_width . '%!important'; } if ( $depth == 0 && ! empty( $sublist_width ) ) { $submenu_width .= 'width:' . $sublist_width . 'px;'; } if ( ! empty( $styles ) ) { wp_add_inline_style( 'xstore-inline-css', '.menu-item-' . $item_id . ' {' . $styles . '}' ); } if ( ! empty( $column_height ) ) { wp_add_inline_style( 'xstore-inline-css', '.menu-item-' . $item_id . ' .nav-sublist-dropdown > .container > ul, .menu-item-' . $item_id . ' .menu-static-block {height: ' . $column_height . 'px!important;}' ); } if ( ! empty( $styles_sublist ) ) { wp_add_inline_style( 'xstore-inline-css', '.menu-item-' . $item_id . ' .nav-sublist-dropdown {' . $styles_sublist . '}' ); } if ( ! empty( $submenu_width ) ) { // wp_add_inline_style( 'xstore-inline-css', '.menu-item-' . $item_id . '.item-design-mega-menu.menu-item .nav-sublist-dropdown {' . $submenu_width . '}' ); if ( apply_filters('menu_item_dropdown_full_width', false) ) { wp_add_inline_style( 'xstore-inline-css', '.menu-item-' . $item_id . '.menu-item-' . $item_id . '.mega-menu-full-width .nav-sublist-dropdown .container { max-' . $submenu_width . '}'); } else { wp_add_inline_style( 'xstore-inline-css', '.et_b_header-menu .secondary-menu-wrapper .menu-item-'.$item_id.'.item-design-mega-menu .nav-sublist-dropdown, .menu-item-' . $item_id . '.item-design-mega-menu.menu-item .nav-sublist-dropdown {' . $submenu_width . '}' ); } } } function et_get_tooltip_html( $item_id ) { $visibility = get_post_meta( $item_id, '_menu-item-item_visibility', true ); if ( ( $visibility == 'logged' && ! ( get_query_var( 'et_is-loggedin', false) ) ) || ( $visibility == 'unlogged' && get_query_var( 'et_is-loggedin', false) ) ) { return; } $output = ''; $post_thumbnail = get_post_thumbnail_id( $item_id ); // $post_thumbnail_url = wp_get_attachment_image_src( $post_thumbnail, 'large' ); $output .= ''; return $output; } function getPostsSubcategories( $item ) { if ( $item->object != 'category' ) { return ''; } $cat_id = $item->object_id; $children = get_categories( array( 'child_of' => $cat_id ) ); $output = '
'; if ( ! empty( $children ) ) { $cat_id = $children[0]->term_id; $output .= '
'; } $output .= '
'; $output .= $this->getPostsByCategory( $cat_id ); $output .= '
'; $output .= '
'; return $output; } function getPostsByCategory( $cat = false ) { if ( defined( 'DOING_AJAX' ) && DOING_AJAX && isset( $_GET['cat'] ) ) { $cat = (int) $_GET['cat']; } if ( ! $cat ) { return ''; } $category = get_category( $cat ); $posts = get_posts( array( 'category' => $cat, 'posts_per_page' => 3, 'post_status' => 'publish', 'post_type' => 'post' ) ); if ( ! empty( $posts ) ) { ob_start(); foreach ( $posts as $post ) { echo '
'; echo '
'; echo get_the_post_thumbnail( $post->ID, 'medium' ); echo ''; echo '
'; echo '' . $post->post_title . ''; echo '
'; } // added !defined('DOING_ETHEME_AJAXIFY') condition for correct work of such menu in Elementor Header editor if ( defined( 'DOING_AJAX' ) && DOING_AJAX && !defined('DOING_ETHEME_AJAXIFY') ) { echo ob_get_clean(); // if ( !defined('DOING_ETHEME_AJAXIFY')) // die(); // creates server error on Elementor editor } else { return ob_get_clean(); } } return ''; } } class ETheme_Navigation_Mobile extends Walker_Nav_Menu { function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { global $wp_query; $indent = ( $depth ) ? str_repeat( "\t", $depth ) : ''; $item_id = $item->ID; $value = ''; $visibility = get_post_meta( $item_id, '_menu-item-item_visibility', true ); $this->visible = $visibility; if ( ( $visibility == 'logged' && ! ( get_query_var( 'et_is-loggedin', false) ) ) || ( $visibility == 'unlogged' && get_query_var( 'et_is-loggedin', false) ) ) { return; } $anchor = get_post_meta( $item_id, '_menu-item-anchor', true ); $icon_type = get_post_meta( $item_id, '_menu-item-icon_type', true ); $icon = get_post_meta( $item_id, '_menu-item-icon', true ); $disable_titles = get_post_meta( $item_id, '_menu-item-disable_titles', true ); if ( ! empty( $anchor ) ) { $item->url = $item->url . '#' . $anchor; if ( ( $key = array_search( 'current_page_item', $item->classes ) ) !== false ) { unset( $item->classes[ $key ] ); } if ( ( $key = array_search( 'current-menu-item', $item->classes ) ) !== false ) { unset( $item->classes[ $key ] ); } } $classes = empty( $item->classes ) ? array() : (array) $item->classes; $classes[] = 'menu-item-' . $item->ID; $classes[] = 'item-level-' . $depth; if ( $icon != '' ) { switch ( $icon_type ) { case 'xstore-icons': $icon = ''; break; default: $icon = ''; break; } } if ( $depth < 3 ) { if ( $disable_titles == 1 ) { $classes[] = 'menu-disable_title'; } } $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) ); $class_names = ' class="' . esc_attr( $class_names ) . '"'; // $id = apply_filters( 'nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args ); // $id = strlen( $id ) ? ' id="' . esc_attr( $id ) . '"' : ''; // $output .= $indent . ''; $output .= $indent . '