323 | | $defaults = array( |
324 | | 'menu-item-db-id' => $menu_item_db_id, |
325 | | 'menu-item-object-id' => 0, |
326 | | 'menu-item-object' => '', |
327 | | 'menu-item-parent-id' => 0, |
328 | | 'menu-item-position' => 0, |
329 | | 'menu-item-type' => 'custom', |
330 | | 'menu-item-title' => '', |
331 | | 'menu-item-url' => '', |
332 | | 'menu-item-description' => '', |
333 | | 'menu-item-attr-title' => '', |
334 | | 'menu-item-target' => '', |
335 | | 'menu-item-classes' => '', |
336 | | 'menu-item-xfn' => '', |
337 | | 'menu-item-status' => '', |
338 | | ); |
| 323 | if ( 0 !== $menu_item_db_id ) { |
| 324 | // Existing item; only changed properties will be updated. |
| 325 | $item = get_post( $menu_item_db_id ); |
| 326 | $item = wp_setup_nav_menu_item( $item ); |
| 327 | $defaults = array( |
| 328 | 'menu-item-db-id' => $menu_item_db_id, |
| 329 | 'menu-item-object-id' => $item->object_id, |
| 330 | 'menu-item-object' => $item->object, |
| 331 | 'menu-item-parent-id' => $item->menu_item_parent, |
| 332 | 'menu-item-position' => $item->menu_order, |
| 333 | 'menu-item-type' => $item->type, |
| 334 | 'menu-item-title' => $item->title, |
| 335 | 'menu-item-url' => $item->url, |
| 336 | 'menu-item-description' => $item->description, |
| 337 | 'menu-item-attr-title' => $item->attr_title, |
| 338 | 'menu-item-target' => $item->target, |
| 339 | 'menu-item-classes' => $item->classes, |
| 340 | 'menu-item-xfn' => $item->xfn, |
| 341 | 'menu-item-status' => $item->post_status, |
| 342 | ); |
| 343 | } else { |
| 344 | $defaults = array( |
| 345 | 'menu-item-db-id' => $menu_item_db_id, |
| 346 | 'menu-item-object-id' => 0, |
| 347 | 'menu-item-object' => '', |
| 348 | 'menu-item-parent-id' => 0, |
| 349 | 'menu-item-position' => 0, |
| 350 | 'menu-item-type' => 'custom', |
| 351 | 'menu-item-title' => '', |
| 352 | 'menu-item-url' => '', |
| 353 | 'menu-item-description' => '', |
| 354 | 'menu-item-attr-title' => '', |
| 355 | 'menu-item-target' => '', |
| 356 | 'menu-item-classes' => '', |
| 357 | 'menu-item-xfn' => '', |
| 358 | 'menu-item-status' => '', |
| 359 | ); |
| 360 | } |