WordPress Release: 5.1.0

Tag Name: 5.1.0

Release Date: 2/21/2019

WordPress LogoWordPress

World's most popular open-source content management system powering over 40% of all websites. Offers extensive plugin ecosystem, themes, and robust community support for blogs, e-commerce, and corporate websites. Highly customizable and scalable platform suitable for beginners and advanced developers.

TL;DR

WordPress 5.1 "Betty" introduces significant performance improvements, enhanced security features, and developer-focused updates. This release focuses on site health checks, particularly PHP version compatibility warnings to help site owners maintain secure and optimized websites. The block editor receives numerous refinements, while developers benefit from new hooks, improved error handling, and better testing tools.

Highlight of the Release

    • Site Health Check: New PHP version compatibility checks warn administrators when they're running outdated PHP versions
    • Performance Improvements: Enhanced database optimization for faster site performance, especially for sites with many published posts
    • Block Editor Enhancements: Numerous refinements to the block editor experience including improved TinyMCE integration in the Classic Block
    • Accessibility Improvements: Better support for Windows High Contrast mode and improved screen reader text handling
    • Developer Tools: New hooks for block rendering, PHPUnit 7.x support, and improved REST API functionality

Migration Guide

PHP Version Compatibility

WordPress 5.1 introduces PHP version compatibility checks. While this doesn't require immediate migration, site owners should plan to update their PHP version if they're running an outdated version. The minimum recommended PHP version is 7.3.

Plugin Developers

If your plugin uses register_rest_route(), ensure it's called on or after the rest_api_init hook. Calling it too early may cause unintended problems. WordPress 5.1 adds a _doing_it_wrong() notice to encourage best practices.

Theme Developers

If your theme relies on specific behaviors of the Twenty Nineteen theme's non-latin font fallbacks, you may need to update your CSS as the approach has been changed to be less aggressive.

Custom Comment Reply Implementations

If you have custom implementations that rely on the comment reply JavaScript, ensure they're compatible with the updated version that uses a MutationObserver to handle lazy-loaded comments.

Upgrade Recommendations

WordPress 5.1 is a recommended upgrade for all users. The performance improvements and security enhancements provide significant benefits, while the Site Health feature helps maintain a more secure and optimized website.

For developers, the new hooks and improved testing tools offer better flexibility and reliability. The block editor refinements enhance the content creation experience.

Before upgrading:

  1. Back up your website files and database
  2. Update all themes and plugins to their latest versions
  3. Test the update on a staging environment if possible

After upgrading:

  1. Check that all themes and plugins function correctly
  2. Review any PHP version compatibility notifications
  3. Test your site's functionality, especially if you use custom blocks or have customized the editor experience

Bug Fixes

Editor and Media

  • Fixed the Edit Image modal in the Classic Block to work as in the Classic Editor
  • Fixed the Advanced Link modal in the Classic Block
  • Fixed repositioning of the inline toolbar on scrolling in the Classic Block
  • Fixed Gallery Widget preview after an image is deleted
  • Fixed date filter width in the media modal

Comments

  • Fixed comment reply JavaScript for backward compatibility with lazy-loaded comments
  • Improved handling of comments awaiting moderation when cookies are disabled
  • Corrected the "Mine" comment count when viewing comments for a particular post

Admin Interface

  • Fixed column visibility saving on small screens
  • Fixed Help tab availability on small screens
  • Fixed error styling in the Menu Name field when errors are addressed
  • Fixed the documentation look up button in the Plugin Editor when no function is selected

Themes

  • Fixed YouTube video display in Twenty Seventeen to prevent them from being cut off in Safari
  • Improved non-latin font fallbacks in Twenty Nineteen
  • Fixed alignment of page title in Twenty Nineteen when there are no posts

Other

  • Fixed Customizer preview iframe for better browser compatibility
  • Fixed REST API user email updates to allow changing letter casing
  • Fixed wp_targeted_link_rel() to prevent adding empty attributes
  • Fixed soft hyphen handling when sanitizing titles

