Bail if WC Is Not Active
Closed this issue · 8 comments
Right now if WC isn't active it'll try to use wc_get_template
which won't exist. Better to just output the unparsed shortcode if WC isn't available.
I prefer to use just a class_exists()
check. I've never used the other method. That's only checking if it's active throughout the network. Checking if class_exists() will just check if the plugin has been loaded for that single site (single or multi).
This is the official recommended way to check if a plugin is active (well kinda, I've modified it to also check the network). http://docs.woothemes.com/document/create-a-plugin/
Doesn't your method require the plugin to be loaded after WC?
The thing I don't like about that is that it requires WooCommerce to be installed in /woocommerce/ which won't always be the case.
If you remove https://github.com/Astoundify/woocommerce-simple-registration/blob/master/woocommerce-simple-registration.php#L188
And call it attached to plugins_loaded
action it will check once all plugin files have been included.
add_action( 'plugins_loaded', 'WooCommerce_Simple_Registration' );
I actually have never encountered a woocommerce plugin in a non-woocommerce folder. Is there a reasonable use-case for that? I can imagine if someone screws up and that happens, but then I would just recommend changing the folder name.
I personally don't like to determine the load order if not needed. E.g. if someone want to hook into our plugin, then they would also be required to use plugins_loaded
and a higher priority.
I think it is reasonable for us to assume that the WC folder is in /woocommerce/ anyways :-)
You've convinced me. I'm fine with going with that way then. I'll do some final testing and let you know if anything comes up.
Woohoooe 😃
Always like discussing stuff like this, makes you think twice about the regular stuff 👍
Yep, love having a second set of eyes/a second brain around.
🍪