From 45f4c51ec45d31ceb0b497279f746d44ee78b9d3 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Wed, 6 Jul 2022 16:28:01 +0000 Subject: [PATCH] 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 [https://github.com/WordPress/pattern-directory/commit/69548ff1f0326c4fd4d9ea7390c48b6d9d227055 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 --- .../endpoints/class-wp-rest-pattern-directory-controller.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php index e79a1615ea..24ff4fb22d 100644 --- a/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php +++ b/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php @@ -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' ),