-
Notifications
You must be signed in to change notification settings - Fork 428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a class_exists to check if plugin is active (like is callable) #754
base: develop
Are you sure you want to change the base?
Conversation
There is an is_callable to check if a function is defined but no class_exists, class_exists is more appropriate IMO
@Tofandel Hi Adrian, thank you for your willingness to contribute. Could you please explain what this adds what you couldn't already do with Every class should have at least one public method otherwise it cannot be instantiated. Using that method with is_callable, as in passing |
@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. Since it doesn't break anything and just gives some flexibility I wouldn't see why not include these options 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)