Too late declaration of HPOS compatibility?
-
Hi there,
I wanted to use your plugin and activated it – without activating the gateway yet (because this should be properly prepared before activating). However, this returned a warning from WooCommerce on my end that the plugin was not compatible with HPOS.
After checking I found that you declare HPOS compatibility after checking, if the gateway is enabled. To prevent other future users of the plugin from reporting this issue as well, you might consider moving the declarations a bit more to the top (and before returning out of the code when the gateway is not activated):
public function run() { $this->load(); add_action( 'init', array( $this, 'load_plugin_textdomain' ) ); // load the plugin framework. add_action( 'plugins_loaded', array( $this, 'plugin_fw_loader' ), 15 ); // add the gateway on woocommerce payment gateways list. add_filter( 'woocommerce_payment_gateways', array( $this, 'add_yith_paypal_ec' ), 10 ); // Declaration might be better happening here add_action( 'before_woocommerce_init', array( $this, 'declare_wc_features_support' ) ); // Declare support with HPOS system for WooCommerce 8. add_action( 'before_woocommerce_init', array( $this, 'declare_hpos_support' ) ); // check if the gateway is enabled. if ( 'yes' !== $this->ec->enabled ) { return; } // check if API are set and are valid if the gateway is on production environment. if ( ! ( 'live' === $this->ec->env && ! $this->ec->valid_api_settings() ) ) { $this->api = new YITH_PayPal_EC_API_Handler( $this->ec->env, $this->ec->api_username, $this->ec->api_password, $this->ec->api_signature ); } add_action( 'admin_notices', array( $this, 'show_admin_warning' ) ); add_action( 'wp_ajax_yith_paypal_ec_dismiss_notice_message', array( $this, 'ajax_dismiss_notice' ) ); add_filter( 'allowed_redirect_hosts', array( $this, 'add_paypal_hosts' ) ); // if there's PayPal Standard or Express checkout mark is disabled remove the gateway. add_action( 'woocommerce_available_payment_gateways', array( $this, 'disable_gateways' ), 100 ); // Declaration is happening here add_action( 'before_woocommerce_init', array( $this, 'declare_wc_features_support' ) ); // Declare support with HPOS system for WooCommerce 8. add_action( 'before_woocommerce_init', array( $this, 'declare_hpos_support' ) ); }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Too late declaration of HPOS compatibility?’ is closed to new replies.