I want to check if the plugin is active without using is_plugin_active() from WordPress because the plugin might not be in the default path. I would like to check using the plugin version constant instead (this one is available).
I have other plugin with constant for example ACME_VERSION. To check if this plugin is activated in another plugin, I am using the PHP defined:
if(defined('ACME_VERSION')) {
//plugin is activated, add the hooks
}
However, it is not working.
Other WordPress constants like WP_DEBUG returns true (I have enabled it in wp-config).
Am I missing something? What’s the proper way of doing this? Thank you for any tips.
You are probably testing the constant before it is defined (e.g. your plugin is loaded before the other plugin). Put your test inside a function called by an action hook, e.g. the ‘init’ action: