Open Tofandel opened 5 years ago
@Tofandel Hi Adrian, thank you for your willingness to contribute. Could you please explain what this adds what you couldn't already do with is_callable()
?
Every class should have at least one public method otherwise it cannot be instantiated. Using that method with is_callable, as in passing someClass::SomeMethod
as a value to the array, should work already.
@jrfnl Hello, well is callable will work only with public static functions, already instantiated objects's private methods (which you cannot do if the plugin is inactive) or public methods BUT NOT THE CONSTRUCTOR
So this would add the possibility to check if a class exists which you cannot currently effectively do with is_callable if only a constructor is available and no other public methods within the class (which is usually the case with well structured plugins)
Thanks
We could also argue that for an hypotetical plugin which only add_filters and actions with anonymous functions and have no class defined or function whatsoever it would be very hard to check that they do exist, but they may define a constant with their version or whatever. Then an is_defined option would also make some sense (even if this is very unlikely that there is not a single function or class) but that would give the entire flexibility of checking whether or not a plugin indeed exists with different methods that can fallback on each other since the condition is made with an 'or' statements
Since it doesn't break anything and just gives some flexibility I wouldn't see why not include these options What do you think ?
By the way I didn't had any answer on the 'mo files are not well generated' issue, should I make a PR with all the mo files regenerated ?
Edit: Added is_defined to the PR following the logic
This PR adds an option 'class_exists' to check if plugin is active (like the is_callable option)