Skip to content

Commit cdb79dc

Browse files
committed
Add maybe doing it wrong functions to all registered route callbacks.
Apply deprecation to route schema's.
1 parent 7e9f3fd commit cdb79dc

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

Diff for: includes/wp-api-menus-v2.php

+12-10
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public function register_routes() {
5757
'methods' => WP_REST_Server::READABLE,
5858
'callback' => array( $this, 'get_menus' ),
5959
'permission_callback' => '__return_true',
60+
'schema' => array( 'deprecated' => true ),
6061
)
6162
) );
6263

@@ -65,10 +66,11 @@ public function register_routes() {
6566
'methods' => WP_REST_Server::READABLE,
6667
'callback' => array( $this, 'get_menu' ),
6768
'permission_callback' => '__return_true',
68-
'args' => array(
69-
'context' => array(
70-
'default' => 'view',
71-
),
69+
'schema' => array( 'deprecated' => true ),
70+
'args' => array(
71+
'context' => array(
72+
'default' => 'view',
73+
),
7274
),
7375
)
7476
) );
@@ -78,6 +80,7 @@ public function register_routes() {
7880
'methods' => WP_REST_Server::READABLE,
7981
'callback' => array( $this, 'get_menu_locations' ),
8082
'permission_callback' => '__return_true',
83+
'schema' => array( 'deprecated' => true ),
8184
)
8285
) );
8386

@@ -86,6 +89,7 @@ public function register_routes() {
8689
'methods' => WP_REST_Server::READABLE,
8790
'callback' => array( $this, 'get_menu_location' ),
8891
'permission_callback' => '__return_true',
92+
'schema' => array( 'deprecated' => true ),
8993
)
9094
) );
9195
}
@@ -98,7 +102,7 @@ public function register_routes() {
98102
* @return array All registered menus
99103
*/
100104
public static function get_menus() {
101-
105+
_wp_rest_menus_doing_it_wrong(__METHOD__);
102106
$rest_url = trailingslashit( get_rest_url() . self::get_plugin_namespace() . '/menus/' );
103107
$wp_menus = wp_get_nav_menus();
104108

@@ -133,7 +137,7 @@ public static function get_menus() {
133137
* @return array Menu data
134138
*/
135139
public function get_menu( $request ) {
136-
140+
_wp_rest_menus_doing_it_wrong(__METHOD__);
137141
$id = (int) $request['id'];
138142
$rest_url = get_rest_url() . self::get_plugin_namespace() . '/menus/';
139143
$wp_menu_object = $id ? wp_get_nav_menu_object( $id ) : array();
@@ -226,7 +230,7 @@ private function has_children( $items, $id ) {
226230
* @return array All registered menus locations
227231
*/
228232
public static function get_menu_locations( $request ) {
229-
233+
_wp_rest_menus_doing_it_wrong(__METHOD__);
230234
$locations = get_nav_menu_locations();
231235
$registered_menus = get_registered_nav_menus();
232236
$rest_url = get_rest_url() . self::get_plugin_namespace() . '/menu-locations/';
@@ -262,7 +266,7 @@ public static function get_menu_locations( $request ) {
262266
* @return array The menu for the corresponding location
263267
*/
264268
public function get_menu_location( $request ) {
265-
269+
_wp_rest_menus_doing_it_wrong(__METHOD__);
266270
$params = $request->get_params();
267271
$location = $params['location'];
268272
$locations = get_nav_menu_locations();
@@ -401,8 +405,6 @@ public function format_menu_item( $menu_item, $children = false, $menu = array()
401405
return apply_filters( 'rest_menus_format_menu_item', $menu_item );
402406
}
403407

404-
405408
}
406409

407-
408410
endif;

0 commit comments

Comments
 (0)