Reputation: 356
When using plugin functions in themes, is it best practice to use class_exists or function_exists?
Example :
If i'm using ACF functions in my theme, should i use :
if ( class_exists('acf') )
or
if function_exists('the_field') )
Upvotes: 0
Views: 283
Reputation: 21
Using class_exists is enough to check if the ACF plugin is active. It is also better to use namespaces.
Upvotes: 0
Reputation: 2025
For check if function exists you must use function_exists() exactly, class_exists() checks if class exists.
http://php.net/manual/en/function.function-exists.php
Upvotes: 2