No code changes are necessary, it can be done entirely in the UI. Sidebars appear in the 3 dot drop down menu, the star is just a way to add a shortcut to the top toolbar, e.g. here are the Yoast and Jetpack sidebars listed:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
// Using ES5 syntax var el = wp.element.createElement; var Fragment = wp.element.Fragment; var PluginSidebar = wp.editPost.PluginSidebar; var PluginSidebarMoreMenuItem = wp.editPost.PluginSidebarMoreMenuItem; var registerPlugin = wp.plugins.registerPlugin; function Component() { return el( Fragment, {}, el( PluginSidebarMoreMenuItem, { target: 'sidebar-name', }, 'My Sidebar' ), el( PluginSidebar, { name: 'sidebar-name', title: 'My Sidebar', }, 'Content of the sidebar' ) ); } registerPlugin( 'plugin-name', { icon: 'smiley', render: Component, } ); |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.