A Field Guide to WordPress 4.6

Field Guide to WordPress 4.6

With the final beta (WordPress 4.6 beta 4) released just a few days ago and the release candidate scheduled for this week, the release of WordPress 4.6 is closing in on us. For the same course, the core development team released a field guide to WordPress 4.6 in the official website of the team, make.blog on July 26, 2016. The guide, posted by Aaron Jorbin, lays down the major changes that will be seen in the upcoming major release. Since most of the improvements made in this version are under-the-hood improvements, the guide highlights the some of the fundamental changes. Jorbin strongly suggests users to test their plugins, themes, and sites with WordPress 4.6 before the release so that they don’t have to face unanticipated issues later.

Below are some of the new features of WordPress 4.6. Some of the new features have already been covered in our previous article “What New Features are in WordPress 4.6?”. We will not be re-highlighting them in this post. You can read the original Field Guide to WordPress 4.6 in make.blog.

Persistent Comment Cache

Since WordPress 2.6, the comments API has purposefully not used a persistent cache. Over the past 20 releases, changes have been made to purge the problems from the comments API that caused this. If you have a plugin which modifies comment data directly please change them to make use of the various comment API functions or use clean_comment_cache().  You can hit this changes announcement for more info.

Resource Hints in 4.6

Resource Hints is a rather new W3C specification that “defines the dns-prefetch, preconect, prefetch and prerender relationships of the HTML Link Element (<link)>)”. These can be used to assist the browser in the decision process of which origins it should connect to, and which resources it should fetch and preprocess to improve page performance.

In 4.6, WordPress adds an API to register and use resource hints. The relevant ticket is #34292.

Developers can use the wp_resource_hints filter to add custom domains and URLs for dns-prefetch, preconnect, prefetch or prerender. One needs to be careful to not add too many resource hints as they could quite easily negatively impact performance, especially on mobile.

Internationalization

Everyone should be able to use WordPress in the language they want. WordPress 4.6 makes a number of changes to assist with internationalization and localization. Some of the highlights include:

  • Just-in-time loading for translations. You do not have to call load_plugin_textdomain() or load_theme_textdomain() anymore (if you distribute your theme/plugin via wordpress.org).
  • Community translations are now favored over translations which are included in your theme/plugin.
  • Localized jQuery UI datepicker.
  • Support for comment number declension in get_comments_number_text(). See #13651.
  • Fallback for TextDomain header field in get_plugin_data(). See #36706.
  • Updated list of continents and cities for the timezone selector. See #37554.
  • Support for the German (Switzerland) locale in remove_accents(). See #37076.
  • Improved support for month name declension. See #36790.

Pre-instantiated Widget Registration in 4.6

Since WP_Widget was introduced in 2.8 the register_widget() and unregister_widget()  functions required the class name (string) of a WP_Widget subclass to be supplied. As of 4.6 these functions also accept a class instance (object) of a WP_Widget subclass as well. See #28216.

Two key benefits of allowing objects to be instantiated are:

  1. Widgets can now be instantiated and registered with constructor dependency injection.
  2. New widget types can now be added dynamically, such as adding a Recent Posts widget for each post type, per #35990.

New and Improved Customizer APIs

The customizer has four major changes in WordPress 4.6. The most prominent is a new collection of APIs for validation of setting values. Included in this new notifications API for the customizer.

Additional changes include some CSS cleanup. Custom controls that use part of the core UI and subclass WP_Customize_Media_Control no longer need to create their own CSS styles that duplicate core rules. Because the markup and styling have changed significantly, please test any custom controls, CSS, or JavaScript that is related to media controls in the customizer.

If your code uses the customizer, you are encouraged to review the changes.

Bootstrap/Load Updates in 4.6

Every time WordPress is loaded, it goes through the bootstrap or loading process. In WordPress 4.6, there will be a few changes to the process focused on making pieces available earlier. Many of these changes will have no effect whatsoever on the vast majority of WordPress sites. However, if you are the type that maintains your own advanced-cache.php drop-in, host/run large profile sites, or work on tools that bootstrap WordPress is odd ways, you need to know about the following changes:

  • Load plugin.php earlier in wp_setting.php
  • is_ssl() is now located in wp-includes/load.php
  • ABSPATH can now be safely defined before WordPress is loaded

Multisite Focused Changes

This release, work continues on multisite with a focus on improved APIs and performance. Some highlights include:

  • New WP_Site_Query and WP_Network_Query classes to query sites and networks in a standardized way
  • Enhancements to WP_Site and WP_Network objects including lazy-loading for site details
  • A new helper function get_current_netwprk_id() to find the current network’s ID
  • wp_get_sites() has been deprecated. get_site(), get_sites(), get_network() and get_networks() are the future

External Library Updates

  • Masonry was updated to version 3.3.2 from version 3.1.4.
  • imagesLoaded was updated to version 3.2.0 from version 3.1.4.
  • imagesLoaded can now be enqueued without Masonry being enqueued. For backward compatibility reasons, imagesLoaded remains a dependency for Masonry.
  • MediaElement.js was updated to version 2.22.0 from version 2.18.1.
  • TinyMCE was updated to version 4.4.1 from version 4.3.10.
  • Backbone.js was updated to version 1.3.3 from 1.2.3.

Summaries for each of these updates and links to full changelogs are available.

But Wait! There’s More!

Over 280 bugs, 125 enhancements, 7 feature requests, and 18 blessed tasks have been marked as fixed in WordPress 4.6. Some additional ones include:

You can read the full field guide to WordPress 4.6 here. Please, test your code. So that any prevailing issues can be fixed before hand and help you and other millions of WordPress users and sites.

Leave a Reply

Your email address will not be published. Required fields are marked *