Updates to the HTML API in 6.5

WordPress 6.5 brings significant updates to the HTMLHTML HyperText Markup Language. The semantic scripting language primarily used for outputting content in web browsers. APIAPI An API or Application Programming Interface is a software intermediary that allows programs to interact with each other and share data in limited, clearly defined ways.. Notably, the Tag Processor received a major overhaul allowing it to scan every token in an HTML document and unlocking a broad array of new functionality. The HTML Processor supports much more of the HTML specification than it did when it was minimally introduced in WordPress 6.4.

New functionality in the Tag Processor.

The Tag Processor was designed to scan every tagtag A directory in Subversion. WordPress uses tags to store a single snapshot of a version (3.6, 3.6.1, etc.), the common convention of tags in version control systems. (Not to be confused with post tags.) in an HTML document, skipping all of the non-tag tokens. In WordPress 6.5 it can scan everything. Tokens are the fundamental pieces that make up a document; in the case of HTML, they are the tags, comments, doctype definitions, and text nodes. This means that it’s now possible to read the text content of an HTML document, trivializing previously-complicated operations like stripping tags or truncating HTML.

Supporting this work is the introduction of a new concept called modifiable text. Modifiable text represents content within token boundaries, or content which can be changed without affecting the structure of the document as a whole. Different tokens contain different types of modifiable text:

  • The entire span of a text node is modifiable text.
  • The inside contents of an HTML comment is modifiable text.
  • The content between the opening and closing tags of special elements is modifiable content.

In this case, special elements refer to elements whose inner contents cannot contain other HTML tags. These include the contents of SCRIPT and STYLE elements as well as the contents of the TITLE and TEXTAREA elements. There are a few more representing deprecated or invalidinvalid A resolution on the bug tracker (and generally common in software development, sometimes also notabug) that indicates the ticket is not a bug, is a support request, or is generally invalid. syntax: see the class documentation for a comprehensive list.

New Methods.

  • next_token() advances to the next token in the document, including closing tags. Unlike next_tag() there is no query for this method. It scans everything.
  • get_token_type() indicates what kind of token was found, e.g. a #tag or #text or #comment.
  • get_token_name() returns a value roughly corresponding to the DOM nodeName, e.g. SPAN or #text or html (for doctype declarations).
  • get_modifiable_text() returns the properly-decoded text content for a matched token.
  • get_comment_type() indicates why the token is a comment, since different kinds of invalid markup become HTML comments. For example, <​![CDA​TA[​text]​]> is an HTML comment of the type COMMENT_AS_CDATA_LOOKALIKE because it appears as though it was intended to be a CDATA section, which doesn’t exist within HTML content.
  • paused_at_incomplete_token() indicates if the Tag Processor reached the end of the document in the middle of a token. For example, it may have been truncated in the middle of a tag.

Example usage:

$title = null;
$text_content = '';
$processor = new WP_HTML_Tag_Processor( $html );
while ( $processor->next_token() ) {
    if ( '#text' === $processor->get_token_type() ) {
        $text_content .= $processor->get_modifiable_text();
    } elseif ( null === $title && 'TITLE' === $processor->get_token_name() ) {
        $title = $processor->get_modifiable_text();
    }
}

echo $title ? $title : '(untitled post)';
echo "\n\n";
echo $text_content;

Expanded support in the HTML Processor.

WordPress is now able to recognize and properly parse most HTML. There are only a few major exceptions.

  • The HTML Processor will bail any time it encounters a FORM, MATH, SVG, TABLE, or TEMPLATE tag. These elements introduce complicated parsing rules that require additional care, testing, and design work.
  • There are times when an HTML parser needs to implicitly create an element that wasn’t in the HTML itself, or when it needs to move a tag to an earlier place in the document. This requires further design work to properly communicate that the document has retroactively changed.
  • If the HTML Processor is fed full HTML documents or snippets that exist outside of a BODY element (e.g. a document HEAD), then it will abort, as it currently only supports parsing HTML inside a BODY context.

The last point highlights that the HTML Processor has been developed following the needs of blockBlock Block is the abstract term used to describe units of markup that, composed together, form the content or layout of a webpage using the WordPress editor. The idea combines concepts of what in the past may have achieved with shortcodes, custom HTML, and embed discovery into a single consistent API and user experience.-related code and focused on rules in the HTML specification relating to how tags ought to be interpreted inside a BODY element. Once this section is complete, the others will be added. Thankfully, this is the hardest section by a long shot, and parsing full documents should follow quickly after the primary work is done.

Notes for experimenters.

If you’ve been experimenting with the HTML API and building custom subclasses of the Tag Processor then it’s important to understand two changes: handling of incomplete documents, and special HTML tags with modifiable text.

Incomplete documents.

Previously, when the Tag Processor reached the end of a document and there was an incomplete token (for instance, “<div cl“), it would return false and finish parsing the document. Now that the Tag Processor can scan and visit every token in the document, however, it will indicate if it encountered such a situation. When it does, it will still return false, but it will back up to the beginning of the token and freeze. In a future release, it will be possible to extend the document and continue processing. For now, if paused_at_incomplete_token() returns true, then you can know that there might have been more to the original HTML that was sent into the processor than it received.

Special HTML tags with modifiable text.

The HTML Processor properly tracks document structure and is the appropriate method for determining when an element starts and ends. Many simpler approaches will often seem correct enough for practical use, but these will all break down in common situations. While the Tag Processor makes it easier to estimate structure than regex-based approaches, be cautioned whenever skipping the rules that the HTML Processor implements, as even normative HTML often breaks simple mental models for translating HTML text into DOM structure.

For those who are relying on the Tag Processor to estimate structure, there’s a change in behavior that might break your subclasses: the Tag Processor no longer visits the closing tag for the group of special elements. These are tags like SCRIPT, STYLE, and TITLE. The reason for this change is that these elements cannot contain other tags inside of them. It will often look like they do (for instance, with <title>an <img> is plain text</title>), but the inner content is parsed as text and not as HTML. This change prevents misinterpreting those inner contents as HTML tags.

