Skip to content

Commit

Permalink
Check for object_type before creating object_slug
Browse files Browse the repository at this point in the history
  • Loading branch information
nine-2-five committed Jun 3, 2017
1 parent 27f2f44 commit 3ba0ed8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion includes/wp-api-menus-v2.php
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,13 @@ public function get_nav_menu_item_children( $parent_id, $nav_menu_items, $depth
public function format_menu_item( $menu_item, $children = false, $menu = array() ) {

$item = (array) $menu_item;

if($item['type'] == 'taxonomy'){
$slug = get_term( $item['object_id'] )->slug;
}
else {
$slug = get_post( $item['object_id'] )->post_name;
}

$menu_item = array(
'id' => abs( $item['ID'] ),
Expand All @@ -383,7 +390,7 @@ public function format_menu_item( $menu_item, $children = false, $menu = array()
'description' => $item['description'],
'object_id' => abs( $item['object_id'] ),
'object' => $item['object'],
'object_slug' => get_post( $item['object_id'] )->post_name,
'object_slug' => $slug,
'type' => $item['type'],
'type_label' => $item['type_label'],
);
Expand Down

0 comments on commit 3ba0ed8

Please sign in to comment.