One possible way to do this is to check whether a specific class or function that is included in the plugin is defined, with class_exists()
or function_exists()
, respectively.
For Gutenberg, you could check for register_block_type()
:
1 2 3 | if ( function_exists( 'register_block_type' ) ) { // Gutenberg is available. } |
I would however side with Mark Kaplun to say this is not a good idea in most cases, and it is not even necessary if you follow best practices.
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.