New Features

Site Health Check

WordPress 5.1 introduces a new Site Health feature that checks for PHP version compatibility. When the system detects that you're running an outdated version of PHP, WordPress will show a notification in your admin dashboard encouraging you to upgrade. This helps site owners maintain more secure and performant websites.

Enhanced Block Editor

The block editor receives several refinements in this release:

  • New pre_render_block and render_block_data filters allow developers to customize block rendering
  • Improved TinyMCE integration in the Classic Block, fixing issues with the Edit Image modal, Advanced Link modal, and inline toolbar positioning
  • Better handling of block capabilities

Improved Internationalization

  • New option to hide en_US locale in wp_dropdown_languages()
  • Better handling of JSON translations when deleting themes or plugins
  • Improved language pack upgrader to clean up unused translations

Security Updates

Link Security

  • Bundled themes (Twenty Ten through Seventeen) have been updated to properly escape the pingback URL through esc_url()
  • Improved handling of targeted links with the wp_targeted_link_rel() function

Authentication

  • Updated admin-post.php to use is_user_logged_in() instead of wp_validate_auth_cookie(), allowing the authentication method to be filtered
  • Set a HTTP 403 error when an incorrect post preview nonce is sent
  • Added extra checking to wp_new_user_notification() to prevent notifications from being sent when an unrecognized value is passed

Input Validation

  • Improved type checking in _sanitize_text_fields() to handle non-string values more gracefully
  • Re-added validation for admin settings that was accidentally removed in a previous update

Performance Improvements

Database Optimization

WordPress 5.1 introduces significant performance improvements to the database operations, particularly for sites with many posts. The database optimization includes:

  • Improved caching for get_pages() when no results are found, reducing unnecessary database calls
  • Enhanced performance of wp_next_scheduled() and wp_get_scheduled_event() by avoiding duplicate function calls and object cache hits
  • Optimized wp_encode_emoji() and wp_staticize_emoji() by moving PHP version checks outside of internal loops, reducing processing time by 50%

Filesystem Operations

  • Improved performance of wp_is_stream() by extracting the scheme and searching the return value of stream_get_wrappers() instead of using regex matching

Network Options

  • Added a maybe_serialize() comparison for old and new values in update_network_option() to avoid unnecessary database writes when options contain identical objects

Impact Summary

WordPress 5.1 "Betty" represents a significant step forward in WordPress's commitment to performance, security, and user experience. The introduction of Site Health checks, particularly the PHP version compatibility warnings, helps site owners maintain more secure and performant websites by encouraging updates to supported PHP versions.

Performance improvements in database operations provide tangible benefits, especially for sites with large amounts of content. These optimizations reduce server load and improve page load times, contributing to better user experience and potentially better search engine rankings.

For content creators, the refinements to the block editor and improvements to the Classic Block's TinyMCE integration provide a more reliable and consistent editing experience. The fixes for comment moderation when cookies are disabled also improve the workflow for managing user-generated content.

Developers benefit from new hooks for block rendering, improved testing tools with PHPUnit 7.x support, and better REST API functionality. These enhancements provide more flexibility and control when extending WordPress.

Accessibility improvements, including better support for Windows High Contrast mode and improved screen reader text handling, continue WordPress's commitment to making the platform usable for everyone.

Overall, WordPress 5.1 delivers a balanced mix of user-facing improvements, developer tools, and under-the-hood optimizations that collectively enhance the WordPress experience for all users.

Statistics:

File Changed300
Line Additions36,499
Line Deletions1,477
Line Changes37,976
Total Commits250

User Affected:

  • Receive PHP version compatibility notifications to help maintain site health
  • Benefit from improved site performance with database optimization
  • Experience enhanced security with better error handling and link targeting

Contributors:

pentopeterwilsonccocean90swissspidydesrosjboonebgorgesfelixarntzaferciaazaozzlaurelfulfordgetsourceSergeyBiryukovjohnbillionyouknowriadellatrixaaronjorbin