File tree Expand file tree Collapse file tree 1 file changed +13
-13
lines changed
Expand file tree Collapse file tree 1 file changed +13
-13
lines changed Original file line number Diff line number Diff line change @@ -123,6 +123,19 @@ function wp_api_v2_menus_dna_test( &$parents, $child ) {
123123function wp_api_v2_menus_get_menu_items ( $ id ) {
124124 $ menu_items = wp_get_nav_menu_items ( $ id );
125125
126+ // check if there is acf installed
127+ if ( class_exists ( 'acf ' ) ) {
128+ foreach ( $ menu_items as $ menu_key => $ menu_item ) {
129+ $ fields = get_fields ( $ menu_item ->ID );
130+ if ( ! empty ( $ fields ) ) {
131+ foreach ( $ fields as $ field_key => $ item ) {
132+ // add all acf custom fields
133+ $ menu_items [ $ menu_key ]->$ field_key = $ item ;
134+ }
135+ }
136+ }
137+ }
138+
126139 // wordpress does not group child menu items with parent menu items
127140 $ child_items = [];
128141 // pull all child menu items into separate object
@@ -142,19 +155,6 @@ function wp_api_v2_menus_get_menu_items( $id ) {
142155 }
143156 } while (count ($ child_items ));
144157
145- // check if there is acf installed
146- if ( class_exists ( 'acf ' ) ) {
147- foreach ( $ menu_items as $ menu_key => $ menu_item ) {
148- $ fields = get_fields ( $ menu_item ->ID );
149- if ( ! empty ( $ fields ) ) {
150- foreach ( $ fields as $ field_key => $ item ) {
151- // add all acf custom fields
152- $ menu_items [ $ menu_key ]->$ field_key = $ item ;
153- }
154- }
155- }
156- }
157-
158158 return $ menu_items ;
159159}
160160
You can’t perform that action at this time.
0 commit comments