src/LIN3S/WPFoundation/Configuration/Assets/Assets.php
protected function registerAjaxUrls($name, $ajaxUrl)
    {
        if (false === is_array($ajaxUrl)) {
            $ajaxUrl = [$ajaxUrl];
        }
        foreach ($ajaxUrl as $url) {
            wp_localize_script($name, $url, [
                'ajaxUrl' => admin_url('admin-ajax.php'),
            ]);
        }
    }
protected function registerAjaxUrls($name, $ajaxUrl)
    {
        if (false === is_array($ajaxUrl)) {
            $ajaxUrl = [$ajaxUrl];
        }
        foreach ($ajaxUrl as $url) {
            wp_localize_script($name, $url, [
                'ajaxUrl' => admin_url('admin-ajax.php'),
            ]);
        }
    }
protected function registerAjaxUrls ( $ name , $ ajaxUrl ) { if ( false === is_array ( $ ajaxUrl ) ) { $ ajaxUrl = [ $ ajaxUrl ] ; } foreach ( $ ajaxUrl as $ url ) { wp_localize_script ( $ name , $ url , [ 'ajaxUrl' => admin_url ( 'admin-ajax.php' ) , ] ) ; } }
Registers the ajax urls inside given JS filename.

@param string $name    The script file name
@param string $ajaxUrl The name that is going to expose in JS file as ajaxUrl

Usage example with name="subscribe" and ajaxUrl="subscribeAjax":

// subscribe.js

$.ajax({
url: subscribeAjax.ajaxUrl,
method: 'GET',
data: {
action: 'ajax-action-registered-in-your-php-file',
}
}).done(function (response) {
(...)
});
Registers the ajax urls inside given JS filename .