Miscellaneous Dev Notes for WordPress 6.0

Here are notes to a few further adjustments coming to WordPress 6.0 for developers.

Upgrade/Install

Replace 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 description on the Plugins > Add New Screen

The 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. #55480 introduces the plugin_install_description 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. in the WP_Plugins_Install_List_Table.

This new filter allows developers to modify or replace the description of a plugin on the Plugins > Add New and/or Networknetwork (versus site, blog) Adminadmin (and super admin) > Plugins > Add New screens.

The following example shows how to replace the description of specific plugin:

function wporg_plugin_install_description( $description, $plugin_data ) {
	if ( 'my-plugin' === $plugin_data['slug'] ) {
		$description = esc_html__( 'A new description for My Plugin', 'textdomain' );
	}

	return $description;
}
add_filter( 'plugin_install_description', 'wporg_plugin_install_description', 10, 2 );

For more info see #55480.

Users

Add ability to filter whole notification email in retrieve_password

New WordPress release introduces two 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. to help developers to filter retrieve password emails:

  • send_retrieve_password_email can be used to filter whether to send the retrieve password email;
  • retrieve_password_notification_email can be used to filter the contents of the reset password notification email sent to the user.

For consistency with some similar filters like send_password_change_email or send_email_change_email, and for more flexibility, pass $user_login and $user_data parameters directly to the new send_retrieve_password_email and retrieve_password_notification_email filters.

apply_filters( 'send_retrieve_password_email', true, $user_login, $user_data );
apply_filters( 'retrieve_password_notification_email', $defaults, $key, $user_login, $user_data );

For more info see #54690.

Toolbar

Site icons in the toolbar My Sites menu

In large 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 networks, the site icons added to the toolbar navigation in WordPress 5.8 could make pages load significantly slower. To remove these icons, use the wp_admin_bar_show_site_icons filter.

add_filter( 'wp_admin_bar_show_site_icons', '__return_false' );

Without using the filter, these icons now include lazy loading when it is enabled for images. The loading attribute can be removed if it does not fit a site specifically in this context.

function wporg_disable_toolbar_image_lazy_loading( $default, $tag_name, $context ) {
    if ( 'img' === $tag_name && 'site_icon_in_toolbar' === $context ) {
        return false;
    }
    return $default;
}
add_filter( 'wp_lazy_loading_enabled', 'wporg_disable_toolbar_image_lazy_loading', 10, 3 );

For more info see #54447.

#6-0, #dev-notes, #dev-notes-6-0