: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* Triggers an action used to switch editor mode.
* @param {string} mode The editor mode.
const switchEditorMode = mode => ({
registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'editorMode', mode);
// Unselect blocks when we switch to a non visual mode.
registry.dispatch(external_wp_blockEditor_namespaceObject.store).clearSelectedBlock();
(0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Visual editor selected'), 'assertive');
} else if (mode === 'text') {
const isDistractionFree = registry.select(external_wp_preferences_namespaceObject.store).get('core', 'distractionFree');
dispatch.toggleDistractionFree();
(0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Code editor selected'), 'assertive');
* Returns an action object used in signalling that the user opened the publish
* @return {Object} Action object
function openPublishSidebar() {
type: 'OPEN_PUBLISH_SIDEBAR'
* Returns an action object used in signalling that the user closed the
* @return {Object} Action object.
function closePublishSidebar() {
type: 'CLOSE_PUBLISH_SIDEBAR'
* Returns an action object used in signalling that the user toggles the publish sidebar.
* @return {Object} Action object
function togglePublishSidebar() {
type: 'TOGGLE_PUBLISH_SIDEBAR'
const getBlockEditorAction = name => (...args) => ({
external_wp_deprecated_default()("`wp.data.dispatch( 'core/editor' )." + name + '`', {
alternative: "`wp.data.dispatch( 'core/block-editor' )." + name + '`',
registry.dispatch(external_wp_blockEditor_namespaceObject.store)[name](...args);
* @see resetBlocks in core/block-editor store.
const resetBlocks = getBlockEditorAction('resetBlocks');
* @see receiveBlocks in core/block-editor store.
const receiveBlocks = getBlockEditorAction('receiveBlocks');
* @see updateBlock in core/block-editor store.
const updateBlock = getBlockEditorAction('updateBlock');
* @see updateBlockAttributes in core/block-editor store.
const updateBlockAttributes = getBlockEditorAction('updateBlockAttributes');
* @see selectBlock in core/block-editor store.
const selectBlock = getBlockEditorAction('selectBlock');
* @see startMultiSelect in core/block-editor store.
const startMultiSelect = getBlockEditorAction('startMultiSelect');
* @see stopMultiSelect in core/block-editor store.
const stopMultiSelect = getBlockEditorAction('stopMultiSelect');
* @see multiSelect in core/block-editor store.
const multiSelect = getBlockEditorAction('multiSelect');
* @see clearSelectedBlock in core/block-editor store.
const clearSelectedBlock = getBlockEditorAction('clearSelectedBlock');
* @see toggleSelection in core/block-editor store.
const toggleSelection = getBlockEditorAction('toggleSelection');
* @see replaceBlocks in core/block-editor store.
const replaceBlocks = getBlockEditorAction('replaceBlocks');
* @see replaceBlock in core/block-editor store.
const replaceBlock = getBlockEditorAction('replaceBlock');
* @see moveBlocksDown in core/block-editor store.
const moveBlocksDown = getBlockEditorAction('moveBlocksDown');
* @see moveBlocksUp in core/block-editor store.
const moveBlocksUp = getBlockEditorAction('moveBlocksUp');
* @see moveBlockToPosition in core/block-editor store.
const moveBlockToPosition = getBlockEditorAction('moveBlockToPosition');
* @see insertBlock in core/block-editor store.
const insertBlock = getBlockEditorAction('insertBlock');
* @see insertBlocks in core/block-editor store.
const insertBlocks = getBlockEditorAction('insertBlocks');
* @see showInsertionPoint in core/block-editor store.
const showInsertionPoint = getBlockEditorAction('showInsertionPoint');
* @see hideInsertionPoint in core/block-editor store.
const hideInsertionPoint = getBlockEditorAction('hideInsertionPoint');
* @see setTemplateValidity in core/block-editor store.
const setTemplateValidity = getBlockEditorAction('setTemplateValidity');
* @see synchronizeTemplate in core/block-editor store.
const synchronizeTemplate = getBlockEditorAction('synchronizeTemplate');
* @see mergeBlocks in core/block-editor store.
const mergeBlocks = getBlockEditorAction('mergeBlocks');
* @see removeBlocks in core/block-editor store.
const removeBlocks = getBlockEditorAction('removeBlocks');
* @see removeBlock in core/block-editor store.
const removeBlock = getBlockEditorAction('removeBlock');
* @see toggleBlockMode in core/block-editor store.
const toggleBlockMode = getBlockEditorAction('toggleBlockMode');
* @see startTyping in core/block-editor store.
const startTyping = getBlockEditorAction('startTyping');
* @see stopTyping in core/block-editor store.
const stopTyping = getBlockEditorAction('stopTyping');
* @see enterFormattedText in core/block-editor store.
const enterFormattedText = getBlockEditorAction('enterFormattedText');
* @see exitFormattedText in core/block-editor store.
const exitFormattedText = getBlockEditorAction('exitFormattedText');
* @see insertDefaultBlock in core/block-editor store.
const insertDefaultBlock = getBlockEditorAction('insertDefaultBlock');
* @see updateBlockListSettings in core/block-editor store.
const updateBlockListSettings = getBlockEditorAction('updateBlockListSettings');
;// CONCATENATED MODULE: external ["wp","htmlEntities"]
const external_wp_htmlEntities_namespaceObject = window["wp"]["htmlEntities"];
;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/store/utils/is-template-revertable.js
// Copy of the function from packages/edit-site/src/utils/is-template-revertable.js
* Check if a template or template part is revertable to its original theme-provided file.
* @param {Object} templateOrTemplatePart The entity to check.
* @return {boolean} Whether the entity is revertable.
function isTemplateRevertable(templateOrTemplatePart) {
if (!templateOrTemplatePart) {
return templateOrTemplatePart.source === TEMPLATE_ORIGINS.custom && templateOrTemplatePart.has_theme_file;
;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/store/private-actions.js
* Returns an action object used to set which template is currently being used/edited.
* @param {string} id Template Id.
* @return {Object} Action object.
function setCurrentTemplateId(id) {
type: 'SET_CURRENT_TEMPLATE_ID',
* Create a block based template.
* @param {Object?} template Template to create and assign.
const createTemplate = template => async ({
const savedTemplate = await registry.dispatch(external_wp_coreData_namespaceObject.store).saveEntityRecord('postType', 'wp_template', template);
registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', select.getCurrentPostType(), select.getCurrentPostId(), {
template: savedTemplate.slug
registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice((0,external_wp_i18n_namespaceObject.__)("Custom template created. You're in template mode now."), {
label: (0,external_wp_i18n_namespaceObject.__)('Go back'),
onClick: () => dispatch.setRenderingMode(select.getEditorSettings().defaultRenderingMode)
* Update the provided block types to be visible.
* @param {string[]} blockNames Names of block types to show.
const showBlockTypes = blockNames => ({
var _registry$select$get;
const existingBlockNames = (_registry$select$get = registry.select(external_wp_preferences_namespaceObject.store).get('core', 'hiddenBlockTypes')) !== null && _registry$select$get !== void 0 ? _registry$select$get : [];
const newBlockNames = existingBlockNames.filter(type => !(Array.isArray(blockNames) ? blockNames : [blockNames]).includes(type));
registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'hiddenBlockTypes', newBlockNames);
* Update the provided block types to be hidden.
* @param {string[]} blockNames Names of block types to hide.
const hideBlockTypes = blockNames => ({
var _registry$select$get2;
const existingBlockNames = (_registry$select$get2 = registry.select(external_wp_preferences_namespaceObject.store).get('core', 'hiddenBlockTypes')) !== null && _registry$select$get2 !== void 0 ? _registry$select$get2 : [];
const mergedBlockNames = new Set([...existingBlockNames, ...(Array.isArray(blockNames) ? blockNames : [blockNames])]);
registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'hiddenBlockTypes', [...mergedBlockNames]);
* Save entity records marked as dirty.
* @param {Object} options Options for the action.
* @param {Function} [options.onSave] Callback when saving happens.
* @param {object[]} [options.dirtyEntityRecords] Array of dirty entities.
* @param {object[]} [options.entitiesToSkip] Array of entities to skip saving.
* @param {Function} [options.close] Callback when the actions is called. It should be consolidated with `onSave`.
const saveDirtyEntities = ({
const PUBLISH_ON_SAVE_ENTITIES = [{
const saveNoticeId = 'site-editor-save-success';
const homeUrl = registry.select(external_wp_coreData_namespaceObject.store).getUnstableBase()?.home;
registry.dispatch(external_wp_notices_namespaceObject.store).removeNotice(saveNoticeId);
const entitiesToSave = dirtyEntityRecords.filter(({
return !entitiesToSkip.some(elt => elt.kind === kind && elt.name === name && elt.key === key && elt.property === property);
const siteItemsToSave = [];
const pendingSavedRecords = [];
entitiesToSave.forEach(({
if ('root' === kind && 'site' === name) {
siteItemsToSave.push(property);
if (PUBLISH_ON_SAVE_ENTITIES.some(typeToPublish => typeToPublish.kind === kind && typeToPublish.name === name)) {
registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord(kind, name, key, {
pendingSavedRecords.push(registry.dispatch(external_wp_coreData_namespaceObject.store).saveEditedEntityRecord(kind, name, key));
if (siteItemsToSave.length) {
pendingSavedRecords.push(registry.dispatch(external_wp_coreData_namespaceObject.store).__experimentalSaveSpecifiedEntityEdits('root', 'site', undefined, siteItemsToSave));
registry.dispatch(external_wp_blockEditor_namespaceObject.store).__unstableMarkLastChangeAsPersistent();
Promise.all(pendingSavedRecords).then(values => {
return onSave ? onSave(values) : values;
if (values.some(value => typeof value === 'undefined')) {
registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice((0,external_wp_i18n_namespaceObject.__)('Saving failed.'));
registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Site updated.'), {
label: (0,external_wp_i18n_namespaceObject.__)('View site'),
}).catch(error => registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(`${(0,external_wp_i18n_namespaceObject.__)('Saving failed.')} ${error}`));
* Reverts a template to its original theme-provided file.
* @param {Object} template The template to revert.
* @param {Object} [options]
* @param {boolean} [options.allowUndo] Whether to allow the user to undo
* reverting the template. Default true.
const revertTemplate = (template, {
const noticeId = 'edit-site-template-reverted';
registry.dispatch(external_wp_notices_namespaceObject.store).removeNotice(noticeId);
if (!isTemplateRevertable(template)) {
registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice((0,external_wp_i18n_namespaceObject.__)('This template is not revertable.'), {
const templateEntityConfig = registry.select(external_wp_coreData_namespaceObject.store).getEntityConfig('postType', template.type);
if (!templateEntityConfig) {
registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice((0,external_wp_i18n_namespaceObject.__)('The editor has encountered an unexpected error. Please reload.'), {
const fileTemplatePath = (0,external_wp_url_namespaceObject.addQueryArgs)(`${templateEntityConfig.baseURL}/${template.id}`, {
const fileTemplate = await external_wp_apiFetch_default()({
registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice((0,external_wp_i18n_namespaceObject.__)('The editor has encountered an unexpected error. Please reload.'), {
const serializeBlocks = ({
blocks: blocksForSerialization = []
}) => (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(blocksForSerialization);
const edited = registry.select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', template.type, template.id);
// We are fixing up the undo level here to make sure we can undo
// the revert in the header toolbar correctly.
registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', template.type, template.id, {
content: serializeBlocks,
// Required to make the `undo` behave correctly.
// Required to revert the blocks in the editor.
source: 'custom' // required to avoid turning the editor into a dirty state
undoIgnore: true // Required to merge this edit with the last undo level.
const blocks = (0,external_wp_blocks_namespaceObject.parse)(fileTemplate?.content?.raw);
registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', template.type, fileTemplate.id, {
content: serializeBlocks,
const undoRevert = () => {
registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', template.type, edited.id, {
content: serializeBlocks,
registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Template reset.'), {
label: (0,external_wp_i18n_namespaceObject.__)('Undo'),
const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('Template revert failed. Please reload.');
registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(errorMessage, {