| Server IP : 172.67.134.116 / Your IP : 216.73.217.68 Web Server : Apache System : Linux server.rehabsharif.com 5.14.0-611.54.3.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 7 16:31:24 EDT 2026 x86_64 User : nobi37te ( 1003) PHP Version : 8.2.33 Disable Function : exec,passthru,shell_exec,system MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/nobi37te/public_html/wp-content/plugins/woocommerce-multi-currency/plugins/ |
Upload File : |
<?php
/**
* Class WOOMULTI_CURRENCY_Plugin_Polylang
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class WOOMULTI_CURRENCY_Plugin_Polylang {
protected $settings;
protected $current_lang;
public function __construct() {
$this->settings = WOOMULTI_CURRENCY_Data::get_ins();
if ( $this->settings->get_enable() ) {
$add_query = $this->settings->get_param( 'add_query_arg_to_languague_switcher' );
if ( $add_query ) {
add_filter( 'pll_the_language_link', array( $this, 'pll_the_language_link' ), 10, 3 );
} else {
add_action( 'pll_language_defined', array( $this, 'pll_language_defined' ) );
}
}
}
public function pll_language_defined( $data ) {
if ( isset( $_GET['wc-ajax'] ) && in_array( sanitize_text_field( $_GET['wc-ajax'] ), [ 'update_order_review', 'get_refreshed_fragments' ] ) ) {
return;
}
if ( isset( $_GET['custom-css'] ) ) {
/*Savoy theme requests for custom css dynamically and causes the issue with this function*/
return;
}
if ( class_exists( 'Polylang' ) ) {
if ( is_admin() && ! wp_doing_ajax() ) {
return;
}
$this->current_lang = $data;
$curlang = isset( $_COOKIE['pll_language'] ) ? sanitize_key( $_COOKIE['pll_language'] ) : PLL()->curlang->slug;
if ( apply_filters( 'wmc_polylang_need_set_currency_by_language', $curlang != $data, $curlang, $data ) ) {
$currency_code = $this->settings->get_currency_by_language( $data );
if ( $currency_code ) {
$this->settings->set_current_currency( $currency_code );
}
}
}
}
/**
* Integrate with Polylang
* @return bool
*/
public function pll_the_language_link( $url, $slug, $locale ) {
if ( $this->settings->get_currency_by_language( $slug ) ) {
if ( isset( $_GET['wmc-currency'] ) ) {
remove_query_arg( 'wmc-currency', $url );
}
$url = add_query_arg( 'wmc-currency', $this->settings->get_currency_by_language( $slug ), $url );
}
return $url;
}
}