WordPress.org

Make WordPress Core


Ignore:
Timestamp:
02/27/2010 11:06:56 PM (10 years ago)
Author:
wpmuguru
Message:

more menu improvements, props ptahdunbar, see #11817

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-ajax.php

    r13409 r13473  
    477477    _wp_ajax_delete_comment_response( $comment->comment_ID );
    478478    die( '0' );
     479    break;
     480case 'add-menu-link':
     481    if ( !current_user_can( 'manage_links' ) )
     482        die('-1');
     483   
     484    $link_url = isset($_POST['link_url']) ? $_POST['link_url'] : false;
     485    $link_name = isset($_POST['link_name']) ? $_POST['link_name'] : false;
     486   
     487    if ( !$link_url || !$link_name )
     488        die('-1');
     489   
     490    $post = array( 'post_type' => 'nav_menu_item', 'post_title' => $link_name, 'ping_status' => false, 'post_excerpt' => '', 'post_content' => '' );
     491    $db_id = wp_insert_post( $post );
     492
     493    update_post_meta( $db_id, 'menu_type', 'custom' );
     494    update_post_meta( $db_id, 'object_id', '' );
     495    update_post_meta( $db_id, 'menu_new_window', 0 );
     496    update_post_meta( $db_id, 'menu_link', esc_url_raw( $link_url ) );
     497   
     498    echo $db_id;
    479499    break;
    480500case 'add-link-category' : // On the Fly
Note: See TracChangeset for help on using the changeset viewer.