I would like to edit the text or remove and re-create the Publish panel of Gutenberg's PrePublish Panel in the editor sidebar.

I know I can use wp.data.dispatch( 'core/edit-post' ).removeEditorPanel( 'example-panel' ); but it doesn't seem to work for any panels in editor-post-publish-panel. Any ideas? enter image description here

The background is that I used the slotfill API to insert a timezone select field so authors can use their local times when selecting their publish date time. That all works great, except when they click Schedule and get the publish time in GMT without any context.

  • 1
    I guess you're going to need to use something like jQuery's .remove() or .hide() for the time being. But, can you show the code for "I used the slotfill API to insert a timezone select field"? – Sally CJ Aug 21 '19 at 7:49
  • Might work. I'd attach a listener to wp.data.select('core/edit-post').isPublishSidebarOpened() and then use a pseudo css class to select the 2nd div in jQuery. Very hacky though and will cause React to redraw everything... – spnzr Aug 21 '19 at 16:34
  • Here's a gist of the timezone select: gist.github.com/spencerm/1005327871474b5cecccb1fb9109dda8 (I'm not super familiar with react.js however) – spnzr Aug 21 '19 at 16:35
  • 1
    Or actually I can just do a hack-y CSS fix – .editor-post-publish-panel__prepublish :nth-child(4){ visibility:hidden; } ... but it is definitely hack-y haha – spnzr Aug 21 '19 at 16:57
  • Well, both CSS and JS are hacky.. but JS has the advantage of completely removing the div from the DOM (and not simply hiding the div visually). So looking at the gist, I suppose you'd add your own "Publish" sub-panel in the post pre-publish panel? And could you post the build version of that gist? – Sally CJ Aug 21 '19 at 17:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.