Skip to content

Commit

Permalink
Inject theme attr in patterns controller
Browse files Browse the repository at this point in the history
  • Loading branch information
ockham committed Oct 17, 2023
1 parent 3be438b commit 0da6e01
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public function get_items( $request ) {
$patterns = WP_Block_Patterns_Registry::get_instance()->get_all_registered();
foreach ( $patterns as $pattern ) {
$migrated_pattern = $this->migrate_pattern_categories( $pattern );
$prepared_pattern = $this->prepare_pattern_content( $pattern );
$prepared_pattern = $this->prepare_item_for_response( $migrated_pattern, $request );
$response[] = $this->prepare_response_for_collection( $prepared_pattern );
}
Expand Down Expand Up @@ -151,6 +152,11 @@ protected function migrate_pattern_categories( $pattern ) {
return $pattern;
}

protected function prepare_pattern_content( $pattern ) {
$blocks = parse_blocks( $pattern['content'] );
$pattern['content'] = traverse_and_serialize_blocks( $blocks, '_inject_theme_attribute_in_template_part_block' );
}

/**
* Prepare a raw block pattern before it gets output in a REST API response.
*
Expand Down

0 comments on commit 0da6e01

Please sign in to comment.