Various bug fixes and improvements to menu management. props ptahdunbar, see #11817.

git-svn-id: http://svn.automattic.com/wordpress/trunk@13802 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
nacin 2010-03-22 19:56:16 +00:00
parent 308c876d27
commit ba6f1cba07
15 changed files with 932 additions and 748 deletions

View File

@ -1004,7 +1004,7 @@ case 'closed-postboxes' :
update_user_option($user->ID, "closedpostboxes_$page", $closed); update_user_option($user->ID, "closedpostboxes_$page", $closed);
if ( is_array($hidden) ) { if ( is_array($hidden) ) {
$hidden = array_diff( $hidden, array('submitdiv', 'linksubmitdiv') ); // postboxes that are always shown $hidden = array_diff( $hidden, array('submitdiv', 'linksubmitdiv', 'manage-menu', 'create-menu') ); // postboxes that are always shown
update_user_option($user->ID, "meta-box-hidden_$page", $hidden); update_user_option($user->ID, "meta-box-hidden_$page", $hidden);
} }
@ -1395,6 +1395,33 @@ case 'set-post-thumbnail':
} }
} }
die( '0' ); die( '0' );
case 'save-custom-link':
if ( ! current_user_can('manage_links') )
die('-1');
$link_name = isset( $_POST['link_name'] ) ? esc_html($_POST['link_name']) : null;
$link_url = isset( $_POST['link_url'] ) ? esc_url_raw($_POST['link_url']) : null;
if ( !$link_name || !$link_url )
die('-1');
$post = array(
'post_status' => 'draft', 'post_type' => 'nav_menu_item', 'ping_status' => 0,
'post_author' => $user_ID, 'post_title' => $link_name, 'post_excerpt' => '',
'post_parent' => 0, 'menu_order' => 0, 'post_content' => '',
);
$link_id = wp_insert_post( $post );
update_post_meta( $link_id, '_menu_item_type', 'custom' );
update_post_meta( $link_id, '_menu_item_object_id', (int) $link_id );
update_post_meta( $link_id, '_menu_item_object', 'custom' );
update_post_meta( $link_id, '_menu_item_target', '_self' );
update_post_meta( $link_id, '_menu_item_classes', '' );
update_post_meta( $link_id, '_menu_item_xfn', '' );
update_post_meta( $link_id, '_menu_item_url', $link_url );
die( json_encode($link_id) );
default : default :
do_action( 'wp_ajax_' . $_POST['action'] ); do_action( 'wp_ajax_' . $_POST['action'] );
die('0'); die('0');

View File

@ -1 +1 @@
#menu-management{clear:both;}#menu-management .inside{padding:0 10px;}#menu-container .submit{margin:0 0 10px;padding:0;}.submitdelete{font-size:11px;}#cancel-save{color:#f00;text-decoration:underline;font-size:11px;margin-left:20px;margin-top:5px;}#cancel-save:hover{background-color:#F00;color:#fff;}.button-controls{float:left;}.add-to-menu{float:right;}#manage-menu .inside{padding:0;}#create-menu-name{width:159px;}#available-links{margin:15px 0 0;}#available-links dt{display:block;}#add-custom-link .howto{font-size:11px;}#add-custom-link label span{display:block;float:left;margin-top:5px;padding-right:5px;}.menu-item-textbox{float:right;width:220px;}.howto span{margin-top:4px;display:block;float:left;}.show-all,.hide-all{cursor:pointer;}.hide-all{display:none;}.quick-search{width:190px;}.list-wrap{display:none;clear:both;}.list-container{max-height:200px;overflow-y:auto;padding:10px 10px 5px;border:1px solid #DFDFDF;-moz-border-radius:4px;}.postbox p.submit{margin-bottom:0;}.list li{display:none;margin:0;margin-bottom:5px;}.list li .menu-item-title{cursor:pointer;display:block;}.list li .menu-item-title input{margin-right:3px;margin-top:-3px;}.list li ul li .menu-item-title{margin-left:14px;}.list li ul li ul li .menu-item-title{margin-left:28px;}.list li ul li ul li ul li .menu-item-title{margin-left:42px;}.list li ul li ul li ul li ul li .menu-item-title{margin-left:56px;}.list li ul li ul li ul li ul li ul li .menu-item-title{margin-left:70px;}.list li ul li ul li ul li ul li ul li ul li .menu-item-title{margin-left:84px;}.list li ul li ul li ul li ul li ul li ul li ul li .menu-item-title{margin-left:98px;}.list li ul li ul li ul li ul li ul li ul li ul li ul li .menu-item-title{margin-left:112px;}#menu-container .inside{padding-bottom:10px;}.menu ul{width:100%;}.menu li{margin:0;}.menu li dl dt{-webkit-border-bottom-left-radius:6px;-webkit-border-bottom-right-radius:6px;-webkit-border-top-left-radius:6px;-webkit-border-top-right-radius:6px;border-bottom-left-radius:6px;border-bottom-right-radius:6px;border-top-left-radius:6px;border-top-right-radius:6px;-moz-border-radius-bottomleft:6px;-moz-border-radius-bottomright:6px;-moz-border-radius-topleft:6px;-moz-border-radius-topright:6px;border:1px solid #E6E6E6;position:relative;padding-left:10px;background-color:#f1f1f1;height:35px;line-height:35px;}.menu li dl dt:hover{cursor:move;}.menu li ul li{margin-left:20px;opacity:.7;}.menu li ul li ul li{opacity:.9;}.menu li ul li ul li ul li{opacity:.9;}.menu li ul li ul li ul li ul li{opacity:.95;}.dropzone{height:7px;margin:3px 0 3px 0;}.ui-draggable-dragging{width:600px;}.item-type{text-transform:uppercase;font-size:11px;color:#999;padding-right:10px;}.item-controls{font-size:11px;position:absolute;right:15px;top:-1px;}.item-controls a{text-decoration:none;}.item-controls a:hover{cursor:pointer;}.item-controls .menu-item-delete:hover{color:#f00;}#menu-item-settings{display:none;}#cancel-save{cursor:pointer;}#cancel-save:hover{color:#fff!important;}#update-menu-item{color:#fff!important;}#update-menu-item:hover,#update-menu-item:active,#update-menu-item:focus{color:#eaf2fa!important;border-color:#13455b!important;} #menu-management{clear:both;}#menu-management .inside{padding:0 10px;}#menu-container .submit{margin:0 0 10px;padding:0;}.submitdelete{font-size:11px;}#cancel-save{color:#f00;text-decoration:underline;font-size:11px;margin-left:20px;margin-top:5px;}#cancel-save:hover{background-color:#F00;color:#fff;}.list-controls{float:left;}.add-to-menu{float:right;}.button-controls{margin:10px 0;}.show-all,.hide-all{cursor:pointer;}.hide-all{display:none;}#create-menu-name{width:159px;}#manage-menu .inside{padding:0;}#available-links dt{display:block;}#add-custom-link .howto{font-size:11px;}#add-custom-link label span{display:block;float:left;margin-top:5px;padding-right:5px;}.menu-item-textbox{float:right;width:220px;}.howto span{margin-top:4px;display:block;float:left;}.quick-search{width:190px;}.list-wrap{display:none;clear:both;margin-bottom:10px;}.list-container{max-height:200px;overflow-y:auto;padding:10px 10px 5px;border:1px solid #DFDFDF;-moz-border-radius:4px;}.postbox p.submit{margin-bottom:0;}.list li{display:none;margin:0;margin-bottom:5px;}.list li .menu-item-title{cursor:pointer;display:block;}.list li .menu-item-title input{margin-right:3px;margin-top:-3px;}.list li ul li .menu-item-title{margin-left:14px;}.list li ul li ul li .menu-item-title{margin-left:28px;}.list li ul li ul li ul li .menu-item-title{margin-left:42px;}.list li ul li ul li ul li ul li .menu-item-title{margin-left:56px;}.list li ul li ul li ul li ul li ul li .menu-item-title{margin-left:70px;}.list li ul li ul li ul li ul li ul li ul li .menu-item-title{margin-left:84px;}.list li ul li ul li ul li ul li ul li ul li ul li .menu-item-title{margin-left:98px;}.list li ul li ul li ul li ul li ul li ul li ul li ul li .menu-item-title{margin-left:112px;}#menu-container .inside{padding-bottom:10px;}.menu ul{width:100%;}.menu li{margin:0;}.menu li dl dt{-webkit-border-radius:6px;border-radius:6px;-moz-border-radius:6px;border:1px solid #E6E6E6;position:relative;padding-left:10px;background-color:#f1f1f1;height:35px;line-height:35px;}.menu li dl dt:hover{cursor:move;}.menu li ul li{margin-left:20px;opacity:.7;}.menu li ul li ul li{opacity:.9;}.menu li ul li ul li ul li{opacity:.9;}.menu li ul li ul li ul li ul li{opacity:.95;}.dropzone{height:7px;margin:3px 0 3px 0;}.ui-draggable-dragging{width:600px;}.item-type{text-transform:uppercase;font-size:11px;color:#999;padding-right:10px;}.item-controls{font-size:11px;position:absolute;right:15px;top:-1px;}.item-controls a{text-decoration:none;}.item-controls a:hover{cursor:pointer;}.item-controls .menu-item-delete:hover{color:#f00;}#menu-item-settings{display:none;}#cancel-save{cursor:pointer;}#cancel-save:hover{color:#fff!important;}#update-menu-item{color:#fff!important;}#update-menu-item:hover,#update-menu-item:active,#update-menu-item:focus{color:#eaf2fa!important;border-color:#13455b!important;}.button-controls:after,#menu-item-url-wrap:after,#menu-item-name-wrap:after{content:".";display:block;height:0;clear:both;visibility:hidden;}.button-controls,#menu-item-url-wrap,#menu-item-name-wrap{display:block;}

View File

