From 51abd57b61bec346614894770f74d149656b6b1d Mon Sep 17 00:00:00 2001 From: Adam Zielinski Date: Mon, 13 Dec 2021 01:36:23 +0100 Subject: [PATCH] Add/navigation blocks post processing after migration from menu items (#36950) * add navigation.menuItemsToBlocks filter to postprocess blocks created from menu items * Add navigation_after_parse_blocks_from_menu_items filter * Make the filter experimental * Lint * Update menu-items-to-blocks.js --- .../block-library/src/navigation/menu-items-to-blocks.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/block-library/src/navigation/menu-items-to-blocks.js b/packages/block-library/src/navigation/menu-items-to-blocks.js index 3d9fa193b803e..9362f290a572c 100644 --- a/packages/block-library/src/navigation/menu-items-to-blocks.js +++ b/packages/block-library/src/navigation/menu-items-to-blocks.js @@ -7,6 +7,7 @@ import { sortBy } from 'lodash'; * WordPress dependencies */ import { createBlock, parse } from '@wordpress/blocks'; +import { applyFilters } from '@wordpress/hooks'; /** * Convert a flat menu item structure to a nested blocks structure. @@ -21,7 +22,12 @@ export default function menuItemsToBlocks( menuItems ) { } const menuTree = createDataTree( menuItems ); - return mapMenuItemsToBlocks( menuTree ); + const blocks = mapMenuItemsToBlocks( menuTree ); + return applyFilters( + 'blocks.navigation.__unstableMenuItemsToBlocks', + blocks, + menuItems + ); } /**