$megamenu_max_width ) { $megamenu_width = $megamenu_max_width; } else { $megamenu_width = $site_width; } } else { $megamenu_width = $megamenu_max_width; } $this->menu_megamenu_maxwidth = $megamenu_width; } /** * @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. */ public function start_lvl( &$output, $depth = 0, $args = array() ) { $indent = str_repeat( "\t", $depth ); if( $depth === 0 && $this->menu_megamenu_status == "enabled" ) { // set overall width of megamenu if( ! $this->menu_megamenu_maxwidth ) { $this->set_megamenu_max_width(); } $output .= "\n{first_level}\n"; $output .= "\n$indent
\n
\n\n\n"; if( $this->total_num_of_columns < $this->max_num_of_columns ) { $col_span = " col-span-" . $this->total_num_of_columns * 2; } else { $col_span = " col-span-" . $this->max_num_of_columns * 2; } if ( $this->menu_megamenu_width == "fullwidth" ) { $col_span = " col-span-12 fusion-megamenu-fullwidth"; // overall megamenu wrapper width in px is max width for fullwidth megamenu $wrapper_width = $this->menu_megamenu_maxwidth; } else { // calc overall megamenu wrapper width in px $wrapper_width = max( $this->menu_megamenu_rowwidth_matrix ) * $this->menu_megamenu_maxwidth; } $output = str_replace( "{first_level}", "
", $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'; */ return $fb_output; } } } // end FusionCoreFrontendWalker() class } // Don't duplicate me! if( ! class_exists( 'FusionCoreMegaMenus' ) ) { class FusionCoreMegaMenus extends Walker_Nav_Menu { /** * Starts the list before the elements are added. * * @see Walker_Nav_Menu::start_lvl() * * @since 3.0.0 * * @param string $output Passed by reference. * @param int $depth Depth of menu item. Used for padding. * @param array $args Not used. */ function start_lvl( &$output, $depth = 0, $args = array() ) {} /** * Ends the list of after the elements are added. * * @see Walker_Nav_Menu::end_lvl() * * @since 3.0.0 * * @param string $output Passed by reference. * @param int $depth Depth of menu item. Used for padding. * @param array $args Not used. */ function end_lvl( &$output, $depth = 0, $args = array() ) {} /** * Start the element output. * * @see Walker_Nav_Menu::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 Not used. * @param int $id Not used. */ function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { global $_wp_nav_menu_max_depth, $wp_registered_sidebars; $_wp_nav_menu_max_depth = $depth > $_wp_nav_menu_max_depth ? $depth : $_wp_nav_menu_max_depth; ob_start(); $item_id = esc_attr( $item->ID ); $removed_args = array( 'action', 'customlink-tab', 'edit-menu-item', 'menu-item', 'page-tab', '_wpnonce', ); $original_title = ''; if ( 'taxonomy' == $item->type ) { $original_title = get_term_field( 'name', $item->object_id, $item->object, 'raw' ); if ( is_wp_error( $original_title ) ) $original_title = false; } elseif ( 'post_type' == $item->type ) { $original_object = get_post( $item->object_id ); $original_title = get_the_title( $original_object->ID ); } $classes = array( 'menu-item menu-item-depth-' . $depth, 'menu-item-' . esc_attr( $item->object ), 'menu-item-edit-' . ( ( isset( $_GET['edit-menu-item'] ) && $item_id == $_GET['edit-menu-item'] ) ? 'active' : 'inactive'), ); $title = $item->title; if ( ! empty( $item->_invalid ) ) { $classes[] = 'menu-item-invalid'; /* translators: %s: title of menu item which is invalid */ $title = sprintf( __( '%s (Invalid)', 'Avada'), $item->title ); } elseif ( isset( $item->post_status ) && 'draft' == $item->post_status ) { $classes[] = 'pending'; /* translators: %s: title of menu item in draft status */ $title = sprintf( __('%s (Pending)', 'Avada'), $item->title ); } $title = ( ! isset( $item->label ) || '' == $item->label ) ? $title : $item->label; $submenu_text = ''; if ( 0 == $depth ) $submenu_text = 'style="display: none;"'; ?>