When the Tag Processor encounters a SCRIPT tag or any of these special elements, it will continue parsing until it finds the associated closing tag and then the inner contents will be available as modifiable text. For algorithms tracking depth in a document, they will not only need to check if the tag is_void(), but also if it’s a special element since the closing tag will no longer be separately visited.

Note that it’s still possible to visit a closing tag for a special element, but only if they are unexpected and come without a corresponding opening tag.


Follow along in the CoreCore Core is the set of software required to run WordPress. The Core Development Team builds WordPress. SlackSlack Slack is a Collaborative Group Chat Platform https://slack.com/. The WordPress community has its own Slack Channel at https://make.wordpress.org/chat/. channel #core-html-api or watch here for updated posts to be part of the conversation driving and developing this API.

Props to @stevenlinx for copy review on this post.

#dev-notes #dev-notes-6-5 #6-5

Hallway Hangout: Let’s chat about what’s next in Gutenberg

There are some big, exciting efforts underway within the GutenbergGutenberg The Gutenberg project is the new Editor Interface for WordPress. The editor improves the process and experience of creating new content, making writing rich content much simpler. It uses ‘blocks’ to add richness rather than shortcodes, custom HTML etc. https://wordpress.org/gutenberg/ project and pluginPlugin A plugin is a piece of software containing a group of functions that can be added to a WordPress website. They can extend functionality or add new features to your WordPress websites. WordPress plugins are written in the PHP programming language and integrate seamlessly with WordPress. These can be free in the WordPress.org Plugin Directory https://wordpress.org/plugins/ or can be cost-based plugin from a third-party that will eventually make their way in some form to a future WordPress release. It’s all WordPress at the end of the day and, in an effort to bring people into the flow of what’s happening in the earlier stages, this hallway hangout seeks to be a snapshot of what’s being worked on to provide broader awareness to more WordPress contributors and get feedback. The hope is that in coming together early before the next betaBeta A pre-release of software that is given out to a large group of users to trial under real conditions. Beta versions have gone through alpha testing in-house and are generally fairly close in look, feel and function to the final product; however, design changes often occur as part of the process. period to talk about different features, we can, as a community, flush out concerns sooner, help more folks get involved, and find ways to work better together. 

Important note: this hallway hangout will likely last for 90 minutes instead of the usual 60 minutes to allow for ample time to demo and discuss. 

How to join

If you’re interested in joining, the Hallway Hangout will happen on 2024-04-24 23:00 . A Zoom link will be shared in the #core SlackSlack Slack is a Collaborative Group Chat Platform https://slack.com/. The WordPress community has its own Slack Channel at https://make.wordpress.org/chat/. channel before starting and all are welcome to join, whether to listen or participate, for as long or as little as you’d like. This will be recorded and recapped. Note that the time for these hallway hangouts are intentionally rotated to allow for different folks to participate in different ones.

If you’re unable to make it but have something to comment on or share, I welcome you to leave feedback in the comments of this post or dive straight into the GitHubGitHub GitHub is a website that offers online implementation of git repositories that can easily be shared, copied and modified by other developers. Public repositories are free to host, private repositories require a paid subscription. GitHub introduced the concept of the ‘pull request’ where code changes done in branches by contributors can be reviewed and discussed before being merged be the repository owner. https://github.com/ issues linked below. This isn’t meant to replace any particular way to get involved but is meant to streamline and offer a more high bandwidth way to connect. 

Agenda

At a high level, the following items are currently on the list to go through but more might be added depending on how the next few weeks take shape. We’ll get through as many of these as we can in the order as shown below, with either demos to go through from figma, from a PR, or via the Gutenberg plugin. @saxonfletcher & @richtabor will help lead these demos:

  • Data views efforts and its relationship to the Adminadmin (and super admin) Redesign.
  • Overrides in synced patterns, including the UXUX User experience and the broader reasoning around naming to unlock an override.
  • Zoomed out view and the experience coming together to focus on patterns rather than granular blockBlock Block is the abstract term used to describe units of markup that, composed together, form the content or layout of a webpage using the WordPress editor. The idea combines concepts of what in the past may have achieved with shortcodes, custom HTML, and embed discovery into a single consistent API and user experience. editing, including Advancing contentOnly editing.
  • Layout improvements, including Grid layout support.
  • Pattern styles, which would offer multiple ways of styling content based on a single palette, and Colors and typeset presets from theme style variations.
  • Style inheritance to help clarify where and why different items are styled as they are. 

There’s obviously more that could be on here but, in an effort to focus on some of the larger, more relevant work, let’s start here. We can always hold more of these in the future! Hope to see you there. 

#gutenberg, #hallway-hangout

Performance Chat Agenda: 9 April 2024

Here is the agenda for this week’s performance team meeting scheduled for Apr 9, 2024 at 15:00 UTC.

  • Announcements
    • Welcome to our new members of #core-performance
    • Plan to launch Performance Lab pluginPlugin A plugin is a piece of software containing a group of functions that can be added to a WordPress website. They can extend functionality or add new features to your WordPress websites. WordPress plugins are written in the PHP programming language and integrate seamlessly with WordPress. These can be free in the WordPress.org Plugin Directory https://wordpress.org/plugins/ or can be cost-based plugin from a third-party version 3.0.0 on Mon April 15
  • Priority items
    • WordPress performance TracTrac An open source project by Edgewall Software that serves as a bug tracker and project management tool for WordPress. tickets
      • Current release (6.6)
      • Future release
    • Performance Lab plugin (and other performance plugins)
      • Open discussion regarding streamlining PL plugin and other standalone plugins #1061
    • Active priority projects
      • INP research opportunities
      • Improve template loading
  • Open floor

If you have any topics you’d like to add to this agenda, please add them in the comments below.


This meeting happens in the #core-performance channel. To join the meeting, you’ll need an account on the Make WordPress Slack.

#agenda, #meeting, #performance, #performance-chat

WordPress 6.5 Field Guide

