Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new hook to allow additional featured block #39816

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion packages/block-library/src/navigation-link/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 );
} );

Expand Down