menutype = get_post_meta( $menu_item->ID, '_menu_item_menutype', true ); return $menu_item; } /* add custom menu fields to menu */ add_filter( 'wp_setup_nav_menu_item', 'ut_add_custom_nav_fields' ); } /* |-------------------------------------------------------------------------- | Update Iconclass Custom Field |-------------------------------------------------------------------------- */ if ( !function_exists( 'ut_update_custom_nav_fields' ) ) { function ut_update_custom_nav_fields( $menu_id, $menu_item_db_id, $args ) { if ( isset($_REQUEST['menu-item-menutype']) && is_array( $_REQUEST['menu-item-menutype']) ) { $menutypeclass_value = $_REQUEST['menu-item-menutype'][$menu_item_db_id]; update_post_meta( $menu_item_db_id, '_menu_item_menutype', $menutypeclass_value ); } } /* save menu custom fields */ add_action( 'wp_update_nav_menu_item', 'ut_update_custom_nav_fields' , 10 , 3 ); } /* |-------------------------------------------------------------------------- | Edit Menutype Custom Field |-------------------------------------------------------------------------- */ if ( !function_exists( 'ut_edit_walker' ) ) { function ut_edit_walker( $walker , $menu_id ) { return 'Walker_Nav_Menu_Edit_Custom'; } /* edit menu walker */ add_filter( 'wp_edit_nav_menu_walker', 'ut_edit_walker' , 10 , 2 ); } /* |-------------------------------------------------------------------------- | Enhance "Appearance" => "Menus" |-------------------------------------------------------------------------- */ class Walker_Nav_Menu_Edit_Custom extends Walker_Nav_Menu { /** * @see Walker_Nav_Menu::start_lvl() * @since 3.0.0 * * @param string $output Passed by reference. */ function start_lvl( &$output, $depth = 0, $args = array() ) { } /** * @see Walker_Nav_Menu::end_lvl() * @since 3.0.0 * * @param string $output Passed by reference. */ 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 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; $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 = ''; 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 = $original_object->post_title; } $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)' , 'unitedthemes' ), $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)' , 'unitedthemes' ), $item->title ); } $title = empty( $item->label ) ? $title : $item->label; ?>