summaryrefslogtreecommitdiffstats
path: root/wp-includes/rest-api/endpoints/class-wp-rest-block-patterns-controller.php
diff options
context:
space:
mode:
Diffstat (limited to 'wp-includes/rest-api/endpoints/class-wp-rest-block-patterns-controller.php')
-rw-r--r--wp-includes/rest-api/endpoints/class-wp-rest-block-patterns-controller.php6
1 files changed, 6 insertions, 0 deletions
diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-block-patterns-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-block-patterns-controller.php
index d8f0839..065b863 100644
--- a/wp-includes/rest-api/endpoints/class-wp-rest-block-patterns-controller.php
+++ b/wp-includes/rest-api/endpoints/class-wp-rest-block-patterns-controller.php
@@ -162,6 +162,12 @@ class WP_REST_Block_Patterns_Controller extends WP_REST_Controller {
* @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure.
*/
public function prepare_item_for_response( $item, $request ) {
+ // Resolve pattern blocks so they don't need to be resolved client-side
+ // in the editor, improving performance.
+ $blocks = parse_blocks( $item['content'] );
+ $blocks = resolve_pattern_blocks( $blocks );
+ $item['content'] = serialize_blocks( $blocks );
+
$fields = $this->get_fields_for_response( $request );
$keys = array(
'name' => 'name',