Remove a component fill from a Block Editor panel

I’m aware there is quite a lot of flexibility to add to the various editor components in the block editor using SlotFills this is useful when you want to add functionality. However my question is about removing functionality.

I’d really like to remove one or more of the components below already added into the PluginPostStatusInfoSlot

Given there aren’t inbuilt filters or hooks into this at the moment – I’m wondering if I’m missing something React-y here that I can use. jQuery is a no-no.

How it’s added in the core:

const PostStatus = ( { isOpened, onTogglePanel } ) => (
    <PanelBody
        className="edit-post-post-status"
        title={ __( 'Status & visibility' ) }
        opened={ isOpened }
        onToggle={ onTogglePanel }
    >
        <PluginPostStatusInfo.Slot>
            { ( fills ) => (
                <Fragment>
                    <PostVisibility />
                    <PostSchedule />
                    <PostFormat />
                    <PostSticky />
                    <PostPendingStatus />
                    <PostAuthor />
                    { fills }
                    <PostTrash />
                </Fragment>
            ) }
        </PluginPostStatusInfo.Slot>
    </PanelBody>
);

Other plugins seem to remove the whole panel and rebuild this if they want to remove components – but that doesn’t seem future friendly to any WP updates.

Any and all help appreciated.

0

Leave a Comment