Make WordPress Core


Ignore:
Timestamp:
12/19/2024 01:24:22 PM (7 months ago)
Author:
Bernhard Reiter
Message:

Block Hooks: Apply to synced patterns.

Apply Block Hooks to synced patterns (i.e. core/block instances).

Props bernhard-reiter, gziolo.
Fixes #62704.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/blocks.php

    r59523 r59543  
    12201220    if ( 'wp_navigation' === $post->post_type ) {
    12211221        $wrapper_block_type = 'core/navigation';
     1222    } elseif ( 'wp_block' === $post->post_type ) {
     1223        $wrapper_block_type = 'core/block';
    12221224    } else {
    12231225        $wrapper_block_type = 'core/post-content';
     
    12921294 */
    12931295function insert_hooked_blocks_into_rest_response( $response, $post ) {
    1294     if ( empty( $response->data['content']['raw'] ) || empty( $response->data['content']['rendered'] ) ) {
     1296    if ( empty( $response->data['content']['raw'] ) ) {
    12951297        return $response;
    12961298    }
     
    13071309    if ( 'wp_navigation' === $post->post_type ) {
    13081310        $wrapper_block_type = 'core/navigation';
     1311    } elseif ( 'wp_block' === $post->post_type ) {
     1312        $wrapper_block_type = 'core/block';
    13091313    } else {
    13101314        $wrapper_block_type = 'core/post-content';
     
    13271331
    13281332    $response->data['content']['raw'] = $content;
     1333
     1334    // If the rendered content was previously empty, we leave it like that.
     1335    if ( empty( $response->data['content']['rendered'] ) ) {
     1336        return $response;
     1337    }
    13291338
    13301339    // `apply_block_hooks_to_content` is called above. Ensure it is not called again as a filter.
Note: See TracChangeset for help on using the changeset viewer.