You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
From add_filter('some_filter', function ($params...) { }
To: add_filter('some_filter', static function ($params...) { }
Similar for add_action with closure.
In case the magic instance variable $this is not needed inside it.
This avoids the closures to bind to each instance, probably a bit less memory and maybe a bit faster, especially in frequently instantiated classes (I think).
Also consider using named functions in case it may be useful for other (site specific) plugins to completely remove the action or filter.
The text was updated successfully, but these errors were encountered:
From
add_filter('some_filter', function ($params...) { }
To:
add_filter('some_filter', static function ($params...) { }
Similar for
add_action
with closure.In case the magic instance variable
$this
is not needed inside it.This avoids the closures to bind to each instance, probably a bit less memory and maybe a bit faster, especially in frequently instantiated classes (I think).
Also consider using named functions in case it may be useful for other (site specific) plugins to completely remove the action or filter.
The text was updated successfully, but these errors were encountered: