From 654bace6e3c7269dfdf99d78b0e08ea8e63376f8 Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Fri, 24 Jan 2025 02:06:19 +0400 Subject: [PATCH] Inline Commenting: Change the PHP compat directory (#68846) Relocates the backport log file for block comments to the experimental feature directory. The feature is currently experimental and will not be included in WordPress 6.8. Co-authored-by: Mamaduka Co-authored-by: shail-mehta --- backport-changelog/6.8/7488.md | 3 --- backport-changelog/6.8/7498.md | 3 --- .../block-comments.php | 8 +++---- ...ass-gutenberg-rest-comment-controller.php} | 22 +++++++++---------- lib/load.php | 8 +++++-- 5 files changed, 21 insertions(+), 23 deletions(-) delete mode 100644 backport-changelog/6.8/7488.md delete mode 100644 backport-changelog/6.8/7498.md rename lib/{compat/wordpress-6.8 => experimental}/block-comments.php (85%) rename lib/{compat/wordpress-6.8/class-gutenberg-rest-comment-controller-6-8.php => experimental/class-gutenberg-rest-comment-controller.php} (87%) diff --git a/backport-changelog/6.8/7488.md b/backport-changelog/6.8/7488.md deleted file mode 100644 index a588bef0e01796..00000000000000 --- a/backport-changelog/6.8/7488.md +++ /dev/null @@ -1,3 +0,0 @@ -https://github.com/WordPress/wordpress-develop/pull/7488 - -* https://github.com/WordPress/gutenberg/pull/60622 \ No newline at end of file diff --git a/backport-changelog/6.8/7498.md b/backport-changelog/6.8/7498.md deleted file mode 100644 index 6c903246166b64..00000000000000 --- a/backport-changelog/6.8/7498.md +++ /dev/null @@ -1,3 +0,0 @@ -https://github.com/WordPress/wordpress-develop/pull/7498 - -* https://github.com/WordPress/gutenberg/pull/60622 \ No newline at end of file diff --git a/lib/compat/wordpress-6.8/block-comments.php b/lib/experimental/block-comments.php similarity index 85% rename from lib/compat/wordpress-6.8/block-comments.php rename to lib/experimental/block-comments.php index ff9f03b69aa1c3..3381882589ef6d 100644 --- a/lib/compat/wordpress-6.8/block-comments.php +++ b/lib/experimental/block-comments.php @@ -1,6 +1,6 @@ query_vars['type'] ) && '' === $query->query_vars['type'] ) { diff --git a/lib/compat/wordpress-6.8/class-gutenberg-rest-comment-controller-6-8.php b/lib/experimental/class-gutenberg-rest-comment-controller.php similarity index 87% rename from lib/compat/wordpress-6.8/class-gutenberg-rest-comment-controller-6-8.php rename to lib/experimental/class-gutenberg-rest-comment-controller.php index 60b45b1a63adef..8409c595032961 100644 --- a/lib/compat/wordpress-6.8/class-gutenberg-rest-comment-controller-6-8.php +++ b/lib/experimental/class-gutenberg-rest-comment-controller.php @@ -7,7 +7,7 @@ */ // Create a new class that extends WP_REST_Comments_Controller -class Gutenberg_REST_Comment_Controller_6_8 extends WP_REST_Comments_Controller { +class Gutenberg_REST_Comment_Controller extends WP_REST_Comments_Controller { public function create_item_permissions_check( $request ) { if ( empty( $request['comment_type'] ) || 'comment' === $request['comment_type'] ) { @@ -18,7 +18,7 @@ public function create_item_permissions_check( $request ) { if ( get_option( 'comment_registration' ) ) { return new WP_Error( 'rest_comment_login_required', - __( 'Sorry, you must be logged in to comment.' ), + __( 'Sorry, you must be logged in to comment.', 'gutenberg' ), array( 'status' => 401 ) ); } @@ -40,7 +40,7 @@ public function create_item_permissions_check( $request ) { if ( ! $allow_anonymous ) { return new WP_Error( 'rest_comment_login_required', - __( 'Sorry, you must be logged in to comment.' ), + __( 'Sorry, you must be logged in to comment.', 'gutenberg' ), array( 'status' => 401 ) ); } @@ -51,7 +51,7 @@ public function create_item_permissions_check( $request ) { return new WP_Error( 'rest_comment_invalid_author', /* translators: %s: Request parameter. */ - sprintf( __( "Sorry, you are not allowed to edit '%s' for comments." ), 'author' ), + sprintf( __( "Sorry, you are not allowed to edit '%s' for comments.", 'gutenberg' ), 'author' ), array( 'status' => rest_authorization_required_code() ) ); } @@ -61,7 +61,7 @@ public function create_item_permissions_check( $request ) { return new WP_Error( 'rest_comment_invalid_author_ip', /* translators: %s: Request parameter. */ - sprintf( __( "Sorry, you are not allowed to edit '%s' for comments." ), 'author_ip' ), + sprintf( __( "Sorry, you are not allowed to edit '%s' for comments.", 'gutenberg' ), 'author_ip' ), array( 'status' => rest_authorization_required_code() ) ); } @@ -71,7 +71,7 @@ public function create_item_permissions_check( $request ) { return new WP_Error( 'rest_comment_invalid_status', /* translators: %s: Request parameter. */ - sprintf( __( "Sorry, you are not allowed to edit '%s' for comments." ), 'status' ), + sprintf( __( "Sorry, you are not allowed to edit '%s' for comments.", 'gutenberg' ), 'status' ), array( 'status' => rest_authorization_required_code() ) ); } @@ -79,7 +79,7 @@ public function create_item_permissions_check( $request ) { if ( empty( $request['post'] ) ) { return new WP_Error( 'rest_comment_invalid_post_id', - __( 'Sorry, you are not allowed to create this comment without a post.' ), + __( 'Sorry, you are not allowed to create this comment without a post.', 'gutenberg' ), array( 'status' => 403 ) ); } @@ -89,7 +89,7 @@ public function create_item_permissions_check( $request ) { if ( ! $post ) { return new WP_Error( 'rest_comment_invalid_post_id', - __( 'Sorry, you are not allowed to create this comment without a post.' ), + __( 'Sorry, you are not allowed to create this comment without a post.', 'gutenberg' ), array( 'status' => 403 ) ); } @@ -97,7 +97,7 @@ public function create_item_permissions_check( $request ) { if ( 'trash' === $post->post_status ) { return new WP_Error( 'rest_comment_trash_post', - __( 'Sorry, you are not allowed to create a comment on this post.' ), + __( 'Sorry, you are not allowed to create a comment on this post.', 'gutenberg' ), array( 'status' => 403 ) ); } @@ -105,7 +105,7 @@ public function create_item_permissions_check( $request ) { if ( ! $this->check_read_post_permission( $post, $request ) ) { return new WP_Error( 'rest_cannot_read_post', - __( 'Sorry, you are not allowed to read the post for this comment.' ), + __( 'Sorry, you are not allowed to read the post for this comment.', 'gutenberg' ), array( 'status' => rest_authorization_required_code() ) ); } @@ -117,7 +117,7 @@ public function create_item_permissions_check( $request ) { add_action( 'rest_api_init', function () { - $controller = new Gutenberg_REST_Comment_Controller_6_8(); + $controller = new Gutenberg_REST_Comment_Controller(); $controller->register_routes(); } ); diff --git a/lib/load.php b/lib/load.php index 69ba59e3718842..789c9f9980e9a3 100644 --- a/lib/load.php +++ b/lib/load.php @@ -42,8 +42,6 @@ function gutenberg_is_experiment_enabled( $name ) { require __DIR__ . '/compat/wordpress-6.7/rest-api.php'; // WordPress 6.8 compat. - require __DIR__ . '/compat/wordpress-6.8/block-comments.php'; - require __DIR__ . '/compat/wordpress-6.8/class-gutenberg-rest-comment-controller-6-8.php'; require __DIR__ . '/compat/wordpress-6.8/class-gutenberg-hierarchical-sort.php'; require __DIR__ . '/compat/wordpress-6.8/rest-api.php'; @@ -54,6 +52,12 @@ function gutenberg_is_experiment_enabled( $name ) { require_once __DIR__ . '/experimental/rest-api.php'; require_once __DIR__ . '/experimental/kses-allowed-html.php'; + + // Block Comments. + if ( gutenberg_is_experiment_enabled( 'gutenberg-block-comment' ) ) { + require __DIR__ . '/experimental/block-comments.php'; + require __DIR__ . '/experimental/class-gutenberg-rest-comment-controller.php'; + } } // Experimental signaling server.