args = array_merge( [ 'header_layout' => fusion_get_option( 'header_layout' ), 'header_position' => fusion_get_option( 'header_position' ), 'megamenu_width' => fusion_get_option( 'megamenu_width' ), 'side_header_width' => fusion_get_option( 'side_header_width' ), 'megamenu_interior_content_width' => fusion_get_option( 'megamenu_interior_content_width' ), 'site_width' => fusion_get_option( 'site_width' ), 'megamenu_max_width' => fusion_get_option( 'megamenu_max_width' ), 'menu_icon_position' => fusion_get_option( 'menu_icon_position' ), 'menu_display_dropdown_indicator' => fusion_get_option( 'menu_display_dropdown_indicator' ), 'menu_highlight_style' => fusion_get_option( 'menu_highlight_style' ), 'main_nav_search_icon' => fusion_get_option( 'main_nav_search_icon' ), 'woocommerce_cart_link_main_nav' => fusion_get_option( 'woocommerce_cart_link_main_nav' ), 'slidingbar_toggle_style' => fusion_get_option( 'slidingbar_toggle_style' ), 'slidingbar_widgets' => fusion_get_option( 'slidingbar_widgets' ), 'disable_megamenu' => fusion_get_option( 'disable_megamenu' ), 'button_type' => fusion_get_option( 'button_type' ), 'woocommerce_acc_link_main_nav' => fusion_get_option( 'woocommerce_acc_link_main_nav' ), 'logo_url' => fusion_get_option( 'logo', 'url' ), 'logo_retina_url' => fusion_get_option( 'logo_retina', 'url' ), 'disable_highlight_arrows' => false, 'fb_menu_element' => false, 'submenu_mode' => 'dropdown', 'transition_type' => '', 'expand_method' => 'hover', 'lazy_load' => 'avada' === fusion_get_option( 'lazy_load' ), ], $args ); } /** * Start level. * * @see Walker::start_lvl() * @since 3.0.0 * * @param string $output Passed by reference. Used to append additional content. * @param int $depth Depth of page. Used for padding. * @param array $args Not used. */ public function start_lvl( &$output, $depth = 0, $args = [] ) { if ( 0 === $depth && 'enabled' === $this->menu_megamenu_status ) { $output .= '{first_level}'; $output .= '
'; $col_span = ' col-span-' . $this->max_num_of_columns * 2; if ( $this->total_num_of_columns < $this->max_num_of_columns ) { $col_span = ' col-span-' . $this->total_num_of_columns * 2; } $total_column_width_per_row = []; foreach ( $this->menu_megamenu_rowwidth_matrix as $row => $columns ) { $total_column_width_per_row[ $row ] = array_sum( $columns ); } $max_row_width = max( $total_column_width_per_row ); $megamenu_interior_width = '"'; // Set overall width of megamenu. $megamenu_width = $this->args['megamenu_width']; if ( 'viewport_width' === $megamenu_width ) { if ( 'top' !== $this->args['header_position'] ) { $site_header_width = (int) $this->args['side_header_width']; $this->menu_megamenu_maxwidth = 'calc(100vw - ' . $site_header_width . 'px)'; $wrapper_width = 'calc(' . $max_row_width . ' * (100vw - ' . $site_header_width . 'px))'; } else { $this->menu_megamenu_maxwidth = '100vw'; $wrapper_width = ( $max_row_width * 100 ) . 'vw'; if ( 'site_width' === $this->args['megamenu_interior_content_width'] && 'fullwidth' === $this->menu_megamenu_width ) { $megamenu_interior_width = ' fusion-megamenu-sitewidth" style="margin: 0 auto;width: 100%;max-width: ' . str_replace( '%', 'vw', $this->args['site_width'] ) . ';"'; } } } elseif ( 'site_width' === $megamenu_width ) { $this->menu_megamenu_maxwidth = str_replace( '%', 'vw', $this->args['site_width'] ); if ( false === strpos( $this->menu_megamenu_maxwidth, 'calc' ) ) { $wrapper_width = ( $max_row_width * Fusion_Sanitize::number( $this->menu_megamenu_maxwidth ) ) . Fusion_Sanitize::get_unit( $this->menu_megamenu_maxwidth ); } else { $wrapper_width = 'calc(' . $max_row_width . ' * (' . str_replace( [ 'calc(', ')' ], [ '', '' ], $this->menu_megamenu_maxwidth ) . '))'; } } else { $this->menu_megamenu_maxwidth = (int) $this->args['megamenu_max_width'] . 'px'; $wrapper_width = ( $max_row_width * (int) $this->menu_megamenu_maxwidth ) . 'px'; } if ( 'fullwidth' === $this->menu_megamenu_width ) { $col_span = ' col-span-12 fusion-megamenu-fullwidth'; if ( 'site_width' === $megamenu_width ) { $col_span .= ' fusion-megamenu-width-site-width'; } // Overall megamenu wrapper width in px is max width for fullwidth megamenu. $wrapper_width = $this->menu_megamenu_maxwidth; } $background_image = ''; $data_bg = ''; if ( ! empty( $this->menu_megamenu_background_image ) ) { if ( $this->args['lazy_load'] ) { $data_bg = ' data-bg="' . $this->menu_megamenu_background_image . '"'; } else { $background_image .= ';background-image: url(' . $this->menu_megamenu_background_image . ');'; } } $output = str_replace( '{first_level}', '
', $output ); $output = str_replace( '{megamenu_final_width}', 'style="width:' . $wrapper_width . $background_image . ';"' . $data_bg . ' data-width="' . $wrapper_width . '"', $output ); $output = str_replace( '{megamenu_interior_width}', $megamenu_interior_width, $output ); $output = str_replace( '{fusion_all_widgets}', $this->total_num_of_widgets === $this->total_num_of_columns ? 'fusion-has-all-widgets' : '', $output ); $replacement = ( $this->total_num_of_columns > $this->max_num_of_columns ) ? ' fusion-megamenu-border' : ''; $output = str_replace( '{megamenu_border}', $replacement, $output ); foreach ( $this->submenu_matrix as $row => $columns ) { $layout_columns = 12 / $columns; $layout_columns = ( 5 === $columns ) ? 2 : $layout_columns; $replacement = 'fusion-megamenu-row-columns-' . $columns; $replacement .= ( ( $row - 1 ) * $this->max_num_of_columns + $columns < $this->total_num_of_columns ) ? ' fusion-megamenu-border' : ''; $output = str_replace( '{row_number_' . $row . '}', $replacement, $output ); $replacement = ( count( $this->submenu_matrix ) === $row ) ? '' : 'fusion-megamenu-border'; $output = str_replace( '{force_row_border_' . $row . '}', $replacement, $output ); $output = str_replace( '{current_row_' . $row . '}', 'fusion-megamenu-columns-' . $columns . ' col-lg-' . $layout_columns . ' col-md-' . $layout_columns . ' col-sm-' . $layout_columns, $output ); $output = str_replace( '{fusion_columns}', 'fusion-columns-' . $columns . ' columns-per-row-' . $columns, $output ); } foreach ( $this->menu_megamenu_rowwidth_matrix as $row => $columns ) { foreach ( $columns as $column => $column_width ) { $weighted_width = ( 100 / $max_row_width * $column_width ) . '%'; $output = str_replace( '{column_width_' . $row . '_' . $column . '}', $weighted_width, $output ); } } } else { $output .= ''; } } /** * Start element. * * @see Walker::start_el() * @since 3.0.0 * * @param string $output Passed by reference. Used to append additional content. * @param object $item Menu item data object. * @param int $depth Depth of menu item. Used for padding. * @param stdClass $args The arguments. * @param int $id Menu item ID. */ public function start_el( &$output, $item, $depth = 0, $args = [], $id = 0 ) { $item_output = ''; $class_columns = ''; $menu_highlight_label = ''; $is_rtl = is_rtl(); $header_layout = $this->args['header_layout']; $header_position = $this->args['header_position']; $menu_icon_position = $this->args['menu_icon_position']; $menu_display_dropdown_indicator = $this->args['menu_display_dropdown_indicator']; $fb_menu_element = $this->args['fb_menu_element']; $expand_method = $this->args['expand_method']; $menu_highlight_style = $this->args['menu_highlight_style']; $transition_type = $this->args['transition_type']; /** * Filters the arguments for a single nav menu item. * * @since 4.4.0 * * @param stdClass $args An object of wp_nav_menu() arguments. * @param WP_Post $item Menu item data object. * @param int $depth Depth of menu item. Used for padding. */ $args = apply_filters( 'nav_menu_item_args', $args, $item, $depth ); if ( null === $item->menu_item_parent ) { $item->menu_item_parent = '0'; } if ( ! $this->top_level_menu_items_count ) { if ( 'v6' === $header_layout || 'v7' === $header_layout || ( $fb_menu_element && 'flyout' === $this->args['submenu_mode'] ) ) { $menu_elements = wp_get_nav_menu_items( $args->menu, [ 'meta_key' => '_menu_item_menu_item_parent', // phpcs:ignore WordPress.DB.SlowDBQuery 'meta_value' => '0', // phpcs:ignore WordPress.DB.SlowDBQuery ] ); // Array of menu item types we don't consider as 'top level' menu items. $exclude_menu_items = apply_filters( 'fusion_exclude_top_menu_items', [ 'wpml_ls_menu_item' ] ); if ( is_array( $menu_elements ) ) { foreach ( $menu_elements as $key => $menu_element ) { if ( isset( $menu_element->type ) && in_array( $menu_element->type, $exclude_menu_items, true ) ) { unset( $menu_elements[ $key ] ); } } $this->top_level_menu_items_count = count( $menu_elements ); foreach ( $menu_elements as $menu_element ) { if ( null === $menu_element->menu_item_parent ) { $menu_element->menu_item_parent = '0'; } } } } if ( 'v6' === $header_layout || 'v7' === $header_layout ) { $is_search_icon_enabled = (int) $this->args['main_nav_search_icon']; $is_cart_icon_enabled = (int) $this->args['woocommerce_cart_link_main_nav']; $is_my_account_menu_enabled = (int) $this->args['woocommerce_acc_link_main_nav']; $is_sliding_bar_icon_enabled = (int) 'menu' === $this->args['slidingbar_toggle_style'] && $this->args['slidingbar_widgets']; if ( 'v7' === $header_layout ) { $this->top_level_menu_items_count += $is_search_icon_enabled + $is_cart_icon_enabled + $is_my_account_menu_enabled + $is_sliding_bar_icon_enabled; if ( 0 === $this->top_level_menu_items_count ) { $this->middle_logo_menu_break_point = $this->top_level_menu_items_count / 2; } else { $this->middle_logo_menu_break_point = ceil( $this->top_level_menu_items_count / 2 ); if ( $is_search_icon_enabled || $is_cart_icon_enabled || $is_sliding_bar_icon_enabled ) { $this->middle_logo_menu_break_point = floor( $this->top_level_menu_items_count / 2 ); } } $this->middle_logo_menu_break_point = apply_filters( 'avada_middle_logo_menu_break_point', $this->middle_logo_menu_break_point ); } } } // Set some vars. $meta_data = get_post_meta( $item->ID ); $fusion_meta = ! empty( $meta_data['_menu_item_fusion_megamenu'][0] ) ? maybe_unserialize( $meta_data['_menu_item_fusion_megamenu'][0] ) : []; $fusion_meta = apply_filters( 'avada_menu_meta', $fusion_meta, $item->ID ); // Skip special links if old menu setup. if ( ! $fb_menu_element && isset( $fusion_meta['special_link'] ) && '' !== $fusion_meta['special_link'] ) { return ''; } $this->menu_style = isset( $fusion_meta['style'] ) ? $fusion_meta['style'] : ''; $this->menu_megamenu_icon = isset( $fusion_meta['icon'] ) ? $fusion_meta['icon'] : ''; $this->menu_megamenu_modal = isset( $fusion_meta['modal'] ) ? $fusion_meta['modal'] : ''; $this->menu_title_only = isset( $fusion_meta['icononly'] ) ? $fusion_meta['icononly'] : ''; $this->fusion_highlight_label = isset( $fusion_meta['highlight_label'] ) ? $fusion_meta['highlight_label'] : ''; $this->fusion_highlight_label_background = isset( $fusion_meta['highlight_label_background'] ) ? $fusion_meta['highlight_label_background'] : ''; $this->fusion_highlight_label_color = isset( $fusion_meta['highlight_label_color'] ) ? $fusion_meta['highlight_label_color'] : ''; $this->fusion_highlight_label_border_color = isset( $fusion_meta['highlight_label_border_color'] ) ? $fusion_meta['highlight_label_border_color'] : ''; // Add the bg image markup for flyout menu items. if ( ( 0 === $depth && 'v6' === $header_layout || ( $fb_menu_element && 'flyout' === $this->args['submenu_mode'] ) ) && isset( $fusion_meta['background_image'] ) && '' !== $fusion_meta['background_image'] ) { if ( $this->args['lazy_load'] ) { $this->flyout_menu_bg_markup .= '
'; } else { $this->flyout_menu_bg_markup .= '
'; } } if ( ! empty( $item->fusion_highlight_label ) ) { $highlight_style = ''; if ( ! empty( $item->fusion_highlight_label_background ) ) { $highlight_style .= 'background-color:' . $item->fusion_highlight_label_background . ';'; } if ( ! empty( $item->fusion_highlight_label_border_color ) ) { $highlight_style .= 'border-color:' . $item->fusion_highlight_label_border_color . ';'; } if ( ! empty( $item->fusion_highlight_label_color ) ) { $highlight_style .= 'color:' . $item->fusion_highlight_label_color . ';'; } $menu_highlight_label = '' . esc_html( $item->fusion_highlight_label ) . ''; } // Megamenu is enabled. if ( $this->args['disable_megamenu'] && 'top_navigation' !== $args->theme_location ) { if ( 0 === $depth ) { $this->menu_megamenu_status = isset( $fusion_meta['status'] ) ? $fusion_meta['status'] : 'disabled'; $this->menu_megamenu_width = isset( $fusion_meta['width'] ) ? $fusion_meta['width'] : ''; $allowed_columns = isset( $fusion_meta['columns'] ) ? $fusion_meta['columns'] : ''; if ( 'auto' !== $allowed_columns ) { $this->max_num_of_columns = (int) $allowed_columns; } $this->num_of_columns = 0; $this->total_num_of_columns = 0; $this->total_num_of_widgets = 0; $this->num_of_rows = 1; $this->menu_megamenu_rowwidth_matrix = []; $this->menu_megamenu_rowwidth_matrix[ $this->num_of_rows ] = []; $this->menu_megamenu_background_image = isset( $fusion_meta['background_image'] ) ? $fusion_meta['background_image'] : ''; } elseif ( 1 === $depth ) { $megamenu_column_background_image = isset( $fusion_meta['background_image'] ) ? $fusion_meta['background_image'] : ''; } $this->menu_megamenu_title = isset( $fusion_meta['title'] ) ? $fusion_meta['title'] : ''; $this->menu_megamenu_widgetarea = isset( $fusion_meta['widgetarea'] ) ? $fusion_meta['widgetarea'] : ''; if ( ! empty( $fusion_meta['thumbnail'] ) ) { $thumbnail_id = isset( $fusion_meta['thumbnail_id'] ) ? $fusion_meta['thumbnail_id'] : 0; $thumbnail_data = fusion_library()->images->get_attachment_data_by_helper( $thumbnail_id, $fusion_meta['thumbnail'] ); if ( $thumbnail_data ) { $this->menu_megamenu_thumbnail = '' . $thumbnail_data['alt'] . ''; } else { $this->menu_megamenu_thumbnail = ''; } } else { $this->menu_megamenu_thumbnail = ''; } // Megamenu is disabled. } else { $this->menu_megamenu_status = 'disabled'; } // We are inside a megamenu. if ( 1 === $depth && 'enabled' === $this->menu_megamenu_status ) { if ( isset( $fusion_meta['columnwidth'] ) && $fusion_meta['columnwidth'] ) { $this->menu_megamenu_columnwidth = floatval( $fusion_meta['columnwidth'] ) . '%'; } else { $this->menu_megamenu_columnwidth = '16.6666%'; if ( 'fullwidth' === $this->menu_megamenu_width && $this->max_num_of_columns ) { $this->menu_megamenu_columnwidth = 100 / $this->max_num_of_columns . '%'; } elseif ( 1 === $this->max_num_of_columns ) { $this->menu_megamenu_columnwidth = '100%'; } } $this->num_of_columns++; $this->total_num_of_columns++; // Check if we need to start a new row. if ( $this->num_of_columns > $this->max_num_of_columns || $this->previous_column_was_100_percent ) { $this->num_of_columns = 1; $this->num_of_rows++; $force_row_border = ''; if ( $this->previous_column_was_100_percent ) { $this->previous_column_was_100_percent = false; $force_row_border = ' {force_row_border_' . $this->num_of_rows . '}'; } $output .= '