Miscellaneous Core changes for WordPress 6.1

WordPress 6.1 brings a number of 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. and functions, which developers should be aware of.

New functions

is_term_publicly_viewable()

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. component gets counterpart to the is_post_publicly_viewable() in a form of is_term_publicly_viewable() function. It will centralise and reduce the logic needed to validate a term and determine if it’s publicly viewable.

Before:

$term = get_term( $term_id );

if ( ( $term instanceof WP_Term ) && is_taxonomy_viewable( $term->taxonomy ) ) {
    $link = get_term_link( $term_id );
}

After:

if ( is_term_publicly_viewable( $term_id ) ) {
    $link = get_term_link( $term_id );
}

Read more in #56215.

did_filter()

Another counterpart comes to Plugins component: did_filter() retrieves the number of times a 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. has been applied during the current request, bringing parity with did_action().

Read more in #35357.

Function changes

Allow to wrap settings sections with custom HTMLHTML HyperText Markup Language. The semantic scripting language primarily used for outputting content in web browsers. in add_settings_section()

WP 6.1 improves the add_settings_section() function to allow developers to pass extra HTML mark-up to be rendered before and after the settings section. Extra argument $args can now be passed to the function, and is an array that can contain the following items:

  • before_section: HTML content to prepend to the section’s HTML output. Receives the section’s class name provided with the section_class argument via an optional %s placeholder. Default empty.
  • after_section: HTML content to append to the section’s HTML output. Default empty.
  • section_class: The class name to use for the section. Used by before_section if a %s placeholder is present. Default empty.

The HTML passed using these extra arguments is escaped using wp_kses_post() just before rendering. This changeset also provides a set of unit tests for this new feature.

Readme more in #17851.

Cron Component

Add error logging and hooks to wp-cron.php

In #56048 error logging was added to WP-Cron to indicate when an event fails to get rescheduled or unscheduled. The actions cron_reschedule_event_error and cron_unschedule_event_error have been introduced to allow developers to run custom tracking on these errors.

Non blocking wp-cron.php with LSAPI

In #54668 requests to wp-cron.php were made non-blocking for the LSAPI PHPPHP The web scripting language in which WordPress is primarily architected. WordPress requires PHP 5.6.20 or higher implementation. Networknetwork (versus site, blog) requests for wp-cron.php will close prior to the processing of events inline with the behaviour for sites using PHP FPM.

New filters

wp_read_audio_metadata

Next to wp_read_image_metadata (added 15 years ago) and wp_read_video_metadata (added 5 years ago), Media component gets another metadata hook, wp_read_audio_metadata, which will allow filtering data extracted from uploaded audio file. Read more in #55828.

pre_option 

Although a pre_option_{$option} filter already exists, this change adds a more general pre_option filter that will run on every get_option call. This brings the control flow into similar flow as update_option. Read more in #37930.

ajax_term_search_results

Taxonomy component get another addition in ajax_term_search_results hook, which can be used to filter the term search results returned by the AJAX term query. Read more in #55606.

get_header_image

Themes that support 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. Image feature can now modify header image URLURL A specific web address of a website or web page on the Internet, such as a website’s URL www.wordpress.org returned by get_header_image() using the new get_header_image filter. Read more in #56180.

wp_list_table_class_name

As list tables are very widely used by extenders, a new filter wp_list_table_class_name will allow them to modify the list table returned for custom screens. Next to this, the private delegation is removed from the following classes and function:

  • WP_List_Table
  • WP_Application_Passwords_List_Table
  • WP_Comments_List_Table
  • WP_Links_List_Table
  • WP_Media_List_Table
  • WP_MS_Sites_List_Table
  • WP_MS_Themes_List_Table
  • WP_MS_Users_List_Table
  • WP_Plugin_Install_List_Table
  • WP_Plugins_List_Table
  • WP_Post_Comments_List_Table
  • WP_Posts_List_Table
  • WP_Terms_List_Table
  • WP_Theme_Install_List_Table
  • WP_Themes_List_Table
  • WP_Users_List_Table
  • _get_list_table()

Read more in #18449.

lost_password_html_link

