WordPress Developer Blog

What’s new for developers? (February 2024)

What’s new for developers? (February 2024)

WordPress 6.5 is expected to ship on March 26, 2024, and the first beta version is scheduled for release on February 13. That means that commits to the Core code base have picked up pace over the last few weeks.

The good news? There are lots of goodies on the way that you can start playing with today.

The sort-of-bad news? There were so many changes in the past month that it’s next to impossible to cover them all in detail in this edition of the monthly roundup. I’ll do my best to cover the most significant features for your work as an extender, but I had to make a few cuts.

In the meantime, make sure you check out the Gutenberg 17.7 RC. It landed on Friday, February 9, and it will include the final features to make it into WordPress 6.5.

As usual, make sure that you are running WordPress trunk and the latest version of the Gutenberg plugin in a development environment to test the following updates.

Highlights

Block Bindings API, custom fields, and pattern overrides

The Block Bindings API is soon to be the talk of the town as folks in the WordPress community begin learning how to extend blocks in a brand new way. 

In a nutshell, the Block Bindings API allows you to bind data from various sources to existing block attributes. For example, you could bind an Image block’s url attribute to a custom field, automatically injecting the URL from the custom field on the front end. In many cases, this new API will even allow you to forgo building a custom block in favor of extending the core blocks.

WordPress 6.5 will arrive with two binding sources for handling post meta (custom fields) and pattern overrides. But you can also register your own binding sources for deeper customization.

To stay up to date on these features, you can follow the Block Bindings API tracking issue and related tickets on GitHub:

Define and filter allowed inner blocks

Landing in Gutenberg 17.6, blocks can now register their allowed inner blocks via the allowedBlocks property in block.json. Perhaps even more important, this property is also exposed via the blocks.registerBlockType hook, allowing you to extend the allowed blocks array.

What does this mean at a practical level? 

You can register and add simple blocks like a Shopping Cart Link inside of a Navigation menu. Or—if you’re feeling particularly adventurous—add advanced blocks like a mega menu dropdown. Any block can opt into the feature, and now is a great time to start exploring what’s possible.

Big feature updates for WordPress Playground

There are several major changes for WordPress Playground. The first is a new WordPress Playground Block available via the Plugin Directory.

Playground now supports WP CLI directly in the browser and multisite instances. And several new areas of the WordPress project have built-in live previews to help contributors test via Playground:

Other highlights include support for PHP 8.3 and the mbregex and OpenSSL PHP extensions.

Plugin dependencies

In memory of the late Alex Mills and Alex King, an 11-year-old feature request for a plugin dependency system was closed as fixed

Yes, you read that right: WordPress 6.5 will handle plugin dependencies.

This change lets you set a Requires Plugins header in your plugin with a list of plugin slugs that are necessary for your plugin to work. Perhaps it will also reopen the door for framework-like plugins in the directory, which have been disallowed since 2016.

Plugins and tools

Breaking change fix for ZIP uploads from Macs

A recent security update for the plugin and theme uploader in WordPress causes a problem with ZIP packages created on a Mac computer via the Finder > Compress command. If a user tries to upload such a compressed ZIP file to the WordPress site, it will render an error message and declare it an “Incompatible Archive.” Core contributors have already patched this, and the fix will be available in the next release—either in 6.4.4 or 6.5, whichever comes first. 

Until then, you must use a command line tool or build script to create ZIP files before uploading directly to WordPress.

This issue does not impact plugin and theme ZIPs downloaded directly from WordPress.org unless you unzip and re-zip from a Mac before uploading to your site.

View stylesheet support for block.json

In WordPress 6.5, you will be able to define a stylesheet for your blocks via the viewStyle property in block.json. It will work similarly to the existing viewScript property and only load on the front end of the site.

JavaScript Modules API

WordPress 6.5 will ship with a new API for registering and enqueuing JavaScript modules. It will work similarly to scripts and styles and includes two new functions:

  • wp_register_script_module()
  • wp_enqueue_script_module()

They are not exactly the same as their script counterparts, though, and are catered to the needs of loading ES modules. This first version is intentionally limited and doesn’t include support for deregistering. Learn more in the notes from the changeset.

HTML API element support updates

The WP_HTML_Processor class will ship even more element support in WordPress 6.5. Elements added in the past month include:

Font Library updates

Additional functions arrived in Gutenberg 17.6 to extend the Font Library and make management easier for developers. One big change is that you can now unregister a font collection with the ​​wp_unregister_font_collection() function.

To obtain path information about the directory that houses the fonts on a site, you can use the new wp_get_font_dir() function. It’s accompanied by the fonts_dir hook that allows you to control the upload directory for fonts. 

There is also an editor setting to disable the font library UI. Here is a PHP code snippet for disabling it:

add_filter( 'block_editor_settings_all', 'pluginslug_editor_settings' );

function pluginslug_editor_settings( $editor_settings ) { 
	$editor_settings['fontLibraryEnabled'] = false;
	return $editor_settings; 
}

REST API

Although attachments technically support custom taxonomies, the REST API hasn’t supported updating the terms. This missing link is now solved. In WordPress 6.5, taxonomy terms are updated across the REST API.

If a plugin or feature makes a REST API call to retrieve a list of templates, the payload now delivers the original source and author_text fields.

Interactivity API

The public API for Interactivity has been enhanced with several new directives: 

