: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* const { createSuccessNotice, createErrorNotice } =
* useDispatch( noticeStore );
* const setTitle = useCallback( ( title ) => {
* page.edit( { title } );
* if ( page.isResolving ) {
* async function onRename( event ) {
* event.preventDefault();
* createSuccessNotice( __( 'Page renamed.' ), {
* createErrorNotice( error.message, { type: 'snackbar' } );
* <form onSubmit={ onRename }>
* value={ page.editedRecord.title }
* <button type="submit">{ __( 'Save' ) }</button>
* // Rendered in the application:
* // <PageRenameForm id={ 1 } />
* In the above example, updating and saving the page title is handled
* via the `edit()` and `save()` mutation helpers provided by
* @return Entity record data.
function useEntityRecord(kind, name, recordId, options = {
} = (0,external_wp_data_namespaceObject.useDispatch)(store);
const mutations = (0,external_wp_element_namespaceObject.useMemo)(() => ({
edit: (record, editOptions = {}) => editEntityRecord(kind, name, recordId, record, editOptions),
save: (saveOptions = {}) => saveEditedEntityRecord(kind, name, recordId, {
}), [editEntityRecord, kind, name, recordId, saveEditedEntityRecord]);
} = (0,external_wp_data_namespaceObject.useSelect)(select => {
editedRecord: use_entity_record_EMPTY_OBJECT,
edits: use_entity_record_EMPTY_OBJECT
editedRecord: select(store).getEditedEntityRecord(kind, name, recordId),
hasEdits: select(store).hasEditsForEntityRecord(kind, name, recordId),
edits: select(store).getEntityRecordNonTransientEdits(kind, name, recordId)
}, [kind, name, recordId, options.enabled]);
} = useQuerySelect(query => {
return query(store).getEntityRecord(kind, name, recordId);
}, [kind, name, recordId, options.enabled]);
function __experimentalUseEntityRecord(kind, name, recordId, options) {
external_wp_deprecated_default()(`wp.data.__experimentalUseEntityRecord`, {
alternative: 'wp.data.useEntityRecord',
return useEntityRecord(kind, name, recordId, options);
;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/hooks/use-entity-records.js
const use_entity_records_EMPTY_ARRAY = [];
* Resolves the specified entity records.
* @since 6.1.0 Introduced in WordPress core.
* @param kind Kind of the entity, e.g. `root` or a `postType`. See rootEntitiesConfig in ../entities.ts for a list of available kinds.
* @param name Name of the entity, e.g. `plugin` or a `post`. See rootEntitiesConfig in ../entities.ts for a list of available names.
* @param queryArgs Optional HTTP query description for how to fetch the data, passed to the requested API endpoint.
* @param options Optional hook options.
* import { useEntityRecords } from '@wordpress/core-data';
* function PageTitlesList() {
* const { records, isResolving } = useEntityRecords( 'postType', 'page' );
* {records.map(( page ) => (
* <li>{ page.title }</li>
* // Rendered in the application:
* In the above example, when `PageTitlesList` is rendered into an
* application, the list of records and the resolution details will be retrieved from
* the store state using `getEntityRecords()`, or resolved if missing.
* @return Entity records data.
function useEntityRecords(kind, name, queryArgs = {}, options = {
// Serialize queryArgs to a string that can be safely used as a React dep.
// We can't just pass queryArgs as one of the deps, because if it is passed
// as an object literal, then it will be a different object on each call even
// if the values remain the same.
const queryAsString = (0,external_wp_url_namespaceObject.addQueryArgs)('', queryArgs);
} = useQuerySelect(query => {
// Avoiding returning a new reference on every execution.
data: use_entity_records_EMPTY_ARRAY
return query(store).getEntityRecords(kind, name, queryArgs);
}, [kind, name, queryAsString, options.enabled]);
} = (0,external_wp_data_namespaceObject.useSelect)(select => {
totalItems: select(store).getEntityRecordsTotalItems(kind, name, queryArgs),
totalPages: select(store).getEntityRecordsTotalPages(kind, name, queryArgs)
}, [kind, name, queryAsString, options.enabled]);
function __experimentalUseEntityRecords(kind, name, queryArgs, options) {
external_wp_deprecated_default()(`wp.data.__experimentalUseEntityRecords`, {
alternative: 'wp.data.useEntityRecords',
return useEntityRecords(kind, name, queryArgs, options);
;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/hooks/use-resource-permissions.js
* Is the data resolved by now?
* Resolves resource permissions.
* @since 6.1.0 Introduced in WordPress core.
* @param resource The resource in question, e.g. media.
* @param id ID of a specific resource entry, if needed, e.g. 10.
* import { useResourcePermissions } from '@wordpress/core-data';
* const { canCreate, isResolving } = useResourcePermissions( 'pages' );
* {canCreate ? (<button>+ Create a new page</button>) : false}
* // Rendered in the application:
* import { useResourcePermissions } from '@wordpress/core-data';
* function Page({ pageId }) {
* } = useResourcePermissions( 'pages', pageId );
* {canCreate ? (<button>+ Create a new page</button>) : false}
* {canUpdate ? (<button>Edit page</button>) : false}
* {canDelete ? (<button>Delete page</button>) : false}
* // Rendered in the application:
* // <Page pageId={ 15 } />
* In the above example, when `PagesList` is rendered into an
* application, the appropriate permissions and the resolution details will be retrieved from
* the store state using `canUser()`, or resolved if missing.
* @return Entity records data.
function useResourcePermissions(resource, id) {
return useQuerySelect(resolve => {
const create = canUser('create', resource);
const read = canUser('read', resource);
const isResolving = create.isResolving || read.isResolving;
const hasResolved = create.hasResolved && read.hasResolved;
let status = Status.Idle;
status = Status.Resolving;
} else if (hasResolved) {
canCreate: create.hasResolved && create.data,
canRead: read.hasResolved && read.data
const read = canUser('read', resource, id);
const update = canUser('update', resource, id);
const _delete = canUser('delete', resource, id);
const isResolving = read.isResolving || create.isResolving || update.isResolving || _delete.isResolving;
const hasResolved = read.hasResolved && create.hasResolved && update.hasResolved && _delete.hasResolved;
let status = Status.Idle;
status = Status.Resolving;
} else if (hasResolved) {
canRead: hasResolved && read.data,
canCreate: hasResolved && create.data,
canUpdate: hasResolved && update.data,
canDelete: hasResolved && _delete.data
function __experimentalUseResourcePermissions(resource, id) {
external_wp_deprecated_default()(`wp.data.__experimentalUseResourcePermissions`, {
alternative: 'wp.data.useResourcePermissions',
return useResourcePermissions(resource, id);
;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/hooks/index.js
;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/index.js
// The entity selectors/resolvers and actions are shortcuts to their generic equivalents
// (getEntityRecord, getEntityRecords, updateEntityRecord, updateEntityRecords)
// Instead of getEntityRecord, the consumer could use more user-friendly named selector: getPostType, getTaxonomy...
// The "kind" and the "name" of the entity are combined to generate these shortcuts.
const build_module_entitiesConfig = [...rootEntitiesConfig, ...additionalEntityConfigLoaders.filter(config => !!config.name)];
const entitySelectors = build_module_entitiesConfig.reduce((result, entity) => {
result[getMethodName(kind, name)] = (state, key, query) => getEntityRecord(state, kind, name, key, query);
result[getMethodName(kind, plural, 'get')] = (state, query) => getEntityRecords(state, kind, name, query);
const entityResolvers = build_module_entitiesConfig.reduce((result, entity) => {
result[getMethodName(kind, name)] = (key, query) => resolvers_getEntityRecord(kind, name, key, query);
const pluralMethodName = getMethodName(kind, plural, 'get');
result[pluralMethodName] = (...args) => resolvers_getEntityRecords(kind, name, ...args);
result[pluralMethodName].shouldInvalidate = action => resolvers_getEntityRecords.shouldInvalidate(action, kind, name);
const entityActions = build_module_entitiesConfig.reduce((result, entity) => {
result[getMethodName(kind, name, 'save')] = (record, options) => saveEntityRecord(kind, name, record, options);
result[getMethodName(kind, name, 'delete')] = (key, query, options) => deleteEntityRecord(kind, name, key, query, options);
const storeConfig = () => ({
reducer: build_module_reducer,
...build_module_actions_namespaceObject,
...build_module_selectors_namespaceObject,
...resolvers_namespaceObject,
* Store definition for the code data namespace.
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, storeConfig());
unlock(store).registerPrivateSelectors(private_selectors_namespaceObject);
(0,external_wp_data_namespaceObject.register)(store); // Register store after unlocking private selectors to allow resolvers to use them.
(window.wp = window.wp || {}).coreData = __webpack_exports__;