Make WordPress Core


Ignore:
Timestamp:
01/19/2023 12:11:57 PM (2 years ago)
Author:
youknowriad
Message:

Editor: Allow block pattern categories to have descriptions.

Updates the corresponding REST API endpoint and unit test.

Fixes #57478.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-block-pattern-categories-controller.php

    r53302 r55097  
    103103    public function prepare_item_for_response( $item, $request ) {
    104104        $fields = $this->get_fields_for_response( $request );
    105         $keys   = array( 'name', 'label' );
     105        $keys   = array( 'name', 'label', 'description' );
    106106        $data   = array();
    107107        foreach ( $keys as $key ) {
    108             if ( rest_is_field_included( $key, $fields ) ) {
     108            if ( isset( $item[ $key ] ) && rest_is_field_included( $key, $fields ) ) {
    109109                $data[ $key ] = $item[ $key ];
    110110            }
     
    131131            'type'       => 'object',
    132132            'properties' => array(
    133                 'name'  => array(
     133                'name'        => array(
    134134                    'description' => __( 'The category name.' ),
    135135                    'type'        => 'string',
     
    137137                    'context'     => array( 'view', 'edit', 'embed' ),
    138138                ),
    139                 'label' => array(
     139                'label'       => array(
    140140                    'description' => __( 'The category label, in human readable format.' ),
     141                    'type'        => 'string',
     142                    'readonly'    => true,
     143                    'context'     => array( 'view', 'edit', 'embed' ),
     144                ),
     145                'description' => array(
     146                    'description' => __( 'The category description, in human readable format.' ),
    141147                    'type'        => 'string',
    142148                    'readonly'    => true,
Note: See TracChangeset for help on using the changeset viewer.