From 4bd57b1b3283dc594e3f22c72beef16fb5d9d2d7 Mon Sep 17 00:00:00 2001 From: Hug0-Drelon Date: Mon, 28 Mar 2022 11:49:31 +0200 Subject: [PATCH] add new hook to allow additional featured block --- packages/block-library/src/navigation-link/edit.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/block-library/src/navigation-link/edit.js b/packages/block-library/src/navigation-link/edit.js index 43cab0244b9406..ef513f731f2a0c 100644 --- a/packages/block-library/src/navigation-link/edit.js +++ b/packages/block-library/src/navigation-link/edit.js @@ -43,6 +43,7 @@ import { import { placeCaretAtHorizontalEdge } from '@wordpress/dom'; import { link as linkIcon, addSubmenu } from '@wordpress/icons'; import { store as coreStore } from '@wordpress/core-data'; +import { applyFilters } from '@wordpress/hooks'; /** * Internal dependencies @@ -507,12 +508,21 @@ export default function NavigationLinkEdit( { replaceBlock( clientId, newSubmenu ); } - const featuredBlocks = [ + const defaultFeaturedBlocks = [ 'core/site-logo', 'core/social-links', 'core/search', ]; const featuredTransforms = blockTransforms.filter( ( item ) => { + /** + * Filters the featured blocks in the transform control panel. + * + * @param {Array} defaultFeaturedBlocks The default blocks to display. + */ + const featuredBlocks = applyFilters( + 'allow_additional_featured_block_in_navigation', + defaultFeaturedBlocks + ); return featuredBlocks.includes( item.name ); } );