@ -20,28 +20,26 @@
#cancel-save:hover { background-color: #FF0000; color: #fff; } #cancel-save:hover { background-color: #FF0000; color: #fff; }
/* Button Secondary Actions */ /* Button Secondary Actions */
.button-controls { float: left; } .list-controls { float: left; }
.add-to-menu { float: right; } .add-to-menu { float: right; }
.button-controls { margin: 10px 0; }
#manage-menu .inside { padding: 0px 0px; } .show-all, .hide-all { cursor: pointer; }
.hide-all { display: none; }
/* Create Menu */ /* Create Menu */
#create-menu-name { width: 159px; } #create-menu-name { width: 159px; }
#manage-menu .inside { padding: 0px 0px; }
/* Custom Links */ /* Custom Links */
#available-links { margin: 15px 0px 0px; }
#available-links dt { display: block; } #available-links dt { display: block; }
#add-custom-link .howto { font-size: 11px; } #add-custom-link .howto { font-size: 11px; }
#add-custom-link label span { display: block; float: left; margin-top: 5px; padding-right: 5px; } #add-custom-link label span { display: block; float: left; margin-top: 5px; padding-right: 5px; }
.menu-item-textbox { float: right; width: 220px; } .menu-item-textbox { float: right; width: 220px; }
.howto span { margin-top: 4px; display: block; float: left; } .howto span { margin-top: 4px; display: block; float: left; }
/* Pages/Categories */ /* Menu item types */
.show-all, .hide-all { cursor: pointer; }
.hide-all { display: none; }
.quick-search { width: 190px; } .quick-search { width: 190px; }
.list-wrap { display: none; clear: both; } .list-wrap { display: none; clear: both; margin-bottom: 10px; }
.list-container { max-height: 200px; overflow-y: auto; padding: 10px 10px 5px; border: 1px solid #DFDFDF; -moz-border-radius: 4px; } .list-container { max-height: 200px; overflow-y: auto; padding: 10px 10px 5px; border: 1px solid #DFDFDF; -moz-border-radius: 4px; }
.postbox p.submit { margin-bottom: 0; } .postbox p.submit { margin-bottom: 0; }
@ -60,12 +58,12 @@
.list li ul li ul li ul li ul li ul li ul li ul li .menu-item-title { margin-left: 98px; } .list li ul li ul li ul li ul li ul li ul li ul li .menu-item-title { margin-left: 98px; }
.list li ul li ul li ul li ul li ul li ul li ul li ul li .menu-item-title { margin-left: 112px; } .list li ul li ul li ul li ul li ul li ul li ul li ul li .menu-item-title { margin-left: 112px; }
/* Menu */ /* Nav Menu */
#menu-container .inside { padding-bottom: 10px; } #menu-container .inside { padding-bottom: 10px; }
.menu ul { width: 100%; } .menu ul { width: 100%; }
.menu li { margin: 0; } .menu li { margin: 0; }
.menu li dl dt { -webkit-border-bottom-left-radius: 6px; -webkit-border-bottom-right-radius: 6px; -webkit-border-top-left-radius: 6px; -webkit-border-top-right-radius: 6px; border-bottom-left-radius: 6px; border-bottom-right-radius: 6px; border-top-left-radius: 6px; border-top-right-radius: 6px; -moz-border-radius-bottomleft: 6px; -moz-border-radius-bottomright: 6px; -moz-border-radius-topleft: 6px; -moz-border-radius-topright: 6px; border: 1px solid #E6E6E6;position: relative; padding-left:10px; background-color: #f1f1f1; height: 35px; line-height: 35px; } .menu li dl dt { -webkit-border-radius: 6px; border-radius: 6px; -moz-border-radius: 6px; border: 1px solid #E6E6E6; position: relative; padding-left: 10px; background-color: #f1f1f1; height: 35px; line-height: 35px; }
.menu li dl dt:hover { cursor: move; } .menu li dl dt:hover { cursor: move; }
.menu li .item-title { } .menu li .item-title { }
@ -78,7 +76,7 @@
.dropzone { height: 7px; margin: 3px 0 3px 0; } .dropzone { height: 7px; margin: 3px 0 3px 0; }
.ui-draggable-dragging { width: 600px; } .ui-draggable-dragging { width: 600px; }
/* Menu Controls */ /* Menu item controls */
.item-type { text-transform: uppercase; font-size: 11px; color: #999999; padding-right: 10px; } .item-type { text-transform: uppercase; font-size: 11px; color: #999999; padding-right: 10px; }
.item-controls { font-size: 11px; position: absolute; right: 15px; top: -1px; } .item-controls { font-size: 11px; position: absolute; right: 15px; top: -1px; }
.item-controls a { text-decoration: none; } .item-controls a { text-decoration: none; }
@ -93,3 +91,7 @@
#update-menu-item:hover, #update-menu-item:hover,
#update-menu-item:active, #update-menu-item:active,
#update-menu-item:focus { color: #eaf2fa !important; border-color: #13455b !important; } #update-menu-item:focus { color: #eaf2fa !important; border-color: #13455b !important; }
/* Clearfix */
.button-controls:after, #menu-item-url-wrap:after, #menu-item-name-wrap:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; }
.button-controls, #menu-item-url-wrap, #menu-item-name-wrap { display: block; }

View File

@ -1,10 +1,46 @@
<?php <?php
/**
* Register nav menu metaboxes
*
* @since 3.0.0
**/
function wp_nav_menu_metaboxes_setup() {
add_meta_box( 'add-custom-links', __('Add Custom Links'), 'wp_nav_menu_item_link_metabox', 'nav-menus', 'side', 'default' );
wp_nav_menu_post_type_metaboxes();
wp_nav_menu_taxonomy_metaboxes();
}
/* Register Metaboxes */ /**
add_meta_box( 'create-menu', __('Create Menu'), 'wp_nav_menu_create_metabox', 'menus', 'side', 'core' ); * Limit the amount of meta boxes to just links, pages and cats for first time users.
add_meta_box( 'add-custom-links', __('Add Custom Links'), 'wp_nav_menu_item_link_metabox', 'menus', 'side', 'default' ); *
wp_nav_menu_post_type_metaboxes(); * @since 3.0.0
wp_nav_menu_taxonomy_metaboxes(); **/
function wp_initial_nav_menu_meta_boxes() {
global $wp_meta_boxes;
if ( !get_user_option( 'meta-box-hidden_nav-menus' ) && is_array($wp_meta_boxes) ) {
$initial_meta_boxes = array( 'manage-menu', 'create-menu', 'add-custom-links', 'add-page', 'add-category' );
$hidden_meta_boxes = array();
foreach ( array_keys($wp_meta_boxes['nav-menus']) as $context ) {
foreach ( array_keys($wp_meta_boxes['nav-menus'][$context]) as $priority ) {
foreach ( $wp_meta_boxes['nav-menus'][$context][$priority] as $box ) {
if ( in_array( $box['id'], $initial_meta_boxes ) ) {
unset( $box['id'] );
} else {
$hidden_meta_boxes[] = $box['id'];
}
}
}
}
$user = wp_get_current_user();
update_user_meta( $user->ID, 'meta-box-hidden_nav-menus', $hidden_meta_boxes );
// returns all the hidden metaboxes to the js function: wpNavMenu.initial_meta_boxes()
return join( ',', $hidden_meta_boxes );
}
}
/** /**
* Creates metaboxes for any post type menu item. * Creates metaboxes for any post type menu item.
@ -15,15 +51,11 @@ function wp_nav_menu_post_type_metaboxes() {
$post_types = get_post_types( array( 'public' => true ), 'object' ); $post_types = get_post_types( array( 'public' => true ), 'object' );
if ( !$post_types ) if ( !$post_types )
return false; return;
$allowed_types = apply_filters('post_types_allowed_in_menus', array('page'));
foreach ( $post_types as $post_type ) { foreach ( $post_types as $post_type ) {
if ( !in_array($post_type->name, $allowed_types) )
continue;
$id = $post_type->name; $id = $post_type->name;
add_meta_box( "add-{$id}", sprintf( __('Add an Existing %s'), $post_type->singular_label ), 'wp_nav_menu_item_post_type_metabox', 'nav-menus', 'side', 'default', $post_type );
add_meta_box( "add-{$id}", sprintf( __('Add an Existing %s'), $post_type->singular_label ), 'wp_nav_menu_item_post_type_metabox', 'menus', 'side', 'default', $post_type );
} }
} }
@ -36,15 +68,12 @@ function wp_nav_menu_taxonomy_metaboxes() {
$taxonomies = get_taxonomies( array( 'show_ui' => true ), 'object' ); $taxonomies = get_taxonomies( array( 'show_ui' => true ), 'object' );
if ( !$taxonomies ) if ( !$taxonomies )
return false; return;
$allowed_types = apply_filters('taxonomies_allowed_in_menus', array('category'));
foreach ( $taxonomies as $tax ) { foreach ( $taxonomies as $tax ) {
if ( !in_array($tax->name, $allowed_types) )
continue;
$id = $tax->name; $id = $tax->name;
add_meta_box( "add-{$id}", sprintf( __('Add an Existing %s'), $tax->singular_label ), 'wp_nav_menu_item_taxonomy_metabox', 'menus', 'side', 'default', $tax ); add_meta_box( "add-{$id}", sprintf( __('Add an Existing %s'), $tax->singular_label ), 'wp_nav_menu_item_taxonomy_metabox', 'nav-menus', 'side', 'default', $tax );
} }
} }
@ -98,11 +127,11 @@ function wp_nav_menu_create_metabox() { ?>
* @since 3.0.0 * @since 3.0.0
*/ */
function wp_nav_menu_item_link_metabox() { function wp_nav_menu_item_link_metabox() {
$args = array( 'post_status' => 'any', 'post_type' => 'nav_menu_item', 'meta_value' => 'custom', 'showposts' => -1 ); // @note: hacky query, see #12660
$args = array( 'post_type' => 'nav_menu_item', 'post_status' => 'any', 'meta_key' => '_menu_item_type', 'numberposts' => -1, 'orderby' => 'title', );
// @todo transient caching of these results with proper invalidation on updating links // @todo transient caching of these results with proper invalidation on updating links
$query = new WP_Query( $args ); $links = get_posts( $args );
?> ?>
<p id="menu-item-url-wrap"> <p id="menu-item-url-wrap">
<label class="howto" for="menu-item-url"> <label class="howto" for="menu-item-url">
@ -110,7 +139,6 @@ function wp_nav_menu_item_link_metabox() {
<input id="custom-menu-item-url" name="custom-menu-item-url" type="text" class="code menu-item-textbox" value="http://" /> <input id="custom-menu-item-url" name="custom-menu-item-url" type="text" class="code menu-item-textbox" value="http://" />
</label> </label>
</p> </p>
<br class="clear" />
<p id="menu-item-name-wrap"> <p id="menu-item-name-wrap">
<label class="howto" for="custom-menu-item-name"> <label class="howto" for="custom-menu-item-name">
<span><?php _e('Text'); ?></span> <span><?php _e('Text'); ?></span>
@ -119,19 +147,22 @@ function wp_nav_menu_item_link_metabox() {
</p> </p>
<p class="button-controls"> <p class="button-controls">
<a class="show-all"><?php _e('View All'); ?></a> <span class="lists-controls">
<a class="hide-all"><?php _e('Hide All'); ?></a> <a class="show-all"><?php _e('View All'); ?></a>
<a class="hide-all"><?php _e('Hide All'); ?></a>
</span>
<span class="add-to-menu">
<a class="button"><?php _e('Add to Menu'); ?></a>
</span>
</p> </p>
<div id="available-links" class="list-wrap"> <div id="available-links" class="list-wrap">
<div class="list-container"> <div class="list-container">
<ul class="list"> <ul class="list">
<?php echo wp_nav_menu_get_items( $query->posts, 'custom' ); ?> <?php echo wp_nav_menu_get_items( $links, 'custom', 'custom' ); ?>
</ul> </ul>
</div><!-- /.list-container--> </div><!-- /.list-container-->
</div><!-- /#available-links--> </div><!-- /#available-links-->
<p class="add-to-menu">
<a class="button"><?php _e('Add to Menu'); ?></a>
</p>
<div class="clear"></div> <div class="clear"></div>
<?php <?php
} }
@ -145,24 +176,19 @@ function wp_nav_menu_item_link_metabox() {
* @param string $post_type The post type object. * @param string $post_type The post type object.
*/ */
function wp_nav_menu_item_post_type_metabox( $object, $post_type ) { function wp_nav_menu_item_post_type_metabox( $object, $post_type ) {
$args = array( 'post_type' => $post_type['args']->name, 'post_status' => 'publish', 'showposts' => -1 ); $args = array( 'post_type' => $post_type['args']->name, 'numberposts' => -1, 'orderby' => 'title', );
if ( 'attachment' == $post_type['args']->name )
$args['post_status'] = 'any';
// @todo transient caching of these results with proper invalidation on updating of a post of this type // @todo transient caching of these results with proper invalidation on updating of a post of this type
$query = new WP_Query( $args ); $posts = get_posts( $args );
if ( !$query->posts ) if ( !$posts )
$error = '<li id="error">'. sprintf( __( 'No %s exists' ), $post_type['args']->label ) .'</li>'; $error = '<li id="error">'. sprintf( __( 'No %s exists' ), $post_type['args']->label ) .'</li>';
$pt_names = ''; $pt_names = '';
if ( is_array($query->posts) ) { if ( is_array($posts) ) {
foreach ( $query->posts as $post ) { foreach ( $posts as $post ) {
if ( $post->post_title ) { if ( $post->post_title ) {
$pt_names .= htmlentities( $post->post_title ) .'|'; $pt_names .= htmlentities( $post->post_title ) .'|';
} else {
$pt_names = sprintf( __('No %s exists'), $post_type['args']->label );
} }
} }
} }
@ -175,26 +201,29 @@ function wp_nav_menu_item_post_type_metabox( $object, $post_type ) {
</p> </p>
<p class="button-controls"> <p class="button-controls">
<a class="show-all"><?php _e('View All'); ?></a> <span class="lists-controls">
<a class="hide-all"><?php _e('Hide All'); ?></a> <a class="show-all"><?php _e('View All'); ?></a>
<a class="hide-all"><?php _e('Hide All'); ?></a>
</span>
<span class="add-to-menu">
<a class="button"><?php _e('Add to Menu'); ?></a>
</span>
</p> </p>
<div id="existing-<?php echo esc_attr( $id ); ?>" class="list-wrap"> <div id="existing-<?php echo esc_attr( $id ); ?>" class="list-wrap">
<div class="list-container"> <div class="list-container">
<ul class="list"> <ul class="list">
<?php echo isset( $error ) ? $error : wp_nav_menu_get_items( $query->posts, 'post_type', $id ); ?> <?php echo isset( $error ) ? $error : wp_nav_menu_get_items( $posts, 'post_type', $id ); ?>
</ul> </ul>
</div><!-- /.list-container--> </div><!-- /.list-container-->
</div><!-- /#existing-categories--> </div><!-- /#existing-categories-->
<p class="add-to-menu">
<a class="button-secondary"><?php _e('Add to Menu'); ?></a>
</p>
<input type="hidden" class="autocomplete" name="autocomplete-<?php echo esc_attr( $id ); ?>-names" value="<?php echo esc_js( $pt_names ); ?>" /> <input type="hidden" class="autocomplete" name="autocomplete-<?php echo esc_attr( $id ); ?>-names" value="<?php echo esc_js( $pt_names ); ?>" />
<br class="clear" /> <br class="clear" />
<script type="text/javascript" charset="utf-8"> <script type="text/javascript" charset="utf-8">
// <![CDATA[ // <![CDATA[
jQuery(document).ready(function(){ jQuery(document).ready(function(){
wp_nav_menu_autocomplete('<?php echo esc_attr($id); ?>'); wpNavMenu.autocomplete('<?php echo esc_attr($id); ?>');
}); });
// ]]> // ]]>
</script> </script>
@ -227,8 +256,6 @@ function wp_nav_menu_item_taxonomy_metabox( $object, $taxonomy ) {
foreach ( $terms as $term ) { foreach ( $terms as $term ) {
if ( $term->name ) { if ( $term->name ) {
$term_names .= htmlentities( $term->name ) .'|'; $term_names .= htmlentities( $term->name ) .'|';
} else {
$term_names = sprintf( __('No %s exists'), $taxonomy['args']->label );
} }
} }
} }
@ -241,8 +268,14 @@ function wp_nav_menu_item_taxonomy_metabox( $object, $taxonomy ) {
</p> </p>
<p class="button-controls"> <p class="button-controls">
<a class="show-all"><?php _e('View All'); ?></a> <span class="lists-controls">
<a class="hide-all"><?php _e('Hide All'); ?></a> <a class="show-all"><?php _e('View All'); ?></a>
<a class="hide-all"><?php _e('Hide All'); ?></a>
</span>
<span class="add-to-menu">
<a class="button"><?php _e('Add to Menu'); ?></a>
</span>
</p> </p>
<div id="existing-<?php echo esc_attr( $id ); ?>" class="list-wrap"> <div id="existing-<?php echo esc_attr( $id ); ?>" class="list-wrap">
@ -252,15 +285,12 @@ function wp_nav_menu_item_taxonomy_metabox( $object, $taxonomy ) {
</ul> </ul>
</div><!-- /.list-container--> </div><!-- /.list-container-->
</div><!-- /#existing-categories--> </div><!-- /#existing-categories-->
<p class="add-to-menu">
<a class="button-secondary"><?php _e('Add to Menu'); ?></a>
</p>
<input type="hidden" class="autocomplete" name="autocomplete-<?php echo esc_attr($id); ?>-names" value="<?php echo esc_js( $term_names ); ?>" /> <input type="hidden" class="autocomplete" name="autocomplete-<?php echo esc_attr($id); ?>-names" value="<?php echo esc_js( $term_names ); ?>" />
<br class="clear" /> <br class="clear" />
<script type="text/javascript" charset="utf-8"> <script type="text/javascript" charset="utf-8">
// <![CDATA[ // <![CDATA[
jQuery(document).ready(function(){ jQuery(document).ready(function(){
wp_nav_menu_autocomplete('<?php echo esc_attr($id); ?>'); wpNavMenu.autocomplete('<?php echo esc_attr($id); ?>');
}); });
// ]]> // ]]>
</script> </script>
@ -290,13 +320,18 @@ function wp_nav_menu_get_items( $menu_items, $object_type, $object = null, $cont
if ( !isset($menu_item->post_parent) ) if ( !isset($menu_item->post_parent) )
$menu_item->post_parent = $menu_item->parent; $menu_item->post_parent = $menu_item->parent;
// Cleanest way to get all attachements // Get all attachements and links
if ( 'attachment' == $object ) if ( in_array($object, array( 'attachment', 'custom' )) )
$menu_item->post_parent = 0; $menu_item->post_parent = 0;
if ( 0 == $menu_item->post_parent ) { if ( 0 == $menu_item->post_parent ) {
// Set up the menu item // Set up the menu item
$menu_item = wp_setup_nav_menu_item( $menu_item, $object_type, $object ); $menu_item = wp_setup_nav_menu_item( $menu_item, $object_type, $object );
// No blank titles
if ( empty($menu_item->title) )
continue;
$attributes = ( 'backend' == $context ) ? ' id="menu-item-'. $i .'" value="'. $i .'"' : ''; $attributes = ( 'backend' == $context ) ? ' id="menu-item-'. $i .'" value="'. $i .'"' : '';
$output .= '<li'. $attributes .'>'; $output .= '<li'. $attributes .'>';

View File

@ -1105,13 +1105,26 @@ function upgrade_290() {
* @since 3.0.0 * @since 3.0.0
*/ */
function upgrade_300() { function upgrade_300() {
global $wp_current_db_version; global $wp_current_db_version, $wpdb;
if ( $wp_current_db_version < 12751 ) { if ( $wp_current_db_version < 12751 ) {
populate_roles_300(); populate_roles_300();
if ( is_multisite() && is_main_site() && ! defined( 'MULTISITE' ) && get_site_option( 'siteurl' ) === false ) if ( is_multisite() && is_main_site() && ! defined( 'MULTISITE' ) && get_site_option( 'siteurl' ) === false )
add_site_option( 'siteurl', '' ); add_site_option( 'siteurl', '' );
} }
// 3.0-alpha nav menu postmeta changes. can be removed before release
if ( $wp_current_db_version >= 13226 && $wp_current_db_version < 13802 ) {
// remove old nav menu post meta keys
$wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_key IN( 'menu_type', 'object_id', 'menu_new_window', 'menu_link', '_menu_item_append', 'menu_item_append' )" );
// update nav menu post meta keys to underscore prefixes
$wpdb->update( $wpdb->postmeta, array( 'meta_key' => '_menu_item_type' ), array( 'meta_key' => 'menu_item_type' ) );
$wpdb->update( $wpdb->postmeta, array( 'meta_key' => '_menu_item_object_id' ), array( 'meta_key' => 'menu_item_object_id' ) );
$wpdb->update( $wpdb->postmeta, array( 'meta_key' => '_menu_item_target' ), array( 'meta_key' => 'menu_item_target' ) );
$wpdb->update( $wpdb->postmeta, array( 'meta_key' => '_menu_item_classes' ), array( 'meta_key' => 'menu_item_classes' ) );
$wpdb->update( $wpdb->postmeta, array( 'meta_key' => '_menu_item_xfn' ), array( 'meta_key' => 'menu_item_xfn' ) );
$wpdb->update( $wpdb->postmeta, array( 'meta_key' => '_menu_item_url' ), array( 'meta_key' => 'menu_item_url' ) );
}
} }
/** /**

View File

@ -1,489 +1,491 @@
/** /**
* WordPress Administration Custom Navigation * WordPress Administration Navigation Menu
* Interface JS functions * Interface JS functions
* *
* @version 1.1.0
*
* @package WordPress
* @subpackage Administration
*/
function wp_nav_menu_autocomplete( id ) {
jQuery('#add-'+ id +' .quick-search').autocomplete(jQuery( '#add-'+ id +' .autocomplete' ).val().split('|'));
jQuery('#add-'+ id +' .quick-search').result(function(event, data, formatted) {
jQuery('#add-'+ id +' .list-wrap').css( 'display', 'block' );
jQuery("#add-"+ id +" .list-wrap li:contains('" + data + "')").css( 'display', 'block' );
jQuery('#add-'+ id +' .show-all').hide();
jQuery('#add-'+ id +' .hide-all').show();
});
}
/**
* Populate the thickbox window with the selected menu items
*
* @param int id - the id of the menu li to edit.
*/
function wp_edit_menu_item( id ) {
var item_type = jQuery('#menu-item-type' + id).val();
var item_title = jQuery('#menu-item-title' + id).val();
var item_link = jQuery('#menu-item-url' + id).val();
var item_attr_title = jQuery('#menu-item-attr-title' + id).val();
var item_target = jQuery('#menu-item-target' + id).val();
var item_description = jQuery('#menu-item-description' + id).val();
var item_classes = jQuery('#menu-item-classes' + id).val();
var item_xfn = jQuery('#menu-item-xfn' + id).val();
// Only allow custom links to be editable.
if ( 'custom' != item_type )
jQuery( '#edit-menu-item-url' ).attr('disabled', 'disabled' );
// Populate the fields for thickbox
jQuery( '#edit-menu-item-id' ).val(id);
jQuery( '#edit-menu-item-title' ).val(item_title);
jQuery( '#edit-menu-item-url' ).val(item_link);
jQuery( '#edit-menu-item-attr-title' ).val(item_attr_title);
jQuery( '#edit-menu-item-target' ).val(item_target);
jQuery( "#edit-menu-item-target option[value='" + item_target + "']" ).attr('selected', 'selected');
jQuery( '#edit-menu-item-description' ).val(item_description);
jQuery( '#edit-menu-item-classes' ).val(item_classes);
jQuery( '#edit-menu-item-xfn' ).val(item_xfn);
// focus
jQuery( '#edit-menu-item-title' ).focus();
};
/**
* Update the values for the menu item being editing
*/
function wp_update_menu_item() {
var id = jQuery('#edit-menu-item-id').val();
var item_title = jQuery('#edit-menu-item-title').val();
var item_link = jQuery('#edit-menu-item-url').val();
var item_attr_title = jQuery('#edit-menu-item-attr-title').val();
var item_target = jQuery('#edit-menu-item-target').val();
var item_description = jQuery('#edit-menu-item-description').val();
var item_classes = jQuery('#edit-menu-item-classes').val();
var item_xfn = jQuery('#edit-menu-item-xfn').val();
// update menu item settings
jQuery('.menu #menu-item' + id).find('span.item-title').html(item_title);
jQuery('.menu #menu-item-title' + id).val(item_title);
jQuery('.menu #menu-item-url' + id).val(item_link);
jQuery('.menu #menu-item-attr-title' + id).val(item_attr_title);
jQuery('.menu #menu-item-target' + id).val(item_target);
jQuery('.menu #menu-item-description' + id).val(item_description);
jQuery('.menu #menu-item-classes' + id).val(item_classes);
jQuery('.menu #menu-item-xfn' + id).val(item_xfn);
jQuery('.menu #menu-item' + id + ' dt:first').animate( { backgroundColor: '#FFFF33' }, { duration: 'normal', complete: function() { jQuery(this).css( 'backgroundColor', '' ); }});
}
/**
* Removes a menu item from current menu
*
* @param int o - the id of the menu li to remove.
*/
function wp_remove_menu_item( o ) {
var todelete = document.getElementById('menu-item' + o);
if ( todelete ) {
// Give some feedback to the user
jQuery( todelete ).find('dt').each(function(){
jQuery(this).animate( { backgroundColor: '#FF3333' }, { duration: 'normal', complete: function() { jQuery(this).parent().parent().remove() } } );
});
}
};
/**
* Adds the item to the menu
*
* @param string item_db_id - The menu item's db id.
* @param string item_object_id - The menu item's object id.
* @param string item_type - The menu item's object type.
* @param string item_append - The menu item's nice name.
* @param string item_parent_id - The menu item's parent id.
* @param string item_title - The menu item title.
* @param string item_url - The menu item url
* @param string item_description - The menu item description.
* @param string item_attr_title - The title attribute.
* @param string item_target - The target attribute.
* @param string item_classes - Optional. Additional CSS classes for the menu item
* @param string item_xfn - Optional. The rel attribute.
*/
function wp_add_item_to_menu( item_db_id, item_object_id, item_type, item_append, item_parent_id, item_title, item_url, item_description, item_attr_title, item_target, item_classes, item_xfn ) {
var randomnumber = wp_get_unique_menu_id();
var hidden = wp_get_hidden_inputs( randomnumber, item_db_id, item_object_id, item_type, item_append, item_parent_id, item_title, item_url, item_description, item_attr_title, item_target, item_classes, item_xfn );
// Adds the item in the queue
jQuery('.menu').append('<li id="menu-item' + randomnumber + '" value="' + randomnumber + '"><div class="dropzone ui-droppable"></div><dl class="ui-droppable"><dt><span class="item-title">' + item_title + '</span><span class="item-controls"><span class="item-type">' + item_append + '</span><a class="item-edit thickbox" id="edit' + randomnumber + '" value="' + randomnumber +'" onClick="wp_edit_menu_item('+ randomnumber +')" title="' + navMenuL10n.thickbox + '" href="#TB_inline?height=540&width=300&inlineId=menu-item-settings">' + navMenuL10n.edit + '</a> | <a class="item-delete" id="delete' + randomnumber + '" value="' + randomnumber +'">Delete</a></span></dt></dl>' + hidden + '</li>');
// Give some feedback to the user
jQuery( '.menu #menu-item' + randomnumber + ' dt:first' ).animate( { backgroundColor: '#FFFF33' }, { duration: 'normal', complete: function() { jQuery(this).css( 'backgroundColor', '' ); }});
// Enable drag-n-drop
wp_drag_and_drop();
// Reload thickbox
tb_init('a.thickbox, area.thickbox, input.thickbox');
};
/**
* Grabs items from the queue and adds them to the menu.
*
* @param string button - a reference to the button that was clicked
*/
function wp_add_checked_items_to_menu( button ) {
// Grab checked items
var items = jQuery(button).siblings('.list-wrap').find(':checked');
// If nothing was checked, cancel
if ( 0 == items.length )
return false;
// Loop through each item, grab it's hidden data and add it to the menu.
jQuery(items).each(function(){
var item_type = jQuery(this).parent().siblings('.menu-item-type').val();
if ( 'custom' == item_type ) {
var item_attr_title = jQuery(this).parent().siblings('.menu-item-attr-title').val();
var item_target = jQuery(this).parent().siblings('.menu-item-target').val();
var item_classes = jQuery(this).parent().siblings('.menu-item-classes').val();
var item_xfn = jQuery(this).parent().siblings('.menu-item-xfn').val();
} else {
var item_attr_title = '';
var item_target = '_self';
var item_classes = '';
var item_xfn = '';
};
var item_db_id = jQuery(this).parent().siblings('.menu-item-db-id').val();
var item_object_id = jQuery(this).parent().siblings('.menu-item-object-id').val();
var item_append = jQuery(this).parent().siblings('.menu-item-append').val();
var item_parent_id = jQuery(this).parent().siblings('.menu-item-parent-id').val();
var item_title = jQuery(this).parent().siblings('.menu-item-title').val();
var item_url = jQuery(this).parent().siblings('.menu-item-url').val();
var item_description = jQuery(this).parent().siblings('.menu-item-description').val();
if ( undefined == item_description ) {
item_description = '';
};
// Add the menu item to the menu
wp_add_item_to_menu( item_db_id, item_object_id, item_type, item_append, item_parent_id, item_title, item_url, item_description, item_attr_title, item_target, item_classes, item_xfn );
// uncheck the menu item in the list
jQuery(this).attr( 'checked', false );
});
};
/**
* Makes the menu items drag and droppable.
*/
function wp_drag_and_drop() {
// Make sure all li's have dropzones
jQuery('.menu li').each(function(){
if ( !jQuery(this).children('.dropzone').attr('class') ) {
jQuery(this).prepend('<div class="dropzone"></div>');
};
});
// make menu item draggable
jQuery('.menu li').draggable({
handle: ' > dl',
opacity: .8,
addClasses: false,
helper: 'clone',
zIndex: 100
});
// make menu item droppable
jQuery('.menu li dl, .menu li .dropzone').droppable({
accept: '.menu li',
tolerance: 'pointer',
drop: function(e, ui) {
var li = jQuery(this).parent();
var child = !jQuery(this).hasClass('dropzone');
// Append UL to first child
if ( child && li.children('ul').length == 0 ) {
li.append( '<ul class="sub-menu" />' );
}
// Make it draggable
if ( child ) {
li.children('ul').append( ui.draggable );
} else {
li.before( ui.draggable );
}
li.find('dl,.dropzone').css({ backgroundColor: '', borderColor: '' });
var draggablevalue = ui.draggable.attr('value');
var droppablevalue = li.attr('value');
li.find('#menu-' + draggablevalue).find('#parent' + draggablevalue).val(droppablevalue);
jQuery(this).parent().find('dt').removeAttr('style');
jQuery(this).parent().find('div:first').removeAttr('style');
},
over: function() {
// Add child
if ( jQuery(this).attr('class') == 'dropzone ui-droppable' ) {
jQuery(this).parent().find('div:first').css('background', 'none').css('height', '50px');
}
// Add above
else if ( jQuery(this).attr('class') == 'ui-droppable' ) {
jQuery(this).parent().find('dt:first').css('background', '#d8d8d8');
} else {
// do nothing
}
var parentid = jQuery(this).parent().attr('id');
},
out: function() {
jQuery(this).parent().find('dt').removeAttr('style');
jQuery(this).parent().find('div:first').removeAttr('style');
jQuery(this).filter('.dropzone').css({ borderColor: '' });
}
}
);
}
/**
* Prepares menu items for POST.
*/
function wp_update_post_data() {
var i = 0;
jQuery('.menu li').each(function(i) {
i = i + 1;
var j = jQuery(this).attr('value');
jQuery(this).find('#menu-item-position' + j).attr('value', i);
jQuery(this).attr('id','menu-item' + i);
jQuery(this).attr('value', i);
jQuery(this).find('#menu-item-db-id' + j).attr('id','menu-item-db-id' + i);
jQuery(this).find('#menu-item-object-id' + j).attr('id','menu-item-object-id' + i);
jQuery(this).find('#menu-item-append' + j).attr('id', 'menu-item-append' + i);
jQuery(this).find('#menu-item-type' + j).attr('id', 'menu-item-type' + i);
jQuery(this).find('#menu-item-position' + j).attr('id', 'menu-item-position' + i);
var p = jQuery(this).find('#menu-item-parent-id' + j).parent().parent().parent().attr('value');
jQuery(this).find('#menu-item-parent-id' + j).attr('id','menu-item-parent-id' + i);
if (p) {
// Do nothing
} else {
// reset p to be top level
p = 0;
}
jQuery(this).find('#menu-item-parent-id' + j).attr('value', p);
jQuery(this).find('#menu-item-title' + j).attr('id','menu-item-title' + i);
jQuery(this).find('#menu-item-url' + j).attr('id','menu-item-url' + i);
jQuery(this).find('#menu-item-description' + j).attr('id','menu-item-description' + i);
jQuery(this).find('#menu-item-classes' + j).attr('id','menu-item-classes' + i);
jQuery(this).find('#menu-item-xfn' + j).attr('id','menu-item-xfn' + i);
jQuery(this).find('#menu-item-description' + j).attr('id','menu-item-description' + i);
jQuery(this).find('#menu-item-attr-title' + j).attr('id','menu-item-attr-title' + i);
jQuery(this).find('#menu-item-target' + j).attr('id','menu-item-target' + i);
jQuery('#li-count').attr( 'value', i );
});
};
/**
* Gets a unique number based on how many items are in the menu
*/
function wp_get_unique_menu_id() {
var count = jQuery('.menu li').length + 1;
var randomnumber = count;
var validatetest = 0;
try {
var test = document.getElementById( 'menu-' + randomnumber.toString() ).value;
}
catch ( err ) {
validatetest = 1;
}
while ( validatetest == 0 ) {
randomnumber = randomnumber + 1;
try {
var test2 = document.getElementById( 'menu-' + randomnumber.toString() ).value;
}
catch ( err ) {
validatetest = 1;
}
}
return randomnumber;
}
/**
* Returns all the nessecary hidden inputs for each menu item.
*
* @param string item_db_id - The menu item's db id.
* @param string item_object_id - The menu item's object id.
* @param string item_type - The menu item's object type.
* @param string item_append - The menu item's nice name.
* @param string item_parent_id - The menu item's parent id.
* @param string item_title - The menu item title.
* @param string item_url - The menu item url
* @param string item_description - The menu item description.
* @param string item_attr_title - The title attribute.
* @param string item_target - The target attribute.
* @param string item_classes - Optional. Additional CSS classes for the menu item
* @param string item_xfn - Optional. The rel attribute.
*/
function wp_get_hidden_inputs( randomnumber, item_db_id, item_object_id, item_type, item_append, item_parent_id, item_title, item_url, item_description, item_attr_title, item_target, item_classes, item_xfn ) {
var hidden = '';
hidden += '<input type="hidden" name="menu-item-db-id[]" id="menu-item-db-id' + randomnumber + '" value="' + item_db_id + '" />';
hidden += '<input type="hidden" name="menu-item-object-id[]" id="menu-item-object-id' + randomnumber + '" value="' + item_object_id + '" />';
hidden += '<input type="hidden" name="menu-item-type[]" id="menu-item-type' + randomnumber + '" value="' + item_type + '" />';
hidden += '<input type="hidden" name="menu-item-append[]" id="menu-item-append' + randomnumber + '" value="' + item_append + '" />';
hidden += '<input type="hidden" name="menu-item-parent-id[]" id="menu-item-parent-id' + randomnumber + '" value="' + item_parent_id + '" />';
hidden += '<input type="hidden" name="menu-item-position[]" id="menu-item-position' + randomnumber + '" value="' + randomnumber + '" />';
hidden += '<input type="hidden" name="menu-item-title[]" id="menu-item-title' + randomnumber + '" value="' + item_title + '" />';
hidden += '<input type="hidden" name="menu-item-attr-title[]" id="menu-item-attr-title' + randomnumber + '" value="' + item_attr_title + '" />';
hidden += '<input type="hidden" name="menu-item-url[]" id="menu-item-url' + randomnumber + '" value="' + item_url + '" />';
hidden += '<input type="hidden" name="menu-item-target[]" id="menu-item-target' + randomnumber + '" value="' + item_target + '" />';
hidden += '<input type="hidden" name="menu-item-description[]" id="menu-item-description' + randomnumber + '" value="' + item_description + '" />';
hidden += '<input type="hidden" name="menu-item-classes[]" id="menu-item-classes' + randomnumber + '" value="' + item_classes + '" />';
hidden += '<input type="hidden" name="menu-item-xfn[]" id="menu-item-xfn' + randomnumber + '" value="' + item_xfn + '" />';
return hidden;
}
/**
* WordPress Administration Custom Navigation
* Interface $ functions
*
* @version 2.0.0 * @version 2.0.0
* *
* @package WordPress * @package WordPress
* @subpackage Administration * @subpackage Administration
*/ */
/** var wpNavMenu;
* Init Functions
*/
jQuery(document).ready(function($){
wp_drag_and_drop(); (function($) {
// Delete AYS wpNavMenu = {
$('#update-nav-menu .deletion').click(function(){
if ( confirm( navMenuL10n.warnDelete ) ) {
return true;
} else {
return false;
};
});
// Handle Save Button Clicks // Functions that run on init.
$('#save_menu').click(function(){ init : function() {
return wp_update_post_data();
});
// Handle some return keypresses wpNavMenu.initial_meta_boxes();
$('#create-menu-name').keypress(function(e){
if ( 13 == e.keyCode ) { wpNavMenu.drag_and_drop();
$('#create-menu-button').click();
return false; // Delete AYS
$('#update-nav-menu .deletion').click(function(){
if ( confirm( navMenuL10n.warnDelete ) ) {
return true;
} else {
return false;
};
});
// Handle Save Button Clicks
$('#update-nav-menu').submit(function(){
wpNavMenu.update_post_data();
});
// Handle some return keypresses
$('#create-menu-name').keypress(function(e){
if ( 13 == e.keyCode ) {
$('#create-menu-button').click();
return false;
}
});
$('#custom-menu-item-url, #custom-menu-item-name').keypress(function(e){
if ( 13 == e.keyCode ) {
$('#add-custom-links a.button').click();
return false;
}
}).focus(function(){
if ( $(this).val() == $(this).attr('defaultValue') && $(this).attr('id') != 'custom-menu-item-url' ) {
$(this).val('');
}
}).blur(function(){
if ( $(this).val() == '' ) {
$(this).val($(this).attr('defaultValue'));
}
});
$('#create-menu-name').focus(function(){
if ( $(this).val() == $(this).attr('defaultValue') ) {
$(this).val('');
}
}).blur(function(){
if ( $(this).val() == '' ) {
$(this).val($(this).attr('defaultValue'));
}
});
// close postboxes that should be closed
$('.if-js-closed').removeClass('if-js-closed').addClass('closed');
// postboxes setup
postboxes.add_postbox_toggles('nav-menus');
// Clear the quick search textbox
$('.quick-search').click(function(){
$(this).attr( 'value', '' );
});
// Quick Search submit
$('.quick-search-submit').click(function(){
$(this).siblings('.quick-search').search();
});
// Edit menu item
$('#menu-container .item-edit').click(function(){
wpNavMenu.edit_menu_item( $(this).attr('value') );
});
// Delete menu item
$('#menu-container .item-delete').click(function(){
wpNavMenu.remove_menu_item( $(this).attr('value') );
});
// Update menu item settings (thickbox)
$('#update-menu-item').click(function(){
wpNavMenu.update_menu_item();
tb_remove();
});
// Close thickbox
$('#cancel-save').click(function(){
tb_remove();
});
// Show All Button
$('.show-all').click(function(e){
$(e.currentTarget).parent().parent().siblings('.list-wrap').css( 'display', 'block' );
$(e.currentTarget).parent().parent().siblings('.list-wrap').find('li').css( 'display', 'block' );
$(e.currentTarget).hide();
$(e.currentTarget).siblings('.hide-all').show();
});
// Hide All Button
$('.hide-all').click(function(e){
$(e.currentTarget).parent().parent().siblings('.list-wrap').css( 'display', 'none' );
$(e.currentTarget).parent().parent().siblings('.list-wrap').find('li').css( 'display', 'none' );
$(e.currentTarget).hide();
$(e.currentTarget).siblings('.show-all').show();
});
// Add menu items into the menu
$('.add-to-menu').click(function(e){
wpNavMenu.add_checked_items_to_menu(e.currentTarget);
});
// Create a new link then add it to the menu
$('#add-custom-links .add-to-menu a').click(function(e){
// Add link to menu
if ( $('#custom-menu-item-url').val() == $('#custom-menu-item-url').attr('defaultValue') )
return; // Do not allow "http://" submissions to go through
wpNavMenu.add_custom_link( $('#custom-menu-item-name').val(), $('#custom-menu-item-url').val() );
// Reset the fields back to their defaults
$('#custom-menu-item-name').val($('#custom-menu-item-name').attr('defaultValue'));
$('#custom-menu-item-url' ).val($('#custom-menu-item-url' ).attr('defaultValue')).focus();
});
},
add_custom_link : function( link_name, link_url ) {
var params = {
action: 'save-custom-link',
link_name: link_name,
link_url: link_url
}
$.post( ajaxurl, params, function(link_id) {
if ( '-1' == link_id )
return;
wpNavMenu.add_to_menu( link_id, link_id, 'custom', 'custom', navMenuL10n.custom, 0, link_name, link_url, '', '', '_self', '', '' );
}, 'json');
},
/**
* In combination with the php function wp_initial_nav_menu_meta_boxes(),
* this function limits the metaboxes for first time users to just links, pages and cats.
*/
initial_meta_boxes : function() {
var hidden = $('#hidden-metaboxes').val().split( ',' );
if ( '' != hidden ) {
for ( var i = 0; i < hidden.length; i++ ) {
$( '#' + hidden[i] ).attr( 'style', 'display: none;' );
$( '#' + hidden[i] + '-hide' ).attr( 'checked', false );
};
};
},
// Makes the menu items drag and droppable.
drag_and_drop : function() {
// Make sure all li's have dropzones
$('.menu li').each(function(){
if ( !$(this).children('.dropzone').attr('class') ) {
$(this).prepend('<div class="dropzone"></div>');
};
});
// make menu item draggable
$('.menu li').draggable({
handle: ' > dl',
opacity: .8,
addClasses: false,
helper: 'clone',
zIndex: 100
});
// make menu item droppable
$('.menu li dl, .menu li .dropzone').droppable({
accept: '.menu li',
tolerance: 'pointer',
drop: function(e, ui) {
var li = $(this).parent();
var child = !$(this).hasClass('dropzone');
// Append UL to first child
if ( child && li.children('ul').length == 0 ) {
li.append( '<ul class="sub-menu" />' );
}
// Make it draggable
if ( child ) {
li.children('ul').append( ui.draggable );
} else {
li.before( ui.draggable );
}
li.find('dl,.dropzone').css({ backgroundColor: '', borderColor: '' });
var draggablevalue = ui.draggable.attr('value');
var droppablevalue = li.attr('value');
li.find('#menu-' + draggablevalue).find('#parent' + draggablevalue).val(droppablevalue);
$(this).parent().find('dt').removeAttr('style');
$(this).parent().find('div:first').removeAttr('style');
},
over: function(e) {
// Add child
if ( $(this).attr('class') == 'dropzone ui-droppable' ) {
$(this).parent().find('div:first').css({ background: '#f5f5f5', border: '1px dashed #bbb', margin: '10px 0px', height: '40px' });
}
// Add above
else if ( $(this).attr('class') == 'ui-droppable' ) {
$(this).parent().find('dt:first').css('background', '#d8d8d8');
} else {
// Do nothing
}
},
out: function() {
$(this).parent().find('dt').removeAttr('style');
$(this).parent().find('div:first').removeAttr('style');
$(this).filter('.dropzone').css({ borderColor: '' });
}
});
},
// Prepares menu items for POST.
update_post_data : function() {
var i = 0; // counter
$('.menu li').each(function(){
i = i + 1; // the menu order for each item
var j = $(this).attr('value'); // reference to the current menu item (e.g. li#menu-item + j)
// Grab the menu item id
var id = $(this).children('input[name=menu-item-db-id[]]').val();
// Update the li value to equal the menu order
$(this).attr('value', i);
// Update the position
$(this).children('input[name=menu-item-position[]]').attr( 'value', i );
// Update the parent id
var pid = $(this).parent('.sub-menu').siblings('input[name=menu-item-object-id[]]').val();
if ( undefined == pid ) {
pid = 0;
};
$(this).children('input[name=menu-item-parent-id[]]').attr( 'value', pid );
// Update the menu item count
$('#li-count').attr( 'value', i );
});
},
/**
* Enables autocomplete for nav menu types.
*
* @param int id - the id of the menu item type.
*/
autocomplete : function( id ) {
$('#add-'+ id +' .quick-search').autocomplete( $( '#add-'+ id +' .autocomplete' ).val().split('|') );
$('#add-'+ id +' .quick-search').result(function( event, data, formatted ) {
$('#add-'+ id +' .list-wrap').css( 'display', 'block' );
$("#add-"+ id +" .list-wrap li:contains('" + data + "')").css( 'display', 'block' );
$('#add-'+ id +' .show-all').hide();
$('#add-'+ id +' .hide-all').show();
});
},
/**
* Populate the thickbox window with the selected menu items
*
* @param int id - the id of the menu item to edit.
*/
edit_menu_item : function( id ) {
var item_type = $('#menu-item-' + id).children('input[name=menu-item-type[]]').val();
var item_title = $('#menu-item-' + id).children('input[name=menu-item-title[]]').val();
var item_link = $('#menu-item-' + id).children('input[name=menu-item-url[]]').val();
var item_attr_title = $('#menu-item-' + id).children('input[name=menu-item-attr-title[]]').val();
var item_target = $('#menu-item-' + id).children('input[name=menu-item-target[]]').val();
var item_description = $('#menu-item-' + id).children('input[name=menu-item-description[]]').val();
var item_classes = $('#menu-item-' + id).children('input[name=menu-item-classes[]]').val();
var item_xfn = $('#menu-item-' + id).children('input[name=menu-item-xfn[]]').val();
// Only allow custom links to be editable.
if ( 'custom' != item_type )
$( '#edit-menu-item-url' ).attr('disabled', 'disabled' );
// Populate the fields for thickbox
$( '#edit-menu-item-id' ).val(id);
$( '#edit-menu-item-title' ).val(item_title);
$( '#edit-menu-item-url' ).val(item_link);
$( '#edit-menu-item-attr-title' ).val(item_attr_title);
$( '#edit-menu-item-target' ).val(item_target);
$( "#edit-menu-item-target option[value='" + item_target + "']" ).attr('selected', 'selected');
$( '#edit-menu-item-description' ).val(item_description);
$( '#edit-menu-item-classes' ).val(item_classes);
$( '#edit-menu-item-xfn' ).val(item_xfn);
// @todo: focus on #edit-menu-item-title
},
/**
* Update the values for the menu item being editing
*/
update_menu_item : function() {
var id = $('#edit-menu-item-id').val();
var item_title = $('#edit-menu-item-title').val();
var item_link = $('#edit-menu-item-url').val();
var item_attr_title = $('#edit-menu-item-attr-title').val();
var item_target = $('#edit-menu-item-target').val();
var item_description = $('#edit-menu-item-description').val();
var item_classes = $('#edit-menu-item-classes').val();
var item_xfn = $('#edit-menu-item-xfn').val();
// update menu item settings
$('.menu #menu-item-' + id).find('span.item-title:first').html(item_title);
$('#menu-item-' + id).children('input[name=menu-item-title[]]').val(item_title);
$('#menu-item-' + id).children('input[name=menu-item-url[]]').val(item_link);
$('#menu-item-' + id).children('input[name=menu-item-attr-title[]]').val(item_attr_title);
$('#menu-item-' + id).children('input[name=menu-item-target[]]').val(item_target);
$('#menu-item-' + id).children('input[name=menu-item-description[]]').val(item_description);
$('#menu-item-' + id).children('input[name=menu-item-classes[]]').val(item_classes);
$('#menu-item-' + id).children('input[name=menu-item-xfn[]]').val(item_xfn);
$('.menu #menu-item-' + id + ' dt:first').animate( { backgroundColor: '#FFFF33' }, { duration: 'normal', complete: function() { $(this).css( 'backgroundColor', '' ); }});
},
/**
* Removes a menu item from current menu
*
* @param int id - the id of the menu item to remove.
*/
remove_menu_item : function( id ) {
var todelete = $('#menu-item-' + id);
if ( todelete ) {
// Give some feedback to the user
$( todelete ).find('dt').each(function(){
$(this).animate( { backgroundColor: '#FF3333' }, { duration: 'normal', complete: function() { $(this).parent().parent().remove() } } );
});
}
},
/**
* Adds the item to the menu
*
* @param string item_db_id - The menu item's db id.
* @param string item_object_id - The menu item's object id.
* @param string item_object - The menu item's object name.
* @param string item_type - The menu item's object type.
* @param string item_append - The menu item's nice name.
* @param string item_parent_id - The menu item's parent id.
* @param string item_title - The menu item title.
* @param string item_url - The menu item url
* @param string item_description - The menu item description.
* @param string item_attr_title - The title attribute.
* @param string item_target - The target attribute.
* @param string item_classes - Optional. Additional CSS classes for the menu item
* @param string item_xfn - Optional. The rel attribute.
*/
add_to_menu : function( item_db_id, item_object_id, item_object, item_type, item_append, item_parent_id, item_title, item_url, item_description, item_attr_title, item_target, item_classes, item_xfn ) {
var randomnumber = $('.menu li').length + 1;
var hidden = wpNavMenu.get_hidden_inputs( randomnumber, item_db_id, item_object_id, item_object, item_type, item_parent_id, item_title, item_url, item_description, item_attr_title, item_target, item_classes, item_xfn );
// Adds the item to the menu
$('.menu').append('<li id="menu-item-' + randomnumber + '" value="' + randomnumber + '"><div class="dropzone ui-droppable"></div><dl class="ui-droppable"><dt><span class="item-title">' + item_title + '</span><span class="item-controls"><span class="item-type">' + item_append + '</span><a class="item-edit thickbox" id="edit' + randomnumber + '" value="' + randomnumber +'" onclick="wpNavMenu.edit_menu_item('+ randomnumber +');" title="' + navMenuL10n.thickbox + '" href="#TB_inline?height=540&width=300&inlineId=menu-item-settings">' + navMenuL10n.edit + '</a> | <a class="item-delete" id="delete' + randomnumber + '" value="' + randomnumber +'" onclick="wpNavMenu.remove_menu_item('+ randomnumber +');">Delete</a></span></dt></dl>' + hidden + '</li>');
// Give some feedback to the user
$( '.menu #menu-item-' + randomnumber + ' dt:first' ).animate( { backgroundColor: '#FFFF33' }, { duration: 'normal', complete: function() { $(this).css( 'backgroundColor', '' ); }});
// Enable drag-n-drop
wpNavMenu.drag_and_drop();
// Reload thickbox
tb_init('a.thickbox, area.thickbox, input.thickbox');
},
/**
* Grabs items from the queue and adds them to the menu.
*
* @param string button - a reference to the button that was clicked
*/
add_checked_items_to_menu : function( button ) {
// Grab checked items
var items = $(button).parent().siblings('.list-wrap').find(':checked');
// If nothing was checked, cancel
if ( 0 == items.length )
return false;
// Loop through each item, grab it's hidden data and add it to the menu.
$(items).each(function(){
var item_type = $(this).parent().siblings('.menu-item-type').val();
if ( 'custom' == item_type ) {
var item_attr_title = $(this).parent().siblings('.menu-item-attr-title').val();
var item_target = $(this).parent().siblings('.menu-item-target').val();
var item_classes = $(this).parent().siblings('.menu-item-classes').val();
var item_xfn = $(this).parent().siblings('.menu-item-xfn').val();
} else {
var item_attr_title = '';
var item_target = '_self';
var item_classes = '';
var item_xfn = '';
};
var item_db_id = $(this).parent().siblings('.menu-item-db-id').val();
var item_object_id = $(this).parent().siblings('.menu-item-object-id').val();
var item_object = $(this).parent().siblings('.menu-item-object').val();
var item_append = $(this).parent().siblings('.menu-item-append').val();
var item_parent_id = $(this).parent().siblings('.menu-item-parent-id').val();
var item_title = $(this).parent().siblings('.menu-item-title').val();
var item_url = $(this).parent().siblings('.menu-item-url').val();
var item_description = $(this).parent().siblings('.menu-item-description').val();
if ( undefined == item_description ) {
item_description = '';
};
if ( undefined == item_attr_title ) {
item_attr_title = '';
};
// Add the menu item to the menu
wpNavMenu.add_to_menu( item_db_id, item_object_id, item_object, item_type, item_append, item_parent_id, item_title, item_url, item_description, item_attr_title, item_target, item_classes, item_xfn );
// uncheck the menu item in the list
$(this).attr( 'checked', false );
});
},
/**
* Returns all the nessecary hidden inputs for each menu item.
*
* @param string item_db_id - The menu item's db id.
* @param string item_object_id - The menu item's object id.
* @param string item_object - The menu item's object name.
* @param string item_type - The menu item's object type.
* @param string item_append - The menu item's nice name.
* @param string item_parent_id - The menu item's parent id.
* @param string item_title - The menu item title.
* @param string item_url - The menu item url
* @param string item_description - The menu item description.
* @param string item_attr_title - The title attribute.
* @param string item_target - The target attribute.
* @param string item_classes - Optional. Additional CSS classes for the menu item
* @param string item_xfn - Optional. The rel attribute.
*/
get_hidden_inputs : function( randomnumber, item_db_id, item_object_id, item_object, item_type, item_parent_id, item_title, item_url, item_description, item_attr_title, item_target, item_classes, item_xfn ) {
var hidden = '';
hidden += '<input type="hidden" name="menu-item-db-id[]" value="' + item_db_id + '" />';
hidden += '<input type="hidden" name="menu-item-object-id[]" value="' + item_object_id + '" />';
hidden += '<input type="hidden" name="menu-item-object[]" value="' + item_object + '" />';
hidden += '<input type="hidden" name="menu-item-type[]" value="' + item_type + '" />';
hidden += '<input type="hidden" name="menu-item-parent-id[]" value="' + item_parent_id + '" />';
hidden += '<input type="hidden" name="menu-item-position[]" value="' + randomnumber + '" />';
hidden += '<input type="hidden" name="menu-item-title[]" value="' + item_title + '" />';
hidden += '<input type="hidden" name="menu-item-attr-title[]" value="' + item_attr_title + '" />';
hidden += '<input type="hidden" name="menu-item-url[]" value="' + item_url + '" />';
hidden += '<input type="hidden" name="menu-item-target[]" value="' + item_target + '" />';
hidden += '<input type="hidden" name="menu-item-description[]" value="' + item_description + '" />';
hidden += '<input type="hidden" name="menu-item-classes[]" value="' + item_classes + '" />';
hidden += '<input type="hidden" name="menu-item-xfn[]" value="' + item_xfn + '" />';
return hidden;
} }
}); }
$('#custom-menu-item-url, #custom-menu-item-name').keypress(function(e){ $(document).ready(function($){ wpNavMenu.init(); });
if ( 13 == e.keyCode ) { })(jQuery);
$('#add-custom-links a.button').click();
return false;
}
}).focus(function(){
if ( $(this).val() == $(this).attr('defaultValue') && $(this).attr('id') != 'custom-menu-item-url' ) {
$(this).val('');
}
}).blur(function(){
if ( $(this).val() == '' ) {
$(this).val($(this).attr('defaultValue'));
}
});
$('#create-menu-name').focus(function(){
if ( $(this).val() == $(this).attr('defaultValue') ) {
$(this).val('');
}
}).blur(function(){
if ( $(this).val() == '' ) {
$(this).val($(this).attr('defaultValue'));
}
});
// close postboxes that should be closed
$('.if-js-closed').removeClass('if-js-closed').addClass('closed');
// postboxes setup
postboxes.add_postbox_toggles('menus');
// Clear the quick search textbox
$('.quick-search').click(function(){
$(this).attr( 'value', '' );
});
// Quick Search submit
$('.quick-search-submit').click(function(){
$(this).siblings('.quick-search').search();
});
// Edit menu item
$('#menu-container .item-edit').click(function(){
return wp_edit_menu_item( $(this).attr('value') );
});
// Delete menu item
$('#menu-container .item-delete').live( 'click', function(e){
return wp_remove_menu_item( $(this).attr('value') );
});
// Update menu item settings (thickbox)
$('#update-menu-item').click(function(){
wp_update_menu_item();
return tb_remove();
});
// Close thickbox
$('#cancel-save').click(function(){
return tb_remove();
});
// Show All Button
$('.show-all').click(function(e){
jQuery(e.currentTarget).parent().siblings('.list-wrap').css( 'display', 'block' );
jQuery(e.currentTarget).parent().siblings('.list-wrap').find('li').css( 'display', 'block' );
jQuery(e.currentTarget).hide();
jQuery(e.currentTarget).siblings('.hide-all').show();
});
// Hide All Button
$('.hide-all').click(function(e){
jQuery(e.currentTarget).parent().siblings('.list-wrap').css( 'display', 'none' );
jQuery(e.currentTarget).parent().siblings('.list-wrap').find('li').css( 'display', 'none' );
jQuery(e.currentTarget).hide();
jQuery(e.currentTarget).siblings('.show-all').show();
});
// Add menu items into the menu
$('.add-to-menu').click(function(e){
return wp_add_checked_items_to_menu(e.currentTarget);
});
// Create a new link then add it to the menu
$('#add-custom-links .add-to-menu a').click(function(e){
// Add link to menu
if ( $('#custom-menu-item-url').val() == $('#custom-menu-item-url').attr('defaultValue') )
return; // Do not allow "http://" submissions to go through
wp_add_item_to_menu( 0, '', 'custom', navMenuL10n.custom, 0, $('#custom-menu-item-name').val(), $('#custom-menu-item-url').val(), '', '', '_self', '', '' );
$('#custom-menu-item-name').val($('#custom-menu-item-name').attr('defaultValue'));
$('#custom-menu-item-url' ).val($('#custom-menu-item-url' ).attr('defaultValue')).focus();
});
});

File diff suppressed because one or more lines are too long

View File

@ -12,6 +12,9 @@
/** Load WordPress Administration Bootstrap */ /** Load WordPress Administration Bootstrap */
require_once( 'admin.php' ); require_once( 'admin.php' );
// Load all the nav menu interface functions
require_once( ABSPATH . 'wp-admin/includes/nav-menu.php' );
// Permissions Check // Permissions Check
if ( ! current_user_can('switch_themes') ) if ( ! current_user_can('switch_themes') )
wp_die( __( 'Cheatin&#8217; uh?' )); wp_die( __( 'Cheatin&#8217; uh?' ));
@ -37,9 +40,6 @@ wp_enqueue_script( 'postbox' );
// Thickbox // Thickbox
add_thickbox(); add_thickbox();
// Load all the nav menu interface functions
require_once( ABSPATH . 'wp-admin/includes/nav-menu.php' );
// Container for any messages displayed to the user // Container for any messages displayed to the user
$messages_div = ''; $messages_div = '';
@ -57,9 +57,15 @@ switch ( $action ) {
check_admin_referer( 'delete-nav_menu-' . $nav_menu_selected_id ); check_admin_referer( 'delete-nav_menu-' . $nav_menu_selected_id );
if ( is_nav_menu($nav_menu_selected_id) ) { if ( is_nav_menu($nav_menu_selected_id) ) {
wp_delete_nav_menu( $nav_menu_selected_id ); $delete_nav_menu = wp_delete_nav_menu( $nav_menu_selected_id );
$messages_div = '<div id="message" class="updated fade below-h2"><p>' . __('Menu successfully deleted.') . '</p></div>';
$nav_menu_selected_id = 0; if ( is_wp_error($delete_nav_menu) ) {
$messages_div = '<div id="message" class="error"><p>' . $delete_nav_menu->get_error_message() . '</p></div>';
} else {
$messages_div = '<div id="message" class="updated"><p>' . __('The menu has been successfully deleted.') . '</p></div>';
$nav_menu_selected_id = 0; // Reset the selected menu
}
unset( $delete_nav_menu );
} }
break; break;
@ -75,18 +81,20 @@ switch ( $action ) {
$add_nav_menu = wp_create_nav_menu( $add_nav_menu ); $add_nav_menu = wp_create_nav_menu( $add_nav_menu );
if ( is_wp_error( $add_nav_menu ) ) { if ( is_wp_error( $add_nav_menu ) ) {
$messages_div = '<div id="message" class="error fade below-h2"><p>' . $add_nav_menu->get_error_message() . '</p></div>'; $messages_div = '<div id="message" class="error"><p>' . $add_nav_menu->get_error_message() . '</p></div>';
} else { } else {
$nav_menu_selected_id = $add_nav_menu->term_id; $nav_menu_selected_id = $add_nav_menu->term_id;
$nav_menu_selected_title = $add_nav_menu->name; $nav_menu_selected_title = $add_nav_menu->name;
$messages_div = '<div id="message" class="updated fade below-h2"><p>' . sprintf( __('The <strong>%s</strong> menu has been successfully created.'), esc_html( $add_nav_menu->name ) ) . '</p></div>'; $messages_div = '<div id="message" class="updated"><p>' . sprintf( __('The <strong>%s</strong> menu has been successfully created.'), $add_nav_menu->name ) . '</p></div>';
} }
} else { } else {
$messages_div = '<div id="message" class="error fade below-h2"><p>' . __('Please enter a valid menu name.') . '</p></div>'; $messages_div = '<div id="message" class="error"><p>' . __('Please enter a valid menu name.') . '</p></div>';
} }
unset($add_nav_menu); unset( $add_nav_menu );
} }
} else { } else {
// @todo wrap this into wp_update_nav_menu_object();
if ( isset($_POST['menu-name']) ) { if ( isset($_POST['menu-name']) ) {
$old_nav_menu = get_term( $nav_menu_selected_id, 'nav_menu', ARRAY_A ); $old_nav_menu = get_term( $nav_menu_selected_id, 'nav_menu', ARRAY_A );
$args = array( 'name' => $_POST['menu-name'], 'slug' => null, 'description' => $old_nav_menu['description'], 'parent' => $old_nav_menu['parent'], ); $args = array( 'name' => $_POST['menu-name'], 'slug' => null, 'description' => $old_nav_menu['description'], 'parent' => $old_nav_menu['parent'], );
@ -94,17 +102,24 @@ switch ( $action ) {
} }
// Update menu items // Update menu items
$update_nav_items = isset( $_POST['li-count'] ) ? (int) $_POST['li-count'] : 0;
// @todo: wrap update logic into wp_update_nav_menu();
$update_count = isset( $_POST['li-count'] ) ? (int) $_POST['li-count'] : 0;
$update_nav_menu = is_nav_menu( $nav_menu_selected_id ); $update_nav_menu = is_nav_menu( $nav_menu_selected_id );
if ( !is_wp_error($update_nav_menu) ) { if ( !is_wp_error($update_nav_menu) ) {
$menu_items = wp_get_nav_menu_items( $nav_menu_selected_id, array('orderby' => 'ID', 'output' => ARRAY_A, 'output_key' => 'ID') ); $menu_items = wp_get_nav_menu_items( $nav_menu_selected_id, array('orderby' => 'ID', 'output' => ARRAY_A, 'output_key' => 'ID') );
$parent_menu_ids = array();
// Loop through all POST variables // Loop through all POST variables
for ( $k = 0; $k < $update_nav_items; $k++ ) { for ( $k = 0; $k < $update_count; $k++ ) {
// Menu item title can't be blank
if ( '' == $_POST['menu-item-title'][$k] )
continue;
$menu_item_db_id = isset( $_POST['menu-item-db-id'][$k] ) ? $_POST['menu-item-db-id'][$k] : 0; $menu_item_db_id = isset( $_POST['menu-item-db-id'][$k] ) ? $_POST['menu-item-db-id'][$k] : 0;
$menu_item_object_id = isset( $_POST['menu-item-object-id'][$k] ) ? $_POST['menu-item-object-id'][$k] : 0; $menu_item_object_id = isset( $_POST['menu-item-object-id'][$k] ) ? $_POST['menu-item-object-id'][$k] : 0;
$menu_item_object = isset( $_POST['menu-item-object'][$k] ) ? $_POST['menu-item-object'][$k] : '';
$menu_item_parent_id = isset( $_POST['menu-item-parent-id'][$k] ) ? $_POST['menu-item-parent-id'][$k] : 0; $menu_item_parent_id = isset( $_POST['menu-item-parent-id'][$k] ) ? $_POST['menu-item-parent-id'][$k] : 0;
$menu_item_position = isset( $_POST['menu-item-position'][$k] ) ? $_POST['menu-item-position'][$k] : 0; $menu_item_position = isset( $_POST['menu-item-position'][$k] ) ? $_POST['menu-item-position'][$k] : 0;
$menu_item_type = isset( $_POST['menu-item-type'][$k] ) ? $_POST['menu-item-type'][$k] : 'custom'; $menu_item_type = isset( $_POST['menu-item-type'][$k] ) ? $_POST['menu-item-type'][$k] : 'custom';
@ -113,41 +128,40 @@ switch ( $action ) {
$menu_item_url = isset( $_POST['menu-item-url'][$k] ) ? $_POST['menu-item-url'][$k] : ''; $menu_item_url = isset( $_POST['menu-item-url'][$k] ) ? $_POST['menu-item-url'][$k] : '';
$menu_item_description = isset( $_POST['menu-item-description'][$k] ) ? $_POST['menu-item-description'][$k] : ''; $menu_item_description = isset( $_POST['menu-item-description'][$k] ) ? $_POST['menu-item-description'][$k] : '';
$menu_item_attr_title = isset( $_POST['menu-item-attr-title'][$k] ) ? $_POST['menu-item-attr-title'][$k] : ''; $menu_item_attr_title = isset( $_POST['menu-item-attr-title'][$k] ) ? $_POST['menu-item-attr-title'][$k] : '';
$menu_item_target = isset( $_POST['menu-item-target'][$k] ) ? $_POST['menu-item-target'][$k] : 0; $menu_item_target = isset( $_POST['menu-item-target'][$k] ) ? $_POST['menu-item-target'][$k] : '_self';
$menu_item_classes = isset( $_POST['menu-item-classes'][$k] ) ? $_POST['menu-item-classes'][$k] : ''; $menu_item_classes = isset( $_POST['menu-item-classes'][$k] ) ? $_POST['menu-item-classes'][$k] : '';
$menu_item_xfn = isset( $_POST['menu-item-xfn'][$k] ) ? $_POST['menu-item-xfn'][$k] : ''; $menu_item_xfn = isset( $_POST['menu-item-xfn'][$k] ) ? $_POST['menu-item-xfn'][$k] : '';
// Menu item title can't be blank // Populate the menu item object
if ( '' == $menu_item_title ) $post = array(
continue; 'post_status' => 'publish', 'post_type' => 'nav_menu_item', 'ping_status' => 0,
'post_author' => $user_ID, 'tax_input' => array( 'nav_menu' => $update_nav_menu->name ),
// Populate the menu item 'post_title' => $menu_item_title, 'post_excerpt' => $menu_item_attr_title,
$post = array( 'post_status' => 'publish', 'post_type' => 'nav_menu_item', 'post_author' => $user_ID, 'post_parent' => $menu_item_parent_id, 'menu_order' => $menu_item_position,
'ping_status' => 0, 'post_parent' => $menu_item_parent_id, 'menu_order' => $menu_item_position, 'post_content' => $menu_item_description,
'post_excerpt' => $menu_item_attr_title, 'tax_input' => array( 'nav_menu' => $update_nav_menu->name ), );
'post_content' => $menu_item_description, 'post_title' => $menu_item_title );
// New menu item // New menu item
if ( $menu_item_db_id == 0 ) { if ( $menu_item_db_id == 0 ) {
$menu_item_db_id = wp_insert_post( $post ); $menu_item_db_id = wp_insert_post( $post );
} elseif ( isset( $menu_items[$menu_item_db_id] ) ) {
// Update existing menu item
} elseif ( isset($menu_items[$menu_item_db_id]) || ( 'custom' == $menu_item_type && 0 != $menu_item_db_id ) ) {
$post['ID'] = $menu_item_db_id; $post['ID'] = $menu_item_db_id;
wp_update_post( $post ); wp_update_post( $post );
unset( $menu_items[$menu_item_db_id] ); unset( $menu_items[$menu_item_db_id] );
} }
$parent_menu_ids[$k] = $menu_item_db_id;
// @todo sanitize type append and ID. update_post_meta( $menu_item_db_id, '_menu_item_type', sanitize_key($menu_item_type) );
update_post_meta( $menu_item_db_id, 'menu_item_type', $menu_item_type ); update_post_meta( $menu_item_db_id, '_menu_item_object_id', (int) $menu_item_object_id );
update_post_meta( $menu_item_db_id, 'menu_item_append', $menu_item_append ); update_post_meta( $menu_item_db_id, '_menu_item_object', sanitize_key($menu_item_object) );
update_post_meta( $menu_item_db_id, 'menu_item_object_id', $menu_item_object_id ); update_post_meta( $menu_item_db_id, '_menu_item_target', sanitize_key($menu_item_target) );
update_post_meta( $menu_item_db_id, 'menu_item_target', sanitize_key($menu_item_target) );
// @todo handle sanitizing multiple classes separated by whitespace. // @todo handle sanitizing multiple classes separated by whitespace.
update_post_meta( $menu_item_db_id, 'menu_item_classes', sanitize_html_class($menu_item_classes) ); update_post_meta( $menu_item_db_id, '_menu_item_classes', sanitize_html_class($menu_item_classes) );
update_post_meta( $menu_item_db_id, 'menu_item_xfn', sanitize_html_class($menu_item_xfn) ); update_post_meta( $menu_item_db_id, '_menu_item_xfn', sanitize_html_class($menu_item_xfn) );
// @todo: only save custom link urls. // @todo: only save custom link urls.
update_post_meta( $menu_item_db_id, 'menu_item_url', esc_url_raw( $menu_item_url ) ); update_post_meta( $menu_item_db_id, '_menu_item_url', esc_url_raw($menu_item_url) );
} }
// Remove menu items from the menu that weren't in $_POST // Remove menu items from the menu that weren't in $_POST
@ -156,7 +170,11 @@ switch ( $action ) {
wp_delete_post( $menu_item_id ); wp_delete_post( $menu_item_id );
} }
} }
$messages_div = '<div id="message" class="updated fade below-h2"><p>' . __('The menu has been updated.') . '</p></div>';
do_action( 'wp_update_nav_menu', $nav_menu_selected_id );
$messages_div = '<div id="message" class="updated"><p>' . sprintf( __('The <strong>%s</strong> menu has been updated.'), $update_nav_menu->name ) . '</p></div>';
unset( $update_nav_menu, $update_count, $menu_items );
} }
} }
break; break;
@ -190,15 +208,24 @@ if ( !$nav_menu_selected_title && $nav_menu_selected_title = is_nav_menu( $nav_m
$nav_menu_selected_title = $nav_menu_selected_title->name; $nav_menu_selected_title = $nav_menu_selected_title->name;
} }
// Create Menu Metabox
add_meta_box( 'create-menu', __('Create Menu'), 'wp_nav_menu_create_metabox', 'nav-menus', 'side', 'core' );
// The user has no menus. // The user has no menus.
if ( !is_nav_menu( $nav_menu_selected_id ) ) { if ( !is_nav_menu( $nav_menu_selected_id ) ) {
if ( current_theme_supports('nav-menus') ) { $messages_div = '<div id="message" class="updated"><p>' . __('You do not have any menus. Create a new menu.') . '</p></div>';
$messages_div = '<div id="message" class="updated"><p>' . __('You do not have any menus. Create a new menu.') . '</p></div>';
} else { // The theme supports menus
$messages_div = '<div id="message" class="error"><p>' . __('The current theme does not support menus.') . '</p></div>'; } elseif ( current_theme_supports('nav-menus') ) {
}
// Register nav menu metaboxes
add_meta_box( 'manage-menu', __( 'Menu Settings' ), 'wp_nav_menu_manage_menu_metabox', 'nav-menus', 'side', 'high', array( $nav_menu_selected_id, $nav_menu_selected_title ) );
wp_nav_menu_metaboxes_setup();
// The theme does not support menus
} else { } else {
add_meta_box( 'manage-menu', __( 'Menu Settings' ), 'wp_nav_menu_manage_menu_metabox', 'menus', 'side', 'high', array( $nav_menu_selected_id, $nav_menu_selected_title ) ); remove_meta_box( 'create-menu', 'nav-menus', 'side' );
$messages_div = '<div id="message" class="error"><p>' . __('The current theme does not support menus.') . '</p></div>';
} }
// Get the admin header // Get the admin header
@ -210,7 +237,7 @@ require_once( 'admin-header.php' );
<?php echo $messages_div; ?> <?php echo $messages_div; ?>
<div class="hide-if-js error"><p><?php _e('You do not have JavaScript enabled in your browser. Please enable it to access the Menus functionality.'); ?></p></div> <div class="hide-if-js error"><p><?php _e('You do not have JavaScript enabled in your browser. Please enable it to access the Menus functionality.'); ?></p></div>
<?php if ( !empty($nav_menus) && count($nav_menus) > 1 ) : ?> <?php if ( !empty($nav_menus) && count($nav_menus) > 1 && current_theme_supports('nav-menus') ) : ?>
<ul class="subsubsub"> <ul class="subsubsub">
<?php <?php
foreach ( $nav_menus as $_nav_menu ) { foreach ( $nav_menus as $_nav_menu ) {
@ -226,35 +253,30 @@ require_once( 'admin-header.php' );
<?php endif; ?> <?php endif; ?>
<div id="menu-management" class="metabox-holder has-right-sidebar"> <div id="menu-management" class="metabox-holder has-right-sidebar">
<form id="update-nav-menu" onsubmit="wp_update_post_data();" action="<?php echo admin_url( 'nav-menus.php' ); ?>" method="post" enctype="multipart/form-data"> <form id="update-nav-menu" action="<?php echo admin_url( 'nav-menus.php' ); ?>" method="post" enctype="multipart/form-data">
<?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?> <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
<?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?> <?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
<?php wp_nonce_field( 'update-nav_menu' ); ?> <?php wp_nonce_field( 'update-nav_menu' ); ?>
<input type="hidden" name="action" value="update" /> <input type="hidden" name="action" value="update" />
<input type="hidden" name="li-count" id="li-count" value="0" /> <input type="hidden" name="li-count" id="li-count" value="-1" />
<input type="hidden" name="menu" id="menu" value="<?php echo esc_attr( $nav_menu_selected_id ); ?>" /> <input type="hidden" name="menu" id="menu" value="<?php echo esc_attr( $nav_menu_selected_id ); ?>" />
<input type="hidden" id="hidden-metaboxes" value="<?php echo wp_initial_nav_menu_meta_boxes(); ?>" />
<div id="post-body"> <div id="post-body">
<div id="post-body-content"> <div id="post-body-content">
<?php if ( is_nav_menu($nav_menu_selected_id) ) : ?> <?php if ( is_nav_menu($nav_menu_selected_id) && current_theme_supports('nav-menus') ) : ?>
<div id="menu-container" class="postbox"> <div id="menu-container" class="postbox">
<h3 class="hndle"><?php echo esc_html( $nav_menu_selected_title ); ?></h3> <h3 class="hndle"><?php echo esc_html( $nav_menu_selected_title ); ?></h3>
<div class="inside"> <div class="inside">
<?php echo wp_get_nav_menu( array( 'context' => 'backend', 'menu' => $nav_menu_selected_id ) ); ?> <?php echo wp_get_nav_menu( array( 'context' => 'backend', 'menu' => $nav_menu_selected_id ) ); ?>
</div><!-- /.inside --> </div><!-- /.inside -->
<!-- /#nav-menu-canvas .postbox--> <!-- /#nav-menu-canvas .postbox-->
</div> </div>
<script type="text/javascript">
wp_update_post_data();
</script>
<?php endif; ?> <?php endif; ?>
</div><!-- /#post-body-content--> </div><!-- /#post-body-content-->
</div><!--- /#post-body --> </div><!--- /#post-body -->
<div id="menu-settings-column" class="inner-sidebar"> <div id="menu-settings-column" class="inner-sidebar">
<?php do_meta_boxes( 'menus', 'side', null ); ?> <?php do_meta_boxes( 'nav-menus', 'side', null ); ?>
</div><!-- /#menu-settings-column --> </div><!-- /#menu-settings-column -->
</form><!--/#update-nav-menu--> </form><!--/#update-nav-menu-->

View File

@ -1123,6 +1123,102 @@ class Walker {
} }
} }
/**
* Create HTML list of nav menu items.
*
* @package WordPress
* @since 3.0.0
* @uses Walker
*/
class Walker_Nav_Menu extends Walker {
/**
* @see Walker::$tree_type
* @since 3.0.0
* @var string
*/
var $tree_type = array( 'post_type', 'taxonomy', 'custom' );
/**
* @see Walker::$db_fields
* @since 3.0.0
* @todo Decouple this.
* @var array
*/
var $db_fields = array( 'parent' => 'post_parent', 'id' => 'object_id' );
/**
* @see Walker::start_lvl()
* @since 3.0.0
*
* @param string $output Passed by reference. Used to append additional content.
* @param int $depth Depth of page. Used for padding.
*/
function start_lvl(&$output, $depth) {
$indent = str_repeat("\t", $depth);
$output .= "\n$indent<ul class=\"sub-menu\">\n";
}
/**
* @see Walker::end_lvl()
* @since 3.0.0
*
* @param string $output Passed by reference. Used to append additional content.
* @param int $depth Depth of page. Used for padding.
*/
function end_lvl(&$output, $depth) {
$indent = str_repeat("\t", $depth);
$output .= "$indent</ul>\n";
}
/**
* @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 int $current_page Menu item ID.
* @param array $args
*/
function start_el(&$output, $item, $depth, $args) {
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
if ( 'frontend' == $args->context ) {
global $wp_query;
$css_class = array( 'menu-item', 'menu-item-type-'. $item->type, $item->classes );
if ( 'custom' != $item->object )
$css_class[] = 'menu-item-object-'. $item->object;
if ( $item->object_id == $wp_query->get_queried_object_id() )
$css_class[] = 'current-menu-item';
// @todo add classes for parent/child relationships
$css_class = join( ' ', apply_filters('nav_menu_css_class', $css_class, $item) );
}
$maybe_value = ( 'backend' == $args->context ) ? ' value="'. $item->ID .'"' : '';
$maybe_classes = ( 'frontend' == $args->context ) ? ' class="'. $css_class .'"' : '';
$output .= $indent . '<li id="menu-item-'. $item->ID .'"'. $maybe_value . $maybe_classes .'>' . wp_get_nav_menu_item( $item, $args->context, $args );
}
/**
* @see Walker::end_el()
* @since 3.0.0
*
* @param string $output Passed by reference. Used to append additional content.
* @param object $item Page data object. Not used.
* @param int $depth Depth of page. Not Used.
*/
function end_el(&$output, $item, $depth) {
$output .= "</li>\n";
}
}
/** /**
* Create HTML list of pages. * Create HTML list of pages.
* *

View File

@ -9,13 +9,11 @@
* menu_class - CSS class to use for the div container of the menu list. Defaults to 'menu'. * menu_class - CSS class to use for the div container of the menu list. Defaults to 'menu'.
* format - Whether to format the ul. Defaults to 'div'. * format - Whether to format the ul. Defaults to 'div'.
* fallback_cb - If the menu doesn't exists, a callback function will fire. Defaults to 'wp_page_menu'. * fallback_cb - If the menu doesn't exists, a callback function will fire. Defaults to 'wp_page_menu'.
* before_link - Output text before the link. * before - Text before the link text.
* after_link - Output text after the link. * after - Text after the link text.
* before_title - Output text before the link text. * link_before - Text before the link.
* before_title - Output text after the link text. * link_after - Text after the link.
* echo - Whether to echo the menu or return it. Defaults to echo. * echo - Whether to echo the menu or return it. Defaults to echo.
*
* TODO:
* show_home - If you set this argument, then it will display the link to the home page. The show_home argument really just needs to be set to the value of the text of the link. * show_home - If you set this argument, then it will display the link to the home page. The show_home argument really just needs to be set to the value of the text of the link.
* *
* @since 3.0.0 * @since 3.0.0
@ -24,7 +22,8 @@
*/ */
function wp_nav_menu( $args = array() ) { function wp_nav_menu( $args = array() ) {
$defaults = array( 'menu' => '', 'container' => 'div', 'container_class' => '', 'menu_class' => 'menu', 'echo' => true, $defaults = array( 'menu' => '', 'container' => 'div', 'container_class' => '', 'menu_class' => 'menu', 'echo' => true,
'fallback_cb' => 'wp_page_menu', 'before_link' => '', 'after_link' => '', 'before_title' => '', 'after_title' => '', ); 'fallback_cb' => 'wp_page_menu', 'before' => '', 'after' => '', 'link_before' => '', 'link_after' => '',
'depth' => 0, 'walker' => '' );
$args = wp_parse_args( $args, $defaults ); $args = wp_parse_args( $args, $defaults );
$args = apply_filters( 'wp_nav_menu_args', $args ); $args = apply_filters( 'wp_nav_menu_args', $args );
@ -83,8 +82,8 @@ function wp_nav_menu( $args = array() ) {
* @return mixed $output False if menu doesn't exists, else, returns the menu. * @return mixed $output False if menu doesn't exists, else, returns the menu.
**/ **/
function wp_get_nav_menu( $args = array() ) { function wp_get_nav_menu( $args = array() ) {
$defaults = array( 'menu' => '', 'menu_class' => 'menu', 'context' => 'frontend', $defaults = array( 'menu' => '', 'menu_class' => 'menu', 'context' => 'frontend', 'depth' => 0,
'fallback_cb' => '', 'before_link' => '', 'after_link' => '', 'before_title' => '', 'after_title' => '', ); 'fallback_cb' => '', 'walker' => '', 'before' => '', 'after' => '', 'link_before' => '', 'link_after' => '', );
$args = wp_parse_args( $args, $defaults ); $args = wp_parse_args( $args, $defaults );
$args = apply_filters( 'wp_get_nav_menu_args', $args ); $args = apply_filters( 'wp_get_nav_menu_args', $args );
@ -93,54 +92,27 @@ function wp_get_nav_menu( $args = array() ) {
// Variable setup // Variable setup
$nav_menu = ''; $nav_menu = '';
$items = ''; $items = '';
$current_parent = 0;
$parent_stack = array();
$parent_menu_order = array();
// Get the menu object // Get the menu object
$menu = wp_get_nav_menu_object( $args->menu ); $menu = wp_get_nav_menu_object( $args->menu );
// If the menu exists, get it's items. // If the menu exists, get it's items.
if ( $menu && !is_wp_error($menu) ) if ( $menu && !is_wp_error($menu) )
$menu_items = wp_get_nav_menu_items( $menu->term_id, 'backend' ); $menu_items = wp_get_nav_menu_items( $menu->term_id, $args->context );
// If no menu was found or if the menu has no items, call the fallback_cb // If no menu was found or if the menu has no items, call the fallback_cb
if ( !$menu || is_wp_error($menu) || ( isset($menu_items) && empty($menu_items) ) ) { if ( !$menu || is_wp_error($menu) || ( isset($menu_items) && empty($menu_items) ) ) {
if ( function_exists($args->fallback_cb) ) { if ( function_exists($args->fallback_cb) || is_callable( $args->fallback_cb ) ) {
$_args = array_merge( (array)$args, array('echo' => false) ); $_args = array_merge( (array) $args, array('echo' => false) );
return call_user_func( $args->fallback_cb, $_args ); return call_user_func( $args->fallback_cb, $_args );
} }
} }
foreach ( $menu_items as $key => $menu_item ) { // Set up the $menu_item variables
// Set up the $menu_item variables foreach ( (array) $menu_items as $key => $menu_item )
$menu_item = wp_setup_nav_menu_item( $menu_item, 'frontend' ); $menu_items[$menu_item->menu_order] = wp_setup_nav_menu_item( $menu_item, 'frontend' );
$type = $menu_item->append; $items .= walk_nav_menu_tree( $menu_items, $args->depth, $args );
$maybe_value = 'frontend' == $args->context ? '' : ' value="'. $menu_item->ID .'"';
$classes = 'frontend' == $args->context ? ' class="menu-item-type-'. $type . $menu_item->li_class .'"' : '';
$items .= '<li id="menu-item-'. $menu_item->ID .'"'. $maybe_value . $classes .'>';
$items .= wp_get_nav_menu_item( $menu_item, $args->context, $args );
// Indent children
$last_item = ( count( $menu_items ) == $menu_item->menu_order );
if ( $last_item || $current_parent != $menu_items[$key + 1]->post_parent ) {
if ( $last_item || in_array( $menu_items[$key + 1]->post_parent, $parent_stack ) ) {
$items .= '</li>';
while ( !empty( $parent_stack ) && ($last_item || $menu_items[$key + 1]->post_parent != $current_parent ) ) {
$items .= '</ul></li>';
$current_parent = array_pop( $parent_stack );
}
} else {
array_push( $parent_stack, $current_parent );
$current_parent = $menu_item->ID;
$items .= '<ul class="sub-menu">';
}
} else {
$items .= '</li>';
}
}
// CSS class // CSS class
$ul_class = $args->menu_class ? ' class="'. $args->menu_class .'"' : ''; $ul_class = $args->menu_class ? ' class="'. $args->menu_class .'"' : '';
@ -174,93 +146,68 @@ function wp_get_nav_menu_item( $menu_item, $context = 'frontend', $args = array(
$output = ''; $output = '';
switch ( $context ) { switch ( $context ) {
case 'frontend': case 'frontend':
$attributes = ( isset($menu_item->anchor_title) && '' != $menu_item->anchor_title ) ? ' title="'. esc_attr($menu_item->anchor_title) .'"' : ''; $attributes = ( isset($menu_item->attr_title) && '' != $menu_item->attr_title ) ? ' title="'. esc_attr($menu_item->attr_title) .'"' : '';
$attributes .= ( isset($menu_item->target) && '' != $menu_item->target ) ? ' target="'. esc_attr($menu_item->target) .'"' : ''; $attributes .= ( isset($menu_item->target) && '' != $menu_item->target ) ? ' target="'. esc_attr($menu_item->target) .'"' : '';
$attributes .= ( isset($menu_item->classes) && '' != $menu_item->classes ) ? ' class="'. esc_attr($menu_item->classes) .'"' : '';
$attributes .= ( isset($menu_item->xfn) && '' != $menu_item->xfn ) ? ' rel="'. esc_attr($menu_item->xfn) .'"' : ''; $attributes .= ( isset($menu_item->xfn) && '' != $menu_item->xfn ) ? ' rel="'. esc_attr($menu_item->xfn) .'"' : '';
$attributes .= ( isset($menu_item->url) && '' != $menu_item->url ) ? ' href="'. esc_attr($menu_item->url) .'"' : ''; $attributes .= ( isset($menu_item->url) && '' != $menu_item->url ) ? ' href="'. esc_attr($menu_item->url) .'"' : '';
$output .= esc_html( $args->before_link ); $output .= esc_html( $args->before );
$output .= '<a'. $attributes .'>'; $output .= '<a'. $attributes .'>';
$output .= esc_html( $args->before_title . $menu_item->title . $args->after_title ); $output .= esc_html( $args->link_before . apply_filters('the_title', $menu_item->title) . $args->link_after );
$output .= '</a>'; $output .= '</a>';
$output .= esc_html( $args->after_link ); $output .= esc_html( $args->after );
break; break;
case 'backend': case 'backend':
$output .= '<dl><dt>'; $output .= '<dl><dt>';
$output .= '<span class="item-title">'. esc_html($menu_item->title) .'</span>'; $output .= '<span class="item-title">'. esc_html( $menu_item->title ) .'</span>';
$output .= '<span class="item-controls">'; $output .= '<span class="item-controls">';
if ( 'custom' == $menu_item->type ) { $output .= '<span class="item-type">'. esc_html( $menu_item->append ) .'</span>';
$label = __('Custom');
} elseif ( 'post_type' == $menu_item->type ) {
$type_obj = get_post_type_object($menu_item->append);
$label = $type_obj->singular_label;
} elseif ( 'taxonomy' == $menu_item->type ) {
$taxonomy = get_taxonomy($menu_item->append);
$label = $taxonomy->singular_label;
} else {
$label = $menu_item->append;
}
$output .= '<span class="item-type">'. esc_html($label) .'</span>';
// Actions // Actions
$output .= '<a class="item-edit thickbox" id="edit'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->menu_order ) .'" title="'. __('Edit Menu Item') .'" href="#TB_inline?height=540&width=300&inlineId=menu-item-settings">'. __('Edit') .'</a> | '; $output .= '<a class="item-edit thickbox" id="edit-'. esc_attr( $menu_item->ID ) .'" value="'. esc_attr( $menu_item->ID ) .'" title="'. __('Edit Menu Item') .'" href="#TB_inline?height=540&width=300&inlineId=menu-item-settings">'. __('Edit') .'</a> | ';
$output .= '<a class="item-delete" id="delete'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->menu_order ) .'">'. __('Delete') .'</a>'; $output .= '<a class="item-delete" id="delete-'. esc_attr( $menu_item->ID ) .'" value="'. esc_attr( $menu_item->ID ) .'">'. __('Delete') .'</a>';
$output .= '</dt></dl>'; $output .= '</span></dt></dl>';
// Menu Item Settings // Menu Item Settings
$output .= '<input type="hidden" name="menu-item-db-id[]" id="menu-item-db-id'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->ID ) .'" />'; $output .= '<input type="hidden" name="menu-item-db-id[]" value="'. esc_attr( $menu_item->ID ) .'" />';
$output .= '<input type="hidden" name="menu-item-object-id[]" id="menu-item-object-id'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->object_id ) .'" />'; $output .= '<input type="hidden" name="menu-item-object-id[]" value="'. esc_attr( $menu_item->object_id ) .'" />';
$output .= '<input type="hidden" name="menu-item-parent-id[]" id="menu-item-parent-id'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->post_parent ) .'" />'; $output .= '<input type="hidden" name="menu-item-object[]" value="'. esc_attr( $menu_item->object ) .'" />';
$output .= '<input type="hidden" name="menu-item-position[]" id="menu-item-position'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->menu_order ) .'" />'; $output .= '<input type="hidden" name="menu-item-parent-id[]" value="'. esc_attr( $menu_item->post_parent ) .'" />';
$output .= '<input type="hidden" name="menu-item-type[]" id="menu-item-type'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->type ) .'" />'; $output .= '<input type="hidden" name="menu-item-position[]" value="'. esc_attr( $menu_item->menu_order ) .'" />';
$output .= '<input type="hidden" name="menu-item-append[]" id="menu-item-append'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->append ) .'" />'; $output .= '<input type="hidden" name="menu-item-type[]" value="'. esc_attr( $menu_item->type ) .'" />';
$output .= '<input type="hidden" name="menu-item-title[]" id="menu-item-title'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->title ) .'" />'; $output .= '<input type="hidden" name="menu-item-title[]" value="'. esc_attr( $menu_item->title ) .'" />';
$output .= '<input type="hidden" name="menu-item-url[]" id="menu-item-url'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->url ) .'" />'; $output .= '<input type="hidden" name="menu-item-url[]" value="'. esc_attr( $menu_item->url ) .'" />';
$output .= '<input type="hidden" name="menu-item-description[]" id="menu-item-description'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->description ) .'" />'; $output .= '<input type="hidden" name="menu-item-description[]" value="'. esc_attr( $menu_item->description ) .'" />';
$output .= '<input type="hidden" name="menu-item-classes[]" id="menu-item-classes'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->classes ) .'" />'; $output .= '<input type="hidden" name="menu-item-classes[]" value="'. esc_attr( $menu_item->classes ) .'" />';
$output .= '<input type="hidden" name="menu-item-xfn[]" id="menu-item-xfn'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->xfn ) .'" />'; $output .= '<input type="hidden" name="menu-item-xfn[]" value="'. esc_attr( $menu_item->xfn ) .'" />';
$output .= '<input type="hidden" name="menu-item-attr-title[]" id="menu-item-attr-title'. esc_attr( $menu_item->menu_order ) .'" value="'.esc_attr( $menu_item->post_excerpt ) .'" />'; $output .= '<input type="hidden" name="menu-item-attr-title[]" value="'.esc_attr( $menu_item->post_excerpt ) .'" />';
$output .= '<input type="hidden" name="menu-item-target[]" id="menu-item-target'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->target ) .'" />'; $output .= '<input type="hidden" name="menu-item-target[]" value="'. esc_attr( $menu_item->target ) .'" />';
break; break;
case 'custom': case 'custom':
$menu_id = 'menu-item-' . $menu_item->db_id; case 'taxonomy':
$output .= '<label class="menu-item-title"><input type="checkbox" id="'. esc_attr( $menu_id ) .'" name="'. esc_attr( $menu_item->title ) .'" value="'. esc_attr( $menu_item->url ) .'" />'. $menu_item->title .'</label>'; case 'post_type':
$output .= '<label class="menu-item-title"><input type="checkbox" id="'. esc_attr( 'menu-item-' . $menu_item->object_id ) .'" value="'. esc_attr( $menu_item->url ) .'" />'. $menu_item->title .'</label>';
// Menu item hidden fields // Menu item hidden fields
$output .= '<input type="hidden" class="menu-item-db-id" value="'. esc_attr( $menu_item->db_id ) .'" />'; $output .= '<input type="hidden" class="menu-item-db-id" value="0" />';
$output .= '<input type="hidden" class="menu-item-object-id" value="'. esc_attr( $menu_item->object_id ) .'" />'; $output .= '<input type="hidden" class="menu-item-object-id" value="'. esc_attr( $menu_item->object_id ) .'" />';
$output .= '<input type="hidden" class="menu-item-parent-id" value="'. esc_attr( $menu_item->parent_id ) .'" />'; $output .= '<input type="hidden" class="menu-item-object" value="'. esc_attr( $menu_item->object ) .'" />';
$output .= '<input type="hidden" class="menu-item-parent-id" value="'. esc_attr( $menu_item->post_parent ) .'" />';
$output .= '<input type="hidden" class="menu-item-type" value="'. esc_attr( $menu_item->type ) .'" />'; $output .= '<input type="hidden" class="menu-item-type" value="'. esc_attr( $menu_item->type ) .'" />';
$output .= '<input type="hidden" class="menu-item-append" value="'. esc_attr( $menu_item->append ) .'" />'; $output .= '<input type="hidden" class="menu-item-append" value="'. esc_attr( $menu_item->append ) .'" />';
$output .= '<input type="hidden" class="menu-item-title" value="'. esc_attr( $menu_item->title ) .'" />'; $output .= '<input type="hidden" class="menu-item-title" value="'. esc_attr( $menu_item->title ) .'" />';
$output .= '<input type="hidden" class="menu-item-url" value="'. esc_attr( $menu_item->url ) .'" />'; $output .= '<input type="hidden" class="menu-item-url" value="'. esc_attr( $menu_item->url ) .'" />';
$output .= '<input type="hidden" class="menu-item-append" value="'. esc_attr( $menu_item->append ) .'" />';
$output .= '<input type="hidden" class="menu-item-target" value="'. esc_attr( $menu_item->target ) .'" />'; $output .= '<input type="hidden" class="menu-item-target" value="'. esc_attr( $menu_item->target ) .'" />';
$output .= '<input type="hidden" class="menu-item-attr_title" value="'. esc_attr( $menu_item->attr_title ) .'" />'; $output .= '<input type="hidden" class="menu-item-attr_title" value="'. esc_attr( $menu_item->attr_title ) .'" />';
$output .= '<input type="hidden" class="menu-item-description" value="'. esc_attr( $menu_item->description ) .'" />'; $output .= '<input type="hidden" class="menu-item-description" value="'. esc_attr( $menu_item->description ) .'" />';
$output .= '<input type="hidden" class="menu-item-classes" value="'. esc_attr( $menu_item->classes ) .'" />'; $output .= '<input type="hidden" class="menu-item-classes" value="'. esc_attr( $menu_item->classes ) .'" />';
$output .= '<input type="hidden" class="menu-item-xfn" value="'. esc_attr( $menu_item->xfn ) .'" />'; $output .= '<input type="hidden" class="menu-item-xfn" value="'. esc_attr( $menu_item->xfn ) .'" />';
break; break;
case 'taxonomy':
case 'post_type':
$menu_id = 'menu-item-' . $menu_item->db_id;
$output .= '<label class="menu-item-title"><input type="checkbox" id="'. esc_attr( $menu_id ) .'" name="'. esc_attr( $menu_item->title ) .'" value="'. esc_attr( $menu_item->url ) .'" />'. $menu_item->title .'</label>';
// Menu item hidden fields
$output .= '<input type="hidden" class="menu-item-db-id" value="0" />';
$output .= '<input type="hidden" class="menu-item-object-id" value="'. esc_attr( $menu_item->object_id ) .'" />';
$output .= '<input type="hidden" class="menu-item-parent-id" value="'. esc_attr( $menu_item->parent_id ) .'" />';
$output .= '<input type="hidden" class="menu-item-type" value="'. esc_attr( $menu_item->type ) .'" />';
$output .= '<input type="hidden" class="menu-item-append" value="'. esc_attr( $menu_item->append ) .'" />';
$output .= '<input type="hidden" class="menu-item-title" value="'. esc_attr( $menu_item->title ) .'" />';
$output .= '<input type="hidden" class="menu-item-url" value="'. esc_attr( $menu_item->url ) .'" />';
$output .= '<input type="hidden" class="menu-item-append" value="'. esc_attr( $menu_item->append ) .'" />';
break;
} }
return $output; return $output;

View File

@ -8,26 +8,26 @@
*/ */
/** /**
* Returns a Navigation Menu object * Returns a navigation menu object.
* *
* @since 3.0.0 * @since 3.0.0
* *
* @param string $menu Menu id * @param string $menu Menu id
* @return mixed $menu|false * @return mixed $menu|false Or WP_Error
*/ */
function wp_get_nav_menu_object( $menu ) { function wp_get_nav_menu_object( $menu ) {
return is_nav_menu( $menu ); return is_nav_menu( $menu );
} }
/** /**
* Check if Menu exists. * Check if navigation menu exists.
* *
* Returns the menu object, or false if the term doesn't exist. * Returns the menu object, or false if the term doesn't exist.
* *
* @since 3.0.0 * @since 3.0.0
* *
* @param int|string $menu The menu to check * @param int|string $menu The menu to check
* @return mixed Menu Object, if exists. * @return mixed Menu Object, if it exists. Else, false or WP_Error
*/ */
function is_nav_menu( $menu ) { function is_nav_menu( $menu ) {
if ( !$menu ) if ( !$menu )
@ -49,7 +49,7 @@ function is_nav_menu( $menu ) {
} }
/** /**
* Creates a navigation menu. * Create a Navigation Menu.
* *
* Optional args: * Optional args:
* slug - the url friendly version of the nav menu. * slug - the url friendly version of the nav menu.
@ -58,13 +58,13 @@ function is_nav_menu( $menu ) {
* *
* @param string $menu_name Menu Name * @param string $menu_name Menu Name
* @param string $args Optional. * @param string $args Optional.
* @return mixed Menu object|WP_Error * @return mixed Menu object on sucess|WP_Error on failure
*/ */
function wp_create_nav_menu( $menu_name, $args = array() ) { function wp_create_nav_menu( $menu_name, $args = array() ) {
$menu_exists = get_term_by( 'name', $menu_name, 'nav_menu' ); $menu_exists = get_term_by( 'name', $menu_name, 'nav_menu' );
if ( $menu_exists ) if ( $menu_exists )
return new WP_Error( 'menu_exists', sprintf( __('A menu named &#8220;%s&#8221; already exists; please try another name.'), esc_html( $menu_exists->name ) ) ); return new WP_Error( 'menu_exists', sprintf( __('A menu named <strong>%s</strong> already exists; please try another name.'), esc_html( $menu_exists->name ) ) );
if ( isset($args['slug']) ) if ( isset($args['slug']) )
$slug = $args['slug']; $slug = $args['slug'];
@ -76,16 +76,23 @@ function wp_create_nav_menu( $menu_name, $args = array() ) {
if ( is_wp_error($menu) ) if ( is_wp_error($menu) )
return $menu; return $menu;
return get_term( $menu['term_id'], 'nav_menu') ; $result = get_term( $menu['term_id'], 'nav_menu' );
if ( $result && !is_wp_error($result) ) {
do_action( 'wp_create_nav_menu', $menu['term_id'] );
return $result;
} else {
return $result;
}
} }
/** /**
* Deletes a navigation menu. * Delete a Navigation Menu.
* *
* @since 3.0.0 * @since 3.0.0
* *
* @param string $menu name|id|slug * @param string $menu name|id|slug
* @return bool true on success, else false. * @return mixed Menu object on sucess|WP_Error on failure
*/ */
function wp_delete_nav_menu( $menu ) { function wp_delete_nav_menu( $menu ) {
$menu = wp_get_nav_menu_object( $menu ); $menu = wp_get_nav_menu_object( $menu );
@ -98,11 +105,19 @@ function wp_delete_nav_menu( $menu ) {
wp_delete_post( $item ); wp_delete_post( $item );
} }
} }
wp_delete_term( $menu->term_id, 'nav_menu' );
$result = wp_delete_term( $menu->term_id, 'nav_menu' );
if ( $result && !is_wp_error($result) ) {
do_action( 'wp_delete_nav_menu', $menu->term_id );
return $result;
} else {
return $result;
}
} }
/** /**
* Returns all Navigation Menu objects. * Returns all navigation menu objects.
* *
* @since 3.0.0 * @since 3.0.0
* *
@ -153,62 +168,85 @@ function wp_get_nav_menu_items( $menu, $args = array() ) {
} }
/** /**
* Adds all the nav menu properties to the $menu_item. * Retrieve the HTML list content for nav menu items.
*
* @uses Walker_Nav_Menu to create HTML list content.
* @since 2.1.0
* @see Walker::walk() for parameters and return description.
*/
function walk_nav_menu_tree( $items, $depth, $r ) {
$walker = ( empty($r->walker) ) ? new Walker_Nav_Menu : $r->walker;
$args = array( $items, $depth, $r );
return call_user_func_array(array(&$walker, 'walk'), $args);
}
/**
* Adds all the navigation menu properties to the menu item.
* *
* @since 3.0.0 * @since 3.0.0
* *
* @param string $menu_item The menu item to modify * @param string $menu_item The menu item to modify
* @param string $menu_item_type The menu item type (template, custom, post_type, taxonomy). * @param string $menu_item_type The menu item type (frontend, custom, post_type, taxonomy).
* @param string $menu_item_object Optional. The menu item object type (post type or taxonomy). * @param string $menu_item_object Optional. The menu item object type (post type or taxonomy).
* @return object $menu_item The modtified menu item. * @return object $menu_item The modified menu item.
*/ */
function wp_setup_nav_menu_item( $menu_item, $menu_item_type = null, $menu_item_object = '' ) { function wp_setup_nav_menu_item( $menu_item, $menu_item_type = null, $menu_item_object = '' ) {
global $wp_query;
switch ( $menu_item_type ) { switch ( $menu_item_type ) {
case 'frontend': case 'frontend':
$menu_item->db_id = (int) $menu_item->ID; $menu_item->db_id = (int) $menu_item->ID;
$menu_item->object_id = get_post_meta( $menu_item->ID, 'menu_item_object_id', true ); $menu_item->object_id = get_post_meta( $menu_item->ID, '_menu_item_object_id', true );
$menu_item->parent_id = (int) $menu_item->post_parent; $menu_item->object = get_post_meta( $menu_item->ID, '_menu_item_object', true );
$menu_item->type = get_post_meta( $menu_item->ID, 'menu_item_type', true ); $menu_item->type = get_post_meta( $menu_item->ID, '_menu_item_type', true );
$menu_item->append = get_post_meta( $menu_item->ID, 'menu_item_append', true ); if ( 'post_type' == $menu_item->type ) {
$object = get_post_type_object( $menu_item->object );
$menu_item->append = $object->singular_label;
} elseif ( 'taxonomy' == $menu_item->type ) {
$object = get_taxonomy( $menu_item->object );
$menu_item->append = $object->singular_label;
} else {
$menu_item->append = __('Custom');
}
$menu_item->title = $menu_item->post_title; $menu_item->title = $menu_item->post_title;
$menu_item->url = get_post_meta( $menu_item->ID, 'menu_item_url', true ); $menu_item->url = get_post_meta( $menu_item->ID, '_menu_item_url', true );
$menu_item->target = get_post_meta( $menu_item->ID, 'menu_item_target', true ); $menu_item->target = get_post_meta( $menu_item->ID, '_menu_item_target', true );
$menu_item->attr_title = strip_tags( $menu_item->post_excerpt ); $menu_item->attr_title = strip_tags( $menu_item->post_excerpt );
$menu_item->description = strip_tags( $menu_item->post_content ); $menu_item->description = strip_tags( $menu_item->post_content );
$menu_item->classes = get_post_meta( $menu_item->ID, 'menu_item_classes', true );; $menu_item->classes = get_post_meta( $menu_item->ID, '_menu_item_classes', true );;
$menu_item->xfn = get_post_meta( $menu_item->ID, 'menu_item_xfn', true ); $menu_item->xfn = get_post_meta( $menu_item->ID, '_menu_item_xfn', true );
$menu_item->li_class = ( $menu_item->object_id == $wp_query->get_queried_object_id() ) ? ' current_page_item' : '';
break; break;
case 'custom': case 'custom':
$menu_item->db_id = (int) $menu_item->ID; $menu_item->db_id = 0;
$menu_item->object_id = (int) $menu_item->ID; $menu_item->object_id = (int) $menu_item->ID;
$menu_item->parent_id = (int) $menu_item->post_parent; $menu_item->object = 'custom';
$menu_item->type = 'custom'; //$menu_item_type $menu_item->type = 'custom';
$menu_item->append = 'custom'; $menu_item->append = __('custom');
$menu_item->attr_title = strip_tags( $menu_item->post_excerpt ); $menu_item->attr_title = strip_tags( $menu_item->post_excerpt );
$menu_item->description = strip_tags( $menu_item->post_content ); $menu_item->description = strip_tags( $menu_item->post_content );
$menu_item->title = $menu_item->post_title; $menu_item->title = $menu_item->post_title;
$menu_item->url = get_post_meta( $menu_item->ID, 'menu_item_url', true ); $menu_item->url = get_post_meta( $menu_item->ID, '_menu_item_url', true );
$menu_item->target = get_post_meta( $menu_item->ID, 'menu_item_target', true ); $menu_item->target = get_post_meta( $menu_item->ID, '_menu_item_target', true );
$menu_item->classes = '';
$menu_item->xfn = '';
break; break;
case 'post_type': case 'post_type':
$menu_item->db_id = 0; $menu_item->db_id = 0;
$menu_item->object_id = (int) $menu_item->ID; $menu_item->object_id = (int) $menu_item->ID;
$menu_item->parent_id = (int) $menu_item->post_parent;
$menu_item->type = $menu_item_type; $menu_item->type = $menu_item_type;
$object = get_post_type_object( $menu_item_object ); $object = get_post_type_object( $menu_item_object );
$menu_item->append = $object->name; $menu_item->object = $object->name;
$menu_item->append = strtolower( $object->singular_label );
$menu_item->title = $menu_item->post_title; $menu_item->title = $menu_item->post_title;
$menu_item->url = get_permalink( $menu_item->ID ); $menu_item->url = get_permalink( $menu_item->ID );
@ -216,29 +254,30 @@ function wp_setup_nav_menu_item( $menu_item, $menu_item_type = null, $menu_item_
$menu_item->attr_title = ''; $menu_item->attr_title = '';
$menu_item->description = strip_tags( $menu_item->post_content ); $menu_item->description = strip_tags( $menu_item->post_content );
$menu_item->classes = '';
$menu_item->xfn = '';
break; break;
case 'taxonomy': case 'taxonomy':
$menu_item->ID = $menu_item->term_id; $menu_item->ID = $menu_item->term_id;
$menu_item->db_id = 0; $menu_item->db_id = 0;
$menu_item->object_id = (int) $menu_item->term_id; $menu_item->object_id = (int) $menu_item->term_id;
$menu_item->parent_id = (int) $menu_item->parent; $menu_item->post_parent = (int) $menu_item->parent;
$menu_item->type = $menu_item_type; $menu_item->type = $menu_item_type;
$object = get_taxonomy( $menu_item_object ); $object = get_taxonomy( $menu_item_object );
$menu_item->append = $object->name; $menu_item->object = $object->name;
$menu_item->append = strtolower( $object->singular_label );
$menu_item->title = $menu_item->name; $menu_item->title = $menu_item->name;
$menu_item->url = get_term_link( $menu_item, $menu_item_object ); $menu_item->url = get_term_link( $menu_item, $menu_item_object );
$menu_item->target = '_self'; $menu_item->target = '_self';
$menu_item->attr_title = ''; $menu_item->attr_title = '';
$menu_item->description = strip_tags( $menu_item->description ); $menu_item->description = strip_tags( $menu_item->description );
$menu_item->classes = '';
$menu_item->xfn = '';
break; break;
} }
$menu_item->classes = get_post_meta( $menu_item->ID, 'menu_item_classes', true );
$menu_item->xfn = get_post_meta( $menu_item->ID, 'menu_item_xfn', true );
return $menu_item; return $menu_item;
} }
?> ?>

View File

@ -63,7 +63,9 @@ function create_initial_post_types() {
'query_var' => false, 'query_var' => false,
) ); ) );
register_post_type( 'nav_menu_item', array( 'public' => false, register_post_type( 'nav_menu_item', array( 'label' => __('Navigation Menu Items'),
'singular_label' => __('Navigation Menu Item'),
'public' => false,
'show_ui' => false, 'show_ui' => false,
'_builtin' => true, '_builtin' => true,
'capability_type' => 'post', 'capability_type' => 'post',

View File

@ -397,11 +397,9 @@ function wp_default_scripts( &$scripts ) {
) ); ) );
// Custom Navigation // Custom Navigation
$scripts->add( 'nav-menu', "/wp-admin/js/nav-menu$suffix.js", false, '20100317b' ); $scripts->add( 'nav-menu', "/wp-admin/js/nav-menu$suffix.js", false, '20100322' );
$scripts->localize( 'nav-menu', 'navMenuL10n', array( $scripts->localize( 'nav-menu', 'navMenuL10n', array(
'custom' => _x('Custom', 'menu nav item type'), 'custom' => _x('Custom', 'menu nav item type'),
'page' => _x('Page', 'menu nav item type'),
'category' => _x('Category', 'menu nav item type'),
'thickbox' => _x('Edit Menu Item', 'Thickbox Title'), 'thickbox' => _x('Edit Menu Item', 'Thickbox Title'),
'edit' => _x('Edit', 'menu item edit text'), 'edit' => _x('Edit', 'menu item edit text'),
'warnDelete' => __( "You are about to permanently delete this menu. \n 'Cancel' to stop, 'OK' to delete." ), 'warnDelete' => __( "You are about to permanently delete this menu. \n 'Cancel' to stop, 'OK' to delete." ),
@ -410,7 +408,6 @@ function wp_default_scripts( &$scripts ) {
$scripts->add( 'custom-background', "/wp-admin/js/custom-background$suffix.js", array('farbtastic'), '20100321' ); $scripts->add( 'custom-background', "/wp-admin/js/custom-background$suffix.js", array('farbtastic'), '20100321' );
$scripts->add_data( 'custom-background', 'group', 1 ); $scripts->add_data( 'custom-background', 'group', 1 );
// See wp_just_in_time_script_localization() for translation data for this object // See wp_just_in_time_script_localization() for translation data for this object
} }
} }

View File

@ -39,6 +39,8 @@ function create_initial_taxonomies() {
) ) ; ) ) ;
register_taxonomy( 'nav_menu', 'nav_menu_item', array( 'hierarchical' => false, register_taxonomy( 'nav_menu', 'nav_menu_item', array( 'hierarchical' => false,
'label' => __('Navigation Menus'),
'singular_label' => __('Navigation Menu'),
'query_var' => false, 'query_var' => false,
'rewrite' => false, 'rewrite' => false,
'show_ui' => false, 'show_ui' => false,

View File

@ -15,7 +15,7 @@ $wp_version = '3.0-alpha';
* *
* @global int $wp_db_version * @global int $wp_db_version
*/ */
$wp_db_version = 13576; $wp_db_version = 13802;
/** /**
* Holds the TinyMCE version * Holds the TinyMCE version