Additionally, for setting initial custom block attribute values, contributors streamlined and introduced the wp_interactivity_state() function to replace the verbose wp_store().

You can follow the GitHub tracking ticket to make the Interactivity API public. At the time of writing, 30 of 50 tasks have already been accomplished. 

Block Hooks API

An update in Gutenberg 17.6 created a mechanism for rendering hooked inner blocks inside the Navigation block. This update should let you hook in custom blocks without issue.

In WordPress trunk, a new hook was introduced for filtering specific hooked blocks: hooked_block_{$block_type}.

Footnotes support for post types

Footnotes support was expanded to include more post types in Gutenberg 17.6. This support will work with any post type that:

  • Is public and available to the REST API.
  • Supports the editor, custom-fields, and revisions features.

New hook

In WordPress 6.5, developers can change the subject line of the email that will go out when a user changes the admin email address via the new_admin_email_subject hook.

Themes

Testing needed: reducing style specificity

There are a couple of major changes to the style engine that could impact existing theme designs, so both of these need to be tested thoroughly as soon as possible. And please leave feedback on the respective tickets.

The first change recently landed in WordPress trunk and will ship with WordPress 6.5. It reduces the specificity of block style variation selectors in the editor. It’s important that you test this against any block style customizations you’ve added to theme.json.

There is also a draft PR for the Gutenberg plugin that would reduce the specificity of the global styles selector. This has a much greater chance of impacting themes and needs feedback before it can ship. The change would lay the groundwork for other features like colorways and typesets.

Block settings and design tools

The last couple of Gutenberg releases have continued to add settings and design tools support to various blocks. Before WordPress 6.5 ships in March, it would be a good time to start testing these and integrating support for them in your patterns and templates.

  • Blocks can now opt into aspect ratio support, and the Cover block now supports the feature out of the box.
  • The Post Navigation Link block has a new Taxonomy filter in the UI. If a taxonomy is chosen, the Next Post and Previous Post links will only link to posts that share the same term within that taxonomy.
  • The Pullquote block now supports padding and margins, which can be defined at the block level or in theme.json.
  • A new Shadow control will appear in the UI under the Effects panel for blocks that opt into box-shadow support, such as Button.

Default font sizes option in theme.json 

An ongoing issue for theme authors has been the inability to completely disable default font sizes and related issues. Gutenberg 17.5 added a new settings.typography.defaultFontSizes boolean that you can use to disable the Core font sizes, but it was reverted after it caused another bug. Another patch has been drafted to address the issues.

Patterns

New audio and videos pattern categories will be available in WordPress 6.5 for grouping your theme patterns. This will round out the available media-specific categories to:

  • audio
  • gallery
  • media
  • videos

Grouped templates in the Site Editor

If you open Appearance > Editor > Templates and wonder where your custom (i.e., non-default) templates went, there’s no need to worry. Gutenberg 17.6 now groups all custom templates under a Custom Templates section. Plugin-specific sections should also exist (depending on how they register templates).

Notable user-facing changes

Gutenberg 17.5 added a new Random order setting in the UI for the Gallery block. This is more of a user-facing feature that brings back an old setting from the classic era. But you can certainly enable it in your theme’s custom patterns.

The control to enable the image lightbox feature has been removed from the sidebar and placed within the link control in the editor toolbar, requiring an additional click to access. While the goal is to make it more intuitive, the change may initially confuse users when they upgrade to WordPress 6.5. Be sure to inform them of the new location for a smoother transition.

Avatar alignments fixed

If you were running into trouble with the Avatar block not aligning left/right correctly, this bug was fixed in Gutenberg 17.6.

Post Featured Image fallback

Since Gutenberg 17.5, you can use the first image from a post as a fallback for the Post Featured Image block. This is the first attempt at recreating a feature that classic theme authors have implemented for years. There is no UI for it, so you must set the useFirstImageFromPost attribute to true in the block markup itself.

This implementation may only work well with some designs. It pulls the <img> element wholesale from the post content and doesn’t apply any of the settings/styles to the <img> that are defined for the Post Featured Image block (e.g., aspect ratio inline styles). Please test thoroughly with a range of image content before shipping to users once WordPress 6.5 is released.

Resources

General

Here are a couple of posts that are worth your time if you missed out on them earlier:

Developer Hours and Hallway Hangouts

In the last few weeks, two new live sessions were held to help you improve your block and theme development skills:

Developer Blog

Readership was way up over the past month—I guess folks are enjoying the content here on the Developer Blog. If you missed any of the posts, catch up with the four latest tutorials to help you extend WordPress:

Props for review @ndiego @bph @rmartinezduque

Categories: , ,

4 responses to “What’s new for developers? (February 2024)”

  1. Joni Ahmed Avatar

    It’s a Great update in February 2024.

  2. Rudi - WordPress Developer Avatar

    Particularly looking forward to the block bindings API! We develop alot of our own custom blocks because extending blocks is very difficult currently.

    1. Justin Tadlock Avatar

      Stay tuned into the Developer Blog. I’m working on an in-depth post that explores the Block Bindings API. I’m really excited about its potential!

  3. Sam Avatar
    Sam

    The latest changes that have been implimented have been quite frustrating

    Before I was able to go between paragraphs to get a + to appear and add in new content blocks like images, videos etc but now that doesn’t appear at all and if I manage to add an image and want to add a link after it has been justified to one side I have to struggle to find the interface.

Leave a Reply