Skip to content

Commit f4e7768

Browse files
authored
Add filters to allow devs to customize responses
1 parent 50e81b7 commit f4e7768

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

wp-rest-api-v2-menus.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ function wp_api_v2_menus_get_all_menus() {
2626
}
2727
}
2828
}
29-
30-
return $menus;
29+
30+
return apply_filters('wp_api_v2_menus__menus', $menus);
3131
}
3232

3333
/**
@@ -48,7 +48,7 @@ function wp_api_v2_menu_get_all_locations() {
4848
$locations->{$location_slug}->menu = get_term( $menu_id );
4949
}
5050

51-
return $locations;
51+
return apply_filters('wp_api_v2_menus__locations', $locations);
5252
}
5353

5454
/**
@@ -82,7 +82,7 @@ function wp_api_v2_locations_get_menu_data( $data ) {
8282
}
8383
}
8484

85-
return $menu;
85+
return apply_filters('wp_api_v2_menus__menu', $menu);
8686
}
8787

8888
/**
@@ -179,7 +179,7 @@ function wp_api_v2_menus_get_menu_items( $id ) {
179179
}
180180
} while(count($child_items));
181181

182-
return array_values($menu_items);
182+
return apply_filters('wp_api_v2_menus__menu_items', array_values($menu_items));
183183
}
184184

185185
/**
@@ -219,7 +219,7 @@ function wp_api_v2_menus_get_menu_data( $data ) {
219219
}
220220
}
221221

222-
return $menu;
222+
return apply_filters('wp_api_v2_menus__menu', $menu);
223223
}
224224

225225
add_action( 'rest_api_init', function () {

0 commit comments

Comments
 (0)