8000 Use `elseif` consistently. · WP-API/WP-API@1a99202 · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Sep 24, 2018. It is now read-only.

Commit 1a99202

Browse files
author
Peter Wilson
committed
Use elseif consistently.
1 parent 6563324 commit 1a99202

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

lib/endpoints/class-wp-rest-comments-controller.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function get_items_permissions_check( $request ) {
7676
$post = $this->get_post( $post_id );
7777
if ( ! empty( $post_id ) && $post && ! $this->check_read_post_permission( $post ) ) {
7878
return new WP_Error( 'rest_cannot_read_post', __( 'Sorry, you cannot read the post for this comment.' ), array( 'status' => rest_authorization_required_code() ) );
79-
} else if ( 0 === $post_id && ! current_user_can( 'moderate_comments' ) ) {
79+
} elseif ( 0 === $post_id && ! current_user_can( 'moderate_comments' ) ) {
8080
return new WP_Error( 'rest_cannot_read', __( 'Sorry, you cannot read comments without a post.' ), array( 'status' => rest_authorization_required_code() ) );
8181
}
8282
}
@@ -94,11 +94,11 @@ public function get_items_permissions_check( $request ) {
9494
if ( 'approve' !== $request[ $param ] ) {
9595
$forbidden_params[] = $param;
9696
}
97-
} else if ( 'type' === $param ) {
97+
} elseif ( 'type' === $param ) {
9898
if ( 'comment' !== $request[ $param ] ) {
9999
$forbidden_params[] = $param;
100100
}
101-
} else if ( ! empty( $request[ $param ] ) ) {
101+
} elseif ( ! empty( $request[ $param ] ) ) {
102102
$forbidden_params[] = $param;
103103
}
104104
}

