| @@ 303-329 (lines=27) @@ | ||
| 300 | * @param array $menu the menu the item belongs to (used when $children is set to true) |
|
| 301 | * @return array a formatted menu item for JSON |
|
| 302 | */ |
|
| 303 | public function format_menu_item( $menu_item, $children = false, $menu = array() ) { |
|
| 304 | ||
| 305 | $item = (array) $menu_item; |
|
| 306 | ||
| 307 | $menu_item = array( |
|
| 308 | 'ID' => abs( $item['ID'] ), |
|
| 309 | 'order' => (int) $item['menu_order'], |
|
| 310 | 'parent' => abs( $item['menu_item_parent'] ), |
|
| 311 | 'title' => $item['title'], |
|
| 312 | 'url' => $item['url'], |
|
| 313 | 'attr' => $item['attr_title'], |
|
| 314 | 'target' => $item['target'], |
|
| 315 | 'classes' => implode( ' ', $item['classes'] ), |
|
| 316 | 'xfn' => $item['xfn'], |
|
| 317 | 'description' => $item['description'], |
|
| 318 | 'object_id' => abs( $item['object_id'] ), |
|
| 319 | 'object' => $item['object'], |
|
| 320 | 'type' => $item['type'], |
|
| 321 | 'type_label' => $item['type_label'], |
|
| 322 | ); |
|
| 323 | ||
| 324 | if ( $children === true && ! empty( $menu ) ) { |
|
| 325 | $menu_item['children'] = $this->get_nav_menu_item_children( $item['ID'], $menu ); |
|
| 326 | } |
|
| 327 | ||
| 328 | return apply_filters( 'json_menus_format_menu_item', $menu_item ); |
|
| 329 | } |
|
| 330 | ||
| 331 | ||
| 332 | } |
|
| @@ 418-444 (lines=27) @@ | ||
| 415 | * @param array $menu The menu the item belongs to (used when $children is set to true) |
|
| 416 | * @return array a formatted menu item for REST |
|
| 417 | */ |
|
| 418 | public function format_menu_item( $menu_item, $children = false, $menu = array() ) { |
|
| 419 | ||
| 420 | $item = (array) $menu_item; |
|
| 421 | ||
| 422 | $menu_item = array( |
|
| 423 | 'id' => abs( $item['ID'] ), |
|
| 424 | 'order' => (int) $item['menu_order'], |
|
| 425 | 'parent' => abs( $item['menu_item_parent'] ), |
|
| 426 | 'title' => $item['title'], |
|
| 427 | 'url' => $item['url'], |
|
| 428 | 'attr' => $item['attr_title'], |
|
| 429 | 'target' => $item['target'], |
|
| 430 | 'classes' => implode( ' ', $item['classes'] ), |
|
| 431 | 'xfn' => $item['xfn'], |
|
| 432 | 'description' => $item['description'], |
|
| 433 | 'object_id' => abs( $item['object_id'] ), |
|
| 434 | 'object' => $item['object'], |
|
| 435 | 'type' => $item['type'], |
|
| 436 | 'type_label' => $item['type_label'], |
|
| 437 | ); |
|
| 438 | ||
| 439 | if ( $children === true && ! empty( $menu ) ) { |
|
| 440 | $menu_item['children'] = $this->get_nav_menu_item_children( $item['ID'], $menu ); |
|
| 441 | } |
|
| 442 | ||
| 443 | return apply_filters( 'rest_menus_format_menu_item', $menu_item ); |
|
| 444 | } |
|
| 445 | ||
| 446 | ||
| 447 | } |
|