Block Patterns: Update the value used for keywords.

Patterns on the [https://wordpress.org/patterns/ Pattern Directory] can have keywords for better discoverability while searching. The way these are stored [69548ff1f0 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.
Built from https://develop.svn.wordpress.org/branches/5.8@53675


git-svn-id: http://core.svn.wordpress.org/branches/5.8@53234 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2022-07-06 16:28:01 +00:00
parent e6ce4269a3
commit 45f4c51ec4
1 changed files with 2 additions and 2 deletions

View File

@ -210,7 +210,7 @@ class WP_REST_Pattern_Directory_Controller extends WP_REST_Controller {
'title' => sanitize_text_field( $raw_pattern->title->rendered ),
'content' => wp_kses_post( $raw_pattern->pattern_content ),
'categories' => array_map( 'sanitize_title', $raw_pattern->category_slugs ),
'keywords' => array_map( 'sanitize_title', $raw_pattern->keyword_slugs ),
'keywords' => array_map( 'sanitize_text_field', explode( ',', $raw_pattern->meta->wpop_keywords ) ),
'description' => sanitize_text_field( $raw_pattern->meta->wpop_description ),
'viewport_width' => absint( $raw_pattern->meta->wpop_viewport_width ),
);
@ -278,7 +278,7 @@ class WP_REST_Pattern_Directory_Controller extends WP_REST_Controller {
),
'keywords' => array(
'description' => __( "The pattern's keyword slugs." ),
'description' => __( "The pattern's keywords." ),
'type' => 'array',
'uniqueItems' => true,
'items' => array( 'type' => 'string' ),