Skip to content

Commit

Permalink
Merge pull request #39 from drosendo/patch-1
Browse files Browse the repository at this point in the history
Fix possible name colision
  • Loading branch information
thebatclaudio authored May 20, 2021
2 parents ad6d3bc + de415d3 commit bbc61e2
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions wp-rest-api-v2-menus.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ function wp_api_v2_menus_get_all_menus() {
if ( class_exists( 'acf' ) ) {
$fields = get_fields( $menu );
if ( ! empty( $fields ) ) {
$menu[ $key ]->acf = new stdClass();

foreach ( $fields as $field_key => $item ) {
// add all acf custom fields
$menus[ $key ]->$field_key = $item;
$menus[ $key ]->acf->$field_key = $item;
}
}
}
Expand Down Expand Up @@ -75,9 +77,11 @@ function wp_api_v2_locations_get_menu_data( $data ) {
if ( class_exists( 'acf' ) ) {
$fields = get_fields( $menu );
if ( ! empty( $fields ) ) {
$menu->acf = new stdClass();

foreach ( $fields as $field_key => $item ) {
// add all acf custom fields
$menu->$field_key = $item;
$menu->acf->$field_key = $item;
}
}
}
Expand Down Expand Up @@ -142,9 +146,11 @@ function wp_api_v2_menus_get_menu_items( $id ) {
foreach ( $menu_items as $menu_key => $menu_item ) {
$fields = get_fields( $menu_item->ID );
if ( ! empty( $fields ) ) {
$menu_items[$menu_key]->acf = new stdClass();

foreach ( $fields as $field_key => $item ) {
// add all acf custom fields
$menu_items[ $menu_key ]->$field_key = $item;
$menu_items[ $menu_key ]->acf->$field_key = $item;
}
}
}
Expand Down Expand Up @@ -232,9 +238,11 @@ function wp_api_v2_menus_get_menu_data( $data ) {
if ( class_exists( 'acf' ) ) {
$fields = get_fields( $menu );
if ( ! empty( $fields ) ) {
$menu->acf = new stdClass();

foreach ( $fields as $field_key => $item ) {
// add all acf custom fields
$menu->$field_key = $item;
$menu->acf->$field_key = $item;
}
}
}
Expand Down

0 comments on commit bbc61e2

Please sign in to comment.