: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
alternative: 'Use the core entities store instead'
* Action for trashing the current post in the editor.
const trashPost = () => async ({
const postTypeSlug = select.getCurrentPostType();
const postType = await registry.resolveSelect(external_wp_coreData_namespaceObject.store).getPostType(postTypeSlug);
registry.dispatch(external_wp_notices_namespaceObject.store).removeNotice(TRASH_POST_NOTICE_ID);
rest_namespace: restNamespace = 'wp/v2'
type: 'REQUEST_POST_DELETE_START'
const post = select.getCurrentPost();
await external_wp_apiFetch_default()({
path: `/${restNamespace}/${restBase}/${post.id}`,
await dispatch.savePost();
registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(...getNotificationArgumentsForTrashFail({
type: 'REQUEST_POST_DELETE_FINISH'
* Action that autosaves the current post. This
* includes server-side autosaving (default) and client-side (a.k.a. local)
* autosaving (e.g. on the Web, the post might be committed to Session
* @param {Object?} options Extra flags to identify the autosave.
const post = select.getCurrentPost();
// Currently template autosaving is not supported.
if (post.type === 'wp_template') {
const isPostNew = select.isEditedPostNew();
const title = select.getEditedPostAttribute('title');
const content = select.getEditedPostAttribute('content');
const excerpt = select.getEditedPostAttribute('excerpt');
localAutosaveSet(post.id, isPostNew, title, content, excerpt);
await dispatch.savePost({
const __unstableSaveForPreview = ({
if ((forceIsAutosaveable || select.isEditedPostAutosaveable()) && !select.isPostLocked()) {
const isDraft = ['draft', 'auto-draft'].includes(select.getEditedPostAttribute('status'));
await dispatch.savePost({
await dispatch.autosave({
return select.getEditedPostPreviewLink();
* Action that restores last popped state in undo history.
registry.dispatch(external_wp_coreData_namespaceObject.store).redo();
* Action that pops a record from undo history and undoes the edit.
registry.dispatch(external_wp_coreData_namespaceObject.store).undo();
* Action that creates an undo history record.
* @deprecated Since WordPress 6.0
function createUndoLevel() {
external_wp_deprecated_default()("wp.data.dispatch( 'core/editor' ).createUndoLevel", {
alternative: 'Use the core entities store instead'
* Action that locks the editor.
* @param {Object} lock Details about the post lock status, user, and nonce.
* @return {Object} Action object.
function updatePostLock(lock) {
type: 'UPDATE_POST_LOCK',
* Enable the publish sidebar.
const enablePublishSidebar = () => ({
registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'isPublishSidebarEnabled', true);
* Disables the publish sidebar.
const disablePublishSidebar = () => ({
registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'isPublishSidebarEnabled', false);
* Action that locks post saving.
* @param {string} lockName The lock name.
* const { subscribe } = wp.data;
* const initialPostStatus = wp.data.select( 'core/editor' ).getEditedPostAttribute( 'status' );
* // Only allow publishing posts that are set to a future date.
* if ( 'publish' !== initialPostStatus ) {
* // Watch for the publish event.
* let unssubscribe = subscribe( () => {
* const currentPostStatus = wp.data.select( 'core/editor' ).getEditedPostAttribute( 'status' );
* if ( 'publish' !== currentPostStatus ) {
* // Compare the post date to the current date, lock the post if the date isn't in the future.
* const postDate = new Date( wp.data.select( 'core/editor' ).getEditedPostAttribute( 'date' ) );
* const currentDate = new Date();
* if ( postDate.getTime() <= currentDate.getTime() ) {
* wp.data.dispatch( 'core/editor' ).lockPostSaving( 'futurelock' );
* wp.data.dispatch( 'core/editor' ).unlockPostSaving( 'futurelock' );
* @return {Object} Action object
function lockPostSaving(lockName) {
type: 'LOCK_POST_SAVING',
* Action that unlocks post saving.
* @param {string} lockName The lock name.
* // Unlock post saving with the lock key `mylock`:
* wp.data.dispatch( 'core/editor' ).unlockPostSaving( 'mylock' );
* @return {Object} Action object
function unlockPostSaving(lockName) {
type: 'UNLOCK_POST_SAVING',
* Action that locks post autosaving.
* @param {string} lockName The lock name.
* // Lock post autosaving with the lock key `mylock`:
* wp.data.dispatch( 'core/editor' ).lockPostAutosaving( 'mylock' );
* @return {Object} Action object
function lockPostAutosaving(lockName) {
type: 'LOCK_POST_AUTOSAVING',
* Action that unlocks post autosaving.
* @param {string} lockName The lock name.
* // Unlock post saving with the lock key `mylock`:
* wp.data.dispatch( 'core/editor' ).unlockPostAutosaving( 'mylock' );
* @return {Object} Action object
function unlockPostAutosaving(lockName) {
type: 'UNLOCK_POST_AUTOSAVING',
* Returns an action object used to signal that the blocks have been updated.
* @param {Array} blocks Block Array.
* @param {?Object} options Optional options.
const resetEditorBlocks = (blocks, options = {}) => ({
__unstableShouldCreateUndoLevel,
if (__unstableShouldCreateUndoLevel !== false) {
} = select.getCurrentPost();
const noChange = registry.select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', type, id).blocks === edits.blocks;
registry.dispatch(external_wp_coreData_namespaceObject.store).__unstableCreateUndoLevel('postType', type, id);
// We create a new function here on every persistent edit
// to make sure the edit makes the post dirty and creates
blocks: blocksForSerialization = []
}) => (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(blocksForSerialization);
dispatch.editPost(edits);
* Returns an action object used in signalling that the post editor settings have been updated.
* @param {Object} settings Updated settings
* @return {Object} Action object
function updateEditorSettings(settings) {
type: 'UPDATE_EDITOR_SETTINGS',
* Returns an action used to set the rendering mode of the post editor. We support multiple rendering modes:
* - `post-only`: This mode extracts the post blocks from the template and renders only those. The idea is to allow the user to edit the post/page in isolation without the wrapping template.
* - `template-locked`: This mode renders both the template and the post blocks but the template blocks are locked and can't be edited. The post blocks are editable.
* @param {string} mode Mode (one of 'post-only' or 'template-locked').
const setRenderingMode = mode => ({
if (select.__unstableIsEditorReady()) {
// We clear the block selection but we also need to clear the selection from the core store.
registry.dispatch(external_wp_blockEditor_namespaceObject.store).clearSelectedBlock();
type: 'SET_RENDERING_MODE',
* Action that changes the width of the editing canvas.
* @param {string} deviceType
* @return {Object} Action object.
function setDeviceType(deviceType) {
* Returns an action object used to enable or disable a panel in the editor.
* @param {string} panelName A string that identifies the panel to enable or disable.
* @return {Object} Action object.
const toggleEditorPanelEnabled = panelName => ({
var _registry$select$get;
const inactivePanels = (_registry$select$get = registry.select(external_wp_preferences_namespaceObject.store).get('core', 'inactivePanels')) !== null && _registry$select$get !== void 0 ? _registry$select$get : [];
const isPanelInactive = !!inactivePanels?.includes(panelName);
// If the panel is inactive, remove it to enable it, else add it to
let updatedInactivePanels;
updatedInactivePanels = inactivePanels.filter(invactivePanelName => invactivePanelName !== panelName);
updatedInactivePanels = [...inactivePanels, panelName];
registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'inactivePanels', updatedInactivePanels);
* Opens a closed panel and closes an open panel.
* @param {string} panelName A string that identifies the panel to open or close.
const toggleEditorPanelOpened = panelName => ({
var _registry$select$get2;
const openPanels = (_registry$select$get2 = registry.select(external_wp_preferences_namespaceObject.store).get('core', 'openPanels')) !== null && _registry$select$get2 !== void 0 ? _registry$select$get2 : [];
const isPanelOpen = !!openPanels?.includes(panelName);
// If the panel is open, remove it to close it, else add it to
updatedOpenPanels = openPanels.filter(openPanelName => openPanelName !== panelName);
updatedOpenPanels = [...openPanels, panelName];
registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'openPanels', updatedOpenPanels);
* Returns an action object used to remove a panel from the editor.
* @param {string} panelName A string that identifies the panel to remove.
* @return {Object} Action object.
function removeEditorPanel(panelName) {
* Returns an action object used to open/close the inserter.
* @param {boolean|Object} value Whether the inserter should be
* opened (true) or closed (false).
* To specify an insertion point,
* @param {string} value.rootClientId The root client ID to insert at.
* @param {number} value.insertionIndex The index to insert at.
* @return {Object} Action object.
function setIsInserterOpened(value) {
type: 'SET_IS_INSERTER_OPENED',
* Returns an action object used to open/close the list view.
* @param {boolean} isOpen A boolean representing whether the list view should be opened or closed.
* @return {Object} Action object.
function setIsListViewOpened(isOpen) {
type: 'SET_IS_LIST_VIEW_OPENED',
* Action that toggles Distraction free mode.
* Distraction free mode expects there are no sidebars, as due to the
* z-index values set, you can't close sidebars.
const toggleDistractionFree = () => ({
const isDistractionFree = registry.select(external_wp_preferences_namespaceObject.store).get('core', 'distractionFree');
registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'fixedToolbar', false);
if (!isDistractionFree) {
registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'fixedToolbar', true);
dispatch.setIsInserterOpened(false);
dispatch.setIsListViewOpened(false);
registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'distractionFree', !isDistractionFree);
registry.dispatch(external_wp_notices_namespaceObject.store).createInfoNotice(isDistractionFree ? (0,external_wp_i18n_namespaceObject.__)('Distraction free off.') : (0,external_wp_i18n_namespaceObject.__)('Distraction free on.'), {
id: 'core/editor/distraction-free-mode/notice',
label: (0,external_wp_i18n_namespaceObject.__)('Undo'),
registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'fixedToolbar', isDistractionFree ? true : false);
registry.dispatch(external_wp_preferences_namespaceObject.store).toggle('core', 'distractionFree');