This is the 70th release we have done with this library since it became WordPress-Libs. This release was all about working with resources; taking the repetitive requirements from scripts and styles and making them stable and accessible.
New Utility Class for working with colors:
We’re finding more and more the need for translating colors from rgba
to hexadecimal
or vice versa. This is most often used for adding or removing transparency from a color set somewhere in the admin. For example, when using dynamic blocks it’s common to reuse a selected color.
Now there is a Util\Colors
class which has helper methods for converting colors from hexadecimal
to rgba
and back:
Example:
New methods for enabling async
and defer
on registered scripts:
As the browser world is getting to be a more asynchronous place, it’s common to add async
or defer
attributes to our script tags. WordPress core currently does not have any built-in mechanism for adding these attributes, but it may be accomplished via filters.
We have taken the complications out of using filters and added support to the Theme\Styles
class as two new helper methods:
Support for adding body classes:
It is common to add a special class to the <body>
tag of a particular page based on a template and/or condition. Now there is a helper method called body_class
available in the Theme\Styles
class which does this:
Live reload now loads asynchronously:
When using the Theme\Styles::live_reload()
method, the script is now loaded with the async
attribute added to prevent any render blocking. This is especially useful when you don’t have a watch running.
Miscellaneous:
- Some Readme.md improvements.
- Improved styles for CMB2 group heading labels.