This guide outlines major developer features and breaking changes in 6.5 and is published in the Release Candidaterelease candidate One of the final stages in the version release cycle, this version signals the potential to be a final release to the public. Also see alpha (beta). cycle to help inform WordPress extending developers, CoreCore Core is the set of software required to run WordPress. The Core Development Team builds WordPress. developers, and others.

In Core TracTrac An open source project by Edgewall Software that serves as a bug tracker and project management tool for WordPress., there are almost 350 tickets: 99 of which are enhancements and feature requests, 216 bug fixes, and 35 other blessed tasks. This time, there are 20 tickets with a focus on performance, 19 for accessibility, and 23 for modernizing code and applying coding standards.

GutenbergGutenberg The Gutenberg project is the new Editor Interface for WordPress. The editor improves the process and experience of creating new content, making writing rich content much simpler. It uses ‘blocks’ to add richness rather than shortcodes, custom HTML etc. https://wordpress.org/gutenberg/ included in this release has 373 enhancements, 515 bugbug A bug is an error or unexpected result. Performance improvements, code optimization, and are considered enhancements, not defects. After feature freeze, only bugs are dealt with, with regressions (adverse changes from the previous version) being the highest priority. fixes, and 65 accessibilityAccessibility Accessibility (commonly shortened to a11y) refers to the design of products, devices, services, or environments for people with disabilities. The concept of accessible design ensures both “direct access” (i.e. unassisted) and “indirect access” meaning compatibility with a person’s assistive technology (for example, computer screen readers). (https://en.wikipedia.org/wiki/Accessibility) improvements.

Changes in 6.5 are spread across 40 Core components. Below is the breakdown of the most important ones.


Table of contents


Principal Changes

Minimum System Requirement

The minimum version of MySQLMySQL MySQL is a relational database management system. A database is a structured collection of data where content, configuration and other options are stored. https://www.mysql.com/. has been raised from v5.0 to v5.5.5. (#60036)

BlockBlock Block is the abstract term used to describe units of markup that, composed together, form the content or layout of a webpage using the WordPress editor. The idea combines concepts of what in the past may have achieved with shortcodes, custom HTML, and embed discovery into a single consistent API and user experience. Editor

A new attribute $variation_callback has been introduced in WP_Block_Type. This limits the ability to modify variations by reference directly as was done previously.

Performance improvements for registering block type variations with callbacks
https://make.wordpress.org/core/2024/02/29/performance-improvements-for-registering-block-variations-with-callbacks/

New Features

Block Editor

WordPress 6.5 brings 10 Gutenberg releases into core – 16.8, 16.9, 17.0, 17.1, 17.2, 17.3, 17.4, 17.5, 17.6, and 17.7. You will find new features, APIs, and various improvements. Highlights include the Interactivity APIAPI An API or Application Programming Interface is a software intermediary that allows programs to interact with each other and share data in limited, clearly defined ways., Font Library, and Block Bindings API.

Interactivity API in 6.5
https://make.wordpress.org/core/2024/03/04/interactivity-api-dev-note/

Font Library
https://make.wordpress.org/core/2024/03/14/new-feature-font-library/

Block Bindings API
https://make.wordpress.org/core/2024/03/06/new-feature-the-block-bindings-api/

Block metadata viewScriptModule field in 6.5
https://make.wordpress.org/core/2024/03/04/block-metadata-viewscriptmodule-field-in-6-5/

Updates to Block Hooks in 6.5
https://make.wordpress.org/core/2024/03/04/updates-to-block-hooks-in-6-5/

Unification of the site and post editors in 6.5
https://make.wordpress.org/core/2024/03/05/unification-of-the-site-and-post-editors-in-6-5/

Miscellaneous Editor changes in WordPress 6.5
hthttps://make.wordpress.org/core/2024/03/09/miscellaneous-editor-changes-in-wordpress-6-5/

HTMLHTML HyperText Markup Language. The semantic scripting language primarily used for outputting content in web browsers. API

WordPress 6.5 brings significant updates to the HTML API. The tagtag A directory in Subversion. WordPress uses tags to store a single snapshot of a version (3.6, 3.6.1, etc.), the common convention of tags in version control systems. (Not to be confused with post tags.) processer has received a major overhaul and a further amount of the HTML specification is now supported. If you have been sub-classing WP_HTML_Tag_Processor, there are some specific changes you should pay attention to.

Updates to the HTML API in 6.5
https://make.wordpress.org/core/2024/03/04/updates-to-the-html-api-in-6-5/

I18Ni18n Internationalization, or the act of writing and preparing code to be fully translatable into other languages. Also see localization. Often written with a lowercase i so it is not confused with a lowercase L or the numeral 1. Often an acquired skill.

The Performant Translations feature plugin has been merged into Core. The new translation system is much faster and uses less memory with the new .l10n.php format; it also continues to support all three existing translationtranslation The process (or result) of changing text, words, and display formatting to support another language. Also see localization, internationalization. formats: .l10n.php, .mo, and .po files. Two new filters translation_file_format and load_translation_file are introduced.

I18N Improvements in 6.5 (Performant Translations)
https://make.wordpress.org/core/2024/02/27/i18n-improvements-6-5-performant-translations/

Media

AVIF support comes to 6.5. AVIF is a modern image format that can be up to 50% smaller than JPEGs while maintaining the same image quality. You can now upload/edit/resize/save AVIF images if supported by your hosting environment. The way you operate on AVIF images remains the same as with other existing image formats. If you run multisitemultisite Used to describe a WordPress installation with a network of multiple blogs, grouped by sites. This installation type has shared users tables, and creates separate database tables for each blog (wp_posts becomes wp_0_posts). See also network, blog, site, there is a FAQ just for you.

WordPress 6.5 adds AVIF support
https://make.wordpress.org/core/2024/02/23/wordpress-6-5-adds-avif-support/

Script Loader

The Script Modules API brings native JavaScriptJavaScript JavaScript or JS is an object-oriented computer programming language commonly used to create interactive effects within web browsers. WordPress makes extensive use of JS for a better user experience. While PHP is executed on the server, JS executes within a user’s browser. https://www.javascript.com/. Module support to 6.5 and provides two modules for use with the WordPress Interactivity API.

