From 0831f905f09c6c7743389a15682bbbca63416d58 Mon Sep 17 00:00:00 2001 From: youknowriad Date: Thu, 19 Jan 2023 12:13:14 +0000 Subject: [PATCH] Editor: Allow block pattern categories to have descriptions. Updates the corresponding REST API endpoint and unit test. Fixes #57478. Built from https://develop.svn.wordpress.org/trunk@55097 git-svn-id: http://core.svn.wordpress.org/trunk@54630 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- ...wp-rest-block-pattern-categories-controller.php | 14 ++++++++++---- wp-includes/version.php | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-block-pattern-categories-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-block-pattern-categories-controller.php index 761c0d6777..bd6b76ac2c 100644 --- a/wp-includes/rest-api/endpoints/class-wp-rest-block-pattern-categories-controller.php +++ b/wp-includes/rest-api/endpoints/class-wp-rest-block-pattern-categories-controller.php @@ -102,10 +102,10 @@ class WP_REST_Block_Pattern_Categories_Controller extends WP_REST_Controller { */ public function prepare_item_for_response( $item, $request ) { $fields = $this->get_fields_for_response( $request ); - $keys = array( 'name', 'label' ); + $keys = array( 'name', 'label', 'description' ); $data = array(); foreach ( $keys as $key ) { - if ( rest_is_field_included( $key, $fields ) ) { + if ( isset( $item[ $key ] ) && rest_is_field_included( $key, $fields ) ) { $data[ $key ] = $item[ $key ]; } } @@ -130,18 +130,24 @@ class WP_REST_Block_Pattern_Categories_Controller extends WP_REST_Controller { 'title' => 'block-pattern-category', 'type' => 'object', 'properties' => array( - 'name' => array( + 'name' => array( 'description' => __( 'The category name.' ), 'type' => 'string', 'readonly' => true, 'context' => array( 'view', 'edit', 'embed' ), ), - 'label' => array( + 'label' => array( 'description' => __( 'The category label, in human readable format.' ), 'type' => 'string', 'readonly' => true, 'context' => array( 'view', 'edit', 'embed' ), ), + 'description' => array( + 'description' => __( 'The category description, in human readable format.' ), + 'type' => 'string', + 'readonly' => true, + 'context' => array( 'view', 'edit', 'embed' ), + ), ), ); diff --git a/wp-includes/version.php b/wp-includes/version.php index ab30af22b4..e3ef98db48 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.2-alpha-55096'; +$wp_version = '6.2-alpha-55097'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.