Live Stream Recap: Adding e2e tests to custom a Gutenberg block
On today's live stream, we worked through adding some e2e tests to a block we created in a previous stream. This was a lot of fun and I learned a…
On today's live stream, we worked through adding some e2e tests to a block we created in a previous stream. This was a lot of fun and I learned a…
WordPress provides a number of ways to retrieve data in Gutenbergs, one way I really like is the getEntityRecords selector. I have started using it more and more recently and find it great to use in my custom blocks.
Unfortunately, the documentation is a little sparse and there are some things to consider when working with it. However, once you start using it and its relatives, I think you’ll agree that it’s a great choice!
(more…)In 2019, I was lucky enough to speak at the fantastic JavaScript for WordPress conference. It was my first virtual conference and I had a really great time. It's a…
InnerBlocks have no built-in way to limit the number of blocks allowed inside them. Let's use the renderAppender prop to achieve this.
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?
(more…)
When unit testing your code, there are times when you need to test the same method or function with a variety of different parameters. For example, we have a function to check to see if a passed email is both valid and not already in the list of known emails:
(more…)
I have run into a bug a few times in the past little while that had me stumped. When creating meta boxes on the admin side of WordPress that contained custom loops, I couldn’t reset $post using wp_reset_postdata() – it just didn’t work.
Originally, I thought maybe I was doing it wrong because I was using get_posts, so I tried WP_Query with the same results. So, thinking I had a legitimate bug, I went to report it and found that there was already a ticket and a patch for it ( gotta love the WordPress community ). The patch is a nice, elegant fix that worked well when I tested it – but until it’s accepted into core it’s not really an option to use because hacking core is bad. So I rolled my own in the meantime. (more…)
Sometimes when we’re developing a plug-in, it’s easy to forget that we’re not building something that is meant to be standalone. What we’re building is going to exist as part of the WordPress ecosystem and as such it should respect it’s configuration. Simply put, if WordPress is in debug mode, than your plugin should be to. (more…)
Sometimes it is necessary to modify or remove the default WordPress post updated messages that are displayed when making changes to a Post in WordPress.
One example is when you are creating a custom post type that does not have a permalink. When you save a draft, publish or update a published post, you are presented with messaging that includes a link to the post – which in that case will take the user to a 404 page. (more…)
When I was at WordCamp Ottawa this year, I was asked a question about how to create custom post types without generating permalinks. This is actually something I do a lot of as I am creating internal content types that are not meant to be viewed individually at their own url.
The snippet below will register the post type and you’ll notice that there is no Permalink line below the title. (more…)