i want to ask a simple question that what to do if i have to check whether a pliugin is installed. for example i want to run a code, which says,
if Gutenberg is installed, then run the following code else not.
i have created this code, but not sure will this work or not
if(defined('Gutenberg')) {
}
is this the right way or is there any other way to that.
thanks in advance
2 Answers
Checking if a plugin is installed is always a bad idea as plugins might be installed but for whatever reason not function, or function in different way than you might expect.
Specifically for gutenberg as it stands right now for example, post types that are not exposed in the REST API can not be edited by gutenberg.
As always, if you have a functionality that depends on a plugin you should hook to its actions and filters to avoid the need to guess if it is active or not (the fact that the action is “called” is the best indication for activity), or ask the plugin author to add the kind of action/filter you might find useful.