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

git-svn-id: https://develop.svn.wordpress.org/trunk@13802 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin
2010-03-22 19:56:16 +00:00
parent d53d09ca48
commit 94ec7ba0eb
15 changed files with 932 additions and 748 deletions
+28 -1
View File
@@ -1004,7 +1004,7 @@ case 'closed-postboxes' :
update_user_option($user->ID, "closedpostboxes_$page", $closed);
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);
}
@@ -1395,6 +1395,33 @@ case 'set-post-thumbnail':
}
}
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 :
do_action( 'wp_ajax_' . $_POST['action'] );
die('0');