It is strongly recommended that developers currently utilizing JavaScript modules in their extensions migrate to the Script Modules API.

Script Modules in 6.5
https://make.wordpress.org/core/2024/03/04/script-modules-in-6-5/

Upgrade/Install

The Plugin Dependencies feature plugin has been merged into Core.

Introducing Plugin Dependencies in WordPress 6.5
https://make.wordpress.org/core/2024/03/05/introducing-plugin-dependencies-in-wordpress-6-5/

Key Info

A pluginPlugin A plugin is a piece of software containing a group of functions that can be added to a WordPress website. They can extend functionality or add new features to your WordPress websites. WordPress plugins are written in the PHP programming language and integrate seamlessly with WordPress. These can be free in the WordPress.org Plugin Directory https://wordpress.org/plugins/ or can be cost-based plugin from a third-party’s dependencies can be declared by using a new Requires Plugins headerHeader The header of your site is typically the first thing people will experience. The masthead or header art located across the top of your page is part of the look and feel of your website. It can influence a visitor’s opinion about your content and you/ your organization’s brand. It may also look different on different screen sizes. in the dependent plugin’s main file. The header must contain a comma-separated list of WordPress.orgWordPress.org The community site where WordPress code is created and shared by the users. This is where you can download the source code for WordPress core, plugins and themes as well as the central location for community conversations and organization. https://wordpress.org/-formatted slugs.

Example:

/**
* Plugin Name: Bridge for Foo and Bar
* Requires Plugins: foo, bar
*/

Dependency slug conditions:

  • Dependent plugins hosted on WordPress.org can only declare dependencies that are also hosted on WordPress.org.
  • Dependent plugins not hosted on WordPress.org can declare dependencies whether hosted on WordPress.org or elsewhere.

Declaring a plugin dependency places the following requirements:

  • Requirements on dependent plugins:
    • Cannot be installed until its dependencies are installed.
    • Cannot be activated until its dependencies are activated.
  • Requirements on dependency plugins:
    • Cannot be deactivated while its dependents are activated.
    • Cannot be deleted while its dependents are installed.

The following features are not currently supported:

  • Version management
  • Must-Use plugins as dependencies
  • Themes that require plugins
  • Automatic deactivation of dependent plugins

A new filterFilter Filters are one of the two types of Hooks https://codex.wordpress.org/Plugin_API/Hooks. They provide a way for functions to modify data of other functions. They are the counterpart to Actions. Unlike Actions, filters are meant to work in an isolated manner, and should never have side effects such as affecting global variables and output. wp_plugin_dependencies_slug has been introduced to allow for alterations to dependency slugs.

A new class WP_Plugin_Dependencies has been introduced with public API methods available.

The UIUI User interface of the plugin row the plugin row has been changed to reflect a plugin’s dependencies/dependents. The UI of dependent plugin cards has been changed to reflect its dependencies, with modal links to install and activate them first.

Automatic redirection from Plugins > Add New is no longer performed upon activation of a plugin.

Props to @cosdev for review.

Additional Changes

External Libraries

The following libraries were updated to the latest versions:

