Version 3.1.0 of WordPress Libs is now available and ready for general use. This version focused on improving the
Actions functionality as well as various enhancements and bug fixes.
WordPress supports short circuiting various methods using filters to allow handling the process in an external way. Sometimes you need to call the original API to run your external process.
Complications arise when the short circuit is part of original API as you end up in an endless loop. A common case for this would be special handling of metadata. This is where the
add_looping_action and its partner method
add_looping_filter come in. These methods automatically handle the register, unregister, and re-register process to prevent infinite loops.
$accepted_args Requirement From
The filters system supports a 4th argument to specify how many arguments will be passed to the callback’s parameters. Omitting this argument will only pass the first argument to the callback.
Failure to specify a large enough number of accepted arguments will prevent your callbacks parameters from populating, but specifying too large a number has virtually no side effects. For this reason, all methods in the
Actions class no longer have an
acccepted_args parameter and will automatically pass the first 10 arguments to callbacks.
Fix Versions Sorting
PHP8 changed the way
version_compare functions when an operator is used for sorting.
version_compare will return
bool instead of
int when using an operator. It’s best to sort using the returned
int instead of using an operator in PHP8. For this reason we have updated the
Versions class to no longer use an operator and therefore fix a bug with PHP8.
Simplify Cache Posts Group Handling
Instead of using our own cache constant for specifying we want a group’s cache to be flushed when a post is updated then translating it back to
posts, we removed the middleman. Now the constant’s value is
posts and will continue to function the same way without the extra logic.
Sometimes you need to adjust the REST responses specifically when doing the initial render of the data to
wp_localize_script. Instead of cluttering up the template by adding a filter directly to it, you now have a method to use directly in the filter’s callback. The method will return
true if currently rendering initial data.
Object Properties Within
Previously you were able to retrieve any property from the retrieved object using the magic
__get method. Now there is a partner
__set magic method for setting any of the objects properties as well.
__set methods now support retrieving and setting properties on the objects
data property as well.
Like the previously existing
crossorigin flag to the tag, otherwise the
crossorigin will be set to the provided value.
sanitization_cbfrom doubling within the meta repo.
- Properly store encryption ‘iterations’ for maintainability.
- Improved PHPStan validations.