diff --git a/lib/compat/wordpress-6.2/class-gutenberg-rest-pattern-directory-controller-6-2.php b/lib/compat/wordpress-6.2/class-gutenberg-rest-pattern-directory-controller-6-2.php
index c038460559021..da3aad56c22be 100644
--- a/lib/compat/wordpress-6.2/class-gutenberg-rest-pattern-directory-controller-6-2.php
+++ b/lib/compat/wordpress-6.2/class-gutenberg-rest-pattern-directory-controller-6-2.php
@@ -25,8 +25,8 @@ public function register_routes() {
'methods' => WP_REST_Server::READABLE,
'callback' => array( $this, 'get_pattern_categories' ),
'permission_callback' => array( $this, 'get_items_permissions_check' ),
- )
- ),
+ ),
+ )
);
parent::register_routes();
@@ -73,8 +73,8 @@ public function get_pattern_categories( $request ) {
'pattern_directory_api_failed',
sprintf(
/* translators: %s: Support forums URL. */
- __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the support forums.' ),
- __( 'https://wordpress.org/support/forums/' )
+ __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the support forums.', 'gutenberg' ),
+ __( 'https://wordpress.org/support/forums/', 'gutenberg' )
),
array(
'response' => wp_remote_retrieve_body( $wporg_response ),
@@ -117,14 +117,14 @@ public function get_pattern_categories( $request ) {
* @param WP_REST_Request $request Request object.
* @return WP_REST_Response
*/
- public function prepare_pattern_category_for_response( $item , $request) {
- $prepared_pattern_category = array(
+ public function prepare_pattern_category_for_response( $item, $request ) {
+ $raw_pattern_category = array(
'id' => absint( $item->id ),
'name' => sanitize_text_field( $item->name ),
- 'slug' => sanitize_text_field( $item->slug )
+ 'slug' => sanitize_text_field( $item->slug ),
);
- $prepared_pattern = $this->add_additional_fields_to_object( $prepared_pattern_category, $request );
+ $prepared_pattern_category = $this->add_additional_fields_to_object( $raw_pattern_category, $request );
return new WP_REST_Response( $prepared_pattern_category );
}
diff --git a/phpunit/class-wp-rest-pattern-directory-controller-test.php b/phpunit/class-wp-rest-pattern-directory-controller-test.php
index fd34a915e96f6..c05e6b4be114f 100644
--- a/phpunit/class-wp-rest-pattern-directory-controller-test.php
+++ b/phpunit/class-wp-rest-pattern-directory-controller-test.php
@@ -100,7 +100,14 @@ public function test_prepare_pattern_category_for_response() {
static::$controller->prepare_pattern_category_for_response( $raw_categories[0], new WP_REST_Request() )
);
- $this->assertArrayNotHasKey( 'description', $prepared_category );
+ $this->assertSame(
+ array(
+ 'id' => 3,
+ 'name' => 'Columns',
+ 'slug' => 'columns',
+ ),
+ $prepared_category
+ );
}