WordPress 4.9. Release For Developers

WordPress has released its 12th update for 2017, and it’s also the second minor version pushed out this year. WordPress 4.9 includes a lot for users. “Tipton” introduces changesets for theme customizations, previewing, and scheduling of theme customizer updates and code editing syntax highlighting, autocompletion, and error checking using CodeMirror. Finally, there’s a new Gallery widget and an “Add Media” button for the venerable text widget.1Days of hard-coding images into the text widget are seemingly over.

As usual with each new release, I look for improvements and additions for developers. Although there isn’t quite as much for developers in this specific version, there are a few key inclusions that I wanted to highlight.

Customizer JavaScript API Updates

As I mentioned, there are a few updates for users using the Theme Customizer in WordPress, changesets being the biggest and most visible of them. For developers, there have been a few changes to make the Customizer a little easier to deal with on the front end with JavaScript. Mainly, these changes make instantiating a new control a little simpler by mirroring the methodology on the PHP side. Aside from no longer having to repeat the ID of a control to instantiate it, we also get a default parameters, flattened parameters object, and control settings. The latter makes it easier to pass attributes/data to your controls during creation, but it also makes them accessible in the global scope by listening for events when a control value is changed.

Next, base HTML5 input types, like number, email, color, etc., are now defined by default using new control “templates”. Further, we can create our own templates for custom controls and reuse them throughout the Customizer.

A new Date/Time Control has also been added to core to support the scheduling of Theme Customizer updates. Developers can use this control independently for their own controls, and there are various settings for date-only and both display and value formatting.

Finally, core adds another sub-panel for control settings and there are new events that can be hooked into for Customizer actions. Notifications have been overhauled to allow for global, section, and panel instances. Notifications can also be filtered and made dismissible. Those of the global type can even be made to take over the entire screen with an OverlayNotification flag.

CodeMirror in Core

CodeMirror JavaScript Linting in WordPress 4.9

With WordPress 4.9 comes the inclusion of CodeMirror with core, and it’s been made available to plugin and theme developers. For users, this is a big addition that should help those not familiar with code by providing autocompletion, syntax highlighting, and linting. Pretty much all of the WordPress related languages are covered for auto-complete and syntax, but only CSS, HTML, JavaScript, and JSON are linted by default.2Although, it looks as if PHP linting will be available in core by the time WordPress 5.0 is released.

UPDATE: Due to licensing issues, the development team will be removing JSHint from CodeMirror in Core. Instead, the team will be replacing JSHint with Esprima in WordPress version 4.9.3. If you built a plugin that included the JSHint dependency from Core, you’ll need to include it in your build independently.

CodeMirror has been added to the popular “Additional CSS” control in the Customizer, the HTML Widget, and the plugin and theme file editor. Excitingly, WordPress’s implementation is in the form of an API that’s available to developers. We can add any or all of these CodeMirror features to fields by including just a few lines of code. You can view the code-editor JS on GitHub to see all of the options available when using the API.

MediaElement.js

This third-party library is used to assist editors with embedded media/video. It’s has been updated to a more recent version which includes bugfixes, updated browser support, updated API usage for YouTube and Vimeo, and removal of all jQuery dependencies. For a full list of details, see the Trac ticket.

Roles and Capabilities

A couple of tweaks here add new capabilities for activate_plugin, deactivate_plugin, deactivate_plugins, install_languages, and update_languages. The first provides a little more control of a specific plugin by passing the plugin file as the second parameter to current_user_can(). The team has also removed the implicit do_not_allow capability, which was a possible resultant value mapped from the map_meta_cap() function.

This latest version of WordPress comes with a lot of bugfixes and improvements for users as well as site builders. You can read the release announcement for “Tipton” here. As always, you should update as soon as practical. If you need help, I offer this sort of thing as a service. =)

The push toward WordPress 5.0 pushes onward inexorably, and it seems to be on schedule for a Q1 2018 release. I expect a few security/bugfix/feature releases that tweak 4.9 in the next couple of months. Developers should really stay on top of all news coming from Matt and the Core channel in Slack in the coming weeks to ensure there are no big surprises when the next major version is revealed early next year. The Gutenberg editor is the talk of the town, for sure, but I fully expect some new security features, more mobile/desktop UI unification, and more.

About

Web Developer

References   [ + ]

1. Days of hard-coding images into the text widget are seemingly over.
2. Although, it looks as if PHP linting will be available in core by the time WordPress 5.0 is released.

Add Your Thoughts

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