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 8.6.1

public function __construct() {
	include_once __DIR__ . '/WCPaymentGatewayPreInstallWCPayPromotion.php';

	$is_payments_page = isset( $_GET['page'] ) && $_GET['page'] === 'wc-settings' && isset( $_GET['tab'] ) && $_GET['tab'] === 'checkout'; // phpcs:ignore WordPress.Security.NonceVerification
	if ( ! wp_is_json_request() && ! $is_payments_page ) {
		return;
	}

	add_filter( 'woocommerce_payment_gateways', array( __CLASS__, 'possibly_register_pre_install_wc_pay_promotion_gateway' ) );
	add_filter( 'option_woocommerce_gateway_order', [ __CLASS__, 'set_gateway_top_of_list' ] );
	add_filter( 'default_option_woocommerce_gateway_order', [ __CLASS__, 'set_gateway_top_of_list' ] );

	$rtl = is_rtl() ? '.rtl' : '';

	wp_enqueue_style(
		'wc-admin-payment-method-promotions',
		WCAdminAssets::get_url( "payment-method-promotions/style{$rtl}", 'css' ),
		array( 'wp-components' ),
		WCAdminAssets::get_file_version( 'css' )
	);

	WCAdminAssets::register_script( 'wp-admin-scripts', 'payment-method-promotions', true );
}