Skip to content

Commit a492bb7

Browse files
committed
Clean up array args
1 parent e08ca13 commit a492bb7

File tree

1 file changed

+40
-55
lines changed

1 file changed

+40
-55
lines changed

wp-includes/rest-api/auth/class-wp-rest-key-pair.php

Lines changed: 40 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -85,78 +85,63 @@ public static function get_rest_uri() {
8585
*/
8686
public function register_routes() {
8787
$args = array(
88-
array(
89-
'methods' => WP_REST_Server::CREATABLE,
90-
'callback' => array(
91-
$this,
92-
'generate_key_pair',
88+
'methods' => WP_REST_Server::CREATABLE,
89+
'callback' => array( $this, 'generate_key_pair' ),
90+
'args' => array(
91+
'name' => array(
92+
'description' => esc_html__( 'The name of the key-pair.', 'jwt-auth' ),
93+
'type' => 'string',
94+
'required' => true,
95+
'sanitize_callback' => 'sanitize_text_field',
96+
'validate_callback' => 'rest_validate_request_arg',
9397
),
94-
'args' => array(
95-
'name' => array(
96-
'description' => esc_html__( 'The name of the key-pair.', 'jwt-auth' ),
97-
'type' => 'string',
98-
'required' => true,
99-
'sanitize_callback' => 'sanitize_text_field',
100-
'validate_callback' => 'rest_validate_request_arg',
101-
),
102-
'user_id' => array(
103-
'description' => esc_html__( 'The ID of the user.', 'jwt-auth' ),
104-
'type' => 'integer',
105-
'required' => true,
106-
'sanitize_callback' => 'absint',
107-
'validate_callback' => 'rest_validate_request_arg',
108-
),
98+
'user_id' => array(
99+
'description' => esc_html__( 'The ID of the user.', 'jwt-auth' ),
100+
'type' => 'integer',
101+
'required' => true,
102+
'sanitize_callback' => 'absint',
103+
'validate_callback' => 'rest_validate_request_arg',
109104
),
110105
),
111-
'schema' => array(
106+
'schema' => array(
112107
$this,
113108
'get_item_schema',
114109
),
115110
);
116111
register_rest_route( self::_NAMESPACE_, '/' . self::_REST_BASE_ . '/(?P<user_id>[\d]+)', $args );
117112

118113
$args = array(
119-
array(
120-
'methods' => WP_REST_Server::DELETABLE,
121-
'callback' => array(
122-
$this,
123-
'delete_all_key_pairs',
124-
),
125-
'args' => array(
126-
'user_id' => array(
127-
'description' => esc_html__( 'The ID of the user.', 'jwt-auth' ),
128-
'type' => 'integer',
129-
'required' => true,
130-
'sanitize_callback' => 'absint',
131-
'validate_callback' => 'rest_validate_request_arg',
132-
),
114+
'methods' => WP_REST_Server::DELETABLE,
115+
'callback' => array( $this, 'delete_all_key_pairs' ),
116+
'args' => array(
117+
'user_id' => array(
118+
'description' => esc_html__( 'The ID of the user.', 'jwt-auth' ),
119+
'type' => 'integer',
120+
'required' => true,
121+
'sanitize_callback' => 'absint',
122+
'validate_callback' => 'rest_validate_request_arg',
133123
),
134124
),
135125
);
136126
register_rest_route( self::_NAMESPACE_, '/' . self::_REST_BASE_ . '/(?P<user_id>[\d]+)/revoke-all', $args );
137127

138128
$args = array(
139-
array(
140-
'methods' => WP_REST_Server::DELETABLE,
141-
'callback' => array(
142-
$this,
143-
'delete_key_pair',
129+
'methods' => WP_REST_Server::DELETABLE,
130+
'callback' => array( $this, 'delete_key_pair' ),
131+
'args' => array(
132+
'user_id' => array(
133+
'description' => esc_html__( 'The ID of the user.', 'jwt-auth' ),
134+
'type' => 'integer',
135+
'required' => true,
136+
'sanitize_callback' => 'absint',
137+
'validate_callback' => 'rest_validate_request_arg',
144138
),
145-
'args' => array(
146-
'user_id' => array(
147-
'description' => esc_html__( 'The ID of the user.', 'jwt-auth' ),
148-
'type' => 'integer',
149-
'required' => true,
150-
'sanitize_callback' => 'absint',
151-
'validate_callback' => 'rest_validate_request_arg',
152-
),
153-
'api_key' => array(
154-
'description' => esc_html__( 'The API key being revoked.', 'jwt-auth' ),
155-
'type' => 'string',
156-
'required' => true,
157-
'sanitize_callback' => 'sanitize_text_field',
158-
'validate_callback' => 'rest_validate_request_arg',
159-
),
139+
'api_key' => array(
140+
'description' => esc_html__( 'The API key being revoked.', 'jwt-auth' ),
141+
'type' => 'string',
142+
'required' => true,
143+
'sanitize_callback' => 'sanitize_text_field',
144+
'validate_callback' => 'rest_validate_request_arg',
160145
),
161146
),
162147
);

0 commit comments

Comments
 (0)