Make WordPress Core


Ignore:
Timestamp:
07/05/2022 04:03:10 PM (4 years 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.
Merges [53665] to the 6.0 branch.
See #56126.

Location:
branches/6.0
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/6.0

  • branches/6.0/src/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php

    r53333 r53666  
    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.