', $output );
$output = str_replace( '{megamenu_final_width}', 'style="width:' . $wrapper_width . 'px;' . $background_image . '" data-width="' . $wrapper_width . '"', $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;
if ( $columns < $this->max_num_of_columns ) {
$row_width = 'style="width:' . $columns / $this->max_num_of_columns * 100 . '% !important;"';
}
$output = str_replace( '{row_width_' . $row . '}', $row_width, $output );
$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 );
$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 );
}
} else {
$output .= '';
} // End if().
}
/**
* 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 array $args The arguments.
* @param int $id Menu item ID.
*/
public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
$item_output = '';
$class_columns = '';
$menu_highlight_label = '';
$is_rtl = is_rtl();
$header_layout = Avada()->settings->get( 'header_layout' );
$header_position = Avada()->settings->get( 'header_position' );
$menu_icon_position = Avada()->settings->get( 'menu_icon_position' );
$menu_display_dropdown_indicator = Avada()->settings->get( 'menu_display_dropdown_indicator' );
$menu_highlight_style = Avada()->settings->get( 'menu_highlight_style' );
if ( null === $item->menu_item_parent ) {
$item->menu_item_parent = '0';
}
if ( 'v7' === $header_layout ) {
if ( ! isset( $this->middle_logo_menu_break_point ) ) {
$is_search_icon_enabled = Avada()->settings->get( 'main_nav_search_icon' );
$is_cart_icon_enabled = Avada()->settings->get( 'woocommerce_cart_link_main_nav' );
$middle_logo_menu_elements = wp_get_nav_menu_items( $args->menu );
$middle_logo_menu_top_level_elements = 0;
foreach ( $middle_logo_menu_elements as $menu_element ) {
if ( null === $menu_element->menu_item_parent ) {
$menu_element->menu_item_parent = '0';
}
if ( '0' === $menu_element->menu_item_parent ) {
$middle_logo_menu_top_level_elements++;
}
}
if ( $is_search_icon_enabled ) {
$middle_logo_menu_top_level_elements++;
}
if ( $is_cart_icon_enabled ) {
$middle_logo_menu_top_level_elements++;
}
$top_level_menu_items_count = $middle_logo_menu_top_level_elements;
if ( 0 === $top_level_menu_items_count ) {
$this->middle_logo_menu_break_point = $middle_logo_menu_top_level_elements / 2;
} else {
$this->middle_logo_menu_break_point = ceil( $middle_logo_menu_top_level_elements / 2 );
if ( $is_search_icon_enabled || $is_cart_icon_enabled ) {
$this->middle_logo_menu_break_point = floor( $middle_logo_menu_top_level_elements / 2 );
}
}
}
}
// Set some vars.
$meta_data = get_post_meta( $item->ID );
$avada_meta = ! empty( $meta_data['_menu_item_fusion_megamenu'][0] ) ? maybe_unserialize( $meta_data['_menu_item_fusion_megamenu'][0] ) : array();
$this->menu_style = isset( $avada_meta['style'] ) ? $avada_meta['style'] : '';
$this->menu_megamenu_icon = isset( $avada_meta['icon'] ) ? $avada_meta['icon'] : '';
$this->menu_megamenu_modal = isset( $avada_meta['modal'] ) ? $avada_meta['modal'] : '';
$this->menu_title_only = isset( $avada_meta['icononly'] ) ? $avada_meta['icononly'] : '';
$this->fusion_highlight_label = isset( $avada_meta['highlight_label'] ) ? $avada_meta['highlight_label'] : '';
$this->fusion_highlight_label_background = isset( $avada_meta['highlight_label_background'] ) ? $avada_meta['highlight_label_background'] : '';
$this->fusion_highlight_label_color = isset( $avada_meta['highlight_label_color'] ) ? $avada_meta['highlight_label_color'] : '';
$this->fusion_highlight_label_border_color = isset( $avada_meta['highlight_label_border_color'] ) ? $avada_meta['highlight_label_border_color'] : '';
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 = '';
}
// Megamenu is enabled.
if ( Avada()->settings->get( 'disable_megamenu' ) && 'top_navigation' !== $args->theme_location ) {
if ( 0 === $depth ) {
$this->menu_megamenu_status = isset( $avada_meta['status'] ) ? $avada_meta['status'] : 'disabled';
$this->menu_megamenu_width = isset( $avada_meta['width'] ) ? $avada_meta['width'] : '';
$allowed_columns = isset( $avada_meta['columns'] ) ? $avada_meta['columns'] : '';
if ( 'auto' !== $allowed_columns ) {
$this->max_num_of_columns = $allowed_columns;
}
$this->num_of_columns = 0;
$this->total_num_of_columns = 0;
$this->num_of_rows = 1;
$this->menu_megamenu_rowwidth_matrix = array();
$this->menu_megamenu_rowwidth_matrix[ $this->num_of_rows ] = 0;
$this->menu_megamenu_background_image = isset( $avada_meta['background_image'] ) ? $avada_meta['background_image'] : '';
} elseif ( 1 === $depth ) {
$megamenu_column_background_image = isset( $avada_meta['background_image'] ) ? $avada_meta['background_image'] : '';
}
$this->menu_megamenu_title = isset( $avada_meta['title'] ) ? $avada_meta['title'] : '';
$this->menu_megamenu_widgetarea = isset( $avada_meta['widgetarea'] ) ? $avada_meta['widgetarea'] : '';
if ( ! empty( $avada_meta['thumbnail'] ) ) {
$thumbnail_data = Avada()->images->get_attachment_data_from_url( $avada_meta['thumbnail'] );
if ( $thumbnail_data ) {
$this->menu_megamenu_thumbnail = '
![' . $thumbnail_data['title'] . ' ' . $thumbnail_data['alt'] . '](' . $thumbnail_data['url'] . ')
';
} 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( $avada_meta['columnwidth'] ) && $avada_meta['columnwidth'] ) {
$this->menu_megamenu_columnwidth = $avada_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->num_of_columns = 1;
$this->num_of_rows++;
// Start new row width calculation.
$this->menu_megamenu_rowwidth_matrix[ $this->num_of_rows ] = floatval( $this->menu_megamenu_columnwidth ) / 100;
$output .= '