本文档介绍了 WordPress 核心编辑器的用户界面数据管理,包括选择器和动作,用于控制编辑器状态、侧边栏、元框、面板等功能。
getActiveGeneralSidebarName 返回活动侧边栏名称,getEditorMode 返回编辑模式。openGeneralSidebar 打开侧边栏,toggleFeature 切换功能标志。initializeMetaBoxes 和 isMetaBoxLocationActive。core/interface 存储替代,如 isModalActive 和 closeModal。hideBlockTypes 和 showBlockTypes。isModalActive、closeModal)自 WordPress 6.3 起已弃用,应改用 core/interface 存储中的对应功能。state 参数,表示全局或编辑器状态,需正确传递以确保功能正常。areMetaBoxesInitialized 检查元框是否已初始化,避免重复操作。Namespace: core/edit-post.
Returns true if meta boxes are initialized.
Parameters
Object: Global application state.Returns
boolean: Whether meta boxes are initialized.Returns the current active general sidebar name, or null if there is no general sidebar active. The active general sidebar is a unique name to identify either an editor or plugin sidebar.
Examples:
edit-post/documentmy-plugin/insert-image-sidebarParameters
Object: Global application state.Returns
?string: Active general sidebar name.Returns an array of active meta box locations.
Parameters
Object: Post editor state.Returns
string[]: Active meta box locations.Returns the list of all the available meta boxes.
Parameters
Object: Global application state.Returns
Array: List of meta boxes.Retrieves the template of the currently edited post.
Returns
?Object: Post Template.Returns the current editing mode.
Parameters
Object: Global application state.Returns
string: Editing mode.Returns an array of blocks that are hidden.
Returns
Array: A list of the hidden block typesReturns the list of all the available meta boxes for a given location.
Parameters
Object: Global application state.string: Meta box location to test.Returns
?Array: List of meta boxes.Parameters
Object: Global application state.string: Preference Key.*: Default Value.Returns
*: Preference Value.Returns the preferences (these preferences are persisted locally).
Parameters
Object: Global application state.Returns
Object: Preferences Object.Returns true if the post is using Meta Boxes
Parameters
Object: Global application stateReturns
boolean: Whether there are metaboxes or not.Deprecated
Returns true if the template editing mode is enabled.
Deprecated
Returns true if the given panel is enabled, or false otherwise. Panels are enabled by default.
Parameters
Object: Global application state.string: A string that identifies the panel.Returns
boolean: Whether or not the panel is enabled.Deprecated
Returns true if the given panel is open, or false otherwise. Panels are closed by default.
Parameters
Object: Global application state.string: A string that identifies the panel.Returns
boolean: Whether or not the panel is open.Deprecated
Returns true if the given panel was programmatically removed, or false otherwise. All panels are not removed by default.
Parameters
Object: Global application state.string: A string that identifies the panel.Returns
boolean: Whether or not the panel is removed.Returns true if the editor sidebar is opened.
Parameters
Object: Global application stateReturns
boolean: Whether the editor sidebar is opened.Returns whether the given feature is enabled or not.
Parameters
Object: Global application state.string: Feature slug.Returns
boolean: Is active.Deprecated
Returns true if the inserter is opened.
Parameters
Object: Global application state.Returns
boolean: Whether the inserter is opened.Returns true if the list view is opened.
Parameters
Object: Global application state.Returns
boolean: Whether the list view is opened.Returns true if there is an active meta box in the given location, or false otherwise.
Parameters
Object: Post editor state.string: Meta box location to test.Returns
boolean: Whether the meta box location is active.Returns true if a metabox location is active and visible
Parameters
Object: Post editor state.string: Meta box location to test.Returns
boolean: Whether the meta box location is active and visible.Deprecated since WP 6.3 use
core/interfacestore’s selector with the same name instead.
Returns true if a modal is active, or false otherwise.
Parameters
Object: Global application state.string: A string that uniquely identifies the modal.Returns
boolean: Whether the modal is active.Returns true if the plugin item is pinned to the header. When the value is not set it defaults to true.
Parameters
Object: Global application state.string: Plugin item name.Returns
boolean: Whether the plugin item is pinned.Returns true if the plugin sidebar is opened.
Parameters
Object: Global application state.Returns
boolean: Whether the plugin sidebar is opened.Deprecated
Returns true if the publish sidebar is opened.
Parameters
Object: Global application stateReturns
boolean: Whether the publish sidebar is open.Returns true if the Meta Boxes are being saved.
Parameters
Object: Global application state.Returns
boolean: Whether the metaboxes are being saved.Returns an action object signalling that the user closed the sidebar.
Deprecated since WP 6.3 use
core/interfacestore’s action with the same name instead.
Returns an action object signalling that the user closed a modal.
Returns
Object: Action object.Deprecated
Returns an action object used in signalling that the user closed the publish sidebar.
Returns
Object: Action object.Update the provided block types to be hidden.
Parameters
string[]: Names of block types to hide.Initializes WordPress postboxes script and the logic for saving meta boxes.
Returns an action object used to signal a failed meta box update.
Returns
Object: Action object.Returns an action object used to signal a successful meta box update.
Returns
Object: Action object.Returns an action object used in signalling that the user opened an editor sidebar.
Parameters
?string: Sidebar name to be opened.Deprecated since WP 6.3 use
core/interfacestore’s action with the same name instead.
Returns an action object used in signalling that the user opened a modal.
Parameters
string: A string that uniquely identifies the modal.Returns
Object: Action object.Deprecated
Returns an action object used in signalling that the user opened the publish sidebar.
Returns
Object: Action objectDeprecated
Returns an action object used to remove a panel from the editor.
Parameters
string: A string that identifies the panel to remove.Returns
Object: Action object.Update a metabox.
Stores info about which Meta boxes are available in which location.
Parameters
Object: Meta boxes per location.Deprecated
Returns an action object used to switch to template editing.
Deprecated
Returns an action object used to open/close the inserter.
Parameters
boolean|Object: Whether the inserter should be opened (true) or closed (false).Deprecated
Returns an action object used to open/close the list view.
Parameters
boolean: A boolean representing whether the list view should be opened or closed.Update the provided block types to be visible.
Parameters
string[]: Names of block types to show.Deprecated
Triggers an action used to switch editor mode.
Parameters
string: The editor mode.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.
Deprecated
Returns an action object used to enable or disable a panel in the editor.
Parameters
string: A string that identifies the panel to enable or disable.Returns
Object: Action object.Deprecated
Opens a closed panel and closes an open panel.
Parameters
string: A string that identifies the panel to open or close.Triggers an action used to toggle a feature flag.
Parameters
string: Feature name.Action that toggles the Fullscreen Mode view option.
Triggers an action object used to toggle a plugin name flag.
Parameters
string: Plugin name.Deprecated
Returns an action object used in signalling that the user toggles the publish sidebar.
Returns
Object: Action objectDeprecated
Returns an action object used in signaling that a style should be auto-applied when a block is created.