| @@ 260-286 (lines=27) @@ | ||
| 257 | * @param array $menu the menu the item belongs to (used when $children is set to true) |
|
| 258 | * @return array a formatted menu item for JSON |
|
| 259 | */ |
|
| 260 | public function format_menu_item( $menu_item, $children = false, $menu = array() ) { |
|
| 261 | ||
| 262 | $item = (array) $menu_item; |
|
| 263 | ||
| 264 | $menu_item = array( |
|
| 265 | 'ID' => abs( $item['ID'] ), |
|
| 266 | 'order' => (int) $item['menu_order'], |
|
| 267 | 'parent' => abs( $item['menu_item_parent'] ), |
|
| 268 | 'title' => $item['title'], |
|
| 269 | 'url' => $item['url'], |
|
| 270 | 'attr' => $item['attr_title'], |
|
| 271 | 'target' => $item['target'], |
|
| 272 | 'classes' => implode( ' ', $item['classes'] ), |
|
| 273 | 'xfn' => $item['xfn'], |
|
| 274 | 'description' => $item['description'], |
|
| 275 | 'object_id' => abs( $item['object_id'] ), |
|
| 276 | 'object' => $item['object'], |
|
| 277 | 'type' => $item['type'], |
|
| 278 | 'type_label' => $item['type_label'], |
|
| 279 | ); |
|
| 280 | ||
| 281 | if ( $children === true && ! empty( $menu ) ) { |
|
| 282 | $menu_item['children'] = $this->get_nav_menu_item_children( $item['ID'], $menu ); |
|
| 283 | } |
|
| 284 | ||
| 285 | return apply_filters( 'json_menus_format_menu_item', $menu_item ); |
|
| 286 | } |
|
| 287 | ||
| 288 | ||
| 289 | } |
|
| @@ 354-380 (lines=27) @@ | ||
| 351 | * @param array $menu The menu the item belongs to (used when $children is set to true) |
|
| 352 | * @return array a formatted menu item for REST |
|
| 353 | */ |
|
| 354 | public function format_menu_item( $menu_item, $children = false, $menu = array() ) { |
|
| 355 | ||
| 356 | $item = (array) $menu_item; |
|
| 357 | ||
| 358 | $menu_item = array( |
|
| 359 | 'id' => abs( $item['ID'] ), |
|
| 360 | 'order' => (int) $item['menu_order'], |
|
| 361 | 'parent' => abs( $item['menu_item_parent'] ), |
|
| 362 | 'title' => $item['title'], |
|
| 363 | 'url' => $item['url'], |
|
| 364 | 'attr' => $item['attr_title'], |
|
| 365 | 'target' => $item['target'], |
|
| 366 | 'classes' => implode( ' ', $item['classes'] ), |
|
| 367 | 'xfn' => $item['xfn'], |
|
| 368 | 'description' => $item['description'], |
|
| 369 | 'object_id' => abs( $item['object_id'] ), |
|
| 370 | 'object' => $item['object'], |
|
| 371 | 'type' => $item['type'], |
|
| 372 | 'type_label' => $item['type_label'], |
|
| 373 | ); |
|
| 374 | ||
| 375 | if ( $children === true && ! empty( $menu ) ) { |
|
| 376 | $menu_item['children'] = $this->get_nav_menu_item_children( $item['ID'], $menu ); |
|
| 377 | } |
|
| 378 | ||
| 379 | return apply_filters( 'rest_menus_format_menu_item', $menu_item ); |
|
| 380 | } |
|
| 381 | ||
| 382 | ||
| 383 | } |
|