Title: [php] How to check module is enabled?
Last modified: September 1, 2018

---

# [php] How to check module is enabled?

 *  Resolved [alx359](https://wordpress.org/support/users/alx359/)
 * (@alx359)
 * [7 years, 9 months ago](https://wordpress.org/support/topic/php-how-to-check-module-is-enabled/)
 * Need to write some code for when the braintree module is enabled. Usually reading
   options like `get_option( 'woocommerce_paypal_express_settings', array() )` would
   work, but specifically for the braintree module I can’t find such accessible 
   option, as everything seems somehow self-contained in `new AngellEYE_Gateway_Paypal();`,
   and with no global variable either to take a reference into the class obj. Obviously
   wouldn’t instantiate the whole thing again to get in there. Maybe my wp/php fu
   is just lacking. Suggestions?
 * Thanks.

Viewing 10 replies - 1 through 10 (of 10 total)

 *  Thread Starter [alx359](https://wordpress.org/support/users/alx359/)
 * (@alx359)
 * [7 years, 9 months ago](https://wordpress.org/support/topic/php-how-to-check-module-is-enabled/#post-10654898)
 * The only way I’ve yet come across is using an unassigned one-off object like:
 *     ```
       if( (new WC_Gateway_Braintree_AngellEYE)->is_available() ) 
       {// do my stuff}
       ```
   
 * but still, instantiating an almost 2k lines class with a lot of stuff going on
   feels overkill and might have unwanted ramifications. Way better if the given
   method was just `static`:
 * `WC_Gateway_Braintree_AngellEYE::is_available()`
 * Please advise.
 *  Plugin Contributor [angelleyesupport](https://wordpress.org/support/users/angelleyesupport/)
 * (@angelleyesupport)
 * [7 years, 9 months ago](https://wordpress.org/support/topic/php-how-to-check-module-is-enabled/#post-10654987)
 * Hi [@alx359](https://wordpress.org/support/users/alx359/), Sorry for the delay
   in response. Please allow me some time to get some more relevant information 
   from our developer.
 * [@angelleye](https://wordpress.org/support/users/angelleye/) can you please look
   into this one?
 * Thanks!
 *  Thread Starter [alx359](https://wordpress.org/support/users/alx359/)
 * (@alx359)
 * [7 years, 9 months ago](https://wordpress.org/support/topic/php-how-to-check-module-is-enabled/#post-10664470)
 * Hey, Angell! It isn’t critical, but would be really enlightening to learn there’s
   an advance (to me) technique to properly access your implicit `WC_Gateway_Braintree_AngellEYE`
   class object. Thanks!
 *  Plugin Contributor [angelleye](https://wordpress.org/support/users/angelleye/)
 * (@angelleye)
 * [7 years, 9 months ago](https://wordpress.org/support/topic/php-how-to-check-module-is-enabled/#post-10665262)
 * [@angelleyesupport](https://wordpress.org/support/users/angelleyesupport/), We
   need to get our lead dev’s feedback on this. Please speak to [@kcppdevelopers](https://wordpress.org/support/users/kcppdevelopers/)
   about it and create any necessary tickets in the system so we can get this taken
   care of.
 *  [kcppdevelopers](https://wordpress.org/support/users/kcppdevelopers/)
 * (@kcppdevelopers)
 * [7 years, 9 months ago](https://wordpress.org/support/topic/php-how-to-check-module-is-enabled/#post-10665762)
 * [@alx359](https://wordpress.org/support/users/alx359/) [@angelleyesupport](https://wordpress.org/support/users/angelleyesupport/)
   [@angelleye](https://wordpress.org/support/users/angelleye/)
 * Here is the code for check specific gateway is enable or not : [https://pastebin.com/SBNKtPtJ](https://pastebin.com/SBNKtPtJ)
 * Thanks
 *  Thread Starter [alx359](https://wordpress.org/support/users/alx359/)
 * (@alx359)
 * [7 years, 9 months ago](https://wordpress.org/support/topic/php-how-to-check-module-is-enabled/#post-10666577)
 * Thanks, kcppdevelopers!
 * I was aware of `WC()->payment_gateways->get_available_payment_gateways()` before,
   but wasn’t using it properly. Actually, `$available_payment_gateways['braintree']`
   array points to the `WC_Gateway_Braintree_AngellEYE` instance e.g. `$available_payment_gateways['
   braintree']->is_available()`, but from your example it also becomes apparent 
   when `is_available() == false` the whole `$available_payment_gateways['braintree']`
   array ceases to exist.
 * Thanks again, and sorry for the hassle!
 *  Thread Starter [alx359](https://wordpress.org/support/users/alx359/)
 * (@alx359)
 * [7 years, 9 months ago](https://wordpress.org/support/topic/php-how-to-check-module-is-enabled/#post-10666944)
 * After some more tinkering, I now see a reason for my previous confusion.
 * `$available_gateways = WC()->payment_gateways->get_available_payment_gateways()`**
   doesn’t work for ‘paypal_express’** ! Oddly enough, checking `enabled=yes` in
   the UI just returns an empty array for PPE. Don’t know why PPE is singled out
   that way?
 * On the other hand, `WC()->payment_gateways->payment_gateways()` does return an
   array with ** all installed** (i.e. enabled and disabled) gateways, from where
   one could figure out easily which ones are enabled, like this:
 *     ```
       $available_gateways = WC()->payment_gateways->payment_gateways();
       $is_enabled_ppe = $available_gateways['paypal_express']->get_option('enabled');
       $is_enabled_bt  = $available_gateways['braintree']->get_option('enabled');
       ```
   
 * Thanks for the pointing me out to the right direction!
 *  Plugin Contributor [angelleyesupport](https://wordpress.org/support/users/angelleyesupport/)
 * (@angelleyesupport)
 * [7 years, 9 months ago](https://wordpress.org/support/topic/php-how-to-check-module-is-enabled/#post-10667130)
 * [@alx359](https://wordpress.org/support/users/alx359/) Happy to help you. Feel
   free to write here again if you need any further assistance.
 * Also, we would love to know what you think of our product and customer support.
   If you have a moment to [[leave a review ]](https://wordpress.org/support/plugin/paypal-for-woocommerce/reviews/)
   it would be greatly appreciated..
 * Thanks!
 *  Thread Starter [alx359](https://wordpress.org/support/users/alx359/)
 * (@alx359)
 * [7 years, 9 months ago](https://wordpress.org/support/topic/php-how-to-check-module-is-enabled/#post-10667231)
 * Oliver, look at who wrote the very last one 😉
 *  Plugin Contributor [angelleyesupport](https://wordpress.org/support/users/angelleyesupport/)
 * (@angelleyesupport)
 * [7 years, 9 months ago](https://wordpress.org/support/topic/php-how-to-check-module-is-enabled/#post-10667236)
 * Thanks for your positive vibe, Much appreciated!
    Cheers!

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘[php] How to check module is enabled?’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/paypal-for-woocommerce_dce4f5.svg)
 * [PayPal for WooCommerce](https://wordpress.org/plugins/paypal-for-woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/paypal-for-woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/paypal-for-woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/paypal-for-woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/paypal-for-woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/paypal-for-woocommerce/reviews/)

 * 10 replies
 * 4 participants
 * Last reply from: [angelleyesupport](https://wordpress.org/support/users/angelleyesupport/)
 * Last activity: [7 years, 9 months ago](https://wordpress.org/support/topic/php-how-to-check-module-is-enabled/#post-10667236)
 * Status: resolved