diff --git a/wp-admin/custom-navigation.php b/wp-admin/custom-navigation.php
index 96962bc9de..6c7937feea 100644
--- a/wp-admin/custom-navigation.php
+++ b/wp-admin/custom-navigation.php
@@ -64,7 +64,7 @@ function wp_custom_navigation() {
$menu_selected_id = 0;
// Default Menu to show
- $custom_menus = get_terms( 'menu', array( 'hide_empty' => false ) );
+ $custom_menus = get_terms( 'nav_menu', array( 'hide_empty' => false ) );
if ( !empty( $custom_menus ) )
$menu_selected_id = $custom_menus[0]->term_id;
@@ -94,13 +94,13 @@ function wp_custom_navigation() {
$insert_menu_name = $_POST['add_menu_name'];
if ( $insert_menu_name != '' ) {
- $existing_term = get_term_by( 'name', $insert_menu_name, 'menu' );
+ $existing_term = get_term_by( 'name', $insert_menu_name, 'nav_menu' );
if ( $existing_term ) {
- $messagesdiv = '
' . $insert_menu_name . ' Menu has already created - please try another name
';
+ $messagesdiv = '' . $existing_term->name . ' Menu has already created - please try another name
';
} else {
- $term = wp_insert_term( $insert_menu_name, 'menu' );
+ $term = wp_insert_term( $insert_menu_name, 'nav_menu' );
if ( !is_wp_error($term) ) {
- $term = get_term($term['term_id'], 'menu');
+ $term = get_term($term['term_id'], 'nav_menu');
$custom_menus[$term->term_id] = $term;
$menu_selected_id = $term->term_id;
$menu_id_in_edit = $menu_selected_id;
@@ -127,13 +127,13 @@ function wp_custom_navigation() {
$messagesdiv = ''.$themename.'s Custom Menu could not be RESET. Please try again.
';
}
} elseif ( $postCounter > 0 && $menu_selected_id > 0 ) {
- $menu_objects = get_objects_in_term( $menu_selected_id, 'menu' );
+ $menu_objects = get_objects_in_term( $menu_selected_id, 'nav_menu' );
$menu_items = wp_custom_navigation_get_menu_items( $menu_objects );
// Loop through all POST variables
for ( $k = 1; $k <= $postCounter; $k++ ) {
if (isset($_POST['dbid'.$k])) { $db_id = $_POST['dbid'.$k]; } else { $db_id = 0; }
- if (isset($_POST['postmenu'.$k])) { $post_id = $_POST['postmenu'.$k]; } else { $post_id = 0; }
+ if (isset($_POST['postmenu'.$k])) { $object_id = $_POST['postmenu'.$k]; } else { $object_id = 0; }
//@todo implement heirarchy
if (isset($_POST['parent'.$k])) { $parent_id = $_POST['parent'.$k]; } else { $parent_id = 0; }
if (isset($_POST['title'.$k])) { $custom_title = $_POST['title'.$k]; } else { $custom_title = ''; }
@@ -146,9 +146,9 @@ function wp_custom_navigation() {
if (isset($_POST['anchortitle'.$k])) { $custom_anchor_title = $_POST['anchortitle'.$k]; } else { $custom_anchor_title = $custom_title; }
if (isset($_POST['newwindow'.$k])) { $new_window = $_POST['newwindow'.$k]; } else { $new_window = 0; }
- $post = array( 'post_status' => 'publish', 'post_type' => 'menu_item', 'post_author' => $user_ID,
- 'ping_status' => 0, 'post_parent' => $post_id, 'menu_order' => $position,
- 'guid' => $custom_linkurl, 'post_excerpt' => $custom_anchor_title, 'tax_input' => array( 'menu' => $menu_title ),
+ $post = array( 'post_status' => 'publish', 'post_type' => 'nav_menu_item', 'post_author' => $user_ID,
+ 'ping_status' => 0, 'post_parent' => 0, 'menu_order' => $position,
+ 'guid' => $custom_linkurl, 'post_excerpt' => $custom_anchor_title, 'tax_input' => array( 'nav_menu' => $menu_title ),
'post_content' => $custom_description, 'post_title' => $custom_title );
if ( $new_window )
$post['post_content_filtered'] = '_blank';
@@ -157,13 +157,14 @@ function wp_custom_navigation() {
// New menu item
if ( $db_id == 0 ) {
- $db_id = $post_id = wp_insert_post( $post );
+ $db_id = wp_insert_post( $post );
} elseif ( isset( $menu_items[$db_id] ) ) {
$post['ID'] = $db_id;
wp_update_post( $post );
unset( $menu_items[$db_id] );
}
update_post_meta($db_id, 'menu_type', $linktype);
+ update_post_meta($db_id, 'object_id', $object_id);
}
if ( !empty( $menu_items ) ) {
foreach ( array_keys( $menu_items ) as $menu_id ) {
@@ -280,8 +281,8 @@ function wp_custom_navigation() {
term_id ) || ( $menu_selected_id == $menu->term_id ) )
$selected_option = 'selected="selected"';
else
diff --git a/wp-includes/custom-navigation.php b/wp-includes/custom-navigation.php
index 9e58a738f8..0932aa65ef 100644
--- a/wp-includes/custom-navigation.php
+++ b/wp-includes/custom-navigation.php
@@ -13,7 +13,7 @@
function wp_custom_navigation_get_menu_items( $menu_objects, $key = 'ID' ) {
$menu_items = array();
if ( !empty( $menu_objects ) && !empty( $key ) ) {
- $args = array( 'orderby' => 'menu_order', 'post_type' => 'menu_item', 'post_status' => 'publish' );
+ $args = array( 'orderby' => 'menu_order', 'post_type' => 'nav_menu_item', 'post_status' => 'publish' );
if ( count( $menu_objects ) > 1 )
$args['include'] = implode( ',', $menu_objects );
else
@@ -49,15 +49,15 @@ function wp_custom_navigation_setup($override = false) {
if(($nav_version_in_db <> $nav_version) || ($override))
update_option('wp_settings_custom_nav_version',$nav_version);
- $custom_menus = get_terms( 'menu', array( 'hide_empty' => false ) );
+ $custom_menus = get_terms( 'nav_menu', array( 'hide_empty' => false ) );
if ( !empty( $custom_menus ) ) {
foreach( $custom_menus as $menu ) {
- $menu_objects = get_objects_in_term( $menu->term_id, 'menu' );
+ $menu_objects = get_objects_in_term( $menu->term_id, 'nav_menu' );
if ( !empty( $menu_objects ) ) {
foreach( $menu_objects as $item )
wp_delete_post( $item );
}
- wp_delete_term( $menu->term_id, 'menu' );
+ wp_delete_term( $menu->term_id, 'nav_menu' );
}
}
@@ -101,35 +101,34 @@ function wp_custom_navigation_output($args = array()) {
extract($args);
}
- $menu_objects = get_objects_in_term( $id, 'menu' );
+ $menu_objects = get_objects_in_term( $id, 'nav_menu' );
$menu_items = wp_custom_navigation_get_menu_items( $menu_objects, 'menu_order' );
//Override for menu descriptions
$advanced_option_descriptions = get_option('wp_settings_custom_nav_advanced_options');
- if ($advanced_option_descriptions == 'no')
- {
+ if ( $advanced_option_descriptions == 'no' )
$desc = 2;
- }
$queried_id = 0;
global $wp_query;
if ( is_page() )
- $queried_id = $wp_query->post->ID;
+ $queried_id = $wp_query->get_queried_object_id();
elseif ( is_category() )
- $queried_id = $wp_query->query_vars['cat'];
- //DISPLAY Loop
- foreach ($menu_items as $menu_item) {
-
- //PREPARE Menu Data
- //Page Menu Item
- switch ( $menu_item->post_status ) {
- case 'menu-page':
- if ($menu_item->guid == '')
- $link = get_permalink( $menu_item->post_parent );
+ $queried_id = $wp_query->get_queried_object_id();
+ // Display Loop
+ foreach ( $menu_items as $menu_item ) {
+ $menu_type = get_post_meta($menu_item->ID, 'menu_type', true);
+ $object_id = get_post_meta($menu_item->ID, 'object_id', true);
+
+ switch ( $menu_type ) {
+ // Page Menu Item
+ case 'page':
+ if ( $menu_item->guid == '' )
+ $link = get_permalink( $object_id );
else
$link = $menu_item->guid;
if ( $menu_item->post_title == '' )
- $title = htmlentities( get_the_title( $menu_item->post_parent ) );
+ $title = htmlentities( get_the_title( $object_id ) );
else
$title = htmlentities( $menu_item->post_title );
@@ -139,28 +138,28 @@ function wp_custom_navigation_output($args = array()) {
$description = htmlentities( $menu_item->post_content );
$target = '';
break;
- //Category Menu Item
- case 'menu-category':
- if ($menu_item->guid == '')
- $link = get_category_link( $menu_item->post_parent );
+ // Category Menu Item
+ case 'category':
+ if ( $menu_item->guid == '' )
+ $link = get_category_link( $object_id );
else
$link = $menu_item->guid;
if ( $menu_item->post_title == '' ) {
- $title_raw = get_categories( 'include='.$menu_item->post_parent );
+ $title_raw = get_categories( array('include' => $object_id) );
$title = htmlentities($title_raw[0]->cat_name);
} else {
$title = htmlentities( $menu_item->post_title );
}
if ( $menu_item->post_content == '' )
- $description = htmlentities( strip_tags( category_description( $menu_item->post_parent ) ) );
+ $description = htmlentities( strip_tags( category_description( $object_id ) ) );
else
$description = htmlentities( $menu_item->post_content );
$target = '';
break;
default:
- //Custom Menu Item
+ // Custom Menu Item
$link = $menu_item->guid;
$title = htmlentities( $menu_item->post_title );
$description = htmlentities( $menu_item->post_content );
@@ -192,16 +191,14 @@ function wp_custom_navigation_output($args = array()) {
}
}
*/
- //List Items
+ // List Items
?>