'menu_item_parent', 'id' => 'db_id' ); var $columns = 0; var $max_columns = 0; var $index = 0; var $rows = 1; var $main_index = 0; var $rowsCounter = array(); var $mega_active = 0; var $bg_type = 'background'; var $column_hide = ""; function start_lvl(&$output, $depth = 0, $args = array() ) { $indent = str_repeat("\t", $depth); if($depth === 0) $output .= "\n{replace_one}\n"; $class = ''; if($depth == 0 && !$this->mega_active) $class = 'non_mega_menu'; $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."}", "cl-header__menu__megamenu__col", $output); } $this->columns = 0; $this->max_columns = 0; $this->rowsCounter = array(); } else { $output = str_replace("{replace_one}", "", $output); } } } function start_el(&$output, $item, $depth = 0, $args = array(), $current_object_id = 0) { global $wp_query; $this->index++; //set maxcolumns $extra_html = ''; if(!isset($args->max_columns)) $args->max_columns = 6; $item_output = $li_text_block_class = $column_class = ""; $bg_img = ''; if($depth === 0) { $this->mega_active = get_post_meta( $item->ID, '_menu-item-custom_codeless-megamenu', true); $bg = get_post_meta( $item->ID, '_menu-item-custom_codeless-megamenu_bg', true); $this->bg_type = get_post_meta( $item->ID, '_menu-item-custom_codeless-bg_type', true); $this->background_image = get_post_meta( $item->ID, '_menu-item-custom_codeless-megamenu_bg', true); if( empty($this->bg_type) ) $this->bg_type = 'background'; if(!empty($bg) ) $bg_img = $bg; } if($depth === 1 && $this->mega_active) { $this->columns ++; $column_hide = get_post_meta( $item->ID, '_menu-item-custom_codeless-column_hide', true); //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) { $this->columns = 1; } $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( $column_hide != '' ){ $column_class .= ' hide-column'; if( $this->bg_type == 'column' ) $extra_html = ''.esc_attr__('Column BG', 'aronia').''; } if($this->columns == 1) { $column_class .= " codeless_custom_menu_first_col"; } } 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 ) .'"' : ''; $attributes .= ! empty( $cl_item_classes ) ? ' class="' . esc_attr( $cl_item_classes ) .'"' : ''; $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 = ''; $animation_delay = $animation_speed = ''; $classes = empty( $item->classes ) ? array() : (array) $item->classes; if( $depth === 0 ){ $this->main_index++; if( codeless_get_from_element( 'cl_menu_start', false ) ){ $classes[] = codeless_get_mod( 'menu_items_animation', 'none' ); $classes[] = codeless_get_mod( 'menu_items_animation', 'none' ) == 'none' ? '' : 'cl-animate-on-visible'; } if( codeless_get_mod( 'menu_items_animation', 'none' ) != 'none' && codeless_get_from_element( 'cl_menu_start', false ) ){ $animation_delay = 'data-delay="'.( (int) 100 *$this->main_index).'"'; $animation_speed = 'data-speed="300"'; } } $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( 'codeless_custom_menu_backend' ) ) { /** * Navigation Menu API: Walker_Nav_Menu_Edit class * * @package WordPress * @subpackage Administration * @since 4.4.0 */ /** * Create HTML list of nav menu input items. * * @since 3.0.0 * * @see Walker_Nav_Menu */ class codeless_custom_menu_backend 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. */ public 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. */ public function end_lvl( &$output, $depth = 0, $args = array() ) {} /** * Start the element output. * * @see Walker_Nav_Menu::start_el() * @since 3.0.0 * * @global int $_wp_nav_menu_max_depth * * @param string $output Used to append additional content (passed by reference). * @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. */ public function start_el( &$output, $item, $depth = 0, $args = array(), $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; // Added By Codeless $indent = ( $depth ) ? str_repeat( "\t", $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( esc_html__( '%s (Invalid)', 'aronia' ), $item->title ); } elseif ( isset( $item->post_status ) && 'draft' == $item->post_status ) { $classes[] = 'pending'; /* translators: %s: title of menu item in draft status */ $title = sprintf( esc_html__('%s (Pending)', 'aronia'), $item->title ); } $title = ( ! isset( $item->label ) || '' == $item->label ) ? $title : $item->label; // Added By Codeless $itemValue = ""; if($depth == 0) { $itemValue = get_post_meta( $item->ID, '_menu-item-custom_codeless-megamenu', true); if($itemValue != "") $itemValue = 'codeless_custom_active '; } $submenu_text = ''; if ( 0 == $depth ) $submenu_text = 'style="display: none;"'; ?>