Tutorials
-

Requesting data in Gutenberg with getEntityRecords
in TutorialsWordPress’s ‘getEntityRecords’ selector greatly assists in fetching data for custom Gutenberg blocks. It requires understanding of parameters like EntityType, Kind, and Query for effective use. Integration of the useSelect and useDispatch hooks ensures real-time data updates and user feedback, though sparse documentation may initially challenge developers. The use of ‘isResolving’ and ‘invalidateResolution’ provides loading states…
-

Limiting the block count for InnerBlocks
in TutorialsThe component is key for Gutenberg block developers, enabling complex block structures in WordPress. While flexibly allowing item insertion and ordering, it lacks a built-in limit for block quantity. The renderAppender prop, particularly in its ‘false’ setting combined with a block count function, offers a solution, preventing further inserts when a threshold is reached. The…
-

Restricting PluginDocumentSettingPanel by post type
in TutorialsNow that the PluginDocumentSettingPanel is in WordPress core, we can add our own panels to the Document Settings panel using the registerPlugin function. 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…
-

Better Unit Testing with DataProviders
in TutorialsWhen 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:
-
New WordPress Plugin: Suspend Transients
in TutorialsRecently while working on a project in WordPress, I found myself adding and remove code to bypass cached transients. Needless to say, this was not a great solution. It caused needless code churn and sometimes it MAY have gotten committed to master. As a result, I wrote a new WordPress plugin that will allow me…
-
Setting up Unit Testing for WordPress Core
in TutorialsRecently I was running into issues with VVV running some units tests for AJAX. I was not able to remedy the issue so I decided to create a testing environment from the SVN repo directly. I went to the page on the codex and while the information there was great, part of the instructions are to…
-
Resetting $post in WordPress admin
in TutorialsI 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…
-
WordPress Plugins and debug mode
in TutorialsSometimes 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…
-
Change the WordPress post updated messages
in TutorialsSometimes 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…
