From 5167f6f487c7ed03eca6fb4dda7fe89c160ed7b7 Mon Sep 17 00:00:00 2001 From: Erik <11491369+kebbet@users.noreply.github.com> Date: Tue, 17 Oct 2023 11:32:01 +0200 Subject: [PATCH 1/3] Docs: improve comments, to align with Coding Standards. --- src/wp-admin/includes/class-wp-comments-list-table.php | 2 +- src/wp-admin/includes/class-wp-list-table.php | 2 +- src/wp-admin/includes/user.php | 2 +- src/wp-includes/media.php | 4 ++-- src/wp-includes/rest-api/class-wp-rest-server.php | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/wp-admin/includes/class-wp-comments-list-table.php b/src/wp-admin/includes/class-wp-comments-list-table.php index 1433818ccfb4f..96e103268b7c2 100644 --- a/src/wp-admin/includes/class-wp-comments-list-table.php +++ b/src/wp-admin/includes/class-wp-comments-list-table.php @@ -662,7 +662,7 @@ public function single_row( $item ) { current_user_can( 'read_post', $comment->comment_post_ID ) ) ) { - // The user has access to the post + // The user has access to the post. } else { return false; } diff --git a/src/wp-admin/includes/class-wp-list-table.php b/src/wp-admin/includes/class-wp-list-table.php index b3aebd9643cdf..d4cb5890516aa 100644 --- a/src/wp-admin/includes/class-wp-list-table.php +++ b/src/wp-admin/includes/class-wp-list-table.php @@ -860,7 +860,7 @@ protected function comments_bubble( $post_id, $pending_comments ) { current_user_can( 'read_post', $post_id ) ) ) { - // The user has access to the post and thus can see comments + // The user has access to the post and thus can see comments. } else { return false; } diff --git a/src/wp-admin/includes/user.php b/src/wp-admin/includes/user.php index 423c13ad15ccd..e3fad6864054b 100644 --- a/src/wp-admin/includes/user.php +++ b/src/wp-admin/includes/user.php @@ -737,7 +737,7 @@ function wp_is_authorize_application_redirect_url_valid( $url ) { $host = wp_parse_url( $url, PHP_URL_HOST ); $is_local = 'local' === wp_get_environment_type(); - // validates if the proper URI format is applied to the $url + // Validates if the proper URI format is applied to the $url. if ( empty( $host ) || empty( $scheme ) || in_array( strtolower( $scheme ), $invalid_protocols, true ) ) { return new WP_Error( 'invalid_redirect_url_format', diff --git a/src/wp-includes/media.php b/src/wp-includes/media.php index 078e3a2daab20..54ddb2f9bd9d8 100644 --- a/src/wp-includes/media.php +++ b/src/wp-includes/media.php @@ -2636,7 +2636,7 @@ function gallery_shortcode( $attr ) { if ( ! empty( $post_parent_id ) ) { $post_parent = get_post( $post_parent_id ); - // terminate the shortcode execution if user cannot read the post or password-protected + // Terminate the shortcode execution if user cannot read the post or password-protected. if ( ( ! is_post_publicly_viewable( $post_parent->ID ) && ! current_user_can( 'read_post', $post_parent->ID ) ) || post_password_required( $post_parent ) ) { @@ -2979,7 +2979,7 @@ function wp_playlist_shortcode( $attr ) { if ( ! empty( $args['post_parent'] ) ) { $post_parent = get_post( $id ); - // terminate the shortcode execution if user cannot read the post or password-protected + // Terminate the shortcode execution if user cannot read the post or password-protected. if ( ! current_user_can( 'read_post', $post_parent->ID ) || post_password_required( $post_parent ) ) { return ''; } 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 fdc3034755981..914a01cb82618 100644 --- a/src/wp-includes/rest-api/class-wp-rest-server.php +++ b/src/wp-includes/rest-api/class-wp-rest-server.php @@ -486,13 +486,13 @@ public function serve_request( $path = null ) { * Filters whether to send nocache headers on a REST API request. * * @since 4.4.0 - * @since 6.3.2 Moved the block to catch the filter added on rest_cookie_check_errors() from rest-api.php + * @since 6.3.2 Moved the block to catch the filter added on rest_cookie_check_errors() from rest-api.php. * * @param bool $rest_send_nocache_headers Whether to send no-cache headers. */ $send_no_cache_headers = apply_filters( 'rest_send_nocache_headers', is_user_logged_in() ); - // send no cache headers if the $send_no_cache_headers is true + // Send no cache headers if the $send_no_cache_headers is true // OR if the HTTP_X_HTTP_METHOD_OVERRIDE is used but resulted a 4x response code. if ( $send_no_cache_headers || ( true === $method_overridden && strpos( $code, '4' ) === 0 ) ) { foreach ( wp_get_nocache_headers() as $header => $header_value ) { From 54a7c454bb4eca0834646e869f1643db0089115f Mon Sep 17 00:00:00 2001 From: Erik <11491369+kebbet@users.noreply.github.com> Date: Tue, 17 Oct 2023 14:03:57 +0200 Subject: [PATCH 2/3] Inline standards --- src/wp-includes/rest-api/class-wp-rest-server.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 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 914a01cb82618..09d656c4e4b53 100644 --- a/src/wp-includes/rest-api/class-wp-rest-server.php +++ b/src/wp-includes/rest-api/class-wp-rest-server.php @@ -492,8 +492,10 @@ public function serve_request( $path = null ) { */ $send_no_cache_headers = apply_filters( 'rest_send_nocache_headers', is_user_logged_in() ); - // Send no cache headers if the $send_no_cache_headers is true - // OR if the HTTP_X_HTTP_METHOD_OVERRIDE is used but resulted a 4x response code. + /* + * Send no cache headers if the $send_no_cache_headers is true + * OR if the HTTP_X_HTTP_METHOD_OVERRIDE is used but resulted a 4x response code. + */ if ( $send_no_cache_headers || ( true === $method_overridden && strpos( $code, '4' ) === 0 ) ) { foreach ( wp_get_nocache_headers() as $header => $header_value ) { if ( empty( $header_value ) ) { From e0f2b787911cec35cb0a514ce1a4d0767c95876f Mon Sep 17 00:00:00 2001 From: Erik <11491369+kebbet@users.noreply.github.com> Date: Tue, 17 Oct 2023 15:56:59 +0200 Subject: [PATCH 3/3] Adds missing comma. --- src/wp-includes/rest-api/class-wp-rest-server.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 09d656c4e4b53..beb9b05c5aa11 100644 --- a/src/wp-includes/rest-api/class-wp-rest-server.php +++ b/src/wp-includes/rest-api/class-wp-rest-server.php @@ -493,7 +493,7 @@ public function serve_request( $path = null ) { $send_no_cache_headers = apply_filters( 'rest_send_nocache_headers', is_user_logged_in() ); /* - * Send no cache headers if the $send_no_cache_headers is true + * Send no cache headers if the $send_no_cache_headers is true, * OR if the HTTP_X_HTTP_METHOD_OVERRIDE is used but resulted a 4x response code. */ if ( $send_no_cache_headers || ( true === $method_overridden && strpos( $code, '4' ) === 0 ) ) {