WordPress.org

WordPress Developer Blog

What’s new for developers? (March 2023)

Welcome to the second edition of this monthly series. If you’re a developer who builds on top of the WordPress platform, this news is for you. The goal is to make it easier to navigate the fast-paced development cycle, narrowing down the list of must-read content into a single digestible source.

The February 2023 edition was a success, based on feedback from readers. If you missed it, do peruse it at your leisure—after you’ve read this latest edition, of course!

WordPress 6.2 is the first major release of 2023 and is expected to launch on March 28. As with other major releases, a new Field Guide has been published on the Make Core blog. If there is truly one must-read bit of content, this document is it: a one-stop shop to catch you up on all the latest developer-related features landing with WordPress 6.2.

Table of contents

Highlights

Several new features have landed in the Gutenberg plugin and core WordPress in the past month. At this point, you should be testing against at least WordPress 6.2 Release Candidate 1 or Gutenberg 15.2 in your local environment.

WordPress 6.2 product walk-through

On March 2, release squad members Anne McCarthy and Rich Tabor presented a live product demo of WordPress 6.2. It was the first product walk-through moderated by a WordPress community member, Nathan Wrigley.

The walk-through highlighted upcoming enhancements and new features, starting with the revamped Site Editor interface. If you have yet to try out WordPress 6.2 during the beta and release candidate cycle, the demo offers a solid introduction before you take the leap into new code.

Community themes initiative

In 2022, 19 designers from 8 countries came together to build 38 style variations for the Twenty Twenty-Three theme. Of those submissions, 10 landed in the final release. Its success showed clearly how the design community can collaboratively build themes atop WordPress.

Following up on that success, the Community Themes Initiative was born. On March 7, more than 20 people participated in an inaugural Hallway Hangout to discuss building block themes under the banner of the WordPress.org username. The project is in its early stages, and anyone who wants to create block themes or learn more about them can participate. Visit the follow-up post for more information or watch the session on WordPress.tv.

Aspect ratio support for Post Featured Image block

The Post Featured Image block now supports setting an aspect ratio. This gives you much more precise control over how your templates output images when you don’t want to define an explicit width or height. It can be particularly useful when building grid layouts where the intention is that featured image output is consistent.

This change also introduced aspect-ratio CSS support for the various KSES functions in WordPress.

Minimum height support

Minimum-height dimension support is here. Now you can add it to your custom blocks. Currently, the core Post Content and Group (along with its Stack and Row variations) blocks offer support by default if enabled in theme.json.

This new block support gives you even more ways to execute custom designs, particularly alongside vertical layout tools and the Stack block. For more information, read the dev note on the feature.

Breaking changes and deprecations

WordPress 6.2 will remove several deprecated APIs and components, which includes the following:

  • The formatting prop for the RichText component
  • Non-strings for block descriptions
  • The experimental @wordpress/edit-navigation package

Plugins and tools

Filesystem API supports moving directories

WordPress 6.2 will introduce a move_dir() function as part of its Filesystem API to move a directory. Since version 2.5, you could copy a directory via copy_dir() but had to manually delete the original. The new function lets you define the current directory location, the new location, and whether to overwrite the destination.

Style Book excludes non-insertable blocks

The Style Book lets you modify global block styles via the Site Editor. In previous iterations of the feature, it showed all third-party blocks alongside those in core WordPress. A recent change excludes blocks that are not allowed to be inserted. Read more about Style Book previews via its dev note.

The Navigator component now supports two additional features:

  • It offers a method to navigate to the parent screen via the goToParent() function and the NavigatorToParentButton component.
  • It can match named arguments, such as /product/:productId.

Both features assume that a NavigatorScreen instance is assigned paths that are hierarchical and follow a URL-like scheme, where path segments are separated by a forward slash.

Hooks

In scenarios where you need to run a filter on the override_load_textdomain hook, WordPress 6.2 will introduce the $locale parameter. This makes sure you always have access to the correct locale. Previously, you might have relied on the determine_locale() function, which may not have returned the same value.

Bug fixes

A recent patch fixed a PHP fatal error in some cases when using the wp_list_authors() function. The issue arose when using the optioncount parameter, which displays each author’s post count, and the resulting query contained a user who does not have any posts. The change is bundled in WordPress 6.2, but the ticket is still open for potentially backporting to the WordPress 6.1 branch.

Themes

