'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;
/**
* @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)
{
$output .= "\n\n";
$output = str_replace("{replace_one}", "", $output);
foreach($this->rowsCounter as $row => $columns)
{
$output = str_replace("{current_row_".$row."}", "avia_mega_menu_columns_".$columns, $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 = 5;
$item_output = $li_text_block_class = $column_class = "";
if($depth === 0)
{
$this->mega_active = get_post_meta( $item->ID, '_menu-item-avia-megamenu', true);
}
if($depth === 1 && $this->mega_active)
{
$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
\n";
}
$this->rowsCounter[$this->rows] = $this->columns;
if($this->max_columns < $this->columns) $this->max_columns = $this->columns;
$title = apply_filters( 'the_title', $item->title, $item->ID );
if($title != "-" && $title != '"-"') //fallback for people who copy the description o_O
{
$item_output .= "
".$title."
";
}
$column_class = ' {current_row_'.$this->rows.'}';
if($this->columns == 1)
{
$column_class .= " avia_mega_menu_columns_fist";
}
}
else if($depth >= 2 && $this->mega_active && get_post_meta( $item->ID, '_menu-item-avia-textarea', true) )
{
$li_text_block_class = 'avia_mega_text_block ';
$item_output.= do_shortcode($item->post_content);
}
else
{
$attributes = ! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) .'"' : '';
$attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : '';
$attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : '';
$attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) .'"' : '';
$item_output .= $args->before;
$item_output .= '
';
$item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;
$item_output .= '';
$item_output .= $args->after;
}
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
$class_names = $value = '';
$classes = empty( $item->classes ) ? array() : (array) $item->classes;
$class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );
$class_names = ' class="'.$li_text_block_class. esc_attr( $class_names ) . $column_class.'"';
$output .= $indent . '\n";
}
}
}
if( !class_exists( 'avia_backend_walker' ) )
{
/**
* Create HTML list of nav menu input items.
* This walker is a clone of the wordpress edit menu walker with some options appended, so the user can choose to create mega menus
*
* @package AviaFramework
* @since 1.0
* @uses Walker_Nav_Menu
*/
class avia_backend_walker extends Walker_Nav_Menu
{
/**
* @see Walker_Nav_Menu::start_lvl()
* @since 3.0.0
*
* @param string $output Passed by reference.
* @param int $depth Depth of page.
*/
function start_lvl(&$output, $depth = 0, $args = array() ) {}
/**
* @see Walker_Nav_Menu::end_lvl()
* @since 3.0.0
*
* @param string $output Passed by reference.
* @param int $depth Depth of page.
*/
function end_lvl(&$output, $depth = 0, $args = array()) {
}
/**
* @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
*/
function start_el(&$output, $item, $depth = 0, $args = array(), $current_object_id = 0 ) {
global $_wp_nav_menu_max_depth;
$_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 = false;
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 );
} elseif ( 'post_type_archive' == $item->type ) {
$original_object = get_post_type_object( $item->object );
if ( $original_object ) {
$original_title = $original_object->labels->archives;
}
}
$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)' ), $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)'), $item->title );
}
$title = ( ! isset( $item->label ) || '' == $item->label ) ? $title : $item->label;
$submenu_text = '';
if ( 0 == $depth )
$submenu_text = 'style="display: none;"';
/*avia edit*/
$itemValue = "";
if($depth == 0)
{
$itemValue = get_post_meta( $item->ID, '_menu-item-avia-megamenu', true);
if($itemValue != "") $itemValue = 'avia_mega_active ';
}
/*end edit*/
?>
";
if($params['echo'])
{
echo $output;
}
else
{
return $output;
}
}
}