settings = get_option( 'woocommerce_gateways_country_limiter' ); add_action( 'init', array( $this, 'init' ), 10 ); } public static function woocommerce_inactive_notice() { if ( current_user_can( 'activate_plugins' ) ) : ?>
payment_gateways->payment_gateways(); if ( !empty( $_GET['section'] ) ) { $this->current_section = sanitize_title( $_GET['section'] ); } foreach ( $payment_gateways as $id => $gateway ) { $title = empty( $gateway->method_title ) ? ucfirst( $gateway->id ) : $gateway->method_title; $section_id = version_compare( WC()->version, '2.6.0', '>=' ) ? $id : 'wc_gateway_' . $id; $this->sections[$section_id] = array( 'title' => esc_html( $title ), 'id' => $id ); } if ( is_admin() && !empty( $this->current_section ) ) { add_action( 'woocommerce_settings_checkout', array( $this, 'country_options_output' ), 1000 ); add_action( 'woocommerce_update_options_checkout', array( $this, 'country_options_update' ), 1000 ); } add_filter( 'woocommerce_available_payment_gateways', array( $this, 'filter_by_country' ), 1000 ); //defaults foreach ( $payment_gateways as $gateway_id => $gateway ) { if ( !isset( $this->settings[$gateway_id]['option'] ) ) { $this->settings[$gateway_id]['option'] = 'all'; } if ( !isset( $this->settings[$gateway_id]['countries'] ) || !is_array( $this->settings[$gateway_id]['countries'] ) ) { $this->settings[$gateway_id]['countries'] = array(); } } if ( is_admin() && !empty( $this->current_section ) ) { if ( isset( $this->sections[$this->current_section] ) ) { $gateway_id = $this->sections[$this->current_section]['id']; wc_enqueue_js( " jQuery(document).ready(function(){ var current_option = jQuery('input[name={$gateway_id}_option]:checked'); if(current_option.val() == 'all_except' || current_option.val() == 'selected'){ jQuery('#pgcl_countries_list').show(); current_option.parent().parent().append(jQuery('#pgcl_countries_list')); } jQuery('input[name={$gateway_id}_option]').change(function(){ if(jQuery(this).val() == 'all_except' || jQuery(this).val() == 'selected'){ jQuery(this).parent().parent().append(jQuery('#pgcl_countries_list')); jQuery('#pgcl_countries_list').show(); }else{ jQuery('#pgcl_countries_list').hide(); } }) }) " ); } } } public function load_plugin_textdomain() { $locale = get_locale(); load_textdomain( 'woocommerce-gateways-country-limiter', dirname( __FILE__ ) . "/i18n/languages/woocommerce-gateways-country-limiter-$locale.mo" ); } function country_options_output() { if ( !empty( $this->current_section ) && !empty( $this->sections[$this->current_section] ) ): $gateway_id = $this->sections[$this->current_section]['id']; ?>