Deprecated JavaScript globals

In WordPress 5.5 the global JavaScriptJavaScript JavaScript or JS is an object-oriented computer programming language commonly used to create interactive effects within web browsers. WordPress makes extensive use of JS for a better user experience. While PHP is executed on the server, JS executes within a user’s browser. https://www.javascript.com/. objects listed below were removed without being deprecated. WordPress 5.5.1 adds a backfill for these globals so they no longer cause JavaScript errors. The following objects were removed:

  • adminCommentsL10n
  • attachMediaBoxL10n
  • authcheckL10n
  • commentL10n
  • commonL10n
  • inlineEditL10n
  • navMenuL10n
  • postL10n
  • plugininstallL10n
  • privacyToolsL10n
  • setPostThumbnailL10n
  • tagsl10n
  • tagsSuggestL10n
  • userProfileL10n
  • wp.themePluginEditor.l10n
  • wp.updates.l10n
  • wpColorPickerL10n
  • wpPointerL10n
  • wpWidgets.l10n

This means that referencing these objects would result in a JavaScript error and would thus halt JavaScript execution. Some of these objects were being used in very popular plugins & themes. @omarreiss and I researched where these were used. This Google sheet shows the impact.

If we only count plugins or themes with more than 100k installs or more, some of these already have an incredible impact. Which is why we decided to 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. this as fast possible.

What will change?

WordPress now redeclares these globals, and they now fail silently: they return an empty string and throw a console error. This makes sure that JavaScript doesn’t break, and also makes clear to 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 & theme developers that they need to adapt. Their code still needs to be updated to fix the translations, preferably using wp.i18n, but the problem no longer blocks JavaScript execution.

What if you already patched this?

If you’d already patched this, which we’ve seen in several plugins and themes, the new patch on coreCore Core is the set of software required to run WordPress. The Core Development Team builds WordPress. will return your reinstated object. We will however still throw a deprecation warning in the console. Please switch to using wp.i18n.

Deprecation policy

The plan is to remove this fallback code in two major versions, so this will be deleted in WordPress 5.7. This gives plugin and theme developers ample time to remove the conflicting code and switch to using wp.i18n.

Props @sergeybiryukov for reviewing.

#5-5-1, #dev-notes