On the login page, the “Register” link for new users has been filterable for some time. Now, with lost_password_html_link hook, we have the ability to filter the “Lost your password?” link as well. Read more in #55388.

wp_send_new_user_notification_to_admin and wp_send_new_user_notification_to_user

New filters in Users component allow conditional suppression of the email notifications that are sent when a new user account is registered. Read more in #54874.

Pass $action to nonce_life filter

WP 6.1 contextualizes the usage of nonce_life filter by passing the $action parameter. It allows to alterate the default lifespan of nonces on a case by case basis. Read more in #35188.

New filters for wp_list_authors() and wp_list_users()

The following three filters allow to customize the wp_list_authors() and wp_list_users() output:

  • wp_list_authors_args: Filters the query arguments for the list of all authors of the site.
  • pre_wp_list_authors_post_counts_query: Filters whether to short-circuit performing the query for author post counts. This may be useful to account for custom post types or post statuses.
  • wp_list_users_args: Filters the query arguments for the list of all users of the site.

Read more in #17025.

New set of fine-grained filters for the feed_links() function

The previously available set of filters in the feed_links() function to enable or disable display of various feed links was quite limited:

  • feed_links_show_posts_feed to control the main feed
  • feed_links_show_comments_feed to control both the global comments feed and the comment feed for singular posts.

In order to disable the other feeds (post type archive, categoryCategory The 'category' taxonomy lets you group posts / content together that share a common bond. Categories are pre-defined and broad ranging., 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.), custom taxonomy, author archive, search results), one would have to unhook feed_links_extra() from wp_head, but that would completely remove all of those feeds, as well as the single post comments feed.

To allow for more flexibility, this commit introduces a full set of filters in the feed_links_extra() function to control each one of the feeds independently, including a way to enable/disable the single post comments feed when the global comments feed is disabled/enabled:

  • feed_links_extra_show_post_comments_feed
  • feed_links_extra_show_post_type_archive_feed
  • feed_links_extra_show_category_feed
  • feed_links_extra_show_tag_feed
  • feed_links_extra_show_tax_feed
  • feed_links_extra_show_author_feed
  • feed_links_extra_show_search_feed

All of them default to true, except for feed_links_extra_show_post_comments_feed which defaults to the result of feed_links_show_comments_feed to ensure backward compatibility.

Read more in #55904.

Ability to filter arguments to the_posts_pagination()

A new the_posts_pagination_args filter has been added that allows developers to modify the arguments passed to the_posts_pagination().

A typical case where this new filter can be helpful is creating a child themeChild theme A Child Theme is a customized theme based upon a Parent Theme. It’s considered best practice to create a child theme if you want to modify the CSS of your theme. https://developer.wordpress.org/themes/advanced-topics/child-themes/..  Suppose a template in a parent theme contains something like (such as in Twentyseventeen) :

the_posts_pagination(
    array(
       'prev_text' => parent_theme_get_svg( 'prev' ),
       'next_text' => parent_theme_get_svg( 'next' ),
    )
);

When the author of a child theme wants to use something other than the parent theme’s SVGs for the next/previous links, for example, simple text links so that they can style them similar to other next/previous that are used in the child theme.

Prior to WordPress 6.1, child theme authors needed to copy the parent theme’s template into their child theme and change the arguments passed to the_posts_pagination().

With this new filter, child theme authors can simply do:

add_filter( 'the_posts_pagination_args', 'child_theme_the_posts_pagination_args' );

public function child_theme_the_posts_pagination_args( $args ) {
    $args['prev_text'] = __( 'Previous', 'child-theme' );
    $args['next_text'] = __( 'Next', 'child-theme' );

    return $args;
}

Read more in #53392.

Other changes

New oEmbed provider: Pocket Casts

Pocket Casts is a podcast player with apps for several platforms. The oEmbed 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. provides rich HTML to embed any audio or video episode onto a website. URLs on the pca.st domain can now be embedded automatically.

Read more in #55860.

Thanks to @audrasjb, @pbiron, @johnbillionand @peterwilsoncc for contributing to 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..

#6-1, #dev-notes, #dev-notes-6-1