lib/endpoints/class-wp-rest-users-controller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ public function get_item_permissions_check( $request ) {
239239

240240
if ( 'edit' === $request['context'] && ! current_user_can( 'list_users' ) ) {
241241
return new WP_Error( 'rest_user_cannot_view', __( 'Sorry, you cannot view this resource with edit context.' ), array( 'status' => rest_authorization_required_code() ) );
242-
} else if ( ! count_user_posts( $id, $types ) && ! current_user_can( 'edit_user', $id ) && ! current_user_can( 'list_users' ) ) {
242+
} elseif ( ! count_user_posts( $id, $types ) && ! current_user_can( 'edit_user', $id ) && ! current_user_can( 'list_users' ) ) {
243243
return new WP_Error( 'rest_user_cannot_view', __( 'Sorry, you cannot view this resource.' ), array( 'status' => rest_authorization_required_code() ) );
244244
}
245245

plugin.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -497,29 +497,29 @@ function rest_validate_request_arg( $value, $request, $param ) {
497497
if ( isset( $args['minimum'] ) && ! isset( $args['maximum'] ) ) {
498498
if ( ! empty( $args['exclusiveMinimum'] ) && $value <= $args['minimum'] ) {
499499
return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s must be greater than %2$d (exclusive)' ), $param, $args['minimum'] ) );
500-
} else if ( empty( $args['exclusiveMinimum'] ) && $value < $args['minimum'] ) {
500+
} elseif ( empty( $args['exclusiveMinimum'] ) && $value < $args['minimum'] ) {
501501
return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s must be greater than %2$d (inclusive)' ), $param, $args['minimum'] ) );
502502
}
503-
} else if ( isset( $args['maximum'] ) && ! isset( $args['minimum'] ) ) {
503+
} elseif ( isset( $args['maximum'] ) && ! isset( $args['minimum'] ) ) {
504504
if ( ! empty( $args['exclusiveMaximum'] ) && $value >= $args['maximum'] ) {
505505
return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s must be less than %2$d (exclusive)' ), $param, $args['maximum'] ) );
506-
} else if ( empty( $args['exclusiveMaximum'] ) && $value > $args['maximum'] ) {
506+
} elseif ( empty( $args['exclusiveMaximum'] ) && $value > $args['maximum'] ) {
507507
return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s must be less than %2$d (inclusive)' ), $param, $args['maximum'] ) );
508508
}
509-
} else if ( isset( $args['maximum'] ) && isset( $args['minimum'] ) ) {
509+
} elseif ( isset( $args['maximum'] ) && isset( $args['minimum'] ) ) {
510510
if ( ! empty( $args['exclusiveMinimum'] ) && ! empty( $args['exclusiveMaximum'] ) ) {
511511
if ( $value >= $args['maximum'] || $value <= $args['minimum'] ) {
512512
return new WP_Error( 'rest_invalid_param', sprintf( /* translators: 1: parameter, 2: minimum number, 3: maximum number */ __( '%1$s must be between %2$d (exclusive) and %3$d (exclusive)' ), $param, $args['minimum'], $args['maximum'] ) );
513513
}
514-
} else if ( empty( $args['exclusiveMinimum'] ) && ! empty( $args['exclusiveMaximum'] ) ) {
514+
} elseif ( empty( $args['exclusiveMinimum'] ) && ! empty( $args['exclusiveMaximum'] ) ) {
515515
if ( $value >= $args['maximum'] || $value < $args['minimum'] ) {
516516
return new WP_Error( 'rest_invalid_param', sprintf( /* translators: 1: parameter, 2: minimum number, 3: maximum number */ __( '%1$s must be between %2$d (inclusive) and %3$d (exclusive)' ), $param, $args['minimum'], $args['maximum'] ) );
517517
}
518-
} else if ( ! empty( $args['exclusiveMinimum'] ) && empty( $args['exclusiveMaximum'] ) ) {
518+
} elseif ( ! empty( $args['exclusiveMinimum'] ) && empty( $args['exclusiveMaximum'] ) ) {
519519
if ( $value > $args['maximum'] || $value <= $args['minimum'] ) {
520520
return new WP_Error( 'rest_invalid_param', sprintf( /* translators: 1: parameter, 2: minimum number, 3: maximum number */ __( '%1$s must be between %2$d (exclusive) and %3$d (inclusive)' ), $param, $args['minimum'], $args['maximum'] ) );
521521
}
522-
} else if ( empty( $args['exclusiveMinimum'] ) && empty( $args['exclusiveMaximum'] ) ) {
522+
} elseif ( empty( $args['exclusiveMinimum'] ) && empty( $args['exclusiveMaximum'] ) ) {
523523
if ( $value > $args['maximum'] || $value < $args['minimum'] ) {
524524
return new WP_Error( 'rest_invalid_param', sprintf( /* translators: 1: parameter, 2: minimum number, 3: maximum number */ __( '%1$s must be between %2$d (inclusive) and %3$d (inclusive)' ), $param, $args['minimum'], $args['maximum'] ) );
525525
}

tests/bootstrap.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919
*/
2020
if ( false !== getenv( 'WP_DEVELOP_DIR' ) ) {
2121
$test_root = getenv( 'WP_DEVELOP_DIR' ) . '/tests/phpunit';
22-
} else if ( false !== getenv( 'WP_TESTS_DIR' ) ) {
22+
} elseif ( false !== getenv( 'WP_TESTS_DIR' ) ) {
2323
$test_root = getenv( 'WP_TESTS_DIR' );
24-
} else if ( false !== getenv( 'WP_ROOT_DIR' ) ) {
24+
} elseif ( false !== getenv( 'WP_ROOT_DIR' ) ) {
2525
$test_root = getenv( 'WP_ROOT_DIR' ) . '/tests/phpunit';
26-
} else if ( file_exists( '../../../../tests/phpunit/includes/bootstrap.php' ) ) {
26+
} elseif ( file_exists( '../../../../tests/phpunit/includes/bootstrap.php' ) ) {
2727
$test_root = '../../../../tests/phpunit';
28-
} else if ( file_exists( '/tmp/wordpress-tests-lib/includes/bootstrap.php' ) ) {
28+
} elseif ( file_exists( '/tmp/wordpress-tests-lib/includes/bootstrap.php' ) ) {
2929
$test_root = '/tmp/wordpress-tests-lib';
3030
}
3131

tests/test-rest-posts-controller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ public function test_get_item_links() {
666666
$tag_link = $link;
667667
} elseif ( 'category' === $link['attributes']['taxonomy'] ) {
668668
$cat_link = $link;
669-
} else if ( 'post_format' === $link['attributes']['taxonomy'] ) {
669+
} elseif ( 'post_format' === $link['attributes']['taxonomy'] ) {
670670
$format_link = $link;
671671
}
672672
}

0 commit comments

Comments
 (0)
0