Introducing the streaming block parser in WordPress 6.9

WordPress 6.9 introduces the WP_Block_Processor class โ€” a new tool inspired by 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. and designed for efficiently scanning, understanding, and modifying 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. structure in HTML documents.

Continue on to learn about this new class, its use-cases, and how you can take advantage of it for more efficient server-side processing.

Continue reading โ†’

#6-9, #block-api, #dev-notes, #dev-notes-6-9

URL-escaping functions can support HTTPS as the default protocol in WordPress 6.9

When a string passed to the esc_url() and esc_url_raw() functions does not include a protocol (https://, http://, etc.), WordPress will prepend http:// to the URLURL A specific web address of a website or web page on the Internet, such as a websiteโ€™s URL www.wordpress.org string before further processing and returning it. This is a reasonable fallback behavior, but there is currently no way to override the default protocol with another (such as https:// for social media profiles).

Starting in WordPress 6.9, the esc_url() and esc_url_raw() functions will now prepend https:// to the URL if it does not already contain a scheme and the first item in the $protocols array is 'https'. The current behavior (prepending http://) will continue when any other value is listed first within the $protocols array.

<?php
/*
 * Recommended approach for defaulting to 'https' while maintaining
 * backward compatibility.
 * 
 * Example: no protocol with $protocols and 'https' first.
 *
 * Output:
 * - WordPress >= 6.9: 'https://profiles.wordpress.org'
 * - WordPress  < 6.9: 'http://profiles.wordpress.org'
 */
echo esc_url( 'profiles.wordpress.org', array( 'https', 'http' ) );

By including 'https' first and then 'http' in the array:

  • WordPress 6.9 would prepend https:// to an incomplete URL.
  • Older WordPress versions would continue to prepend http://, which remains the default scheme when the $protocols argument is not defined. If the array only contains 'https', esc_url() would return an empty string because http is not included in the list of valid protocols.

Additional examples of output include:

<?php
/*
 * Example 1: no protocol included in $url.
 * 
 * Output:
 * - WordPress >= 6.9: 'http://profiles.wordpress.org'
 * - WordPress  < 6.9: 'http://profiles.wordpress.org'
 */
echo esc_url( 'profiles.wordpress.org' );

/*
 * Example 2: 'http' protocol included in $url.
 *
 * Output:
 * - WordPress >= 6.9: 'http://profiles.wordpress.org'
 * - WordPress  < 6.9: 'http://profiles.wordpress.org'
 */
echo esc_url( 'http://profiles.wordpress.org' );

/*
 * Example 3: 'https' protocol included in $url.
 *
 * Output:
 * - WordPress >= 6.9: 'https://profiles.wordpress.org'
 * - WordPress  < 6.9: 'https://profiles.wordpress.org'
 */
echo esc_url( 'https://profiles.wordpress.org' );

/*
 * Example 4: no protocol with $protocols and 'http' first.
 *
 * Output:
 * - WordPress >= 6.9: 'http://profiles.wordpress.org'
 * - WordPress  < 6.9: 'http://profiles.wordpress.org'
 */
echo esc_url( 'profiles.wordpress.org', array( 'http', 'https' ) );
       
/*
 * Example 5: no protocol in $url with $protocols and no 'http'.
 *
 * Output:
 * - WordPress >= 6.9: 'https://profiles.wordpress.org'
 * - WordPress  < 6.9: ''
 *
 * Note: if 'http' is not included in the $protocols array,
 * the fully escaped URL will not pass the final check that
 * a valid, allowed protocol is included.
 */
echo esc_url( 'profiles.wordpress.org', array( 'https' ) );
             
/*
 * Example 6: protocol within $url missing within $protocols.
 *
 * Output for all:
 * - WordPress >= 6.9: ''
 * - WordPress  < 6.9: ''
 *
 * Note: if 'http' is not included in the $protocols array,
 * the fully escaped URL will not pass the final check that
 * a valid, allowed protocol is included.
 */
echo esc_url( 'https://profiles.wordpress.org', array( 'http' ) );
echo esc_url( 'http://profiles.wordpress.org', array( 'https' ) );
echo esc_url( 'mailto:indana@jon.es', array( 'https', 'http' ) );

For more information, refer to #52886.


Props to @desrosj for co-authoring the note, writing the code examples and expanding on details. Props to @jorbin for review.

#6-9, #dev-notes, #dev-notes-6-9

Dev Chat Agenda โ€“ November 19, 2025

The next WordPress Developers Chat will take place on Wednesday, November 19, 2025, at 15: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.

The various curated agenda sections below refer to additional items. If you haveย ticketticket Created for both bug reports and feature development on the bug tracker.ย requests for help, please continue to post details in the comments section at the end of this agenda or bring them up during the dev chat.

Announcements ๐Ÿ“ข

WordPress 6.9ย 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 now available!

WordPress 6.9 Release Candidate 2 is now available for download and testing.
Further information you can find here.

WordPress 6.9 Dev Notesdev 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.

For more detailed information, see the following WordPress 6.9 Dev Notes:

Forthcoming releases ๐Ÿš€

WordPress 6.9 Timeline

WordPress 6.9ย is planned forย December 2, 2025. Release Candidate 3 is planned forย November 25.

Call for Testingย 

The Test Team invitesย testing and feedbackย on the following upcomingย 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 features:

Discussions ๐Ÿ’ฌ

The discussion section of the agenda is for discussing important topics affecting the upcoming release or larger initiatives that impact the CoreCore Core is the set of software required to run WordPress. The Core Development Team builds WordPress. Team. To nominate a topic for discussion, please leave a comment on this agenda with a summary of the topic, any relevant links that will help people get context for the discussion, and what kind of feedback you are looking for from others participating in the discussion.

Core block selection process

@elrae raises the question of how decisions on new Core blocks are made and how relevance and prioritization are determined (e.g., Math block, โ€œMarqueeโ€ in Issue 71026).

Open floor ย ๐ŸŽ™๏ธ

Any topic can be raised for discussion in the comments, as well as requests for assistance on tickets. Tickets in the milestone for the next major or maintenance release will be prioritized.

Please include details of tickets / PRs and the links in the comments, and indicate whether you intend to be available during the meeting for discussion or will be async.

#6-9, #agenda, #core, #dev-chat

More-reliable email in WordPress 6.9

Emails sent from WordPress will be more reliable in WordPress 6.9 thanks to a few updates and 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 to the wp_mail() function.

The sender address is extensibly configured.

The sender address, also known as the Envelope-From, the MAIL FROM, the Return-Path (and even more), is the address where other email servers send โ€œbounce messagesโ€ when they canโ€™t deliver a message. Since WordPress 4.7.0 this value was being set by the outgoing mail server and would often end up misconfigured1. That doesnโ€™t sound like it should be a big problem โ€” a site may not receive those notifications from failed delivery โ€” but itโ€™s a bigger problem because of the Sender Policy Framework (SPF) and DMARC systems which help prevent the transmission of spam. They reject these emails entirely.

Thanks to the change in [61010], WordPress 6.9 sets the sender address in an extensibleExtensible This is the ability to add additional functionality to the code. Plugins extend the WordPress core software. way:

  • If a From email 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. is present it uses the From address. Otherwise it defaults to wordpress@home_url(), where home_url() is โ€œthe URLURL A specific web address of a website or web page on the Internet, such as a websiteโ€™s URL www.wordpress.org for the current site where the front end is accessible.โ€
  • Plugins can then 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. the sender address via the wp_mail_from filter in the case the inferred or default address is incorrect2.

For those with custom email configurations it may be necessary to hook into the wp_mail_from filter. If your site was relying on 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. to work around this issue before, or you relied on the phpmailer_init filter to do so, you may no longer need to do that. Otherwise, without any effort on your part, WordPress 6.9 should become more reliable out-of-the-box at sending emails.

The Encoding headers are protected between calls.

wp_mail() calls a $phpmailer global object to actually send emails, meaning that certain state is shared between calls for a given PHPPHP The web scripting language in which WordPress is primarily architected. WordPress requires PHP 7.4 or higher request. Internal logic in the PHPMailer class looks for certain factors in a message that it uses to set or change the Encoding headers in outbound emails. Because this object is global, those encoding changes persisted and, in some cases, would apply to successive emails and cause problems when trying to read them.

In [61131] the internal encoding is reset before sending emails so that PHPMailer sends the appropriate encoding type for each email, based solely on the server configuration and specifics in that message.

Multipart messages are assigned the proper Content-Type.

For the past seventeen years there was a lurking bug in how WordPress interacts with PHPMailer for multipart messages. Ironically, the bug was introduced in a patchpatch A special text file that describes changes to code, by identifying the files and lines which are added, removed, and altered. It may also be referred to as a diff. A patch can be applied to a codebase for testing. meant to address this specific case, but an oversight left WordPress sending a corrupted ContentType to PHPMailer. In these cases, PHPMailer would further corrupt the outbound message because of this 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. content type. In rare cases this led to a duplicate Content-Type header, but the normative expression was corrupting the multipart boundaries.

This complicated interaction is resolved in [61201] which simplifies the previous fix by relying on PHPMailerโ€™s facilities for setting the content type rather than attempting (erroneously) to manually specify that header.

Acknowledgements

Props to @jorbin, @sirlouen, @stankea, and @westonruter for reviewing this post, and to @websupporter and @stankea for providing expertise knowledge on the interactions of the sender address and SPF/DMARC/DKIM.

  1. Many mail servers auto-generate a sender address from the system user running on the server and the local server hostname, such as www@node-14-dc3.example.com. โ†ฉ๏ธŽ
  2. This could be the case for sites with more advanced email setups, particularly those which send emails from a subdomain or different domain than on which the site is hosted. โ†ฉ๏ธŽ

#6-9, #dev-notes, #dev-notes-6-9, #email

Modernizing UTF-8 support in WordPress 6.9

A number of changes in WordPress 6.9 are coming which modernize WordPressโ€™ text encoding and UTF-8 handling. These improvements establish more reliable and consistent text processing across WordPressโ€™ widely-supported environments, benefiting plugins and themes that handle international content, emoji, diacritics, and more.

TL;DR

  • UTF-8 handling in WordPress no longer depends on the running environment thanks to a new fallback pipeline written in pure PHPPHP The web scripting language in which WordPress is primarily architected. WordPress requires PHP 7.4 or higher. This means that code which works on your development server will work everywhere itโ€™s deployedDeploy Launching code from a local development environment to the production web server, so that it's available to visitors..
  • Some legacy functions are misleading in their design and are difficult to use properly; these have been deprecated and replaced by more specific and purpose-built alternatives.
    • Prefer wp_is_valid_utf8() instead of seems_utf8().
    • Prefer wp_scrub_utf8() instead of wp_check_invalid_utf8().
    • Prefer mb_convert_encoding() instead of utf8_encode() and utf8_decode().

While humbler than some of the other exciting features in this release, this overhaul of UTF-8 support reflects WordPressโ€™ commitment to a stable and trustworthy internationalized experience.

Read on to learn more about these changes and how to avoid common mistakes and misunderstandings around strings and text.

Continue reading โ†’

#6-9, #dev-notes, #dev-notes-6-9, #formatting, #utf8

WordPress 6.9 Frontend Performance Field Guide

This post is the latest in a series of updates focused on the performance improvements of major releases (see 6.8, 6.7, 6.6, 6.5, 6.4, 6.3, and 6.2).

WordPress 6.9 is the second and final 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. of 2025. It includes numerous improvements to the performance of loading pages on the frontend:

  • Scripts: improve script loading performance by adding support for fetchpriority, printing script modules in the footer, and optimizing the emoji detection script.
  • Styles: optimize loading of stylesheets by loading 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. styles on demand in classic themes, omitting styles for hidden blocks, increasing the inline style limit from 20K to 40K, and inlining minified stylesheets in block themes.
  • Introduce the template enhancementenhancement Enhancements are simple improvements to WordPress, such as the addition of a hook, a new feature, or an improvement to an existing feature. output buffer to implement optimizations previously impossible (such as the aforementioned on-demand style loading in classic themes).
  • More: spawn WP Cron at shutdown, eliminate layout shifts in the Video block, fix RSS feedRSS Feed RSS is an acronym for Real Simple Syndication which is a type of web feed which allows users to access updates to online content in a standardized, computer-readable format. This is the feed. caching, and so on.

The performance changes in this release include 38 Trac tickets (26 enhancements, 11 defects, 1 task) and 31 Gutenberg PRs, although this post does not describe improvements to the performance of the editor nor the database query and caching optimizations. This post highlights the key changes to the frontend for site visitors, as well as looking at their impact in terms of web vitals metrics, such as TTFB, FCP, and LCP.

Continue reading โ†’

#6-9, #core, #core-performance, #css, #dev-notes, #dev-notes-6-9, #javascript, #performance

Consistent Cache Keys for Query Groups in WordPress 6.9

Query caches have historically used the last changed timestamp as a salt. While this has proven effective for most sites, it leads to an excessive number of caches which can be problematic on high-traffic and heavily updated sites. WordPress 6.9 introduces changes to how cache keys are created in order to ensure efficient use of object caches and help caches clean up after themselves.

These changes are compatible with existing implementations of persistent caching drop-ins. Vendors are not required to make any changes to their code to support these features in WordPress 6.9. As with other caching functions, the functions are pluggable should vendors wish to optimize for their particular caching implementation. These new functions are:

  • wp_cache_get_salted( string $cache_key, string $group, string|string[] $salt ): mixed
  • wp_cache_set_salted( string $cache_key, mixed $data, string $group, string|string[] $salt, int $expire = 0 ): bool
  • wp_cache_get_multiple_salted( string[] $cache_keys, string $group, string|string[] $salt ): mixed[]
  • wp_cache_set_multiple_salted( mixed[] $data, string $group, string|string[] $salt, int $expire = 0 ): bool[]

What Behavior is Changing

Previous behavior in WordPress 6.8 and earlier:

  • A post object is saved
  • WordPress stores the last changed time of the posts table
  • WP Query is called
  • WordPress caches the database query using a key containing the last changed time
  • Another post is saved, updating the posts tableโ€™s last changed time
  • The previous cache becomes unreachable
  • WP Query is called
  • WordPress does not see a cached query
  • WordPress caches the database query using a new key containing the updated last changed time

New behavior in WordPress 6.9

  • A post object is saved
  • WordPress stores the last changed time of the posts table
  • WP Query is called
  • WordPress caches the database query alongside the last changed time
  • Another post is saved, updating the posts tableโ€™s last changed time
  • WP Query is called
  • WordPress hits the previously generated cache
  • WordPress uses the last changed value to determine if the cache is up-to-date
  • WordPress replaces the previously generated cache with the new results

While both operations perform two cache lookups, the new behavior re-uses the existing cache key and does an in memory comparison of the last changed time. This prevents the cache from containing unreachable cache keys.

The same change in behavior applies to other Query classes such as term queries, comment queries, user queries, etc.

Checking/setting query caches directly

Broadly, the caches affected are in the following cache groups:

  • comment-queries
  • network-queries
  • post-queries
  • site-queries
  • term-queries
  • user-queries
The following specific cache keys are affected and will now be different.ย  If you have been directly checking or setting caches that start with the following keys, you will need to adjust your code.
  • get_comments
  • get_comment_child_ids
  • get_network_ids
  • comment_feed
  • wp_query
  • get_sites
  • wp_get_archives
  • adjacent_post
  • get_page_by_path
  • find_post_by_old_slug
  • get_objects_in_term
  • count_user_postscount_user_posts

Additionally, keys that are generated by WP_User_Query:generate_cache_key and WP_Term_Query::generate_cache_key are affected as well. However, these keys are md5 hashes and thus are less likely to be used directly.

When using the new wp_cache_*_salted functions and passing in an array of salts, the order of items in the array must be consistent. If you are using the changed caches in coreCore Core is the set of software required to run WordPress. The Core Development Team builds WordPress., please review the order in core and use the same order to ensure cache hits.ย 

If you need to support multiple versions of WordPress when updating your code, you can use code that looks similar to:

if (function_exists( 'wp_cache_get_salted` ) ){
ย ย $data = wp_cache_get_salted( $cache_key, 'comment-queries', $last_changed );
} else {
ย ย // your current code here
}

See [60697] for specific examples of how core has been updated and [60941] for an example of how these new functions help cache previously uncached code.ย 

On Upgrade to WordPress 6.9

With the update to cache keys, itโ€™s expected that you may see a short term increase in cache misses upon upgrade. You may wish to preemptively evict the old cache keys in order to prevent stale entries from sticking around, potentially leading to unnecessary evictions based on your cache policies.

For more information, please see #59592.

Props to @desrosj,ย  @peterwilsoncc, and @spacedmonkey for review. Props to @spacedmonkey for comments on the ticketticket Created for both bug reports and feature development on the bug tracker. that could be easily reused here.

#6-9, #cache-api, #dev-notes, #dev-notes-6-9

Miscellaneous Developer-focused Changes in 6.9

In WordPress 6.9, a handful of small, developer-focused changes were made that deserve to be called out. Letโ€™s take a look!

PHPPHP The web scripting language in which WordPress is primarily architected. WordPress requires PHP 7.4 or higher 8.5 New Function Polyfills

The upcoming 8.5 release of PHP includes 2 new functions that can be used to retrieve values from an array:

To encourage more modern PHP practices, polyfills of these functions have been added to WordPress CoreCore Core is the set of software required to run WordPress. The Core Development Team builds WordPress. so that they can be used safely without needing to include function_exists() checks.

For more information, see #63853.

Improved Feed Caching on 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 Installs

When RSS feeds are fetched using fetch_feed(), they are currently cached using the (get|set|delete)_transient() functions. On multisite installs, single site transients cannot be shared between sites, but site transients managed through (get|set|delete)_site_transient() can.

In WordPress 6.9, fetch_feed() will now store feeds as site transients instead. This allows a feed to be fetched and stored once for all sites on a multisite install, which improves the overall performance of feeds and reduces the amount of data cached in the database (or persistent object cache, if configured). One example where this is beneficial is the WordPress News blogblog (versus network, site) feed, which is fetched and displayed in a widgetWidget A WordPress Widget is a small block that performs a specific function. You can add these widgets in sidebars also known as widget-ready areas on your web page. WordPress widgets were originally created to provide a simple and easy-to-use way of giving design and structure control of the WordPress theme to the user. on the dashboard for every user.

See #63719 for more details.

External Library Updates

The following external libraries bundled in WordPress are being updated in the 6.9 release:

  • ID3 has been updated to include two changes from the upstream repository that address PHP 8.5 compatibility issues (see #64051). Once a new version containing these two changes has officially been tagged, the library will be updated in full (see #64253).
  • PHPMailer has been updated from 6.9.1 to 6.11.1 (see #63811, #64052, #64055).
  • SimplePie has been updated from 1.8.0 to 1.9.0 (see #63717, #63961).
  • Sodium Compat has been updated from 1.21.1 to 1.23.0 (see #64008, #64079).

New Classic Themes Template for TaxonomyTaxonomy A taxonomy is a way to group things together. In WordPress, some common taxonomies are category, link, tag, or post format. https://codex.wordpress.org/Taxonomies#Default_Taxonomies. Terms

In classic themes, you can now use term IDs when creating taxonomy templates. With taxonomy-$taxonomy-{$term->term_id}.php templates, you donโ€™t need to worry about templates breaking if you rename the Oakland Athletics term to Athletics the way you do if you use slug based template names.ย 

See #35326 for more information.

Better Handling of Transparent PNGs

WordPress 6.8 introduced a regressionregression A software bug that breaks or degrades something that previously worked. Regressions are often treated as critical bugs or blockers. Recent regressions may be given higher priorities. A "3.6 regression" would be a bug in 3.6 that worked as intended in 3.5. that could degrade the quality of PNG images with transparency when processed with Imagick. This was fixed in [60667] by improving the detection of the various types of transparent PNG files and handles them each appropriately.

See #63448 for more information.

New 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.

WordPress 6.9 will see 21 new action and 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. hooks added. Some will be detailed in a separate developer note, but theyโ€™re all listed below for easy reference.

New Action Hooks

There are 8 new action hooks being introduced in 6.9:ย 

New Filter Hooks

There are 13 new filters being introduced in 6.9:

A Final Farewell to Flash

While Flash was officially retired at the end of 2020, there were a few artifacts remaining within WordPress in the form of SWFObject and SWFUpload. These were removed in [60281] and will no longer ship in new versions of WordPress going forward.

For more information, see #52699 on TracTrac An open source project by Edgewall Software that serves as a bug tracker and project management tool for WordPress..

Props @adamsilverstein for helping to draft the post, and @jorbin for peer-review.

#6-9, #dev-notes, #dev-notes-6-9

X-post: A Month in Core โ€“ October 2025

X-comment from +make.wordpress.org/updates: Comment on A Month in Core โ€“ October 2025

Notes feature in WordPress 6.9

WordPress 6.9 introduces Notes, a new feature that allows you to leave contextual feedback at 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. level. With notes your team can stay aligned, track changes, and turn feedback into action all in one place. Notes can be resolved, and notes and their replies can be edited or deleted.

Who can use notes?

Because notes can only be created or viewed within the post editor, users must have the edit_post capabilitycapability Aย capabilityย is permission to perform one or more types of task. Checking if a user has a capability is performed by the current_user_can function. Each user of a WordPress site might have some permissions but not others, depending on theirย role. For example, users who have the Author role usually have permission to edit their own posts (the โ€œedit_postsโ€ capability), but not permission to edit other usersโ€™ posts (the โ€œedit_others_postsโ€ capability). for that post. By default, this means that:

  • Administrators and Editors can view all notes on all posts.
  • Authors and Contributors can view all notes for posts that they have authored.
  • Subscribers cannot view any notes.

Enabling notes for custom post types

Notes are enabled by default for the post and page built-in post types, but they can be enabled for any custom post typeCustom Post Type WordPress can hold and display many different types of content. A single item of such a content is generally called a post, although post is also a specific post type. Custom Post Types gives your site the ability to have templated posts, to simplify the concept.. When you control the register_post_type() call, this is the preferred way to register support for Notes:

register_post_type( 'book', array(
	'label' => 'Books',
	'public' => true,
	'show_in_rest' => true,
	'supports' => array(
		'title',
		'editor' => array( 'notes' => true ),
		'author',
	),
) );

When the custom post type is registered through 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., support for Notes can be added by registering support using the following code snippet:

function custom_add_post_type_support() {
	$supports        = get_all_post_type_supports( 'my-post-type' );
	$editor_supports = array( 'notes' => true );

	// `add_post_type_support()` overwrites feature sub-properties, 
	// so they must be explicitly merged. 
	// See https://core.trac.wordpress.org/ticket/64156.
	if ( 
		is_array( $supports['editor'] ) && 
		isset( $supports['editor'][0] ) && 
		is_array( $supports['editor'][0] ) 
	) {
		$editor_supports = array_merge( $editor_supports, $supports['editor'][0] );
	}
	add_post_type_support( 'my-post-type', 'editor', $editor_supports );
}
add_action( 'init', 'custom_add_post_type_support' );

Since notes is a sub-feature of the editor, the code needs to manually merge the notes setting with other editor attributes. Work is underway in https://core.trac.wordpress.org/ticket/64156 to make this easier. Once this 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. is fixed, adding support will be simplified:

add_post_type_support( 'my-post-type', 'editor', array(
ย ย ย ย 'notes' => true,
) );

Accessing notes programmatically

Under the hood, Notes are WP_Comments stored in the comments table, and the standard comments APIs can be used to access them by specifying a comment_type ofย  note.ย 

For example, this will retrieve all notes for a given post ID:

$notes = get_comments( 
	array(
		'post_id' => $post_id,
		'type'    => 'note',
	)
);

Notes can also be retrieved using 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/:

$request = new WP_REST_Request( 'GET', '/wp/v2/comments' );
$request->set_param( 'post', $post_id );
$request->set_param( 'type', 'note' );
$response = rest_get_server()->dispatch( $request );
if ( ! is_wp_error( $response ) ) {
	$notes = $response->get_data();
	foreach ( $notes as $note ) {
		// Process each note as needed
	}
}

Note status

When a note is added to a block, it:

  • Starts in an โ€œOpenโ€ state with a comment_status of 0 (aka hold).ย 
  • When resolved, changes to a comment_status of 1 (aka approve).
  • When deleted, changes to a status of trash, unless EMPTY_TRASH_DAYS is 0 in which case deleted immediately.

The following snippet will get a list of all unresolved Notes for a given post:

$notes = get_comments( 
	array(
		'post_id' => $post_id,
		'type'    => 'note',
		'status'  => 'hold'
	)
);

Important: Notes must be explicitly requested by specifying either the note or all comment type. Otherwise they are excluded when retrieving comments:

// This only returns comments, 'notes' are automatically excluded.
$comments = get_comments( array ( 'post_id' => $post_id ) );

Notification emails

When another user adds a note to a post, the post_author will receive a notification that a note has been added to the post. Notifications are enabled by default and can be controlled at a site level under Settings->Discussions โ€“ Email me whenever > Anyone posts a note. Developers can also use the existing comment filters to control notifications.ย 

For example, to send notifications for notes on pages but not posts, use this snippet:

function only_notify_page_authors_of_notes( $notify, $comment_id ) {
	if ( 'note' !== get_comment_type( $comment_id ) {
		return $notify;
	}

	if ( 'page' === get_post_type( $comment_post_ID ) {
		return true;
	}

	return false;
}
add_filter( 'notify_post_author', 'only_notify_page_authors_of_notes', 10, 2 );

Miscellaneous

Notes permissions

As previously mentioned, only users who can edit a given post are able to add notes. Because notes are an internal/authorized user feature, the normal restrictions that apply to comment posting do not apply to notes, including the flood protection and duplicate prevention. In addition, the pre_comment_approved 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. is not run for notes.

Linking blocks to notes

Top level notes are linked to blocks with a metadata attribute. . When you add a new note to a block, the note ID is stored in block attributes metadata as noteId. Replies are linked to top level notes as children (with their parent set to the top level note)

To get the note ID from a block based on its clientId, you can use this code:

const attributes = getBlockAttributes( clientId );
const noteId     = attributes.metadata?.noteId;

Important: The reverse is not true โ€“ notes do not contain a link back to their associated block. To identify the block(s) associated with a note, search the blocks for the noteId in metadata. You can use this code snippet:

import { store as blockEditorStore } from '@wordpress/block-editor';

const { getBlockAttributes } = useSelect( blockEditorStore );

const { clientIds } = useSelect( ( select ) => {
	const { getClientIdsWithDescendants } = select( blockEditorStore );
	return {
		clientIds: getClientIdsWithDescendants(),
	};
}, [] );

// expectedNoteId is the note we are filtering for.
const blocksWithNote = clientIds.reduce( ( results, clientId ) => {
	const commentId = getBlockAttributes( clientId )?.metadata?.noteId;
	if ( commentId === expectedNoteId ) {
		results[ clientId ] = commentId;
	}
	return results;
}, {} );

Known limitations

  • A note can be associated with more than one block. If a block with a note is split or duplicated, the note becomes associated with both blocks. This is primarily due to an underlying limitation in 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/ that will be fixed in #29693.
  • A notification is sent for each new non-author note which may not be ideal for all users, especially for cases where a high volume of notes are added to a post will in turn generate a high volume of emails to the post author.
  • Notes do not work outside post content types, for example in templates.
  • All notes are block level, for example this means that they can not reference specific text within a paragraph or text across paragraph blocks.ย  In-line notes will become available as part of #59445.

Whatโ€™s next

There are already new features and enhancements planned for Notes in the next release of WordPress (7.0). These features were suggested during the development cycle, but didnโ€™t make it into the 6.9 release.

  • Fragment notes โ€“ the ability to leave a note on a part of a block or across blocks.
  • โ€œ@โ€ mentions โ€“ mention another user in a post and they will receive a notification.
  • Improved notifications โ€“ control frequency for notifications, for example receive a daily digest of all new note activity.
  • Improved floating layout for wide screens โ€“ shift the floating to sit between the editor frame and the sidebarSidebar A sidebar in WordPress is referred to a widget-ready area used by WordPress themes to display information that is not a part of the main content. It is not always a vertical column on the side. It can be a horizontal rectangle below or above the content area, footer, header, or any where in the theme..
  • Minified mode โ€“ notes display as icons with avatars beside blocks that expand when clicked..
  • Wider availability across the editor including using notes with templates.
  • Real time collaboration with Notes.

You can follow along and contribute to the ongoing effort on the Notes iteration for 7.0 tracking issue.

Have an idea for how to improve Notes? Leave your feedback as a comment below or on the tracking issue linked above.

Props to @jeffpaul, @mamaduka, @wildworks, @annezazu, and @desrosj for review.

#6-9, #core, #dev-notes, #dev-notes-6-9, #notes