Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (6 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-controller.php

    r42000 r42343  
    306306    public function get_collection_params() {
    307307        return array(
    308             'context'                => $this->get_context_param(),
    309             'page'                   => array(
    310                 'description'        => __( 'Current page of the collection.' ),
    311                 'type'               => 'integer',
    312                 'default'            => 1,
    313                 'sanitize_callback'  => 'absint',
    314                 'validate_callback'  => 'rest_validate_request_arg',
    315                 'minimum'            => 1,
     308            'context'  => $this->get_context_param(),
     309            'page'     => array(
     310                'description'       => __( 'Current page of the collection.' ),
     311                'type'              => 'integer',
     312                'default'           => 1,
     313                'sanitize_callback' => 'absint',
     314                'validate_callback' => 'rest_validate_request_arg',
     315                'minimum'           => 1,
    316316            ),
    317             'per_page'               => array(
    318                 'description'        => __( 'Maximum number of items to be returned in result set.' ),
    319                 'type'               => 'integer',
    320                 'default'            => 10,
    321                 'minimum'            => 1,
    322                 'maximum'            => 100,
    323                 'sanitize_callback'  => 'absint',
    324                 'validate_callback'  => 'rest_validate_request_arg',
     317            'per_page' => array(
     318                'description'       => __( 'Maximum number of items to be returned in result set.' ),
     319                'type'              => 'integer',
     320                'default'           => 10,
     321                'minimum'           => 1,
     322                'maximum'           => 100,
     323                'sanitize_callback' => 'absint',
     324                'validate_callback' => 'rest_validate_request_arg',
    325325            ),
    326             'search'                 => array(
    327                 'description'        => __( 'Limit results to those matching a string.' ),
    328                 'type'               => 'string',
    329                 'sanitize_callback'  => 'sanitize_text_field',
    330                 'validate_callback'  => 'rest_validate_request_arg',
     326            'search'   => array(
     327                'description'       => __( 'Limit results to those matching a string.' ),
     328                'type'              => 'string',
     329                'sanitize_callback' => 'sanitize_text_field',
     330                'validate_callback' => 'rest_validate_request_arg',
    331331            ),
    332332        );
     
    345345    public function get_context_param( $args = array() ) {
    346346        $param_details = array(
    347             'description'        => __( 'Scope under which the request is made; determines fields present in response.' ),
    348             'type'               => 'string',
    349             'sanitize_callback'  => 'sanitize_key',
    350             'validate_callback'  => 'rest_validate_request_arg',
     347            'description'       => __( 'Scope under which the request is made; determines fields present in response.' ),
     348            'type'              => 'string',
     349            'sanitize_callback' => 'sanitize_key',
     350            'validate_callback' => 'rest_validate_request_arg',
    351351        );
    352352
     
    557557                // Only use required / default from arg_options on CREATABLE endpoints.
    558558                if ( WP_REST_Server::CREATABLE !== $method ) {
    559                     $params['arg_options'] = array_diff_key( $params['arg_options'], array( 'required' => '', 'default' => '' ) );
     559                    $params['arg_options'] = array_diff_key(
     560                        $params['arg_options'], array(
     561                            'required' => '',
     562                            'default'  => '',
     563                        )
     564                    );
    560565                }
    561566
Note: See TracChangeset for help on using the changeset viewer.