此SlotFill允许注册UI来编辑文档设置。
- 名称
一串
:标识面板的字符串。
- 类名
一串
:添加到侧边栏正文的可选类名。
- 标题
一串
:标题显示在侧边栏顶部。
- 偶像
(字符串|元素)
:该仪表盘图标图标slug字符串或SVG WP元素。
从“@wordpress/plugins”导入{registerPlugin};从“@wordpress/editor”导入{PluginDocumentSettingsPanel};const PluginDocumentSettingPanelDemo=()=>(<插件文档设置面板name=“custom-panel”title=“自定义面板”className=“custom-panel”>自定义面板内容</PluginDocumentSettingsPanel>);registerPlugin('plugin-document-setting-panel-demo'{render:插件文档设置面板演示,icon:'棕榈树',} );
可以使用面板名称以编程方式访问核心面板和自定义面板。核心面板名称为:
- 摘要面板:
岗位地位
- 类别面板:
分类学-单分类
- 标签面板:
分类-panel-post_tag
- 特色图像面板:
特征图像
- 摘录面板:
后摘录
- 讨论小组:
讨论小组
自定义面板以传递给的插件名称命名寄存器插件
.
为了使用以下功能访问面板切换编辑器面板已打开
或切换编辑器面板已启用
请确保预先添加名称空间。
要以编程方式切换面板,请使用以下命令:
从“@wordpress/data”导入{useDispatch};从“@wordpress/editor”导入{store as editorStore};常量示例=()=>{const{toggleEditorPanelOpened}=useDispatch(editorStore);返回(<按钮variant=“主要”onClick={()=>{//切换“摘要”面板toggleEditorPanelOpened(“后期状态”);//切换上述示例中引入的自定义面板。切换编辑器面板已打开('插件-document-setting-panel-demo/custom-panel');} }>切换面板</按钮>);};
也可以使用删除编辑器面板
函数通过传递已注册面板的名称。
从“@wordpress/data”导入{useDispatch};从“@wordpress/editor”导入{store as editorStore};常量示例=()=>{const{removeEditorPanel}=useDispatch(editorStore);返回(<按钮variant=“主要”onClick={()=>{//删除“特色图像”面板。removeEditorPanel('featured-image');//删除上述示例中引入的自定义面板。删除编辑器面板('插件文档设置面板演示/自定义面板');} }>切换面板</按钮>);};