mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-17 07:10:27 +00:00
Coding Standards: Upgrade WPCS to 1.0.0
WPCS 1.0.0 includes a bunch of new auto-fixers, which drops the number of coding standards issues across WordPress significantly. Prior to running the auto-fixers, there were 15,312 issues detected. With this commit, we now drop to 4,769 issues. This change includes three notable additions: - Multiline function calls must now put each parameter on a new line. - Auto-formatting files is now part of the `grunt precommit` script. - Auto-fixable coding standards issues will now cause Travis failures. Fixes #44600. git-svn-id: https://develop.svn.wordpress.org/trunk@43571 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -44,7 +44,9 @@ class WP_REST_Comments_Controller extends WP_REST_Controller {
|
||||
public function register_routes() {
|
||||
|
||||
register_rest_route(
|
||||
$this->namespace, '/' . $this->rest_base, array(
|
||||
$this->namespace,
|
||||
'/' . $this->rest_base,
|
||||
array(
|
||||
array(
|
||||
'methods' => WP_REST_Server::READABLE,
|
||||
'callback' => array( $this, 'get_items' ),
|
||||
@@ -62,7 +64,9 @@ class WP_REST_Comments_Controller extends WP_REST_Controller {
|
||||
);
|
||||
|
||||
register_rest_route(
|
||||
$this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array(
|
||||
$this->namespace,
|
||||
'/' . $this->rest_base . '/(?P<id>[\d]+)',
|
||||
array(
|
||||
'args' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the object.' ),
|
||||
|
||||
@@ -586,7 +586,8 @@ abstract class WP_REST_Controller {
|
||||
// Only use required / default from arg_options on CREATABLE endpoints.
|
||||
if ( WP_REST_Server::CREATABLE !== $method ) {
|
||||
$params['arg_options'] = array_diff_key(
|
||||
$params['arg_options'], array(
|
||||
$params['arg_options'],
|
||||
array(
|
||||
'required' => '',
|
||||
'default' => '',
|
||||
)
|
||||
|
||||
@@ -36,7 +36,9 @@ class WP_REST_Post_Statuses_Controller extends WP_REST_Controller {
|
||||
public function register_routes() {
|
||||
|
||||
register_rest_route(
|
||||
$this->namespace, '/' . $this->rest_base, array(
|
||||
$this->namespace,
|
||||
'/' . $this->rest_base,
|
||||
array(
|
||||
array(
|
||||
'methods' => WP_REST_Server::READABLE,
|
||||
'callback' => array( $this, 'get_items' ),
|
||||
@@ -48,7 +50,9 @@ class WP_REST_Post_Statuses_Controller extends WP_REST_Controller {
|
||||
);
|
||||
|
||||
register_rest_route(
|
||||
$this->namespace, '/' . $this->rest_base . '/(?P<status>[\w-]+)', array(
|
||||
$this->namespace,
|
||||
'/' . $this->rest_base . '/(?P<status>[\w-]+)',
|
||||
array(
|
||||
'args' => array(
|
||||
'status' => array(
|
||||
'description' => __( 'An alphanumeric identifier for the status.' ),
|
||||
|
||||
@@ -36,7 +36,9 @@ class WP_REST_Post_Types_Controller extends WP_REST_Controller {
|
||||
public function register_routes() {
|
||||
|
||||
register_rest_route(
|
||||
$this->namespace, '/' . $this->rest_base, array(
|
||||
$this->namespace,
|
||||
'/' . $this->rest_base,
|
||||
array(
|
||||
array(
|
||||
'methods' => WP_REST_Server::READABLE,
|
||||
'callback' => array( $this, 'get_items' ),
|
||||
@@ -48,7 +50,9 @@ class WP_REST_Post_Types_Controller extends WP_REST_Controller {
|
||||
);
|
||||
|
||||
register_rest_route(
|
||||
$this->namespace, '/' . $this->rest_base . '/(?P<type>[\w-]+)', array(
|
||||
$this->namespace,
|
||||
'/' . $this->rest_base . '/(?P<type>[\w-]+)',
|
||||
array(
|
||||
'args' => array(
|
||||
'type' => array(
|
||||
'description' => __( 'An alphanumeric identifier for the post type.' ),
|
||||
|
||||
@@ -58,7 +58,9 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
||||
public function register_routes() {
|
||||
|
||||
register_rest_route(
|
||||
$this->namespace, '/' . $this->rest_base, array(
|
||||
$this->namespace,
|
||||
'/' . $this->rest_base,
|
||||
array(
|
||||
array(
|
||||
'methods' => WP_REST_Server::READABLE,
|
||||
'callback' => array( $this, 'get_items' ),
|
||||
@@ -86,7 +88,9 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
||||
);
|
||||
}
|
||||
register_rest_route(
|
||||
$this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array(
|
||||
$this->namespace,
|
||||
'/' . $this->rest_base . '/(?P<id>[\d]+)',
|
||||
array(
|
||||
'args' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the object.' ),
|
||||
@@ -1691,7 +1695,6 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
||||
'id' => $last_revision,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$post_type_obj = get_post_type_object( $post->post_type );
|
||||
|
||||
@@ -66,7 +66,9 @@ class WP_REST_Revisions_Controller extends WP_REST_Controller {
|
||||
public function register_routes() {
|
||||
|
||||
register_rest_route(
|
||||
$this->namespace, '/' . $this->parent_base . '/(?P<parent>[\d]+)/' . $this->rest_base, array(
|
||||
$this->namespace,
|
||||
'/' . $this->parent_base . '/(?P<parent>[\d]+)/' . $this->rest_base,
|
||||
array(
|
||||
'args' => array(
|
||||
'parent' => array(
|
||||
'description' => __( 'The ID for the parent of the object.' ),
|
||||
@@ -84,7 +86,9 @@ class WP_REST_Revisions_Controller extends WP_REST_Controller {
|
||||
);
|
||||
|
||||
register_rest_route(
|
||||
$this->namespace, '/' . $this->parent_base . '/(?P<parent>[\d]+)/' . $this->rest_base . '/(?P<id>[\d]+)', array(
|
||||
$this->namespace,
|
||||
'/' . $this->parent_base . '/(?P<parent>[\d]+)/' . $this->rest_base . '/(?P<id>[\d]+)',
|
||||
array(
|
||||
'args' => array(
|
||||
'parent' => array(
|
||||
'description' => __( 'The ID for the parent of the object.' ),
|
||||
|
||||
@@ -36,7 +36,9 @@ class WP_REST_Settings_Controller extends WP_REST_Controller {
|
||||
public function register_routes() {
|
||||
|
||||
register_rest_route(
|
||||
$this->namespace, '/' . $this->rest_base, array(
|
||||
$this->namespace,
|
||||
'/' . $this->rest_base,
|
||||
array(
|
||||
array(
|
||||
'methods' => WP_REST_Server::READABLE,
|
||||
'callback' => array( $this, 'get_item' ),
|
||||
@@ -187,7 +189,9 @@ class WP_REST_Settings_Controller extends WP_REST_Controller {
|
||||
*/
|
||||
if ( is_wp_error( rest_validate_value_from_schema( get_option( $args['option_name'], false ), $args['schema'] ) ) ) {
|
||||
return new WP_Error(
|
||||
'rest_invalid_stored_value', sprintf( __( 'The %s property has an invalid stored value, and cannot be updated to null.' ), $name ), array( 'status' => 500 )
|
||||
'rest_invalid_stored_value',
|
||||
sprintf( __( 'The %s property has an invalid stored value, and cannot be updated to null.' ), $name ),
|
||||
array( 'status' => 500 )
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,9 @@ class WP_REST_Taxonomies_Controller extends WP_REST_Controller {
|
||||
public function register_routes() {
|
||||
|
||||
register_rest_route(
|
||||
$this->namespace, '/' . $this->rest_base, array(
|
||||
$this->namespace,
|
||||
'/' . $this->rest_base,
|
||||
array(
|
||||
array(
|
||||
'methods' => WP_REST_Server::READABLE,
|
||||
'callback' => array( $this, 'get_items' ),
|
||||
@@ -48,7 +50,9 @@ class WP_REST_Taxonomies_Controller extends WP_REST_Controller {
|
||||
);
|
||||
|
||||
register_rest_route(
|
||||
$this->namespace, '/' . $this->rest_base . '/(?P<taxonomy>[\w-]+)', array(
|
||||
$this->namespace,
|
||||
'/' . $this->rest_base . '/(?P<taxonomy>[\w-]+)',
|
||||
array(
|
||||
'args' => array(
|
||||
'taxonomy' => array(
|
||||
'description' => __( 'An alphanumeric identifier for the taxonomy.' ),
|
||||
|
||||
@@ -74,7 +74,9 @@ class WP_REST_Terms_Controller extends WP_REST_Controller {
|
||||
public function register_routes() {
|
||||
|
||||
register_rest_route(
|
||||
$this->namespace, '/' . $this->rest_base, array(
|
||||
$this->namespace,
|
||||
'/' . $this->rest_base,
|
||||
array(
|
||||
array(
|
||||
'methods' => WP_REST_Server::READABLE,
|
||||
'callback' => array( $this, 'get_items' ),
|
||||
@@ -92,7 +94,9 @@ class WP_REST_Terms_Controller extends WP_REST_Controller {
|
||||
);
|
||||
|
||||
register_rest_route(
|
||||
$this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array(
|
||||
$this->namespace,
|
||||
'/' . $this->rest_base . '/(?P<id>[\d]+)',
|
||||
array(
|
||||
'args' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the term.' ),
|
||||
@@ -422,7 +426,12 @@ class WP_REST_Terms_Controller extends WP_REST_Controller {
|
||||
if ( $term_id = $term->get_error_data( 'term_exists' ) ) {
|
||||
$existing_term = get_term( $term_id, $this->taxonomy );
|
||||
$term->add_data( $existing_term->term_id, 'term_exists' );
|
||||
$term->add_data( array( 'status' => 400, 'term_id' => $term_id ) );
|
||||
$term->add_data(
|
||||
array(
|
||||
'status' => 400,
|
||||
'term_id' => $term_id,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return $term;
|
||||
|
||||
@@ -46,7 +46,9 @@ class WP_REST_Users_Controller extends WP_REST_Controller {
|
||||
public function register_routes() {
|
||||
|
||||
register_rest_route(
|
||||
$this->namespace, '/' . $this->rest_base, array(
|
||||
$this->namespace,
|
||||
'/' . $this->rest_base,
|
||||
array(
|
||||
array(
|
||||
'methods' => WP_REST_Server::READABLE,
|
||||
'callback' => array( $this, 'get_items' ),
|
||||
@@ -64,7 +66,9 @@ class WP_REST_Users_Controller extends WP_REST_Controller {
|
||||
);
|
||||
|
||||
register_rest_route(
|
||||
$this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array(
|
||||
$this->namespace,
|
||||
'/' . $this->rest_base . '/(?P<id>[\d]+)',
|
||||
array(
|
||||
'args' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique identifier for the user.' ),
|
||||
@@ -108,7 +112,9 @@ class WP_REST_Users_Controller extends WP_REST_Controller {
|
||||
);
|
||||
|
||||
register_rest_route(
|
||||
$this->namespace, '/' . $this->rest_base . '/me', array(
|
||||
$this->namespace,
|
||||
'/' . $this->rest_base . '/me',
|
||||
array(
|
||||
array(
|
||||
'methods' => WP_REST_Server::READABLE,
|
||||
'callback' => array( $this, 'get_current_item' ),
|
||||
@@ -194,7 +200,7 @@ class WP_REST_Users_Controller extends WP_REST_Controller {
|
||||
|
||||
if ( 'authors' === $request['who'] ) {
|
||||
$can_view = false;
|
||||
$types = get_post_types( array( 'show_in_rest' => true ), 'objects' );
|
||||
$types = get_post_types( array( 'show_in_rest' => true ), 'objects' );
|
||||
foreach ( $types as $type ) {
|
||||
if ( post_type_supports( $type->name, 'author' )
|
||||
&& current_user_can( $type->cap->edit_posts ) ) {
|
||||
|
||||
Reference in New Issue
Block a user