Make WordPress Core


Ignore:
Timestamp:
07/06/2022 04:26:08 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.

Follow-up to [51021].

Props ryelle, TimothyBlynJacobs.
Merges [53665] to the 5.8 branch.
See #56126.

Location:
branches/5.8
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.8

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

    r51317 r53675  
    211211            'content'        => wp_kses_post( $raw_pattern->pattern_content ),
    212212            'categories'     => array_map( 'sanitize_title', $raw_pattern->category_slugs ),
    213             'keywords'       => array_map( 'sanitize_title', $raw_pattern->keyword_slugs ),
     213            'keywords'       => array_map( 'sanitize_text_field', explode( ',', $raw_pattern->meta->wpop_keywords ) ),
    214214            'description'    => sanitize_text_field( $raw_pattern->meta->wpop_description ),
    215215            'viewport_width' => absint( $raw_pattern->meta->wpop_viewport_width ),
     
    279279
    280280                'keywords'       => array(
    281                     'description' => __( "The pattern's keyword slugs." ),
     281                    'description' => __( "The pattern's keywords." ),
    282282                    'type'        => 'array',
    283283                    'uniqueItems' => true,
Note: See TracChangeset for help on using the changeset viewer.