array( 'label'=>esc_html__('Enable Megamenu','bigc'), 'type'=>'checkbox', 'depth'=>0, ), 'new_label'=>array( 'label'=>esc_html__('New label','bigc'), 'type'=>'text', 'depth'=>0, ), 'hot_label'=>array( 'label'=>esc_html__('Hot label','bigc'), 'type'=>'text', 'depth'=>0, ), 'icon_menu1'=>array( 'label'=>esc_html__('Icon Menu','bigc'), 'type'=>'text', 'depth'=>1, 'class'=>'sv_iconpicker', ), 'icon_menu2'=>array( 'label'=>esc_html__('Icon Menu','bigc'), 'type'=>'text', 'depth'=>2, 'class'=>'sv_iconpicker', ), 'content1'=>array( 'label'=>esc_html__('Content','bigc'), 'type'=>'text_html', 'depth'=>1, ), 'content2'=>array( 'label'=>esc_html__('Content','bigc'), 'type'=>'text_html', 'depth'=>2, ), 'col_size'=>array( 'label'=>esc_html__('Column Size','bigc'), 'type'=>'select', 'choices'=>array( 0 =>esc_html__('-- Select --','bigc'), 1 =>'1/12', 2 =>'2/12', 3 =>'3/12', 4 =>'4/12', 5 =>'5/12', 6 =>'6/12', 7 =>'7/12', 8 =>'8/12', 9 =>'9/12', 10 =>'10/12', 11 =>'11/12', 12 =>'12/12' ), 'depth' =>1 ) ); //add menu custom fields add_filter( 'wp_setup_nav_menu_item', array( __CLASS__, 'add_custom_menu_fields' ) ); //Add walker add_filter( 'wp_edit_nav_menu_walker', array( __CLASS__, 'add_menu_custom_walker'),10,2 ); // save menu custom fields add_action( 'wp_update_nav_menu_item', array( __CLASS__, 'save_custom_menu_fields'), 10, 3 ); //add_action( 'admin_enqueue_scripts', array(__CLASS__,'_add_scripts')); } static function _add_scripts() { $screen=get_current_screen(); if($screen->base=='nav-menus') { wp_register_script( 'st-jspicker', get_template_directory_uri().'/js/colpick.js', array( 'jquery' ),'', true ); wp_enqueue_script('st-jspicker'); wp_register_script( 'st-custompicker', get_template_directory_uri().'/js/custompicker.js', array( 'jquery' ),'', true ); wp_enqueue_script('st-custompicker'); wp_enqueue_style( 'st-colorpicker', get_template_directory_uri().'/css/colpick.css' ); } } static function add_custom_menu_fields($item) { // if(!empty(self::$allFields)) { foreach(self::$allFields as $key=>$value) { $item->$key=get_post_meta($item->ID,$key,TRUE); } } return $item; } static function save_custom_menu_fields($menu_id, $menu_item_db_id, $args ) { if(!empty(self::$allFields)) { foreach(self::$allFields as $key=>$value) { if(isset($_REQUEST[$key][$menu_item_db_id])) { $data=$_REQUEST[$key][$menu_item_db_id]; update_post_meta( $menu_item_db_id, $key, $data ); // if($data == '1' || $data == 1) update_post_meta( $menu_item_db_id, 'enable_megamenu123', '' ); }elseif(isset($args[$key])) { $data=$args[$key]; update_post_meta( $menu_item_db_id, $key, $data ); // if($data == '1' || $data == 1) update_post_meta( $menu_item_db_id, 'enable_megamenu123', '' ); } if($value['type']=='checkbox') { if(!isset($_REQUEST[$key][$menu_item_db_id])) { delete_post_meta($menu_item_db_id,$key); } } } } } static function add_menu_custom_walker() { return 'STWalkerNavMenu'; } static function AdminAddFields($item, $d=0) { if(!empty(self::$allFields)) { foreach(self::$allFields as $key=>$value) { $default=array( 'type' =>'', 'class' =>"", 'compare'=>'', 'min_depth' =>'', 'depth' =>'' ); $value=wp_parse_args($value,$default); if($value['min_depth'] and $d<$value['min_depth']){ continue; } if($value['depth']!=='' and $d!=$value['depth']){ continue; } $func='_field_type_'.$value['type']; if(method_exists(__CLASS__,$func)){ self::$func($item,$key,$value,$d); } } } } // ======================================================================= // Field helper /* * * * */ static function _field_type_text($item,$key,$value,$d=0){ $item_id=esc_attr( $item->ID ); $item_value=get_post_meta($item_id,$key,true); ?>

ID ); $item_value=get_post_meta($item_id,$key,true); $name = $key.'['. $item_id.']'; $wp_editor_settings = array( 'wpautop' => false, 'textarea_rows' => 5, // 'tinymce' => array( 'plugins' => 'wordpress' ), 'textarea_name' => $name, // 'media_buttons' => true, // // 'editor_class' => 'st_editor_class', ); ?>
ID ); $default=array( 'type' =>'checkbox', 'class' =>"", 'depth'=>'', 'label'=>'' ); $value=wp_parse_args($value,$default); if($value['depth'] and $d>$value['depth']) return; $item_id=esc_attr( $item->ID ); $item_value=get_post_meta($item_id,'enable_megamenu123',true); if($item_value){ update_post_meta( $item_id, 'enable_megamenu', '1' ); update_post_meta( $item_id, 'enable_megamenu123', '' ); } ?>

'select', 'class' =>"", 'choices'=>array() ); $value=wp_parse_args($value,$default); $item_id=esc_attr( $item->ID ); ?>

$_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 = ''; 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 ); } $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)' ,'bigc'), $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)','bigc'), $item->title ); } $title = ( ! isset( $item->label ) || '' == $item->label ) ? $title : $item->label; $submenu_text = ''; if ( 0 == $depth ) $submenu_text = 'display: none;'; ?>