@@ 275-303 (lines=29) @@ | ||
272 | * @param array $menu the menu the item belongs to (used when $children is set to true) |
|
273 | * @return array a formatted menu item for JSON |
|
274 | */ |
|
275 | public function format_menu_item( $menu_item, $children = false, $menu = array() ) { |
|
276 | ||
277 | $item = (array) $menu_item; |
|
278 | ||
279 | $menu_item = array( |
|
280 | 'ID' => abs( $item['ID'] ), |
|
281 | 'order' => (int) $item['menu_order'], |
|
282 | 'parent' => abs( $item['menu_item_parent'] ), |
|
283 | 'title' => $item['title'], |
|
284 | 'url' => $item['url'], |
|
285 | 'attr' => $item['attr_title'], |
|
286 | 'target' => $item['target'], |
|
287 | 'classes' => implode( ' ', $item['classes'] ), |
|
288 | 'xfn' => $item['xfn'], |
|
289 | 'description' => $item['description'], |
|
290 | 'object_id' => abs( $item['object_id'] ), |
|
291 | 'object' => $item['object'], |
|
292 | 'object_slug' => get_post($item['object_id'])->post_name, |
|
293 | 'type' => $item['type'], |
|
294 | 'type_label' => $item['type_label'], |
|
295 | ); |
|
296 | ||
297 | if ( $children === true && ! empty( $menu ) ) { |
|
298 | ||
299 | $menu_item['children'] = $this->get_nav_menu_item_children( $item['ID'], $menu ); |
|
300 | } |
|
301 | ||
302 | return apply_filters( 'json_menus_format_menu_item', $menu_item ); |
|
303 | } |
|
304 | ||
305 | ||
306 | } |
@@ 397-424 (lines=28) @@ | ||
394 | * @param array $menu The menu the item belongs to (used when $children is set to true) |
|
395 | * @return array a formatted menu item for REST |
|
396 | */ |
|
397 | public function format_menu_item( $menu_item, $children = false, $menu = array() ) { |
|
398 | ||
399 | $item = (array) $menu_item; |
|
400 | $id = (int)$item['ID']; |
|
401 | $menu_item = array( |
|
402 | 'id' => abs( $item['ID'] ), |
|
403 | 'order' => (int) $item['menu_order'], |
|
404 | 'parent' => abs( $item['menu_item_parent'] ), |
|
405 | 'title' => $item['title'], |
|
406 | 'url' => $item['url'], |
|
407 | 'attr' => $item['attr_title'], |
|
408 | 'target' => $item['target'], |
|
409 | 'classes' => implode( ' ', $item['classes'] ), |
|
410 | 'xfn' => $item['xfn'], |
|
411 | 'description' => $item['description'], |
|
412 | 'object_id' => abs( $item['object_id'] ), |
|
413 | 'object' => $item['object'], |
|
414 | 'object_slug' => get_post( $item['object_id'] )->post_name, |
|
415 | 'type' => $item['type'], |
|
416 | 'type_label' => $item['type_label'] |
|
417 | ); |
|
418 | ||
419 | if ( $children === true && ! empty( $menu ) ) { |
|
420 | $menu_item['children'] = $this->get_nav_menu_item_children( $item['ID'], $menu ); |
|
421 | } |
|
422 | ||
423 | return apply_filters( 'rest_menus_format_menu_item', $menu_item ); |
|
424 | } |
|
425 | ||
426 | ||
427 | } |