'; if ( ! empty( $settings[ $item->ID ]['icon'] ) ) { $output .= ''; } elseif ( ! empty( $settings[ $item->ID ]['icon_image'] ) ) { if ( ! empty( $settings[ $item->ID ]['dark_icon_image'] ) ) { $output .= ''; $output .= '' . esc_attr( $title ) . ''; $output .= '' . esc_attr( $title ) . ''; $output .= ''; } else { $output .= '' . esc_attr( $title ) . ''; } } $output .= $title; if ( ! empty( $settings[ $item->ID ]['sub_label'] ) ) { $output .= '' . esc_html( $settings[ $item->ID ]['sub_label'] ) . ''; } $output .= ''; return $output; } } if ( ! class_exists( 'Foxiz_Walker_Nav_Menu', false ) ) { /** * Class Foxiz_Walker_Nav_Menu */ class Foxiz_Walker_Nav_Menu extends Walker_Nav_Menu { static function get_menu_id( $args ) { if ( ! empty( $args->menu->term_id ) ) { return intval( $args->menu->term_id ); } elseif ( ! empty( $args->menu ) ) { $menu = wp_get_nav_menu_object( $args->menu ); return $menu->term_id; } return false; } public function start_el( &$output, $item, $depth = 0, $args = null, $id = 0 ) { $rb_settings = get_option( 'rb_menu_settings_' . self::get_menu_id( $args ), array() ); if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) { $t = ''; $n = ''; } else { $t = "\t"; $n = "\n"; } $indent = ( $depth ) ? str_repeat( $t, $depth ) : ''; $classes = empty( $item->classes ) ? array() : (array) $item->classes; $classes[] = 'menu-item-' . $item->ID; if ( empty( $depth ) && 'category' === $item->object && ! empty( $rb_settings[ $item->ID ]['category'] ) ) { $classes[] = 'menu-item-has-children menu-has-child-mega is-child-wide'; if ( ! empty ( $rb_settings[ $item->ID ]['layout'] ) ) { $classes[] = 'mega-hierarchical'; } } elseif ( empty( $depth ) && ( 'custom' === $item->object ) && ! empty ( $rb_settings[ $item->ID ]['mega_shortcode'] ) ) { $classes[] = 'menu-item-has-children menu-has-child-mega menu-has-child-mega-template'; if ( empty( $rb_settings[ $item->ID ]['mega_width'] ) ) { $classes[] = 'is-child-wide'; } } elseif ( empty( $depth ) && ( 'custom' === $item->object ) && ( ! empty ( $rb_settings[ $item->ID ]['columns'] ) ) ) { $classes[] = 'menu-item-has-children menu-has-child-mega menu-has-child-mega-columns'; if ( empty( $rb_settings[ $item->ID ]['mega_width'] ) ) { $classes[] = 'is-child-wide'; } if ( ! empty( $rb_settings[ $item->ID ]['mega_shortcode'] ) ) { $rb_settings[ $item->ID ]['columns_per_row'] = 1; } if ( ! empty ( $rb_settings[ $item->ID ]['columns_per_row'] ) ) { $classes[] = 'layout-col-' . $rb_settings[ $item->ID ]['columns_per_row']; } } $args = apply_filters( 'nav_menu_item_args', $args, $item, $depth ); $class_names = implode( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args, $depth ) ); $class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : ''; $id = apply_filters( 'nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args, $depth ); $id = $id ? ' id="' . esc_attr( $id ) . '"' : ''; $output .= $indent . ''; $atts = array(); $atts['title'] = ! empty( $item->attr_title ) ? $item->attr_title : ''; $atts['target'] = ! empty( $item->target ) ? $item->target : ''; if ( '_blank' === $item->target && empty( $item->xfn ) ) { $atts['rel'] = 'noopener'; } else { $atts['rel'] = $item->xfn; } $atts['href'] = ! empty( $item->url ) ? $item->url : ''; $atts['aria-current'] = $item->current ? 'page' : ''; $atts = apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ); $attributes = ''; foreach ( $atts as $attr => $value ) { if ( is_scalar( $value ) && '' !== $value && false !== $value ) { $value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value ); $attributes .= ' ' . $attr . '="' . $value . '"'; } } $title = apply_filters( 'the_title', $item->title, $item->ID ); $title = apply_filters( 'nav_menu_item_title', $title, $item, $args, $depth ); $item_output = $args->before; $item_output .= ''; $item_output .= $args->link_before . $title . $args->link_after; $item_output .= ''; $item_output .= $args->after; if ( empty( $depth ) && 'category' === $item->object && ! empty( $rb_settings[ $item->ID ]['category'] ) ) { /** mega category */ $mega_category_classes = 'mega-dropdown is-mega-category'; $inner_classes = 'mega-dropdown-inner'; if ( in_array( 'menu-item-has-children', $item->classes, true ) ) { $mega_category_classes .= ' mega-menu-has-children'; } if ( empty( $rb_settings[ $item->ID ]['sub_scheme'] ) ) { if ( ! empty( $args->sub_scheme ) ) { $inner_classes .= ' ' . esc_attr( $args->sub_scheme ); } } elseif ( '1' === $rb_settings[ $item->ID ]['sub_scheme'] ) { $inner_classes .= ' light-scheme'; } $item_output .= '
'; $item_output .= '
'; $item_output .= '
'; } elseif ( empty( $depth ) && ( 'custom' === $item->object ) && ! empty ( $rb_settings[ $item->ID ]['mega_shortcode'] ) ) { /** mega template */ if ( ! empty( $rb_settings[ $item->ID ]['mega_width'] ) ) { $item_output .= '
'; } else { $item_output .= '
'; } $item_output .= '
'; } elseif ( empty( $depth ) && ( 'custom' === $item->object ) && ! empty ( $rb_settings[ $item->ID ]['columns'] ) ) { /** mega columns */ $inner_classes = 'mega-dropdown-inner'; if ( empty( $rb_settings[ $item->ID ]['sub_scheme'] ) ) { if ( ! empty( $args->sub_scheme ) ) { $inner_classes .= ' ' . esc_attr( $args->sub_scheme ); } } elseif ( '1' === $rb_settings[ $item->ID ]['sub_scheme'] ) { $inner_classes .= ' light-scheme'; } if ( ! empty( $rb_settings[ $item->ID ]['mega_width'] ) ) { $item_output .= '
'; } else { $item_output .= '
'; } $item_output .= '
'; $item_output .= '
'; } /** filter */ $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args ); } public function end_el( &$output, $item, $depth = 0, $args = null ) { $rb_settings = get_option( 'rb_menu_settings_' . self::get_menu_id( $args ), array() ); if ( empty( $depth ) && 'category' === $item->object && ! empty( $rb_settings[ $item->ID ]['category'] ) ) { $output .= $this->category_mega_menu( $item, $rb_settings ); $output .= '
'; } elseif ( empty( $depth ) && ( 'custom' === $item->object ) && ! empty ( $rb_settings[ $item->ID ]['mega_shortcode'] ) ) { $output .= $this->column_mega_menu( $item, $rb_settings ); $output .= '
'; } elseif ( empty( $depth ) && ( 'custom' === $item->object ) && ( ! empty ( $rb_settings[ $item->ID ]['columns'] ) ) ) { $output .= $this->column_mega_menu( $item, $rb_settings ); $output .= '
'; } if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) { $t = ''; $n = ''; } else { $t = "\t"; $n = "\n"; } $output .= "{$n}"; } /** * @param $item * @param $rb_settings * * @return string */ public function category_mega_menu( $item, $rb_settings ) { if ( ! empty ( $rb_settings[ $item->ID ]['layout'] ) ) { return $this->blog_hierarchical( $item ); } else { return $this->blog_default( $item ); } } /** mega category default */ public function blog_default( $item ) { $output = ''; if ( ! empty( $item->object_id ) ) { $output .= ''; $output .= foxiz_get_grid_small_1( array( 'uuid' => 'mega-listing-' . $item->ID, 'duplicate_allowed' => 1, 'columns' => 5, 'posts_per_page' => 5, 'title_tag' => 'span', 'crop_size' => 'foxiz_crop_g1', 'title_classes' => 'h4', 'review' => 'replace', 'entry_meta' => 'date', 'entry_category' => '-1', 'excerpt_length' => '-1', 'category' => $item->object_id ) ); } return $output; } /** * @param $item * * @return string */ public function blog_hierarchical( $item ) { $output = ''; if ( ! empty( $item->object_id ) ) { $data = get_option( 'foxiz_category_meta', array() ); $description = term_description( $item->object_id ); $featured = ''; if ( isset( $data[ $item->object_id ]['featured_image'] ) ) { $featured = $data[ $item->object_id ]['featured_image']; } $output .= '
'; $output .= ''; $output .= foxiz_get_category_hero( $featured ); if ( ! empty( $description ) ) { $output .= '
' . wp_trim_words( $description, 25 ) . '
'; } $output .= 'target ) ) { $output .= 'target="' . $item->target . '"'; } $output .= '>' . foxiz_html__( 'Show More', 'foxiz' ) . ''; $output .= '
'; $output .= ''; $output .= '
'; $output .= '
'; $output .= '' . foxiz_html__( 'Latest News', 'foxiz' ) . ''; $output .= '
'; $output .= foxiz_get_list_small_1( array( 'uuid' => 'mega-listing-latest-' . $item->ID, 'duplicate_allowed' => 1, 'posts_per_page' => 4, 'title_tag' => 'span', 'title_classes' => 'h4', 'category' => $item->object_id, 'review' => 'replace', 'entry_format' => 'false', 'review_description' => '-1', 'entry_category' => '-1', 'entry_meta' => 'date', 'excerpt_length' => '-1', 'readmore' => '-1', 'bottom_border' => 'gray', 'last_bottom_border' => '-1' ) ); $output .= '
'; } return $output; } /** * @param $item * @param $rb_settings * * @return false|string */ public function column_mega_menu( $item, $rb_settings ) { ob_start(); if ( ! empty( $rb_settings[ $item->ID ]['mega_shortcode'] ) ) : ?> ID ]['mega_shortcode'] ) ); ?> ID ]['columns'] ) ) : ?>
ID ]['columns'] ); ?>