'menu_item_parent', 'id' => 'db_id' ); /** * @var int $columns */ var $columns = 0; /** * @var int $max_columns maximum number of columns within one mega menu */ var $max_columns = 0; /** * @var int $rows holds the number of rows within the mega menu */ var $rows = 1; /** * @var array $rowsCounter holds the number of columns for each row within a multidimensional array */ var $rowsCounter = array(); /** * @var string $mega_active hold information whetever we are currently rendering a mega menu or not */ var $mega_active = 0; /** * @var array $grid_array holds the grid classes that get applied to the mega menu depending on the number of columns */ var $grid_array = array(); /** * @var stores if we already have an active first level main menu item. */ var $active_item = false; /** * @var stores if we got a top or a sidebar main menu. */ var $top_menu = true; /** * @var stores if we got a text menu or a single burger icon */ var $icon_menu = true; /** * @var stores if we got a top or a sidebar main menu. */ var $blog_id = false; /** * @var stores the number of first level menu items */ var $first_level_count = 0; /** * @var stores if mega menu is active */ var $mega_allowed = true; /** * * Constructor that sets the grid variables * */ function __construct($options = array()) { $this->grid_array = array( 1 => "three units", 2 => "six units", 3 => "nine units", 4 => "twelve units", 5 => "twelve units", 6 => "twelve units" ); $this->top_menu = avia_get_option('header_position','header_top') == 'header_top' ? true : false; $this->icon_menu = avia_is_burger_menu(); if(avia_get_option('frontpage') && avia_get_option('blogpage')) { $this->blog_id = avia_get_option('blogpage'); } if(isset($options['megamenu']) && $options['megamenu'] == "disabled") $this->mega_allowed = false; if($this->icon_menu) { //$this->mega_active = false; //$this->mega_allowed = false; } } /** * @see Walker::start_lvl() * * @param string $output Passed by reference. Used to append additional content. * @param int $depth Depth of page. Used for padding. */ function start_lvl(&$output, $depth = 0, $args = array()) { $indent = str_repeat("\t", $depth); if($depth === 0) $output .= "\n{replace_one}\n"; $output .= "\n$indent\n"; if($depth === 0) { if($this->mega_active && $this->mega_allowed) { $output .= "\n\n"; $output = str_replace("{replace_one}", "
", $output); $output = str_replace("{last_item}", "avia_mega_menu_columns_last", $output); foreach($this->rowsCounter as $row => $columns) { $output = str_replace("{current_row_".$row."}", "avia_mega_menu_columns_".$columns." ".$this->grid_array[1], $output); } $this->columns = 0; $this->max_columns = 0; $this->rowsCounter = array(); } else { $output = str_replace("{replace_one}", "", $output); } } } /** * @see Walker::start_el() * * @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 */ function start_el(&$output, $item, $depth = 0, $args = array(), $current_object_id = 0 ) { global $wp_query; //set maxcolumns if(!isset($args->max_columns)) $args->max_columns = 6; $item = apply_filters( 'avf_menu_items' , $item ); $item_output = $li_text_block_class = $column_class = ""; if($depth === 0) { $this->first_level_count ++; $this->mega_active = get_post_meta( $item->ID, '_menu-item-avia-megamenu', true); $style = get_post_meta( $item->ID, '_menu-item-avia-style', true); } if(!empty($item->url) && strpos($item->url, "[domain]") !== false) { $replace = str_replace( "http://", "", get_home_url() ); $replace = str_replace( "https://", "", $replace ); $item->url = str_replace( "[domain]", $replace, $item->url); } if($depth === 1 && $this->mega_active && $this->mega_allowed) { $this->columns ++; //check if we have more than $args['max_columns'] columns or if the user wants to start a new row if($this->columns > $args->max_columns || (get_post_meta( $item->ID, '_menu-item-avia-division', true) && $this->columns != 1)) { $this->columns = 1; $this->rows ++; $output .= "\n