From b58bb705ce22e220e864d91062022a9f917bb1bc Mon Sep 17 00:00:00 2001 From: Drew Jaynes Date: Sun, 30 Oct 2016 17:53:04 +0000 Subject: [PATCH] REST: Fix some errant `else if` conditions and add a few missing periods on inline comments. Props mrahmadawais. See #38398. git-svn-id: https://develop.svn.wordpress.org/trunk@39029 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/rest-api/class-wp-rest-server.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/wp-includes/rest-api/class-wp-rest-server.php b/src/wp-includes/rest-api/class-wp-rest-server.php index 391f549f3a..1b1a24439b 100644 --- a/src/wp-includes/rest-api/class-wp-rest-server.php +++ b/src/wp-includes/rest-api/class-wp-rest-server.php @@ -114,7 +114,7 @@ class WP_REST_Server { */ public function check_authentication() { /** - * Pass an authentication error to the API + * Filters REST authentication errors. * * This is used to pass a WP_Error from an authentication method back to * the API. @@ -391,7 +391,7 @@ class WP_REST_Server { } if ( $jsonp_callback ) { - // Prepend '/**/' to mitigate possible JSONP Flash attacks + // Prepend '/**/' to mitigate possible JSONP Flash attacks. // https://miki.it/blog/2014/7/8/abusing-jsonp-with-rosetta-flash/ echo '/**/' . $jsonp_callback . '(' . $result . ')'; } else { @@ -502,7 +502,7 @@ class WP_REST_Server { continue; } - // Relation now changes from '$uri' to '$curie:$relation' + // Relation now changes from '$uri' to '$curie:$relation'. $rel_regex = str_replace( '\{rel\}', '(.+)', preg_quote( $curie['href'], '!' ) ); preg_match( '!' . $rel_regex . '!', $rel, $matches ); if ( $matches ) { @@ -582,6 +582,7 @@ class WP_REST_Server { // Determine if any real links were found. $has_links = count( array_filter( $embeds ) ); + if ( $has_links ) { $embedded[ $rel ] = $embeds; } @@ -741,7 +742,7 @@ class WP_REST_Server { // Allow comma-separated HTTP methods. if ( is_string( $handler['methods'] ) ) { $methods = explode( ',', $handler['methods'] ); - } else if ( is_array( $handler['methods'] ) ) { + } elseif ( is_array( $handler['methods'] ) ) { $methods = $handler['methods']; } else { $methods = array(); @@ -755,6 +756,7 @@ class WP_REST_Server { } } } + return $endpoints; } @@ -896,7 +898,7 @@ class WP_REST_Server { if ( is_wp_error( $permission ) ) { $response = $permission; - } else if ( false === $permission || null === $permission ) { + } elseif ( false === $permission || null === $permission ) { $response = new WP_Error( 'rest_forbidden', __( 'Sorry, you are not allowed to do that.' ), array( 'status' => 403 ) ); } }