I wrote a very minor extension for Woocommerce some while ago, which just puts an entry on the Admin Bar to show how many orders need dealing with. Obviously, the extension plugin needs to check whether Woocommerce exists or not. I guess this is second nature for most of you, but if there any other developers who are early in the process of developing plugins, the code I used originally looked like this:
if ( is_plugin_active('woocommerce/woocommerce.php') ) {
add_action( 'admin_bar_menu', 'ocws_wcab_newmenu',1000 );
} // end of testing for WooCommerce
The alteration needed to include a check for Classic Commerce is very minor. Here it is, if you need to copy it for your own plugins.
if ( (is_plugin_active('woocommerce/woocommerce.php')) || (is_plugin_active('classic-commerce/woocommerce.php')) ) {
add_action( 'admin_bar_menu', 'ocws_wcab_newmenu',1000 );
} // end of testing for WooCommerce and Classic Commerce
Keep your eye on that “if” line - I guess it is likely that the main developers will eventually change the filename of the plugin file to something like classic-commerce.php.
Thanks Paul. There is actually a big ongoing discussion about how to handle this with CC. We obviously need CC to to work with existing plugins that include statements like is_plugin_active('woocommerce/woocommerce.php')
The trouble is there seem to be half a dozen different ways that plugins make this check. There’s been some suggestions here and it’s also been discussed on Slack.
Readers should note that the main file now current in Classic Commerce is called, logically, classic-commerce.php. Therefore, my code given above should now be changed to:
if ( (is_plugin_active('woocommerce/woocommerce.php')) || (is_plugin_active('classic-commerce/classic-commerce.php')) ) {
add_action( 'admin_bar_menu', 'ocws_wcab_newmenu',1000 );
} // end of testing for WooCommerce and Classic Commerce