: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
const variations = selectors_getBlockVariations(state, blockName, scope);
const defaultVariation = [...variations].reverse().find(({
return defaultVariation || variations[0];
* Returns all the available block categories.
* @param {Object} state Data state.
* import { store as blocksStore } from '@wordpress/blocks';
* import { useSelect, } from '@wordpress/data';
* const ExampleComponent = () => {
* const blockCategories = useSelect( ( select ) =>
* select( blocksStore ).getCategories(),
* { blockCategories.map( ( category ) => (
* <li key={ category.slug }>{ category.title }</li>
* @return {WPBlockCategory[]} Categories list.
function getCategories(state) {
* Returns all the available collections.
* @param {Object} state Data state.
* import { store as blocksStore } from '@wordpress/blocks';
* import { useSelect } from '@wordpress/data';
* const ExampleComponent = () => {
* const blockCollections = useSelect( ( select ) =>
* select( blocksStore ).getCollections(),
* { Object.values( blockCollections ).length > 0 &&
* Object.values( blockCollections ).map( ( collection ) => (
* <li key={ collection.title }>{ collection.title }</li>
* @return {Object} Collections list.
function getCollections(state) {
return state.collections;
* Returns the name of the default block name.
* @param {Object} state Data state.
* import { __, sprintf } from '@wordpress/i18n';
* import { store as blocksStore } from '@wordpress/blocks';
* import { useSelect } from '@wordpress/data';
* const ExampleComponent = () => {
* const defaultBlockName = useSelect( ( select ) =>
* select( blocksStore ).getDefaultBlockName(),
* { sprintf( __( 'Default block name: %s' ), defaultBlockName ) }
* @return {string?} Default block name.
function selectors_getDefaultBlockName(state) {
return state.defaultBlockName;
* Returns the name of the block for handling non-block content.
* @param {Object} state Data state.
* import { __, sprintf } from '@wordpress/i18n';
* import { store as blocksStore } from '@wordpress/blocks';
* import { useSelect } from '@wordpress/data';
* const ExampleComponent = () => {
* const freeformFallbackBlockName = useSelect( ( select ) =>
* select( blocksStore ).getFreeformFallbackBlockName(),
* freeformFallbackBlockName && (
* 'Freeform fallback block name: %s' ),
* freeformFallbackBlockName
* @return {string?} Name of the block for handling non-block content.
function getFreeformFallbackBlockName(state) {
return state.freeformFallbackBlockName;
* Returns the name of the block for handling unregistered blocks.
* @param {Object} state Data state.
* import { __, sprintf } from '@wordpress/i18n';
* import { store as blocksStore } from '@wordpress/blocks';
* import { useSelect } from '@wordpress/data';
* const ExampleComponent = () => {
* const unregisteredFallbackBlockName = useSelect( ( select ) =>
* select( blocksStore ).getUnregisteredFallbackBlockName(),
* unregisteredFallbackBlockName && (
* 'Unregistered fallback block name: %s' ),
* unregisteredFallbackBlockName
* @return {string?} Name of the block for handling unregistered blocks.
function getUnregisteredFallbackBlockName(state) {
return state.unregisteredFallbackBlockName;
* Returns the name of the block for handling the grouping of blocks.
* @param {Object} state Data state.
* import { __, sprintf } from '@wordpress/i18n';
* import { store as blocksStore } from '@wordpress/blocks';
* import { useSelect } from '@wordpress/data';
* const ExampleComponent = () => {
* const groupingBlockName = useSelect( ( select ) =>
* select( blocksStore ).getGroupingBlockName(),
* __( 'Default grouping block name: %s' ),
* @return {string?} Name of the block for handling the grouping of blocks.
function selectors_getGroupingBlockName(state) {
return state.groupingBlockName;
* Returns an array with the child blocks of a given block.
* @param {Object} state Data state.
* @param {string} blockName Block type name.
* import { store as blocksStore } from '@wordpress/blocks';
* import { useSelect } from '@wordpress/data';
* const ExampleComponent = () => {
* const childBlockNames = useSelect( ( select ) =>
* select( blocksStore ).getChildBlockNames( 'core/navigation' ),
* childBlockNames.map( ( child ) => (
* <li key={ child }>{ child }</li>
* @return {Array} Array of child block names.
const selectors_getChildBlockNames = (0,external_wp_data_namespaceObject.createSelector)((state, blockName) => {
return selectors_getBlockTypes(state).filter(blockType => {
return blockType.parent?.includes(blockName);
}, state => [state.blockTypes]);
* Returns the block support value for a feature, if defined.
* @param {Object} state Data state.
* @param {(string|Object)} nameOrType Block name or type object
* @param {Array|string} feature Feature to retrieve
* @param {*} defaultSupports Default value to return if not
* import { __, sprintf } from '@wordpress/i18n';
* import { store as blocksStore } from '@wordpress/blocks';
* import { useSelect } from '@wordpress/data';
* const ExampleComponent = () => {
* const paragraphBlockSupportValue = useSelect( ( select ) =>
* select( blocksStore ).getBlockSupport( 'core/paragraph', 'anchor' ),
* __( 'core/paragraph supports.anchor value: %s' ),
* paragraphBlockSupportValue
* @return {?*} Block support value
const selectors_getBlockSupport = (state, nameOrType, feature, defaultSupports) => {
const blockType = getNormalizedBlockType(state, nameOrType);
if (!blockType?.supports) {
return getValueFromObjectPath(blockType.supports, feature, defaultSupports);
* Returns true if the block defines support for a feature, or false otherwise.
* @param {Object} state Data state.
* @param {(string|Object)} nameOrType Block name or type object.
* @param {string} feature Feature to test.
* @param {boolean} defaultSupports Whether feature is supported by
* default if not explicitly defined.
* import { __, sprintf } from '@wordpress/i18n';
* import { store as blocksStore } from '@wordpress/blocks';
* import { useSelect } from '@wordpress/data';
* const ExampleComponent = () => {
* const paragraphBlockSupportClassName = useSelect( ( select ) =>
* select( blocksStore ).hasBlockSupport( 'core/paragraph', 'className' ),
* __( 'core/paragraph supports custom class name?: %s' ),
* paragraphBlockSupportClassName
* @return {boolean} Whether block supports feature.
function selectors_hasBlockSupport(state, nameOrType, feature, defaultSupports) {
return !!selectors_getBlockSupport(state, nameOrType, feature, defaultSupports);
* Normalizes a search term string: removes accents, converts to lowercase, removes extra whitespace.
* @param {string|null|undefined} term Search term to normalize.
* @return {string} Normalized search term.
function getNormalizedSearchTerm(term) {
return remove_accents_default()(term !== null && term !== void 0 ? term : '').toLowerCase().trim();
* Returns true if the block type by the given name or object value matches a
* search term, or false otherwise.
* @param {Object} state Blocks state.
* @param {(string|Object)} nameOrType Block name or type object.
* @param {string} searchTerm Search term by which to filter.
* import { __, sprintf } from '@wordpress/i18n';
* import { store as blocksStore } from '@wordpress/blocks';
* import { useSelect } from '@wordpress/data';
* const ExampleComponent = () => {
* const termFound = useSelect(
* select( blocksStore ).isMatchingSearchTerm(
* 'Search term was found in the title, keywords, category or description in block.json: %s'
* @return {Object[]} Whether block type matches search term.
function isMatchingSearchTerm(state, nameOrType, searchTerm = '') {
const blockType = getNormalizedBlockType(state, nameOrType);
const normalizedSearchTerm = getNormalizedSearchTerm(searchTerm);
const isSearchMatch = candidate => getNormalizedSearchTerm(candidate).includes(normalizedSearchTerm);
return isSearchMatch(blockType.title) || blockType.keywords?.some(isSearchMatch) || isSearchMatch(blockType.category) || typeof blockType.description === 'string' && isSearchMatch(blockType.description);
* Returns a boolean indicating if a block has child blocks or not.
* @param {Object} state Data state.
* @param {string} blockName Block type name.
* import { __, sprintf } from '@wordpress/i18n';
* import { store as blocksStore } from '@wordpress/blocks';
* import { useSelect } from '@wordpress/data';
* const ExampleComponent = () => {
* const navigationBlockHasChildBlocks = useSelect( ( select ) =>
* select( blocksStore ).hasChildBlocks( 'core/navigation' ),
* __( 'core/navigation has child blocks: %s' ),
* navigationBlockHasChildBlocks
* @return {boolean} True if a block contains child blocks and false otherwise.
const selectors_hasChildBlocks = (state, blockName) => {
return selectors_getChildBlockNames(state, blockName).length > 0;
* Returns a boolean indicating if a block has at least one child block with inserter support.
* @param {Object} state Data state.
* @param {string} blockName Block type name.
* import { __, sprintf } from '@wordpress/i18n';
* import { store as blocksStore } from '@wordpress/blocks';
* import { useSelect } from '@wordpress/data';
* const ExampleComponent = () => {
* const navigationBlockHasChildBlocksWithInserterSupport = useSelect( ( select ) =>
* select( blocksStore ).hasChildBlocksWithInserterSupport(
* __( 'core/navigation has child blocks with inserter support: %s' ),
* navigationBlockHasChildBlocksWithInserterSupport
* @return {boolean} True if a block contains at least one child blocks with inserter support
const selectors_hasChildBlocksWithInserterSupport = (state, blockName) => {
return selectors_getChildBlockNames(state, blockName).some(childBlockName => {
return selectors_hasBlockSupport(state, childBlockName, 'inserter', true);
* DO-NOT-USE in production.
* This selector is created for internal/experimental only usage and may be
* removed anytime without any warning, causing breakage on any plugin or theme invoking it.
const __experimentalHasContentRoleAttribute = (0,external_wp_data_namespaceObject.createSelector)((state, blockTypeName) => {
const blockType = selectors_getBlockType(state, blockTypeName);
return Object.entries(blockType.attributes).some(([, {
}]) => __experimentalRole === 'content');
}, (state, blockTypeName) => [state.blockTypes[blockTypeName]?.attributes]);
;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/private-selectors.js
const ROOT_BLOCK_SUPPORTS = ['background', 'backgroundColor', 'color', 'linkColor', 'captionColor', 'buttonColor', 'headingColor', 'fontFamily', 'fontSize', 'fontStyle', 'fontWeight', 'lineHeight', 'padding', 'contentSize', 'wideSize', 'blockGap', 'textDecoration', 'textTransform', 'letterSpacing'];
* Filters the list of supported styles for a given element.
* @param {string[]} blockSupports list of supported styles.
* @param {string|undefined} name block name.
* @param {string|undefined} element element name.
* @return {string[]} filtered list of supported styles.