Skip to content
Advertisement

Tag: closures

Is it good pratice to add closure inside constructor?

I have added closure inside the constructor and unsure of its performance as well as best practice. What is the best way to do that if it is not the right way to do it? Answer I have an own array class with a lot of functions (or closures) defined in the constructor. This type of definition of functions also

Anonymous functions in WordPress hooks

WordPress hooks can be used in two ways: using callback function name and appropriate function using anonymous function (closure) Is there any difference for WordPress what way to use? What is prefered way and why? Answer The disadvantage of the anonymous function is that you’re not able to remove the action with remove_action. Important: To remove a hook, the $function_to_remove

Advertisement