Limiting the block count for InnerBlocks

One of the most versatile components that Gutenberg block developers have is the <InnerBlocks/> component. This component allows other blocks to be inserted into it. WordPress Core ships with the Group and Columns blocks that both use InnerBlocks internally to allow the creation of very complex block structures.

The InnerBlocks component solves some interesting problems for custom blocks, for example creating a list of ordered items. By leveraging InnerBlocks, one can skip having to build a bespoke system and rely on Gutenberg to handle the insertion, deletion, and ordering of items. It is very flexible and easy to use. However, while working with it I discovered that there is no built-in way to limit the number of blocks that can be inserted.

The renderAppender prop will allow us to solve this issue

Continue reading “Limiting the block count for InnerBlocks”

@GoodFirstBugs bot is back!

A couple of years ago, I created a Twitter bot that tweets out WordPress core trac tickets marked as GoodFirstBugs to help new contributors find a good starting place. It got a fantastic response from the community and even got an article on WP Tavern!

It had been offline for a while due to some issues with the account. Once I got that sorted out, I rewrote the bot to address some issues it was having with retrieving the trac report and added some new functionality to also include the list of issues labeled with Good First Issue from the Gutenberg project.

I am very excited to bring the bot back and hopefully it’s helpful! If you’re interested in contributing, the code is available on Github.

Restricting PluginDocumentSettingPanel by post type

Now that the PluginDocumentSettingPanel is in WordPress core, we can add our own panels to the Document Settings panel using the registerPlugin function.

const { registerPlugin } = wp.plugins;
const { PluginDocumentSettingPanel } = wp.editPost;

const MyCustomSideBarPanel = () => (
    <PluginDocumentSettingPanel
        name="my-custom-panel"
        title="My Custom Panel"
    >
        Hello, World!
    </PluginDocumentSettingPanel>
);
registerPlugin( 'my-custom-panel', {render: MyCustomSideBarPanel } );

The above code will insert a new Panel in the Document Sidebar with the title of My Custom Panel ” and will display “Hello, World!” as it’s content. If we want this panel to appear on every post type registered, then we’re done but what if we want to restrict this panel to just a single post type?

Continue reading “Restricting PluginDocumentSettingPanel by post type”