| @@ 472-498 (lines=27) @@ | ||
| 469 | * @param array $menu The menu the item belongs to (used when $children is set to true) |
|
| 470 | * @return array a formatted menu item for REST |
|
| 471 | */ |
|
| 472 | public function format_menu_item( $menu_item, $children = false, $menu = array() ) { |
|
| 473 | ||
| 474 | $item = (array) $menu_item; |
|
| 475 | ||
| 476 | $menu_item = array( |
|
| 477 | 'id' => abs( $item['ID'] ), |
|
| 478 | 'order' => (int) $item['menu_order'], |
|
| 479 | 'parent' => abs( $item['menu_item_parent'] ), |
|
| 480 | 'title' => $item['title'], |
|
| 481 | 'url' => $item['url'], |
|
| 482 | 'attr' => $item['attr_title'], |
|
| 483 | 'target' => $item['target'], |
|
| 484 | 'classes' => implode( ' ', $item['classes'] ), |
|
| 485 | 'xfn' => $item['xfn'], |
|
| 486 | 'description' => $item['description'], |
|
| 487 | 'object_id' => abs( $item['object_id'] ), |
|
| 488 | 'object' => $item['object'], |
|
| 489 | 'type' => $item['type'], |
|
| 490 | 'type_label' => $item['type_label'], |
|
| 491 | ); |
|
| 492 | ||
| 493 | if ( $children === true && ! empty( $menu ) ) { |
|
| 494 | $menu_item['children'] = $this->get_nav_menu_item_children( $item['ID'], $menu ); |
|
| 495 | } |
|
| 496 | ||
| 497 | return apply_filters( 'rest_menus_format_menu_item', $menu_item ); |
|
| 498 | } |
|
| 499 | ||
| 500 | ||
| 501 | } |
|
| @@ 350-376 (lines=27) @@ | ||
| 347 | * @param array $menu the menu the item belongs to (used when $children is set to true) |
|
| 348 | * @return array a formatted menu item for JSON |
|
| 349 | */ |
|
| 350 | public function format_menu_item( $menu_item, $children = false, $menu = array() ) { |
|
| 351 | ||
| 352 | $item = (array) $menu_item; |
|
| 353 | ||
| 354 | $menu_item = array( |
|
| 355 | 'ID' => abs( $item['ID'] ), |
|
| 356 | 'order' => (int) $item['menu_order'], |
|
| 357 | 'parent' => abs( $item['menu_item_parent'] ), |
|
| 358 | 'title' => $item['title'], |
|
| 359 | 'url' => $item['url'], |
|
| 360 | 'attr' => $item['attr_title'], |
|
| 361 | 'target' => $item['target'], |
|
| 362 | 'classes' => implode( ' ', $item['classes'] ), |
|
| 363 | 'xfn' => $item['xfn'], |
|
| 364 | 'description' => $item['description'], |
|
| 365 | 'object_id' => abs( $item['object_id'] ), |
|
| 366 | 'object' => $item['object'], |
|
| 367 | 'type' => $item['type'], |
|
| 368 | 'type_label' => $item['type_label'], |
|
| 369 | ); |
|
| 370 | ||
| 371 | if ( $children === true && ! empty( $menu ) ) { |
|
| 372 | $menu_item['children'] = $this->get_nav_menu_item_children( $item['ID'], $menu ); |
|
| 373 | } |
|
| 374 | ||
| 375 | return apply_filters( 'json_menus_format_menu_item', $menu_item ); |
|
| 376 | } |
|
| 377 | ||
| 378 | ||
| 379 | } |
|