// Unhook and redo eu_vat to fix current_url Errors and WP_CLI
if(class_exists('Alg_WC_EU_VAT')){
remove_action( 'init', array( \Alg_WC_EU_VAT::instance()->core, 'start_session' ) );
add_action( 'init', function(){
// Redo start_session function to fix current_url function errors
// site/web/app/plugins/eu-vat-for-woocommerce/includes/class-alg-wc-eu-vat-core.php
if( ! defined('WP_CLI') ){
$current_url = ( !isset($_SERVER["HTTPS"]) || $_SERVER["HTTPS"] != 'on' ) ? 'https://'.$_SERVER["SERVER_NAME"] : 'https://'.$_SERVER["SERVER_NAME"];
$current_url .= ( $_SERVER["SERVER_PORT"] != 80 ) ? ":".$_SERVER["SERVER_PORT"] : "";
$current_url .= $_SERVER["REQUEST_URI"];
$curl = rtrim($current_url,'/');
$home = rtrim(home_url(),'/');
if(!( $curl == $home )){
alg_wc_eu_vat_session_start();
$args = array();
if ( isset( $_POST['post_data'] ) ) {
parse_str( $_POST['post_data'], $args );
if ( isset( $args[ alg_wc_eu_vat_get_field_id() ] ) && alg_wc_eu_vat_session_get( 'alg_wc_eu_vat_to_check' ) != $args[ alg_wc_eu_vat_get_field_id() ] ) {
alg_wc_eu_vat_session_set( 'alg_wc_eu_vat_valid', null );
alg_wc_eu_vat_session_set( 'alg_wc_eu_vat_to_check', null );
}
}
}
}
} );
}