Make WordPress Core


Ignore:
Timestamp:
07/05/2022 04:01:36 PM (23 months ago)
Author:
SergeyBiryukov
Message:

Block Patterns: Update the value used for keywords.

Patterns on the Pattern Directory can have keywords for better discoverability while searching. The way these are stored was changed from a taxonomy to meta value, but the /wp/v2/pattern-directory/patterns endpoint was still pulling from that old value.

The correct property to use for this field is meta.wpop_keywords, which returns a single string with comma-separated keywords.

Props ryelle, TimothyBlynJacobs.
See #56126.

File:
1 edited

Legend:

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

    r53333 r53665  
    207207            'content'        => wp_kses_post( $raw_pattern->pattern_content ),
    208208            'categories'     => array_map( 'sanitize_title', $raw_pattern->category_slugs ),
    209             'keywords'       => array_map( 'sanitize_title', $raw_pattern->keyword_slugs ),
     209            'keywords'       => array_map( 'sanitize_text_field', explode( ',', $raw_pattern->meta->wpop_keywords ) ),
    210210            'description'    => sanitize_text_field( $raw_pattern->meta->wpop_description ),
    211211            'viewport_width' => absint( $raw_pattern->meta->wpop_viewport_width ),
     
    275275
    276276                'keywords'       => array(
    277                     'description' => __( "The pattern's keyword slugs." ),
     277                    'description' => __( "The pattern's keywords." ),
    278278                    'type'        => 'array',
    279279                    'uniqueItems' => true,
Note: See TracChangeset for help on using the changeset viewer.