HEX
Server: Apache
System: Linux webd006.cluster128.gra.hosting.ovh.net 6.18.42-ovh-vps-grsec-zfs+ #1 SMP PREEMPT_DYNAMIC Wed Aug 5 15:59:48 CEST 2026 x86_64
User: zwafgyp (177615)
PHP: 7.4.33
Disabled: _dyuweyrj4,_dyuweyrj4r,dl
Upload Files
File: /home/zwafgyp/lacalita/wp-content/plugins/woo-poly-integration/src/Hyyan/WPI/Ajax.php
<?php

/**
 * This file is part of the hyyan/woo-poly-integration plugin.
 * (c) Hyyan Abo Fakher <hyyanaf@gmail.com>.
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Hyyan\WPI;

/**
 * Ajax.
 *
 * Handle Ajax
 *
 * @author Marian Kadanka <marian.kadanka@gmail.com>
 */
class Ajax
{

    /**
     * Construct object.
     */
    public function __construct()
    {
        add_filter('woocommerce_ajax_get_endpoint', array($this, 'filter_woocommerce_ajax_get_endpoint'), 10, 2);
    }

    /**
     * Filter woocommerce_ajax_get_endpoint URL - replace the path part 
     * with the correct relative home URL according to the current language 
     * and append the query string
     *
     * @param string $url WC AJAX endpoint URL to filter
     * @param string $request
     *
     * @return string filtered WC AJAX endpoint URL
     */
    public function filter_woocommerce_ajax_get_endpoint($url, $request)
    {
        global $polylang;
        $lang = ( $polylang->curlang ) ? $polylang->curlang : $polylang->pref_lang;
        return parse_url($polylang->filters_links->links->get_home_url($lang), PHP_URL_PATH) . '?' . parse_url($url, PHP_URL_QUERY);
    }
}