mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-12 04:40:26 +00:00
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. Props ryelle, TimothyBlynJacobs. See #56126. git-svn-id: https://develop.svn.wordpress.org/trunk@53665 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -206,7 +206,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 ),
|
||||
);
|
||||
@@ -274,7 +274,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' ),
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
"meta": {
|
||||
"spay_email": "",
|
||||
"wpop_description": "A heading preceded by a chapter number, and followed by a paragraph.",
|
||||
"wpop_keywords": "blog post",
|
||||
"wpop_viewport_width": 1000
|
||||
},
|
||||
"category_slugs": [ "text" ],
|
||||
@@ -25,6 +26,7 @@
|
||||
"meta": {
|
||||
"spay_email": "",
|
||||
"wpop_description": "A large hero section with an example background image and a heading in the center.",
|
||||
"wpop_keywords": "header, hero",
|
||||
"wpop_viewport_width": 1000
|
||||
},
|
||||
"category_slugs": [ "header" ],
|
||||
@@ -41,6 +43,7 @@
|
||||
"meta": {
|
||||
"spay_email": "",
|
||||
"wpop_description": "A large hero section with a bright gradient background, a big heading and a filled button.",
|
||||
"wpop_keywords": "call to action, hero section",
|
||||
"wpop_viewport_width": 1000
|
||||
},
|
||||
"category_slugs": [ "header" ],
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
"meta": {
|
||||
"spay_email": "",
|
||||
"wpop_description": "Three filled buttons with rounded corners, side by side.",
|
||||
"wpop_keywords": "",
|
||||
"wpop_viewport_width": 600
|
||||
},
|
||||
"category_slugs": [ "buttons" ],
|
||||
@@ -25,6 +26,7 @@
|
||||
"meta": {
|
||||
"spay_email": "",
|
||||
"wpop_description": "Two buttons, one filled and one outlined, side by side.",
|
||||
"wpop_keywords": "",
|
||||
"wpop_viewport_width": 500
|
||||
},
|
||||
"category_slugs": [ "buttons" ],
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
"meta": {
|
||||
"spay_email": "",
|
||||
"wpop_description": "A heading preceded by a chapter number, and followed by a paragraph.",
|
||||
"wpop_keywords": "",
|
||||
"wpop_viewport_width": 1000
|
||||
},
|
||||
"category_slugs": [ "text" ],
|
||||
@@ -25,6 +26,7 @@
|
||||
"meta": {
|
||||
"spay_email": "",
|
||||
"wpop_description": "A large hero section with an example background image and a heading in the center.",
|
||||
"wpop_keywords": "",
|
||||
"wpop_viewport_width": 1000
|
||||
},
|
||||
"category_slugs": [ "header" ],
|
||||
@@ -41,6 +43,7 @@
|
||||
"meta": {
|
||||
"spay_email": "",
|
||||
"wpop_description": "A large hero section with a bright gradient background, a big heading and a filled button.",
|
||||
"wpop_keywords": "",
|
||||
"wpop_viewport_width": 1000
|
||||
},
|
||||
"category_slugs": [ "header" ],
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
"meta": {
|
||||
"spay_email": "",
|
||||
"wpop_description": "A large hero section with a bright gradient background, a big heading and a filled button.",
|
||||
"wpop_keywords": "",
|
||||
"wpop_viewport_width": 1000
|
||||
},
|
||||
"category_slugs": [ "header" ],
|
||||
@@ -25,6 +26,7 @@
|
||||
"meta": {
|
||||
"spay_email": "",
|
||||
"wpop_description": "Three small columns of text, each with an outlined button with rounded corners at the bottom.",
|
||||
"wpop_keywords": "",
|
||||
"wpop_viewport_width": 1000
|
||||
},
|
||||
"category_slugs": [ "columns" ],
|
||||
@@ -41,6 +43,7 @@
|
||||
"meta": {
|
||||
"spay_email": "",
|
||||
"wpop_description": "Three filled buttons with rounded corners, side by side.",
|
||||
"wpop_keywords": "",
|
||||
"wpop_viewport_width": 600
|
||||
},
|
||||
"category_slugs": [ "buttons" ],
|
||||
@@ -57,6 +60,7 @@
|
||||
"meta": {
|
||||
"spay_email": "",
|
||||
"wpop_description": "Two buttons, one filled and one outlined, side by side.",
|
||||
"wpop_keywords": "",
|
||||
"wpop_viewport_width": 500
|
||||
},
|
||||
"category_slugs": [ "buttons" ],
|
||||
|
||||
@@ -111,6 +111,9 @@ class WP_REST_Pattern_Directory_Controller_Test extends WP_Test_REST_Controller_
|
||||
$this->assertGreaterThan( 0, count( $patterns ) );
|
||||
|
||||
array_walk( $patterns, array( $this, 'assertPatternMatchesSchema' ) );
|
||||
$this->assertSame( array( 'blog post' ), $patterns[0]['keywords'] );
|
||||
$this->assertSame( array( 'header', 'hero' ), $patterns[1]['keywords'] );
|
||||
$this->assertSame( array( 'call to action', 'hero section' ), $patterns[2]['keywords'] );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -157,10 +160,6 @@ class WP_REST_Pattern_Directory_Controller_Test extends WP_Test_REST_Controller_
|
||||
$this->assertGreaterThan( 0, count( $patterns ) );
|
||||
|
||||
array_walk( $patterns, array( $this, 'assertPatternMatchesSchema' ) );
|
||||
|
||||
foreach ( $patterns as $pattern ) {
|
||||
$this->assertContains( 'core', $pattern['keywords'] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user