Skip to content

Commit ab34f4e

Browse files
Merge pull request #42 from thebatclaudio/41-array_values-throwing-a-typeerror
fix array_values() throwing a TypeError
2 parents 631d033 + 578c7d5 commit ab34f4e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

wp-rest-api-v2-menus.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function wp_api_v2_menus_get_all_menus() {
2828
}
2929
}
3030
}
31-
31+
3232
return apply_filters('wp_api_v2_menus__menus', $menus);
3333
}
3434

@@ -139,6 +139,12 @@ function wp_api_v2_find_object_by_id( $array, $id ) {
139139
*/
140140
function wp_api_v2_menus_get_menu_items( $id ) {
141141
$menu_items = wp_get_nav_menu_items( $id );
142+
143+
// fallback: if menu_items is null then return empty array
144+
if($menu_items === false) {
145+
return [];
146+
}
147+
142148
$all_menu_items = $menu_items;
143149

144150
// check if there is acf installed

0 commit comments

Comments
 (0)