Default themes bundling web fonts

Several of the default WordPress have been updated to bundle Google Fonts inside their respective themes folders:

  • Twenty Twelve
  • Twenty Thirteen
  • Twenty Fourteen
  • Twenty Fifteen
  • Twenty Sixteen
  • Twenty Seventeen

These are all classic themes that do not support theme.json. Therefore, they do not use the newer Fonts API available to theme developers. But, they do give you a solid model to emulate when you are building purely classic themes and would like to serve privacy-friendly web fonts. The dev note details the changes.

Starter patterns for template types

A modal now appears when you’re creating a new template from the site editor. These starter patterns are currently limited to a default fallback template or a completely empty state. Eventually, this feature will tie into the Pattern API’s support for template types, letting you present custom patterns for specific templates.

Themes can control the Post Excerpt block length

Now, you can control the number of maximum words used for the Post Excerpt block. A new excerptLength attribute lets you change the max on a per-query basis and solves a longstanding issue where themers could only filter the excerpt_length hook globally or hack together solutions for context-based customizations.

Button block now considered a “content” block

The Button block is now a “content” block. In practice, this change lets you use the Locking API to curate the editor experience for users. For example, you can set the block’s templateLock attribute to contentOnly, which preserves its design but lets users edit the content.

Block support updates

Over the past month, several core blocks received support for additional design tools:

These updates should make it much easier to customize the output of the default blocks.

New and updated default shadow presets

Gutenberg 14.9 introduced box-shadow presets you can add to your designs. There is both a dev note and Developer Blog tutorial that will walk you through using the feature when WordPress 6.2 lands.

Along with custom presets, the feature originally shipped two default shadows, Natural and Sharp. A recent change updated the code for these two and introduced new Deep, Outlined, and Crisp presets. If you have been using Natural and Sharp, you will want to test your designs to see how the change looks in your themes.

Bug fixes

A defect was recently fixed in cases where an active theme with a numeric directory name was not identified as the active. Numeric theme names have long been allowed, so this patch only addresses an issue with the directory itself.

The conditional logic behind loading the wp-block-library-theme style was patched in the past month. In some cases, such as when a theme did not include an editor stylesheet, the opinionated block library theme style was being incorrectly enqueued. This would sometimes lead to inconsistencies between the editor and front end.

In WordPress 6.1, button element styles were moved to theme.json. However, this change didn’t account for styling the button element in the File block for themes without a theme.json. A patch for 6.2 re-introduces the CSS to the classic stylesheet.

The documentation for adding a filter on rss_widget_feed_link has been updated to recommend returning a string value. The core Twenty Twenty-One theme now uses the __return_empty_string() function as a filter on the hook. Developers who modeled their own themes on this code should update their themes. This is a non-breaking change.

In some cases, such as deprecated versions of the Gallery block, layout classes were being added to inner blocks. A recent patch ensures that these classes are only applied on the inner wrapper if the block is a container.

Events and resources

Developers Hours sessions

Developer Hours, a series of question-and-answer discussions with community members, are back in full swing. The current discussions are centered on migrating shortcode and widget plugins to blocks.

In February, the first two events were held for those in the EMEA and Americas. The third event, specific to the EMEA and Asia-Pacific region, will be held on March 27.

Learn WordPress

Jonathan Bossenger published a new video tutorial that introduces securely developing plugins. It covers five key areas that you should familiarize yourself with:

  1. Sanitizing input
  2. Data validation
  3. Escaping output
  4. Preventing untrusted requests
  5. Checking user capabilities

All modules of the Develop Your First Low-Code Block Theme course are now available. It walks you through the foundation of building a simple block theme.

Developer Blog articles

Over the past month, contributors have published six new posts for the WordPress development community here on the Developer Blog:

The goal is to make this a high-quality resource for extenders to continue learning from. It is also open for contributions, so please share your knowledge and pay it forward.

Props to @bph for co-writing and wrangling these resources and @marybaum and @webcommsat for feedback and review. Photos by @shamimmiashuhagh, @rajualam, and @topher1kenobe from the WordPress photos directory.

One response to “What’s new for developers? (March 2023)”

  1. Grzegorz Avatar

    That’s a hefty number of improvements and bug fixes. Though nothing on the list particularly ecites me, it’s good to see major updates rolling out from time to time.

Leave a Reply

Your email address will not be published. Required fields are marked *