Skip to content

Commit 4eb209c

Browse files
committed
Merge branch 'norregaarden-master'
2 parents 6baad7a + 995b232 commit 4eb209c

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

wp-rest-api-v2-menus.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,17 @@ function wp_api_v2_locations_get_menu_data ( $data ) {
6868
return new WP_Error( 'not_found', 'No location has been found with this id or slug: `'.$data['id'].'`. Please ensure you passed an existing location ID or location slug.', array( 'status' => 404 ) );
6969
}
7070

71+
// check if there is acf installed
72+
if( class_exists('acf') ) {
73+
$fields = get_fields($menu);
74+
if(!empty($fields)) {
75+
foreach($fields as $field_key => $item) {
76+
// add all acf custom fields
77+
$menu->$field_key = $item;
78+
}
79+
}
80+
}
81+
7182
return $menu;
7283
}
7384

@@ -140,6 +151,17 @@ function wp_api_v2_menus_get_menu_data ( $data ) {
140151
return new WP_Error( 'not_found', 'No menu has been found with this id or slug: `'.$data['id'].'`. Please ensure you passed an existing menu ID, menu slug, location ID or location slug.', array( 'status' => 404 ) );
141152
}
142153

154+
// check if there is acf installed
155+
if( class_exists('acf') ) {
156+
$fields = get_fields($menu);
157+
if(!empty($fields)) {
158+
foreach($fields as $field_key => $item) {
159+
// add all acf custom fields
160+
$menu->$field_key = $item;
161+
}
162+
}
163+
}
164+
143165
return $menu;
144166
}
145167

0 commit comments

Comments
 (0)