WP Rig 3.1 is here and it is jam packed with improvements and new features for theme developers. Lets go through what’s new. Buckle up, because there is a lot here.
Performance
In v3.0, we dramatically overhauled the JS and CSS compile system in WP Rig to improve performance and move away from older less performant processes. While this brought huge performance gains to WP Rig, this was really just phase 1 of 2 phases. In 3.1, we have finished phase 2 of this process, removing our dependency on Gulp altogether. While Gulp was great to us in the past, the package has become bloated over the years, support has been questionable, and efforts to modernize it have been less than ideal by today’s standards. So, instead of attempting to find a new task manager, we decided to write our own bespoke internal node scripts for performing many of the main WP Rig task processes. As a result, WP Rig 3.1 is even faster than 3.0, boosting build speeds by approx 2x of 3.0.
We didn’t stop there either. While BrowserSync is still a pretty cool technology, it is a bit slow and dated by modern standards. In an effort to keep up with the times, we decided that we needed something closer to HMR (hot module reloading). While true HMR is not technically possible in the scope of PHP, there are some interesting concepts that have been brought forward over the last decade that get PHP/WordPress sytems much closer to this kind of developer experience. So, with that said, we now have a more modern watch process built into WP Rig that makes realtime updates to your theme faster than ever!
Believe it or not, this puts WP Rig’s build, watch, and bundle processes up to par with modern systems like Vite. What a time to be alive!
Modernizations
The goal of WP Rig is to remain a progressive and cutting edge toolkit for WordPress theme developers. As the web continues to evolve, so must WP Rig.
Image processing
Previously, all image processing in WP Rig was done by imagemin. Well, there’s a new kid on the block and it’s pretty good. Now, WP Rig leverages Sharp for all image processing. This means better and faster image processing. How images are processed remains similar to before, just faster, better, and lighter. Just a reminder, WP Rig does now convert to webp for you and the image processing task was moved out of the dev/watch server to speed up Rig, so images are now processed using the dedicated command, or by the build or bundle processes.
Bun Support
WP Rig now supports (and encourages) the usage of Bun. While we kept npm support (for now) for those who have not jumped on the Bun train yet, we do highly recommend installing Bun and leveraging this new and extremely fast and powerful all-in-one JavaScript, TypeScript & JSX toolkit. You will be amazed by the blazing fast performance. Also, as we move forward, it is highly likely that some future WP Rig features will require Bun to leverage them in an a continued effort to keep our dependency tree as small as possible.
Command Prompts
In an effort to improve the DX of WP Rig, we have begun leveraging command prompts to make WP Rig more intuitive. This means less having to remember specific steps and less manual adjustments to config files and such. The rig-init command now prompts for basic config details after installing all Node and Composer packages to help new users set up their BrowserSync/HMR config and better guide users. These are also used in our new component generator and childify conversion.
New scripts, commands, and generators
While building the latest version of this website’s theme, some obvious room for improvement was discovered. We even made a blog post highlighting some of our learnings and we were committed to improving. This means less common manual file manipulation, and more automation.
Learn more about how our cli scripts
Component generation
Creating new PHP components seemed way too necessary/common in more theme builds and the process was just unnecessarily manual. With that in mind, we have added a new cli command to automatically scaffold new components for you. This process not only creates the necessary folder and file for your new component in the /inc folder, but it also adds this component to the Theme.php class for you. This means you just run the command and dive right into your new Component.php file already set up with a standard structure and method declarations. Now creating new components is faster and easier than ever.
Child Themes
Historically, WP Rig was only able to be used as a parent theme. If you wanted to build a child theme for another theme and wanted a build process to compile your child theme’s custom JavaScript or CSS, you had to manually set up/configure some other build/bundling system from scratch in your child theme (Webpack, Vite, etc.). So we thought, “Why can’t WP Rig be used for child themes anyway?”. After much thought, we realized there was really no good answer to this question. So, just like you can convert WP rig to a universal or block based theme, you can now also convert it to a child theme. Just run a single cli command and Rig will guide ask for some input before modifying the WP Rig codebase to be used as a child theme. This basically means it will remove a fair number of features from WP Rig that only make sense for parent themes and also add a dependency on your parent theme of choice. Presto! Now you have a child theme with multiple build processes, allowing WordPress developers relying on any theme (premium or not) to modify that theme’s functionality progressively for any client project.
Fonts
Relying on Google fonts like most web developers do? We get it. It’s easy, there a lot of good ones to choose from, and best of all – no licensing worries. The only problem with Google fonts is having to rely on their CDN. This is not the best practice. It is much better for reliability and performance to host your font files on your website’s server. So why not bundle these fonts into your theme? WP Rig now has a new command that will use the built-in Fonts component to scan for any registered Google fonts in the theme and download the font files directly into the /assets/fonts directory while also writing some boilerplate css to register the fonts for usage with relative pathing to these font files. That’s it. Now you can start using these fonts in your theme without having to make requests to the Google CDN. Better performance. Better reliability. Better security. Better theme.
Theme-level Block development
Trigger warning – we believe that in very specific scenarios, it makes sense to build custom Gutenberg blocks into your theme instead of a plugin. Now, before you raise any pitch forks or just stop reading to flame WP Rig, please hear us out.
We get it, blocks should be a plugin-level concern – we completely agree. In most cases, we recommend building your custom blocks using the @wordpress/create-block package which is designed to build your blocks as a plugin. It’s great and we would never recommend always building any block into your theme as it limits your block’s modularity, portability, and the ability to deactivate it separately from your theme.
With that said, now that blocks can be used across your entire site, not just the page/post content, the lines are blurring. Navigation, search functionality, accessibility, and other concerns often make sense to build into your theme, especially when you consider that custom menu walkers are also often part of the theme as well. Also, many bespoke site projects can be rather involved and your custom theme can easily become the main driving force of the site experience.
Adding functionality to your theme, while technically not proper because functionality should always be the responsibility of plugins, in some cases does make sense. Furthermore, we believe the plugin manager in WordPress fails to address the issues and separation of concerns that prevent admins from effectively managing large numbers of plugins. This problem becomes exacerbated by the entire concept of block plugins. If a site is always going to be reliant on it’s bespoke theme, and this theme is often going to manage the styles of custom blocks, then what really is the problem (as long as you are not planning on distributing your blocks or using them across multiple projects)?
So, with all of this mind, we thought it would be ideal to provide theme developers with the option to build some of their custom blocks into their theme using the existing WP Rig build system. Our new block development system will create/register blocks, list blocks, remove blocks, build blocks, and even move blocks out to a plugin if you realize later you want to use one of these blocks in other projects or share them. This new system is based on the create-block package, so you would develop blocks in WP Rig the same way you would for create-block.
Learn more about how our new block system works
Block Based Themes
While previously we added a command to add Site Editor support to your theme by converting it to a universal theme, it still required some manual effort to convert it to a truly block-based theme. Now we have added a command to convert your universal theme to truly block-based theme with a single command. So, to make a truly block-based theme, WP Rig theme devs will now add editor support, then convert to block based. This essentially removes support for the Customizer, menu manager, and any other features that become obsolete with the concept of full site editing. Added editor support to your theme (universal or block-based) now also generates a starter theme.json file for you.
Other enhancements
- New wp cli commands for mocking menus and importing/exporting menus between sites/environments
- A number of long lasting bugs have been addressed
- All new default header, primary nav and mobile navigation styling and walker for a better starting point
- More organized css
- Better nav accessibility
- Improvements to eslint system, TS compiling, styles and js minification
- Less dependencies
- and more
See the CHANGELOG.md file for more details.
Conclusion
I (Rob Ruiz) hope everyone finds these new features and enhancements valuable. I remain committed to this open source project. I will continue to build enhancements to this extremely powerful and beneficial theme development tool as I continue to grow my skills building custom Node/Bun tooling and focusing on the DX of WP theme developers. I have many more ideas for enhancements to this tool. I will always welcome open-source contributions from the community as they align with the needs of the WP Rig user base.
Many thanks to those that continue to use WP Rig. Please share this exciting news with other WP dev you know. Please lets us know what you think in the discussion boards on Github.