Edit Site Edit

Namespace: core/edit-site.

Selectors

Top ↑

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.

Top ↑

getCurrentTemplateNavigationPanelSubMenu

Returns the current template or template part’s corresponding
navigation panel’s sub menu, to be used with openNavigationPanelToMenu.

Parameters

  • state Object: Global application state.

Returns

  • string: The current template or template part’s sub menu.

Top ↑

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.

Top ↑

getEditedPostId

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

Parameters

  • state Object: Global application state.

Returns

  • string?: Post ID.

Top ↑

getEditedPostType

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

Parameters

  • state Object: Global application state.

Returns

  • TemplateType?: Template type.

Top ↑

getEditorMode

Returns the current editing mode.

Parameters

  • state Object: Global application state.

Returns

  • string: Editing mode.

Top ↑

getHomeTemplateId

Returns the current home template ID.

Parameters

  • state Object: Global application state.

Returns

  • number?: Home template ID.

Top ↑

getNavigationPanelActiveMenu

Returns the active menu in the navigation panel.

Parameters

  • state Object: Global application state.

Returns

  • string: Active menu.

Top ↑

getPage

Returns the current page object.

Parameters

  • state Object: Global application state.

Returns

  • Object: Page.

Top ↑

getReusableBlocks

Returns any available Reusable blocks.

Parameters

  • state Object: Global application state.

Returns

  • Array: The available reusable blocks.

Top ↑

getSettings

Returns the settings, taking into account active features and permissions.

Parameters

  • state Object: Global application state.
  • setIsInserterOpen Function: Setter for the open state of the global inserter.

Returns

  • Object: Settings.

Top ↑

isFeatureActive

Returns whether the given feature is enabled or not.

Parameters

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

Returns

  • boolean: Is active.

Top ↑

isInserterOpened

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

Parameters

  • state Object: Global application state.

Returns

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

Top ↑

isListViewOpened

Returns the current opened/closed state of the list view panel.

Parameters

  • state Object: Global application state.

Returns

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

Top ↑

isNavigationOpened

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

Parameters

  • state Object: Global application state.

Returns

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

Top ↑

Actions

Top ↑

addTemplate

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.

Top ↑

closeGeneralSidebar

Action that closes the sidebar.

Top ↑

openGeneralSidebar

Action that opens an editor sidebar.

Parameters

  • name ?string: Sidebar name to be opened.

Top ↑

openNavigationPanelToMenu

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

Parameters

  • menu string: Identifies the menu to open.

Top ↑

removeTemplate

Action that removes a template.

Parameters

  • template Object: The template object.

Top ↑

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.

Top ↑

setHomeTemplateId

Action that sets the home template ID to the template ID of the page resolved
from a given path.

Parameters

  • homeTemplateId number: The template ID for the homepage.

Top ↑

setIsInserterOpened

Opens or closes the inserter.

Parameters

  • value boolean|Object: Whether the inserter should be opened (true) or closed (false). To specify an insertion point, use an object.
  • value.rootClientId string: The root client ID to insert at.
  • value.insertionIndex number: The index to insert at.

Returns

  • Object: Action object.

Top ↑

setIsListViewOpened

Sets whether the list view panel should be open.

Parameters

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

Top ↑

setIsNavigationPanelOpened

Sets whether the navigation panel should be open.

Parameters

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

Top ↑

setNavigationPanelActiveMenu

Action that sets the active navigation panel menu.

Parameters

  • menu string: Menu prop of active menu.

Returns

  • Object: Action object.

Top ↑

setPage

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 }.

Parameters

  • page Object: The page object.
  • page.type string: The page type.
  • page.slug string: The page slug.
  • page.path string: The page path.
  • page.context Object: The page context.

Returns

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

Top ↑

setTemplate

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

Parameters

  • templateId number: The template ID.
  • templateSlug string: The template slug.

Returns

  • Object: Action object.

Top ↑

setTemplatePart

Action that sets a template part.

Parameters

  • templatePartId string: The template part ID.

Returns

  • Object: Action object.

Top ↑

switchEditorMode

Undocumented declaration.

Top ↑

toggleFeature

Dispatches an action that toggles a feature flag.

Parameters

  • featureName string: Feature name.

Top ↑

updateSettings

Returns an action object used to update the settings.

Parameters

  • settings Object: New settings.

Returns

  • Object: Action object.