// Populate the menu item object.
$post = array
( 'menu_order' =>
$args['menu-item-position'
],
'ping_status' => 0,
'post_content' =>
$args['menu-item-description'
],
'post_excerpt' =>
$args['menu-item-attr-title'
],
'post_parent' =>
$original_parent,
'post_title' =>
$args['menu-item-title'
],
'post_type' => 'nav_menu_item',
);
$post_date =
wp_resolve_post_date( $args['menu-item-post-date'
],
$args['menu-item-post-date-gmt'
] );
if ( $post_date ) { $post['post_date'
] =
$post_date;
} $update = 0 !=
$menu_item_db_id;
// New menu item. Default is draft status.
if ( !
$update ) { $post['ID'
] = 0;
$post['post_status'
] = 'publish' ===
$args['menu-item-status'
] ? 'publish' : 'draft';
$menu_item_db_id =
wp_insert_post( $post, true,
$fire_after_hooks );