Make WordPress Core


Ignore:
Timestamp:
09/19/2023 12:48:41 PM (20 months ago)
Author:
gziolo
Message:

Blocks: Introduce a variation of serialize blocks helper with traversing

Introduces two new functions traverse_and_serialize_blocks and traverse_and_serialize_block with the additional $callback argument. It is possible to pass parent block, block index, chunk index to the callback argument.

Reverts changes applied to serialize_blocks and serialize_block in #59327 with [56557].

Props ockham, mukesh27.
See #59313.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/block-template-utils.php

    r56578 r56620  
    610610
    611611    $blocks            = parse_blocks( $template_content );
    612     $template->content = serialize_blocks( $blocks, '_inject_theme_attribute_in_template_part_block' );
     612    $template->content = traverse_and_serialize_blocks( $blocks, '_inject_theme_attribute_in_template_part_block' );
    613613
    614614    return $template;
Note: See TracChangeset for help on using the changeset viewer.