diff -r c7c34916027a -r 177826044cd9 wp/wp-includes/rest-api/endpoints/class-wp-rest-post-statuses-controller.php --- a/wp/wp-includes/rest-api/endpoints/class-wp-rest-post-statuses-controller.php Mon Oct 14 18:06:33 2019 +0200 +++ b/wp/wp-includes/rest-api/endpoints/class-wp-rest-post-statuses-controller.php Mon Oct 14 18:28:13 2019 +0200 @@ -35,33 +35,41 @@ */ public function register_routes() { - register_rest_route( $this->namespace, '/' . $this->rest_base, array( + register_rest_route( + $this->namespace, + '/' . $this->rest_base, array( - 'methods' => WP_REST_Server::READABLE, - 'callback' => array( $this, 'get_items' ), - 'permission_callback' => array( $this, 'get_items_permissions_check' ), - 'args' => $this->get_collection_params(), - ), - 'schema' => array( $this, 'get_public_item_schema' ), - ) ); + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_items' ), + 'permission_callback' => array( $this, 'get_items_permissions_check' ), + 'args' => $this->get_collection_params(), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) + ); - register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P[\w-]+)', array( - 'args' => array( - 'status' => array( - 'description' => __( 'An alphanumeric identifier for the status.' ), - 'type' => 'string', - ), - ), + register_rest_route( + $this->namespace, + '/' . $this->rest_base . '/(?P[\w-]+)', array( - 'methods' => WP_REST_Server::READABLE, - 'callback' => array( $this, 'get_item' ), - 'permission_callback' => array( $this, 'get_item_permissions_check' ), - 'args' => array( - 'context' => $this->get_context_param( array( 'default' => 'view' ) ), + 'args' => array( + 'status' => array( + 'description' => __( 'An alphanumeric identifier for the status.' ), + 'type' => 'string', + ), ), - ), - 'schema' => array( $this, 'get_public_item_schema' ), - ) ); + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_item' ), + 'permission_callback' => array( $this, 'get_item_permissions_check' ), + 'args' => array( + 'context' => $this->get_context_param( array( 'default' => 'view' ) ), + ), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) + ); } /** @@ -81,7 +89,7 @@ return true; } } - return new WP_Error( 'rest_cannot_view', __( 'Sorry, you are not allowed to edit posts in this post type.' ), array( 'status' => rest_authorization_required_code() ) ); + return new WP_Error( 'rest_cannot_view', __( 'Sorry, you are not allowed to manage post statuses.' ), array( 'status' => rest_authorization_required_code() ) ); } return true; @@ -96,8 +104,8 @@ * @return WP_Error|WP_REST_Response Response object on success, or WP_Error object on failure. */ public function get_items( $request ) { - $data = array(); - $statuses = get_post_stati( array( 'internal' => false ), 'object' ); + $data = array(); + $statuses = get_post_stati( array( 'internal' => false ), 'object' ); $statuses['trash'] = get_post_status_object( 'trash' ); foreach ( $statuses as $slug => $obj ) { @@ -107,7 +115,7 @@ continue; } - $status = $this->prepare_item_for_response( $obj, $request ); + $status = $this->prepare_item_for_response( $obj, $request ); $data[ $obj->name ] = $this->prepare_response_for_collection( $status ); } @@ -227,8 +235,8 @@ } $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; - $data = $this->add_additional_fields_to_object( $data, $request ); - $data = $this->filter_response_by_context( $data, $context ); + $data = $this->add_additional_fields_to_object( $data, $request ); + $data = $this->filter_response_by_context( $data, $context ); $response = rest_ensure_response( $data ); @@ -261,51 +269,51 @@ */ public function get_item_schema() { $schema = array( - '$schema' => 'http://json-schema.org/draft-04/schema#', - 'title' => 'status', - 'type' => 'object', - 'properties' => array( - 'name' => array( - 'description' => __( 'The title for the status.' ), - 'type' => 'string', - 'context' => array( 'embed', 'view', 'edit' ), - 'readonly' => true, + '$schema' => 'http://json-schema.org/draft-04/schema#', + 'title' => 'status', + 'type' => 'object', + 'properties' => array( + 'name' => array( + 'description' => __( 'The title for the status.' ), + 'type' => 'string', + 'context' => array( 'embed', 'view', 'edit' ), + 'readonly' => true, ), - 'private' => array( - 'description' => __( 'Whether posts with this status should be private.' ), - 'type' => 'boolean', - 'context' => array( 'edit' ), - 'readonly' => true, + 'private' => array( + 'description' => __( 'Whether posts with this status should be private.' ), + 'type' => 'boolean', + 'context' => array( 'edit' ), + 'readonly' => true, ), - 'protected' => array( - 'description' => __( 'Whether posts with this status should be protected.' ), - 'type' => 'boolean', - 'context' => array( 'edit' ), - 'readonly' => true, + 'protected' => array( + 'description' => __( 'Whether posts with this status should be protected.' ), + 'type' => 'boolean', + 'context' => array( 'edit' ), + 'readonly' => true, ), - 'public' => array( - 'description' => __( 'Whether posts of this status should be shown in the front end of the site.' ), - 'type' => 'boolean', - 'context' => array( 'view', 'edit' ), - 'readonly' => true, + 'public' => array( + 'description' => __( 'Whether posts of this status should be shown in the front end of the site.' ), + 'type' => 'boolean', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, ), - 'queryable' => array( - 'description' => __( 'Whether posts with this status should be publicly-queryable.' ), - 'type' => 'boolean', - 'context' => array( 'view', 'edit' ), - 'readonly' => true, + 'queryable' => array( + 'description' => __( 'Whether posts with this status should be publicly-queryable.' ), + 'type' => 'boolean', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, ), - 'show_in_list' => array( - 'description' => __( 'Whether to include posts in the edit listing for their post type.' ), - 'type' => 'boolean', - 'context' => array( 'edit' ), - 'readonly' => true, + 'show_in_list' => array( + 'description' => __( 'Whether to include posts in the edit listing for their post type.' ), + 'type' => 'boolean', + 'context' => array( 'edit' ), + 'readonly' => true, ), - 'slug' => array( - 'description' => __( 'An alphanumeric identifier for the status.' ), - 'type' => 'string', - 'context' => array( 'embed', 'view', 'edit' ), - 'readonly' => true, + 'slug' => array( + 'description' => __( 'An alphanumeric identifier for the status.' ), + 'type' => 'string', + 'context' => array( 'embed', 'view', 'edit' ), + 'readonly' => true, ), ), );