", $output );
$output = str_replace( "{megamenu_final_width}", sprintf( 'style="width:%spx;" data-width="%s"', $wrapper_width, $wrapper_width ), $output );
if ( $this->total_num_of_columns > $this->max_num_of_columns ) {
$output = str_replace( "{megamenu_border}","fusion-megamenu-border", $output );
} else {
$output = str_replace( "{megamenu_border}","", $output );
}
foreach($this->submenu_matrix as $row => $columns) {
$layout_columns = 12 / $columns;
if( $columns == '5' ) {
$layout_columns = 2;
}
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);
if( ( $row - 1 ) * $this->max_num_of_columns + $columns < $this->total_num_of_columns ) {
$output = str_replace( "{row_number_".$row."}", "fusion-megamenu-row-columns-" . $columns . " fusion-megamenu-border", $output);
} else {
$output = str_replace( "{row_number_".$row."}", "fusion-megamenu-row-columns-" . $columns, $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}", sprintf( 'fusion-columns-%s columns-per-row-%s', $columns, $columns ), $output );
}
} else {
$output .= "$indent\n";
}
}
/**
* @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 int $current_page Menu item ID.
* @param object $args
*/
public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
global $smof_data;
$item_output = $class_columns = '';
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
/* set some vars */
if( $depth === 0 ) {
$this->menu_megamenu_status = get_post_meta( $item->ID, '_menu_item_fusion_megamenu_status', true );
$this->menu_megamenu_width = get_post_meta( $item->ID, '_menu_item_fusion_megamenu_width', true);
$allowed_columns = get_post_meta( $item->ID, '_menu_item_fusion_megamenu_columns', true );
if( $allowed_columns != "auto" ) {
$this->max_num_of_columns = $allowed_columns;
}
$this->num_of_columns = $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_title = get_post_meta( $item->ID, '_menu_item_fusion_megamenu_title', true);
$this->menu_megamenu_widgetarea = get_post_meta( $item->ID, '_menu_item_fusion_megamenu_widgetarea', true);
$this->menu_megamenu_icon = get_post_meta( $item->ID, '_menu_item_fusion_megamenu_icon', true);
$this->menu_megamenu_thumbnail = get_post_meta( $item->ID, '_menu_item_fusion_megamenu_thumbnail', true);
/* we are inside a mega menu */
if( $depth === 1 && $this->menu_megamenu_status == "enabled" ) {
if( get_post_meta( $item->ID, '_menu_item_fusion_megamenu_columnwidth', true) ) {
$this->menu_megamenu_columnwidth = get_post_meta( $item->ID, '_menu_item_fusion_megamenu_columnwidth', true);
} else {
if ( $this->menu_megamenu_width == "fullwidth" ) {
$this->menu_megamenu_columnwidth = 100 / $this->max_num_of_columns . '%';
} else {
$this->menu_megamenu_columnwidth = '16.6666%';
}
}
$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 .= "\n\n