Edit Site

Namespace: core/edit-site.

Selectors

getCanUserCreateMedia

Returns whether the current user can create media or not.

Parameters

  • state Object: Global application state.

Returns

  • Object: Whether the current user can create media or not.

getCurrentTemplateNavigationPanelSubMenu

Deprecated

getCurrentTemplateTemplateParts

Returns the template parts and their blocks for the current edited template.

Parameters

  • state Object: Global application state.

Returns

  • Array: Template parts and their blocks in an array.

getEditedPostContext

Deprecated

Returns the edited post’s context object.

Parameters

  • state Object: Global application state.

Returns

  • Object: Page.

getEditedPostId

Returns the ID of the currently edited template or template part.

Parameters

  • state Object: Global application state.

Returns

  • string?: Post ID.

getEditedPostType

Returns the current edited post type (wp_template or wp_template_part).

Parameters

  • state Object: Global application state.

Returns

  • TemplateType?: Template type.

getEditorMode

Returns the current editing mode.

Parameters

  • state Object: Global application state.

Returns

  • string: Editing mode.

getHomeTemplateId

Deprecated

getNavigationPanelActiveMenu

Deprecated

getPage

Deprecated

Returns the current page object.

Parameters

  • state Object: Global application state.

Returns

  • Object: Page.

getReusableBlocks

Returns any available Reusable blocks.

Parameters

  • state Object: Global application state.

Returns

  • Array: The available reusable blocks.

getSettings

Returns the site editor settings.

Parameters

  • state Object: Global application state.

Returns

  • Object: Settings.

hasPageContentFocus

Deprecated

Whether or not the editor allows only page content to be edited.

Returns

  • boolean: Whether or not focus is on editing page content.

isFeatureActive

Deprecated

Returns whether the given feature is enabled or not.

Parameters

  • state Object: Global application state.
  • featureName string: Feature slug.

Returns

  • boolean: Is active.

isInserterOpened

Deprecated

Returns true if the inserter is opened.

Parameters

  • state Object: Global application state.

Returns

  • boolean: Whether the inserter is opened.

isListViewOpened

Returns true if the list view is opened.

Parameters

  • state Object: Global application state.

Returns

  • boolean: Whether the list view is opened.

isNavigationOpened

Deprecated

isPage

Whether or not the editor has a page loaded into it.

Related

  • setPage

Parameters

  • state Object: Global application state.

Returns

  • boolean: Whether or not the editor has a page loaded into it.

isSaveViewOpened

Returns the current opened/closed state of the save panel.

Parameters

  • state Object: Global application state.

Returns

  • boolean: True if the save panel should be open; false if closed.

Actions

addTemplate

Deprecated

Action that adds a new template and sets it as the current template.

Parameters

  • template Object: The template.

Returns

  • Object: Action object used to set the current template.

closeGeneralSidebar

Action that closes the sidebar.

openGeneralSidebar

Action that opens an editor sidebar.

Parameters

  • name ?string: Sidebar name to be opened.

openNavigationPanelToMenu

Deprecated

Opens the navigation panel and sets its active menu at the same time.

removeTemplate

Action that removes a template.

Parameters

  • template Object: The template object.

revertTemplate

Reverts a template to its original theme-provided file.

Parameters

  • template Object: The template to revert.
  • options [Object]:
  • options.allowUndo [boolean]: Whether to allow the user to undo reverting the template. Default true.

setEditedEntity

Action that sets an edited entity.

Parameters

  • postType string: The entity’s post type.
  • postId string: The entity’s ID.
  • context Object: The entity’s context.

Returns

  • Object: Action object.

setEditedPostContext

Set’s the current block editor context.

Parameters

  • context Object: The context object.

Returns

  • Object: Action object.

setHasPageContentFocus

Sets whether or not the editor allows only page content to be edited.

Parameters

  • hasPageContentFocus boolean: True to allow only page content to be edited, false to allow template to be edited.

setHomeTemplateId

Deprecated

setIsInserterOpened

Deprecated

Returns an action object used to open/close the inserter.

Parameters

  • value boolean|Object: Whether the inserter should be opened (true) or closed (false).

setIsListViewOpened

Deprecated

Returns an action object used to open/close the list view.

Parameters

  • isOpen boolean: A boolean representing whether the list view should be opened or closed.

setIsNavigationPanelOpened

Deprecated

Sets whether the navigation panel should be open.

setIsSaveViewOpened

Sets whether the save view panel should be open.

Parameters

  • isOpen boolean: If true, opens the save view. If false, closes it. It does not toggle the state, but sets it directly.

setNavigationMenu

Action that sets a navigation menu.

Parameters

  • navigationMenuId string: The Navigation Menu Post ID.

Returns

  • Object: Action object.

setNavigationPanelActiveMenu

Deprecated

Action that sets the active navigation panel menu.

Returns

  • Object: Action object.

setPage

Deprecated

Resolves the template for a page and displays both. If no path is given, attempts to use the postId to generate a path like ?p=${ postId }.

Returns

  • number: The resolved template ID for the page route.

setTemplate

Action that sets a template, optionally fetching it from REST API.

Returns

  • Object: Action object.

setTemplatePart

Action that sets a template part.

Parameters

  • templatePartId string: The template part ID.

Returns

  • Object: Action object.

switchEditorMode

Deprecated

Triggers an action used to switch editor mode.

Parameters

  • mode string: The editor mode.

toggleDistractionFree

Deprecated

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.

toggleFeature

Dispatches an action that toggles a feature flag.

Parameters

  • featureName string: Feature name.

updateSettings

Returns an action object used to update the settings.

Parameters

  • settings Object: New settings.

Returns

  • Object: Action object.