getID3 has been updated to v1.9.23 (#59683)

PHPMailer has been updated to v6.9.1 (#59966)

wordpress/scripts version 17 has dropped official support for unmaintained Node.js versions. The oldest supported Node.js version is now Node.js 18. (Misc Editor Dev Changes)

Miscellaneous Developer Changes

Miscellaneous developer changes in WordPress 6.5
https://make.wordpress.org/core/2024/03/08/miscellaneous-developer-changes-in-wordpress-6-5/

Other Updates

Themes

Classic themes can now opt in to appearance tools support. (#60118)

Media

Control of jpeg progressive image output has been enabled. A new image_save_progressive filter has been added, which controls whether intermediate image sizes are saved in a progressive format (when available). By default, progressive image output is disabled, matching the current behavior. (#21668)

Caddy web server: support pretty permalinks when Caddy web server is detected. (#41877)

Rest APIREST API The REST API is an acronym for the RESTful Application Program Interface (API) that uses HTTP requests to GET, PUT, POST and DELETE data. It is how the front end of an application (think “phone app” or “website”) can communicate with the data store (think “database” or “file system”) https://developer.wordpress.org/rest-api/.

A featured_media field for featured imageFeatured image A featured image is the main image used on your blog archive page and is pulled when the post or page is shared on social media. The image can be used to display in widget areas on your site or in a summary list of posts. (also known as a poster image) has been added to the REST API wp/v2/media attachments endpoint. (#41692)

Site Health

Site ID has been included in the debug data on multisite installations. (#60081)

Upgrade/Install

During bulk upgrades, a theme upgrade is now checked for satisfying the minimum WordPress version or the server PHPPHP The web scripting language in which WordPress is primarily architected. WordPress requires PHP 5.6.20 or higher version. This was previously done for plugins, but not themes. (#59758)

New/Modified HooksHooks In WordPress theme and development, hooks are functions that can be applied to an action or a Filter in WordPress. Actions are functions performed when a certain event occurs in WordPress. Filters allow you to modify certain functions. Arguments used to hook both filters and actions look the same.

For a list of all new and updated Functions/Hooks/Classes/Methods in WP 6.5, please see this page on Developer Resources after the release:
https://developer.wordpress.org/reference/since/6.5.0/

New Filter Hooks

  • new_admin_email_subject (#59250)
  • wp_is_rest_endpoint (#42061)
  • image_save_progressive (#21668)
  • wp_admin_canonical_url (#59545)
  • wp_plugin_dependencies_slug (#22316)
  • hooked_block (#59572)
  • hooked_block_{$block_type} (#59572)
  • get_block_type_variations (#59969)
  • translation_file_format (#59656)
  • load_translation_file (#59656)

Props to @swissspidy for technical review, to @get_dave and @youknowriad for technical review (Editor), to @jorbin for technical/copy review.

#6-5, #field-guide

New Feature: Font Library

Introduced in WordPress 6.5, the Font Library allows users to manage fonts directly in the editor. It comes with a set of APIs that allow developers to control, adapt, and disable its behavior.

Font Collections

A Font Collection is a list of font family definitions that can be installed by the user via the editor. The font family definition is a fontFamily item in theme.json format. By default, WordPress 6.5 allows users to opt-in to a collection listing for Google Fonts. To allow sites to remain GDPR compliant, installing a Google Font downloads the file to the WordPress server.

When a Font Collection is registered, it will appear in the Font Library UIUI User interface in the editor. From here, users can install and activate fonts from the collection.

Adding a Font Collection

A new Font Collection can be added using the wp_register_font_collection() function. This can be done by supplying a list of font families and their font faces in either PHPPHP The web scripting language in which WordPress is primarily architected. WordPress requires PHP 5.6.20 or higher or JSONJSON JSON, or JavaScript Object Notation, is a minimal, readable format for structuring data. It is used primarily to transmit data between a server and web application, as an alternative to XML. format as part of the Font Collection array.

Here is an example of adding a Font Collection in PHP:

$font_families = [
array(
'font_family_settings' => (
array (
'fontFamily' => 'Open Sans, sans-serif',
'slug' => 'open-sans',
'name' => 'Open Sans',
'fontFace' => array (
array (
'fontFamily' => 'Open Sans',
'fontStyle' => 'normal',
'fontWeight' => '300',
'src' => 'https://fonts.gstatic.com/s/opensans/v40/memSYaGs126MiZpBA-UvWbX2vVnXBbObj2OVZyOOSr4dVJWUgsiH0C4iY1M2xLER.woff2',
),
array (
'fontFamily' => 'Open Sans',
'fontStyle' => 'italic',
'fontWeight' => '400',
'src' => 'https://fonts.gstatic.com/s/opensans/v40/memQYaGs126MiZpBA-UFUIcVXSCEkx2cmqvXlWq8tWZ0Pw86hd0Rk8ZkaVIUwaERZjA.woff2'
),
),
)
),
'categories' => [ 'sans-serif' ],
),
array(
'font_family_settings' => (
array (
'fontFamily' => 'Monoton, system-ui',
'slug' => 'monoton',
'name' => 'Monoton',
'fontFace' => array (
array (
'fontFamily' => 'Monoton',
'fontStyle' => 'normal',
'fontWeight' => '400',
'src' => 'https://fonts.gstatic.com/s/monoton/v19/5h1aiZUrOngCibe4fkPBQ2S7FU8.woff2',
'preview' => 'https://s.w.org/images/fonts/17.7/previews/monoton/monoton-400-normal.svg'
),
),
)
),
'categories' => [ 'display' ],
),
array(
'font_family_settings' => (
array (
'fontFamily' => 'Arial, Helvetica, Tahoma, Geneva, sans-serif',
'slug' => 'arial',
'name' => 'Arial',
)
),
'categories' => [ 'sans-serif' ],
),
];

$categories = [
array(
'name' => _x( 'Display', 'Font category name' ),
'slug' => 'display',
),
array(
'name' => _x( 'Sans Serif', 'Font category name' ),
'slug' => 'sans-serif',
),
];

$config = array (
'name' => _x( 'My font collection', 'Font collection name' ),
'description' => _x( 'A collection of my favorite fonts.', 'Font collection description' ),
'font_families' => $font_families,
'categories' => $categories,
);

wp_register_font_collection ( 'my-font-collection', $config );

Please note that the name and description fields of the Font Collection array must be translatable, which can be achieved by wrapping the strings in the _x() function. Font Family names are not typically translated. For more information and background discussion, see #60509.

JSON format for the font_families field can be a local path or a remote URLURL A specific web address of a website or web page on the Internet, such as a website’s URL www.wordpress.org that points to the JSON file.

Removing a Font Collection

A Font Collection can be disabled by using the wp_unregister_font_collection() function. Here is an example which disables the default font collection:

add_action( 'init', function() {
wp_unregister_font_collection( 'default-font-collection' );
} );

For more information, see #57980.

Installing and Activating Fonts

Fonts definitions are based on the theme.json format for font settings. “Installing” a font to the site saves the theme.json formatted settings from the collection into the database, so the font can be activated for any theme.

When the font is “activated,” the Global Styles settings for the theme are updated so that the font is included, along with the fonts defined by the theme, and can be used in the typography settings for Global Styles and individual blocks.

When switching to a new theme, installed fonts need to be re-activated, to update the site’s Global Styles settings for that theme. If Global Styles for a theme are reset, this will deactivate all installed fonts, but they will remain installed on the site and can be reactivated as desired.

Additionally, the Font Library can be used to deactivate fonts included with the theme, if they aren’t needed, to improve the loading performance of the site.

Customizing the Fonts Upload Directory

Please note that some of the following details, such as function names, may change prior to the 6.5 release. For more information, see #60751 and GutenbergGutenberg The Gutenberg project is the new Editor Interface for WordPress. The editor improves the process and experience of creating new content, making writing rich content much simpler. It uses ‘blocks’ to add richness rather than shortcodes, custom HTML etc. https://wordpress.org/gutenberg/ issue #59699.

By default, fonts will be uploaded to the wp-content/fonts directory. However, this location can be customized as required using the font_dir filterFilter Filters are one of the two types of Hooks https://codex.wordpress.org/Plugin_API/Hooks. They provide a way for functions to modify data of other functions. They are the counterpart to Actions. Unlike Actions, filters are meant to work in an isolated manner, and should never have side effects such as affecting global variables and output.. For installations that don’t support modification of the wp-content directory, it is recommended to install the Fonts To Uploads plugin or use the code snippet below.

It is possible to return the location of the fonts upload directory by using wp_get_font_dir().

The example below changes the fonts directory to the WordPress “Uploads” directory (by default, this is wp-content/uploads):

function alter_wp_fonts_dir( $defaults ) {
$wp_upload_dir = wp_get_upload_dir();
$uploads_basedir = $wp_upload_dir['basedir'];
$uploads_baseurl = $wp_upload_dir['baseurl'];

$fonts_dir = $uploads_basedir . '/fonts';
// Generate the URL for the fonts directory from the font dir.
$fonts_url = str_replace( $uploads_basedir, $uploads_baseurl, $fonts_dir );

$defaults['path'] = $fonts_dir;
$defaults['url'] = $fonts_url;

return $defaults;
}
add_filter( 'font_dir', 'alter_wp_fonts_dir' );

When modifying the upload location, it is important to ensure that the chosen location exists and has appropriate read/write permissions set.

Like the wp-content/uploads directory, the fonts upload directory will not adhere to wp_is_file_mod_allowed / DISALLOW_FILE_MODS to prevent font uploads.

For further info, see #59417 and this post.

How to Disable the Font Library

The Font Library is accessible via the editor by default.

Disable the UI

The UI can be disabled using a filter to customize the editor settings:

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

add_filter( 'block_editor_settings_all', 'disable_font_library_ui' );

Disable the REST APIREST API The REST API is an acronym for the RESTful Application Program Interface (API) that uses HTTP requests to GET, PUT, POST and DELETE data. It is how the front end of an application (think “phone app” or “website”) can communicate with the data store (think “database” or “file system”) https://developer.wordpress.org/rest-api/.

The register_post_type_args() filter can be used to disable the wp_font_family and wp_font_face REST API endpoints:

function my_disable_fonts_rest_api_endpoints( $arg, $post_type ) {
if ( 'wp_font_family' === $post_type || 'wp_font_face' === $post_type ) {
$arg['show_in_rest'] = false;
}

return $arg;
}
add_filter( 'register_post_type_args', 'my_disable_fonts_rest_api_endpoints', 10, 2 );

The rest_endpoints filter can be used to disable the font collections APIAPI An API or Application Programming Interface is a software intermediary that allows programs to interact with each other and share data in limited, clearly defined ways. endpoints:

function my_disable_font_collections_rest_api_endpoints( $endpoints ) {
foreach ( $endpoints as $route => $endpoint ){
if ( str_starts_with( $route, '/wp/v2/font-collections' ) ) {
unset( $endpoints[ $route ] );
}
}

return $endpoints;
}
add_filter( 'rest_endpoints', 'my_disable_font_collections_rest_api_endpoints' );

WordPress includes a polyfill for str_starts_with(), so it is safe to run this function in the above code on < PHP 8.0.

This allows extenders to disable the Font Library, while retaining the UI for managing fonts provided by the active theme.

For more info, see #55275 and #57818.

New REST API

The Font Library feature introduces three new REST API endpoints:

For detailed documentation about each of the new endpoints, please refer to the REST API Handbook and #57616.

Props and a massive thank you to everyone who helped put this dev notedev note Each important change in WordPress Core is documented in a developers note, (usually called dev note). Good dev notes generally include a description of the change, the decision that led to this change, and a description of how developers are supposed to work with that change. Dev notes are published on Make/Core blog during the beta phase of WordPress release cycle. Publishing dev notes is particularly important when plugin/theme authors and WordPress developers need to be aware of those changes.In general, all dev notes are compiled into a Field Guide at the beginning of the release candidate phase. together: @mmaattiiaass, @grantmkin, @peterwilsoncc, @youknowriad, @get_dave, @stevenlinx, @leonnugraha.

Update: This dev-note has been modified following a late decision to modify how font files were stored. Please refer to this follow up post on the subject of font file storage.

Update: This dev-note has been modified to update the code examples in the “Disable the REST API” section, as the previous example included the use of unregister_post_type(), which does not work on built-in post types. Please update any references to the previous example.

#6-5, #dev-notes, #dev-notes-6-5

Hallway Hangout: Data Liberation Discussion and Brainstorm

Data Liberation is a major focus for the WordPress Project in 2024 – furthering the mission of Democratizing Publishing by making it easier for people to get their content in and out of WordPress.

This is an exciting area of work, but also very broad. It is important to make sure the initiatives that make up this work are best suited to be impactful and meet the needs of real users. 

Come and join an open discussion on this area of work – and help shape the future of data liberation in WordPress.

In this informal chat we may touch on:

  • Challenges of migrating from third-party platforms to WordPress
  • The good, bad, and ugly of exporting WordPress content
  • The potential of interoperability between BlockBlock Block is the abstract term used to describe units of markup that, composed together, form the content or layout of a webpage using the WordPress editor. The idea combines concepts of what in the past may have achieved with shortcodes, custom HTML, and embed discovery into a single consistent API and user experience. libraries and page builders
  • What work will make data liberation, and who should work on it

Join us on Zoom at Wednesday, April 3, 2024, at 7pm. Add this event to your Calendar.

If you’d like to do some reading in advance I can recommend checking out:

Agenda, Dev Chat, Wednesday April 3, 2024

The next WordPress Developers Chat will take place on  Wednesday April 3, 2024 at 20:00 UTC in the core channel on Make WordPress Slack.

The live meeting will focus on the discussion for upcoming releases, and have an open floor section.

Additional items will be referred to in the various curated agenda sections, as below. If you have ticketticket Created for both bug reports and feature development on the bug tracker. requests for help, please do continue to post details in the comments section at the end of this agenda.

Announcements

WordPress 6.5 “Regina” has been released. Thank you to everyone who worked on, tested, and supported this release 🎉.

Forthcoming releases

Next major releasemajor release A release, identified by the first two numbers (3.6), which is the focus of a full release cycle and feature development. WordPress uses decimaling count for major release versions, so 2.8, 2.9, 3.0, and 3.1 are sequential and comparable in scope.: 6.6

We are officially in the WordPress 6.6 release cycle. @priethor published this WordPress 6.6 Planning Proposal & Call for Volunteers post last week. Please take note of the following callouts on that post:

  • Please leave your feedback about the schedule and release squad size in the comments by April 7th.
  • If you are interested in participating in WordPress 6.6’s release squad as a lead or as a cohort, please show interest in the comments, specifying the role and the type of involvement (lead/cohort).

Next maintenance release: 6.5.1

There is no specific target date for WordPress 6.5.1 yet. However, we can start ensuring that all the correct bugs are targeted for it and that work progresses towards fixing them.

To assist with preparation for 6.5.1, an initial scrub will be held at Thursday, April 4, 2024 at 01:00 PM CDT in the #core slackSlack Slack is a Collaborative Group Chat Platform https://slack.com/. The WordPress community has its own Slack Channel at https://make.wordpress.org/chat/. channel.

@jorbin, Initial Bug Scrub for 6.5.1

Next GutenbergGutenberg The Gutenberg project is the new Editor Interface for WordPress. The editor improves the process and experience of creating new content, making writing rich content much simpler. It uses ‘blocks’ to add richness rather than shortcodes, custom HTML etc. https://wordpress.org/gutenberg/ release: 18.1

Gutenberg 18.1 is scheduled for release on April 10 and will include these issues.

Discussions

This week the discussion will be a follow-up from the WordPress 6.5 release to address any high priority topics that that need to be addressed following the release.

Feel free to suggest additional topics related to this release in the comments.

Highlighted posts

CoreCore Core is the set of software required to run WordPress. The Core Development Team builds WordPress. Editor Updates

Props to @annezazu for putting together these updates.

  • Project managementProviding more clarity in the Gutenberg GitHub Repo recapping some recent efforts to better organize the repo and ensure the high level labels and associated issues folks use to follow work at various scales are as accurate and robust as possible.
  • WordPress 6.6: Check out an early look at what’s on the mind already for 6.6: Block Hooks features for future WP releasesHTML API: Plans for 6.6Interactivity API – Iteration for WP 6.6. Keep in mind that these are meant to act as a container for iterations and will be actively updated as the cycle gets underway. If you want to follow a narrower scope of work for a release, this is the best way to do so.
  • Template extension: Allow extensions to customize the template name in the ‘Add template’ screen to help ease template registration and improve the experience extenders provide to end users when they add a custom template.
  • Styles: Filter out color and typography variations PR is underway, which gives theme authors the ability to create multiple color and typography settings. It does this by filtering out color and typography variations out of the list of style variations so that theme authors can add variations that target only these properties without having to create full variations.
  • Create BlockBlock Block is the abstract term used to describe units of markup that, composed together, form the content or layout of a webpage using the WordPress editor. The idea combines concepts of what in the past may have achieved with shortcodes, custom HTML, and embed discovery into a single consistent API and user experience. Theme PluginPlugin A plugin is a piece of software containing a group of functions that can be added to a WordPress website. They can extend functionality or add new features to your WordPress websites. WordPress plugins are written in the PHP programming language and integrate seamlessly with WordPress. These can be free in the WordPress.org Plugin Directory https://wordpress.org/plugins/ or can be cost-based plugin from a third-party: a community plugin that helps supercharge the Site Editor to create and edit block themes has a few efforts underway including early work to add a theme.json editor and bring creating theme variation to the site editor interface.
  • Design: recent design share has a slightly new format (links to useful design related figma links, issues, etc) to go along with some fresh, in progress designs. This includes the 18 min long walk through of current thinking with the Adminadmin (and super admin) Redesign, thoughts on the UXUX User experience for overrides in synced patterns, improvements to contentOnly experience, and more.
  • Patterns: a draft PR is underway to Merge Patterns & Template parts categories into a single group in the Site Editor > Patterns view allowing for less differentiation and easier access (no longer need to go into “manage all template parts”.  This is done as part of Advancing site editor index views.
  • Design tools: Allow negative values for margin controls has long been requested and is actively being explored in a promising draft PR.

Tickets for assistance

Tickets for 6.6 will be prioritized.
Please include detail of tickets / PR and the links into comments, and if you intend to be available during the meeting if there are any questions or will be async.

Open floor

Items for this can be shared in the comments.

Props to @mikachan for reviewing.

#agenda, #dev-chat

Block metadata viewScriptModule field in 6.5

The BlockBlock Block is the abstract term used to describe units of markup that, composed together, form the content or layout of a webpage using the WordPress editor. The idea combines concepts of what in the past may have achieved with shortcodes, custom HTML, and embed discovery into a single consistent API and user experience. APIAPI An API or Application Programming Interface is a software intermediary that allows programs to interact with each other and share data in limited, clearly defined ways. now recognizes the viewScriptModule field in block.json metadata. This provides an experience for script modules that’s analogous to what scripts and the viewScript field currently provide. The script module declared in viewScriptModule will be enqueued when a block is rendered for viewing on the frontend.

This new field is important so that developers can use script modules on the frontend. Scripts cannot depend on script modules, so script modules are necessary to use script modules like the Interactivity API (via the @wordpress/interactivity script module).

Read more: Block metadata viewScriptModule field in 6.5

This post assumes a basic understanding of the Script Modules API, read more about it here.

Getting started

You can generate a simple block pluginPlugin A plugin is a piece of software containing a group of functions that can be added to a WordPress website. They can extend functionality or add new features to your WordPress websites. WordPress plugins are written in the PHP programming language and integrate seamlessly with WordPress. These can be free in the WordPress.org Plugin Directory https://wordpress.org/plugins/ or can be cost-based plugin from a third-party using the @wordpress/create-block-interactive-template package:

npx @wordpress/create-block --template @wordpress/create-block-interactive-template

This will generate an interactive block from a template that uses viewScriptModule.

Usage

Add a viewScriptModule field to the metadata in block.json that points to the script module.

Here’s what a simple plugin might look like:

myplugin/
├── build/
│ ├── block.json
│ ├── …snip…
│ ├── view.asset.php
│ └── view.js
└── plugin.php

The only code in the plugin.php file calls register_block_type for the block:

add_action( 'init', function() {
register_block_type( __DIR__ . '/build/block.json' );
} );

The relevant metadata in build/block.json includes viewScriptModule:

{
"…snip…": "…",
"viewScriptModule": "file:./view.js"
}

build/view.js is the script module that depends on @wordpress/interactivity:

import { getContext, store } from '@wordpress/interactivity';

store( 'myplugin/demo', {
increment() {
getContext().val += 1;
},
decrement() {
getContext().val -= 1;
},
} );

The module asset file build/view.asset.php declares the view script module’s dependency on @wordpress/interactivity:

<?php return array(
'dependencies' => array('@wordpress/interactivity'),
);

REST APIREST API The REST API is an acronym for the RESTful Application Program Interface (API) that uses HTTP requests to GET, PUT, POST and DELETE data. It is how the front end of an application (think “phone app” or “website”) can communicate with the data store (think “database” or “file system”) https://developer.wordpress.org/rest-api/.

A new field view_script_module_ids has been added to the Block Types REST API. The field is a list of the view script module IDs associated with a block type.

Tooling

The @wordpress/scripts package is the standard way of compiling JavaScriptJavaScript JavaScript or JS is an object-oriented computer programming language commonly used to create interactive effects within web browsers. WordPress makes extensive use of JS for a better user experience. While PHP is executed on the server, JS executes within a user’s browser. https://www.javascript.com/. assets for use in WordPress. Experimental functionality has been added to the build and start scripts to support compiling modules. It can be enabled using --experimental-modules on the command line, for example:

 wp-scripts build --experimental-modules

Script module compilation with @wordpress/scripts does not support using your own webpack file at this time.

The example plugin above was compiled using the experimental module build with @wordpress/scripts.

@wordpress/dependency-extraction-webpack-plugin has been updated to produce script module asset files. No special configuration is required. See the package documentation for details.

Relevant links

Props

#6-5, #dev-notes, #dev-notes-6-5

Performance Chat Agenda: 12 March 2024

Here is the agenda for this week’s performance team meeting scheduled for Mar 12, 2024 at 16:00 UTC.

  • Announcements
    • Welcome to our new members of #core-performance
    • WordPress 6.5 Release Candidaterelease candidate One of the final stages in the version release cycle, this version signals the potential to be a final release to the public. Also see alpha (beta). 2 is today
    • Reminder on timezone difference for the next 3 weeks, this chat will remain at 16:00 UTC
  • Priority items
    • WordPress performance TracTrac An open source project by Edgewall Software that serves as a bug tracker and project management tool for WordPress. tickets
    • Performance Lab pluginPlugin A plugin is a piece of software containing a group of functions that can be added to a WordPress website. They can extend functionality or add new features to your WordPress websites. WordPress plugins are written in the PHP programming language and integrate seamlessly with WordPress. These can be free in the WordPress.org Plugin Directory https://wordpress.org/plugins/ or can be cost-based plugin from a third-party (and other performance plugins)
    • Active priority projects
      • Plugin checker
      • Improve template loading
      • INP opportunities research
  • Open floor

If you have any topics you’d like to add to this agenda, please add them in the comments below.


This meeting happens in the #core-performance channel. To join the meeting, you’ll need an account on the Make WordPress Slack.

#agenda, #meeting, #performance, #performance-chat

WordPress 6.5 release delayed 1 week

Based on community feedback on the Unblocking WP6.5 – Font Library and Synced Pattern Overrides and Font Library follow up posts, there has been a change to the WordPress 6.5 release schedule and a final change to the Font Library. 

The release of WordPress 6.5 will be delayed one week and is now scheduled for release on Tuesday, April 2nd, 2024.

The delay is to accommodate the following:

  • The directory for font storage will be changed to wp-content/uploads/fonts.
  • The Editor team will work on including fixes for a select few high impact bugs that have been identified with the Font Library feature in the upcoming GutenbergGutenberg The Gutenberg project is the new Editor Interface for WordPress. The editor improves the process and experience of creating new content, making writing rich content much simpler. It uses ‘blocks’ to add richness rather than shortcodes, custom HTML etc. https://wordpress.org/gutenberg/ 18.0.0 release. This ensures they will receive some testing before being considered for merge into trunk prior to WordPress 6.5 RC4.
  • An unplanned WordPress 6.5 RC4 is now scheduled for release on 28 March 2024 at 16:00 UTC with the updated font storage location and any other related bugs deemed critical to the release. This will be a normal release candidaterelease candidate One of the final stages in the version release cycle, this version signals the potential to be a final release to the public. Also see alpha (beta)., with the announcement being published on the WordPress.orgWordPress.org The community site where WordPress code is created and shared by the users. This is where you can download the source code for WordPress core, plugins and themes as well as the central location for community conversations and organization. https://wordpress.org/ News blogblog (versus network, site) for extra reach.
  • The 1 week delay allows for ample time for testing, acknowledging that Thursday-Monday is a major holiday for parts of the globe.

Why the change?

This approach ensures that the greatest number of sites possible can benefit from the new Font Library feature without the need to install or configure anything.

While attempting to implement the originally suggested compromise, the sentiment from the trusted contributors involved was that a solution could not be shipped with a level of confidence that meets the standards that core contributorsCore Contributors Core contributors are those who have worked on a release of WordPress, by creating the functions or finding and patching bugs. These contributions are done through Trac. https://core.trac.wordpress.org. hold themselves to in the remaining time before the originally scheduled release.

After evaluating the potential options and discussing the proposed solution, the most risk averse option was determined to be storing fonts in the wp-content/uploads/fonts directory.

Shipping a feature that requires additional configuration or technical knowledge isn’t in line with the guiding philosophies that have helped the project mature into the successful project that exists today. Part of the original post was a call to return back to those project philosophies, and something this change attempts to adhere to.

The Dry run post will be updated to reflect the schedule for the new release date of 2 April.

Post release

Following the 6.5 release, these items detailed in the original post should still be explored:

  • A roadmap will be published outlining where the project components are headed in relation to establishing new first-class concepts outside of previously established paradigms within the software (like breaking down themes into fonts, patterns, templates, etc.). Why was this such an important and impactful decision? What is the goal we are trying to accomplish? And how might it present itself again in the future?
  • A means to move the canonical location of the fonts directory. Should the wp-content directory become writable for a site, a safe path forward should be offered for its owners.
  • Explore whether additional checks should be added to Site Health.

Props to @desrosj, @davidbaumwald,@hellofromtonya, @chanthaboune, @peterwilsoncc, @priethor, @jorbin, @annezazu, @akshayar, & @courane01 for pre-publish review.

#6-5, #core, #release-process