Plugin Directory

Changeset 2248282


Ignore:
Timestamp:
02/21/2020 04:31:23 PM (6 years ago)
Author:
paybox
Message:

Fixing Woocommerce active detection

File:
1 edited

Legend:

Unmodified
Added
Removed
  • e-transactions-wc/trunk/wc-etransactions.php

    r2240486 r2248282  
    2828   
    2929function wooCommerceActiveETwp(){
    30     $wooCommerceActiveET = (in_array('woocommerce/woocommerce.php',apply_filters('active_plugins', get_option('active_plugins'))));
    31     if(is_multisite()){
    32         //Si multisite
    33         $wooCommerceActiveET = (array_key_exists('woocommerce/woocommerce.php',
    34                                                         apply_filters('active_plugins', get_site_option('active_sitewide_plugins'))));
    35     }
    36     return $wooCommerceActiveET;
     30        // Makes sure the plugin is defined before trying to use it
     31        if ( !class_exists( 'WC_Payment_Gateway' ) ) {
     32            return false;
     33        }
     34        return true;
    3735}
     36// Ensure WooCommerce is active
    3837
    39 // Ensure WooCommerce is active
    40 if (!wooCommerceActiveETwp()) {
    41     return;
    42 }
     38
    4339if(defined('WC_ETRANSACTIONS_PLUGIN')){
    4440        _e('Previous plugin already installed. deactivate the previous one first.', WC_ETRANSACTIONS_PLUGIN);
     
    7773}
    7874function wc_etransactions_initialization() {
     75    if(!wooCommerceActiveETwp()){
     76        return ("Woocommerce not Active") ;
     77    }
    7978    $class = 'WC_Etransactions_Abstract_Gateway';
    8079
     
    127126function hmac_admin_notice(){
    128127   
    129     $temp = new WC_Etransactions_Standard_Gateway();
    130     $plugin_data = get_plugin_data( __FILE__ );
    131     $plugin_name = $plugin_data['Name'];
    132     if ( !$temp->checkCrypto() ) {
    133     echo "<div class='notice notice-error  is-dismissible'>
    134           <p><strong>/!\ Attention ! plugin ".$plugin_name." : </strong>".__('HMAC key cannot be decrypted please re-enter or reinitialise it.', WC_ETRANSACTIONS_PLUGIN)."</p>
    135          </div>";
    136     }
     128    if(wooCommerceActiveETwp()){
     129        $temp = new WC_Etransactions_Standard_Gateway();
     130        $plugin_data = get_plugin_data( __FILE__ );
     131        $plugin_name = $plugin_data['Name'];
     132        if ( !$temp->checkCrypto() ) {
     133        echo "<div class='notice notice-error  is-dismissible'>
     134              <p><strong>/!\ Attention ! plugin ".$plugin_name." : </strong>".__('HMAC key cannot be decrypted please re-enter or reinitialise it.', WC_ETRANSACTIONS_PLUGIN)."</p>
     135             </div>";
     136        }
     137    }else{
     138        echo "<div class='notice notice-error  is-dismissible'>
     139              <p><strong>/!\ Attention ! plugin E-Transactions : </strong>".__('Woocommerce is not active !.', 'wc-etransactions')."</p>
     140             </div>";
     141       
     142    }
    137143}
    138144add_action('admin_notices', 'hmac_admin_notice');
Note: See TracChangeset for help on using the changeset viewer.