Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #59783, comment 2


Ignore:
Timestamp:
11/02/2023 08:15:20 AM (3 years ago)
Author:
Bernhard Reiter

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #59783, comment 2

    initial v1  
    33Much like the latter, `traverse_and_serialize_blocks()` takes a data structure (in our case, a block tree), traverses it, and applies a callback to each element it finds.
    44
    5 Granted, `traverse_and_serialize_blocks()` is somewhat more domain-specific at it is traversing a tree of ''blocks'' rather than a more generic data structure; but within the domain of blocks and block trees, its applications are arguably comparably wide-ranging as `array_map()` is for arrays.
     5Granted, `traverse_and_serialize_blocks()` is somewhat more domain-specific as it is traversing a tree of ''blocks'' rather than a more generic data structure; but within the domain of blocks and block trees, its applications are arguably comparably wide-ranging as `array_map()` is for arrays.
    66
    77For a generic traversal tool like that, filters didn't seem like the right fit, much like one wouldn't want to add a filter before invoking `array_map` instead of passing a callback to it (and remembering to remove the filter afterwards!) While it's really only used inside of Core for now, it's conceivable that `traverse_and_serialize_blocks()` could be of some use to extenders.