%PDF- %PDF-
Direktori : /var/www/html/shaban/laviva/wp-content/themes/levelup/inc/nav_menu/ |
Current File : /var/www/html/shaban/laviva/wp-content/themes/levelup/inc/nav_menu/rdy_menu.php |
<?php class levelup_custom_menu { function __construct() { // add custom menu fields to menu add_filter( 'wp_setup_nav_menu_item', array( $this, 'rdy_add_custom_nav_fields' ) ); // save menu custom fields add_action( 'wp_update_nav_menu_item', array( $this, 'rdy_update_custom_nav_fields'), 10, 3 ); // edit menu walker add_filter( 'wp_edit_nav_menu_walker', array( $this, 'rdy_edit_walker'), 10, 2 ); } function rdy_add_custom_nav_fields( $menu_item ) { $menu_item->icon = get_post_meta( $menu_item->ID, '_menu_item_icon', true ); $menu_item->onlytitle = get_post_meta( $menu_item->ID, '_menu_item_onlytitle', true ); $menu_item->sidebar = get_post_meta( $menu_item->ID, '_menu_item_sidebar', true ); $menu_item->linkcolor = get_post_meta( $menu_item->ID, '_menu_item_linkcolor', true ); $menu_item->blank = get_post_meta( $menu_item->ID, '_menu_item_blank', true ); return $menu_item; } function rdy_update_custom_nav_fields( $menu_id, $menu_item_db_id, $args ) { $enable_item_blank = isset($_REQUEST['menu-item-blank'], $_REQUEST['menu-item-blank'][$menu_item_db_id]); update_post_meta( $menu_item_db_id, '_menu_item_blank', $enable_item_blank ); if ( isset( $_REQUEST['menu-item-icon'][$menu_item_db_id]) ) { $icon_value = $_REQUEST['menu-item-icon'][$menu_item_db_id]; update_post_meta( $menu_item_db_id, '_menu_item_icon', esc_attr( $icon_value ) ); } if ( isset( $_REQUEST['menu-item-onlytitle'][$menu_item_db_id] ) ) { $value = $_REQUEST['menu-item-onlytitle'][$menu_item_db_id]; update_post_meta( $menu_item_db_id, '_menu_item_onlytitle', esc_attr( $value ) ); }else{ update_post_meta( $menu_item_db_id, '_menu_item_onlytitle', 0 ); } if ( isset( $_REQUEST['menu-item-sidebar'][$menu_item_db_id]) ) { $sidebar_value = $_REQUEST['menu-item-sidebar'][$menu_item_db_id]; update_post_meta( $menu_item_db_id, '_menu_item_sidebar', esc_attr( $sidebar_value ) ); } if ( isset( $_REQUEST['menu-item-linkcolor'][$menu_item_db_id]) ) { $link_value = $_REQUEST['menu-item-linkcolor'][$menu_item_db_id]; update_post_meta( $menu_item_db_id, '_menu_item_linkcolor', esc_attr( $link_value ) ); } } function rdy_edit_walker($walker,$menu_id) { return 'Levelup_Walker_Nav_Menu_Edit'; } } // instantiate plugin's class $levelup_custom_menu = new levelup_custom_menu(); require_once LEVELUP_TEMPLATE_PATH . '/inc/nav_menu/edit_custom_walker.php'; require_once LEVELUP_TEMPLATE_PATH . '/inc/nav_menu/mega-menu.class.php'; $mega_menu = new Levelup_Mega_menu(); if (!class_exists( 'levelup_main_walker_nav_menu' )) { class levelup_main_walker_nav_menu extends Walker_Nav_Menu { private $rdy_is_first = true; private $rdy_fat_menu = false; public function start_lvl( &$output, $depth = 0, $args = array() ) { // if ( levelup_get_options( 'header-layout' ) == 'gamburg_full' && $depth != 0 ) { // return; // } $this->rdy_is_first = true; $style = ''; if($depth === 0 && $this->megamenu_enabled) { $style .= ! empty( $this->megamenu_background ) ? ( 'background-image:url(' . esc_url( $this->megamenu_background ) . ');' ) : ''; $style .= ! empty( $this->megamenu_styles ) ? esc_attr( $this->megamenu_styles ) : ''; } $out_div = ''; $indent = str_repeat("\t", $depth); // if ( levelup_get_options( 'header-layout' ) != 'gamburg_full' ) { $out_div = '<ul class="sub-menu" style="' . esc_attr( $style ) . '">'; // } $output .= "\n" . $indent . $out_div . '' . "\n"; } public function end_lvl( &$output, $depth = 0, $args = array() ) { // if ( levelup_get_options( 'header-layout' ) == 'gamburg_full' && $depth != 0 ) { // return; // } $this->rdy_is_first = false; $out_div_close = ''; $indent = str_repeat("\t", $depth); // if ( levelup_get_options( 'header-layout' ) != 'gamburg_full' ) { $out_div_close = '</ul>'; // } $output .= $indent . $out_div_close . "\n"; } // add main/sub classes to li's and links public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { global $wp_query; global $levelup_options; $args = (object) $args; $onlytitle_allow_d0 = false; $columns_enable = false; $has_children = isset( $args->walker->has_children ) && $args->walker->has_children ? true : false; // if( $levelup_options['header-layout'] == 'gamburg_full' && $depth != 0){ // return; // } $this->megamenu_enabled = get_post_meta( $item->ID, '_menu_item_rdy_mega_menu_enabled', true ); $this->megamenu_background = esc_url( get_post_meta( $item->ID, '_menu_item_rdy_mega_menu_background', true ) ); $this->megamenu_styles = esc_attr( get_post_meta( $item->ID, '_menu_item_rdy_mega_menu_styles', true ) ); $sub = ""; $indent = ( $depth > 0 ? str_repeat( "\t", $depth ) : '' ); // code indent if ( $depth == 0 && $has_children ) { $sub = ' has_sub'; } if ( $depth == 1 && $has_children ) { $sub = 'sub'; } $active = ""; // depth dependent classes if ( ( ( $item->current && $depth == 0 ) || ( $item->current_item_ancestor && $depth == 0 ) ) ) { $active = 'active'; } // passed classes $classes = empty( $item->classes ) ? array() : (array) $item->classes; $class_names = esc_attr( implode( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) ) ); if ( 0 == $depth ) { if ( ! empty( $item->rdy_mega_menu_enabled ) ) { $this->rdy_fat_menu = true; } else { $this->rdy_fat_menu = false; } } if ( $this->rdy_fat_menu ) { if ( 0 == $depth ) { $class_names .= ' wide megamenu'; if ( !empty($item->rdy_mega_menu_fullwidth) ) { $class_names .= ' mega-full-width'; } else { $class_names .= ' mega-auto-width'; } } else if ( 1 == $depth ) { $class_names .= ' rdy-mega-parent'; if ( !empty($item->rdy_mega_menu_new_row) ) { $class_names .= ' new-row'; } } else if ( 2 == $depth ) { if ( !empty($item->rdy_mega_menu_new_column) ) { $this->rdy_is_first = true; } } } $menu_type = ""; $wide_menu_position = ""; if ( $depth == 0 ) { if ( $item->wide_position == "right" ) { $wide_menu_position = " right_position"; } elseif ( $item->wide_position == "left" ) { $wide_menu_position = " left_position"; } else { $wide_menu_position = ""; } } $anchor = ''; if ( $item->anchor != "" ) { $anchor = '#' . esc_attr( $item->anchor ); $class_names .= ' anchor-item'; } $class_names .= ' menu-depth-' . $depth; if ( ! ( $this->rdy_fat_menu && ! $item->onlytitle && $depth == 1 ) ) { if ( $depth != 0 ) { if ( $item->onlytitle ) { $class_names .= ' menu-is-title'; } } } // build html $output .= $indent . '<li id="nav-menu-item-'. $item->ID . '" class="' . esc_attr( $class_names . ' ' . $active . $sub . $menu_type . $wide_menu_position ) . '">'; $current_a = ""; // link attributes $attributes = ! empty( $item->attr_title ) ? ' title="' . esc_attr( apply_filters('levelup_menu_attr_title', $item->attr_title) ) .'"' : ''; $attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : ''; $attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : ''; $attributes .= ' href="' . esc_attr( $item->url ) . $anchor . '"'; if ( ( $item->current && $depth == 0 ) || ( $item->current_item_ancestor && $depth == 0 ) ) { $current_a .= ' current '; } $attributes .= ' class="' . esc_attr( $current_a ) . '"'; $linkcolor_style = ''; if ( $item->linkcolor ) { $linkcolor_style = ' style="color: ' . esc_attr( $item->linkcolor ) . '"'; $attributes .= $linkcolor_style; } if ( $item->blank ) { $attributes .= ' target="_blank"'; } $item_output = ''; $item_output = $args->before; if ( ( levelup_get_options( 'header-layout' ) == 'gamburg' || levelup_get_options( 'header-layout' ) == 'static' ) && levelup_get_options( 'header-style-menu-columns' ) ) { $onlytitle_allow_d0 = true; $columns_enable = true; } if ( ! ( $this->rdy_fat_menu && ! $item->onlytitle && $depth == 1 ) ) { if ( $depth == 0 ) { if ( $onlytitle_allow_d0 && $item->onlytitle ) { $item_output .= '<p class="title"' . $linkcolor_style . '>'; } else { $item_output .= '<a' . $attributes . '>'; } } elseif ( $depth != 0 ) { if ( $item->onlytitle ) { $item_output .= '<p class="title"' . $linkcolor_style . '>'; } else { $item_output .= '<a' . $attributes . '>'; } } if ( $item->icon != "" ) { $icon = esc_attr( $item->icon ); } else { $icon = ""; } $dropdown = ''; if ( $has_children && $depth == 0 && ! $columns_enable ) { if ( $levelup_options['menu-angle-down-enable'] ) { $dropdown = '<em class="fa-sub-indicator"><i class="fa fa-angle-down"></i></em>'; } } if ( $has_children && $depth != 0 && ! $columns_enable && levelup_get_options( 'header-layout' ) != 'gamburg_full' ) { $dropdown = '<em class="fa-sub-indicator"><i class="fa fa-angle-right"></i></em>'; } if ( $icon ) { $item_output .= '<i class="menu_icon fa ' . esc_attr( $icon ) . '"></i>'; } $item_output .= '<span>' . apply_filters( 'the_title', $item->title, $item->ID ) . $dropdown . '</span>'; if ( $depth == 0 ) { if ( $onlytitle_allow_d0 && $item->onlytitle ) { $item_output .= '</p>'; } else { $item_output .= '</a>'; } } elseif ( $depth != 0 ) { if ( $item->onlytitle ) { $item_output .= '</p>'; } else { $item_output .= '</a>'; } } } if($item->sidebar != "" && $depth > 0){ ob_start(); dynamic_sidebar($item->sidebar); $sidebar_content = ob_get_contents(); ob_end_clean(); $item_output .= $sidebar_content; } $item_output .= $args->after; // build html $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args ); } public function end_el( &$output, $item, $depth = 0, $args = array() ) { global $levelup_options; if( $levelup_options['header-layout'] == 'gamburg_full' && $depth != 0){ return; } $output .= "</li>\n"; } } } if (!class_exists( 'levelup_mobile_walker_nav_menu' )) { class levelup_mobile_walker_nav_menu extends Walker_Nav_Menu { public function start_lvl( &$output, $depth = 0, $args = array() ) { $out_div = ''; $indent = str_repeat("\t", $depth); $out_div = '<ul class="sub-menu">'; $output .= "\n" . $indent . $out_div . '' . "\n"; } public function end_lvl( &$output, $depth = 0, $args = array() ) { $out_div = ''; $indent = str_repeat("\t", $depth); $out_div_close = '</ul>'; $output .= $indent . $out_div_close . "\n"; } // add main/sub classes to li's and links public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { global $wp_query; $args = (object) $args; $has_children = isset( $args->walker->has_children ) && $args->walker->has_children ? true : false; $sub = ""; $expand = ""; $indent = ( $depth > 0 ? str_repeat( "\t", $depth ) : '' ); // code indent if ( $has_children ) { $expand = ( levelup_get_options( 'mobile_menu-expand-touch' ) ? ' expand' : '' ); } if ( $depth == 0 && $has_children ) { $sub = ' has_sub' . $expand; } if ( $depth == 1 && $has_children ) { $sub = 'sub' . $expand; } $active = ""; // depth dependent classes if ( ( ( $item->current && $depth == 0 ) || ( $item->current_item_ancestor && $depth == 0 ) ) ) { $active = 'active'; } // passed classes $classes = empty( $item->classes ) ? array() : (array) $item->classes; $class_names = esc_attr( implode( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) ) ); //menu type class $menu_type = ""; if ( $depth == 0 ) { $menu_type = " narrow"; } //wide menu position class $wide_menu_position = ""; if ( $depth == 0 ) { if ( $item->wide_position == "right" ) { $wide_menu_position = " right_position"; } elseif ( $item->wide_position == "left" ) { $wide_menu_position = " left_position"; } else { $wide_menu_position = ""; } } $anchor = ''; if ( $item->anchor != "" ) { $anchor = '#' . esc_attr( $item->anchor ); $class_names .= ' anchor-item'; } if ( isset( $args->walker->has_children ) && ( $item->anchor == '' || $item->anchor == '#' ) ) { $class_names .= ' open-item'; } // build html $output .= $indent . '<li id="mnav-menu-item-' . $item->ID . '" class="' . esc_attr( $class_names . ' ' . $active . $sub . $menu_type . $wide_menu_position ) . '">'; $current_a = ""; // link attributes $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 .= ' href="' . esc_attr( $item->url ) . $anchor . '"'; if ( ( $item->current && $depth == 0 ) || ( $item->current_item_ancestor && $depth == 0 ) ) { $current_a .= ' current '; } $no_link_class = ''; if ( $item->onlytitle ) { $no_link_class = ' title '; } $attributes .= ' class="' . esc_attr( $current_a . $no_link_class ) . '"'; $item_output = ''; $item_output = $args->before; $item_output .= '<a'. $attributes .'>'; //append arrow for dropdown $dropdown = ''; $item_output .= '<span>' . apply_filters( 'the_title', $item->title, $item->ID ) . $dropdown . '</span>'; $item_output .= '</a>'; if ( $item->sidebar != "" && $depth > 0 ) { ob_start(); dynamic_sidebar( $item->sidebar ); $sidebar_content = ob_get_contents(); ob_end_clean(); $item_output .= $sidebar_content; } $item_output .= $args->after; // build html $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args ); } } }