Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (9 years ago)
Author:
pento
Message:

Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-post-statuses-controller.php

    r41731 r42343  
    3636        public function register_routes() {
    3737
    38                 register_rest_route( $this->namespace, '/' . $this->rest_base, array(
    39                         array(
    40                                 'methods'             => WP_REST_Server::READABLE,
    41                                 'callback'            => array( $this, 'get_items' ),
    42                                 'permission_callback' => array( $this, 'get_items_permissions_check' ),
    43                                 'args'                => $this->get_collection_params(),
    44                         ),
    45                         'schema' => array( $this, 'get_public_item_schema' ),
    46                 ) );
    47 
    48                 register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<status>[\w-]+)', array(
    49                         'args' => array(
    50                                 'status' => array(
    51                                         'description' => __( 'An alphanumeric identifier for the status.' ),
    52                                         'type'        => 'string',
    53                                 ),
    54                         ),
    55                         array(
    56                                 'methods'             => WP_REST_Server::READABLE,
    57                                 'callback'            => array( $this, 'get_item' ),
    58                                 'permission_callback' => array( $this, 'get_item_permissions_check' ),
    59                                 'args'                => array(
    60                                         'context' => $this->get_context_param( array( 'default' => 'view' ) ),
    61                                 ),
    62                         ),
    63                         'schema' => array( $this, 'get_public_item_schema' ),
    64                 ) );
     38                register_rest_route(
     39                        $this->namespace, '/' . $this->rest_base, array(
     40                                array(
     41                                        'methods'             => WP_REST_Server::READABLE,
     42                                        'callback'            => array( $this, 'get_items' ),
     43                                        'permission_callback' => array( $this, 'get_items_permissions_check' ),
     44                                        'args'                => $this->get_collection_params(),
     45                                ),
     46                                'schema' => array( $this, 'get_public_item_schema' ),
     47                        )
     48                );
     49
     50                register_rest_route(
     51                        $this->namespace, '/' . $this->rest_base . '/(?P<status>[\w-]+)', array(
     52                                'args'   => array(
     53                                        'status' => array(
     54                                                'description' => __( 'An alphanumeric identifier for the status.' ),
     55                                                'type'        => 'string',
     56                                        ),
     57                                ),
     58                                array(
     59                                        'methods'             => WP_REST_Server::READABLE,
     60                                        'callback'            => array( $this, 'get_item' ),
     61                                        'permission_callback' => array( $this, 'get_item_permissions_check' ),
     62                                        'args'                => array(
     63                                                'context' => $this->get_context_param( array( 'default' => 'view' ) ),
     64                                        ),
     65                                ),
     66                                'schema' => array( $this, 'get_public_item_schema' ),
     67                        )
     68                );
    6569        }
    6670
    … …  
    97101         */
    98102        public function get_items( $request ) {
    99                 $data = array();
    100                 $statuses = get_post_stati( array( 'internal' => false ), 'object' );
     103                $data              = array();
     104                $statuses          = get_post_stati( array( 'internal' => false ), 'object' );
    101105                $statuses['trash'] = get_post_status_object( 'trash' );
    102106
    … …  
    108112                        }
    109113
    110                         $status = $this->prepare_item_for_response( $obj, $request );
     114                        $status             = $this->prepare_item_for_response( $obj, $request );
    111115                        $data[ $obj->name ] = $this->prepare_response_for_collection( $status );
    112116                }
    … …  
    207211
    208212                $context = ! empty( $request['context'] ) ? $request['context'] : 'view';
    209                 $data = $this->add_additional_fields_to_object( $data, $request );
    210                 $data = $this->filter_response_by_context( $data, $context );
     213                $data    = $this->add_additional_fields_to_object( $data, $request );
     214                $data    = $this->filter_response_by_context( $data, $context );
    211215
    212216                $response = rest_ensure_response( $data );
    … …  
    241245        public function get_item_schema() {
    242246                $schema = array(
    243                         '$schema'              => 'http://json-schema.org/draft-04/schema#',
    244                         'title'                => 'status',
    245                         'type'                 => 'object',
    246                         'properties'           => array(
    247                                 'name'             => array(
    248                                         'description'  => __( 'The title for the status.' ),
    249                                         'type'         => 'string',
    250                                         'context'      => array( 'embed', 'view', 'edit' ),
    251                                         'readonly'     => true,
    252                                 ),
    253                                 'private'          => array(
    254                                         'description'  => __( 'Whether posts with this status should be private.' ),
    255                                         'type'         => 'boolean',
    256                                         'context'      => array( 'edit' ),
    257                                         'readonly'     => true,
    258                                 ),
    259                                 'protected'        => array(
    260                                         'description'  => __( 'Whether posts with this status should be protected.' ),
    261                                         'type'         => 'boolean',
    262                                         'context'      => array( 'edit' ),
    263                                         'readonly'     => true,
    264                                 ),
    265                                 'public'           => array(
    266                                         'description'  => __( 'Whether posts of this status should be shown in the front end of the site.' ),
    267                                         'type'         => 'boolean',
    268                                         'context'      => array( 'view', 'edit' ),
    269                                         'readonly'     => true,
    270                                 ),
    271                                 'queryable'        => array(
    272                                         'description'  => __( 'Whether posts with this status should be publicly-queryable.' ),
    273                                         'type'         => 'boolean',
    274                                         'context'      => array( 'view', 'edit' ),
    275                                         'readonly'     => true,
    276                                 ),
    277                                 'show_in_list'     => array(
    278                                         'description'  => __( 'Whether to include posts in the edit listing for their post type.' ),
    279                                         'type'         => 'boolean',
    280                                         'context'      => array( 'edit' ),
    281                                         'readonly'     => true,
    282                                 ),
    283                                 'slug'             => array(
    284                                         'description'  => __( 'An alphanumeric identifier for the status.' ),
    285                                         'type'         => 'string',
    286                                         'context'      => array( 'embed', 'view', 'edit' ),
    287                                         'readonly'     => true,
     247                        '$schema'    => 'http://json-schema.org/draft-04/schema#',
     248                        'title'      => 'status',
     249                        'type'       => 'object',
     250                        'properties' => array(
     251                                'name'         => array(
     252                                        'description' => __( 'The title for the status.' ),
     253                                        'type'        => 'string',
     254                                        'context'     => array( 'embed', 'view', 'edit' ),
     255                                        'readonly'    => true,
     256                                ),
     257                                'private'      => array(
     258                                        'description' => __( 'Whether posts with this status should be private.' ),
     259                                        'type'        => 'boolean',
     260                                        'context'     => array( 'edit' ),
     261                                        'readonly'    => true,
     262                                ),
     263                                'protected'    => array(
     264                                        'description' => __( 'Whether posts with this status should be protected.' ),
     265                                        'type'        => 'boolean',
     266                                        'context'     => array( 'edit' ),
     267                                        'readonly'    => true,
     268                                ),
     269                                'public'       => array(
     270                                        'description' => __( 'Whether posts of this status should be shown in the front end of the site.' ),
     271                                        'type'        => 'boolean',
     272                                        'context'     => array( 'view', 'edit' ),
     273                                        'readonly'    => true,
     274                                ),
     275                                'queryable'    => array(
     276                                        'description' => __( 'Whether posts with this status should be publicly-queryable.' ),
     277                                        'type'        => 'boolean',
     278                                        'context'     => array( 'view', 'edit' ),
     279                                        'readonly'    => true,
     280                                ),
     281                                'show_in_list' => array(
     282                                        'description' => __( 'Whether to include posts in the edit listing for their post type.' ),
     283                                        'type'        => 'boolean',
     284                                        'context'     => array( 'edit' ),
     285                                        'readonly'    => true,
     286                                ),
     287                                'slug'         => array(
     288                                        'description' => __( 'An alphanumeric identifier for the status.' ),
     289                                        'type'        => 'string',
     290                                        'context'     => array( 'embed', 'view', 'edit' ),
     291                                        'readonly'    => true,
    288292                                ),
    289293                        ),
Note: See TracChangeset for help on using the changeset viewer.