Automattic\WooCommerce\Internal\Admin\WCPayPromotion

Init::__construct()publicWC 1.0

Constructor.

Method of the class: Init{}

No Hooks.

Return

null. Nothing (null).

Usage

$Init = new Init();
$Init->__construct();

Init::__construct() code WC 9.6.1

public function __construct() {
	// If the React-based Payments settings page is enabled, we don't need the old WooPayments promotion system,
	// as we will show the WooPayments suggestion with the new system.
	if ( Features::is_enabled( 'reactify-classic-payments-settings' ) ) {
		return;
	}

	/* phpcs:disable WordPress.Security.NonceVerification */
	$is_payments_setting_page = isset( $_GET['page'] ) && 'wc-settings' === $_GET['page'] && isset( $_GET['tab'] ) && 'checkout' === $_GET['tab'];
	$is_wc_admin_page         = isset( $_GET['page'] ) && 'wc-admin' === $_GET['page'];

	if ( $is_payments_setting_page || $is_wc_admin_page ) {
		add_filter( 'woocommerce_admin_shared_settings', array( $this, 'add_component_settings' ) );
	}

	if ( ! wp_is_json_request() && ! $is_payments_setting_page ) {
		return;
	}

	add_filter( 'woocommerce_payment_gateways', array( __CLASS__, 'possibly_register_pre_install_wc_pay_promotion_gateway' ) );
	add_filter( 'option_woocommerce_gateway_order', array( __CLASS__, 'set_gateway_top_of_list' ) );
	add_filter( 'default_option_woocommerce_gateway_order', array( __CLASS__, 'set_gateway_top_of_list' ) );
	add_action( 'admin_enqueue_scripts', array( __CLASS__, 'load_payment_method_promotions' ) );
	add_action( 'update_option_woocommerce_default_country', array( $this, 'delete_specs_transient' ) );
}