diff --git a/assets/js/sync.js b/assets/js/sync.js index 43c899a832..f78151ccfd 100644 --- a/assets/js/sync.js +++ b/assets/js/sync.js @@ -1,9 +1,11 @@ import apiFetch from '@wordpress/api-fetch'; /* eslint-disable camelcase, no-use-before-define */ -const { ajaxurl, epDash, history } = window; +const { epDash, history } = window; const { __, sprintf } = wp.i18n; +const { ajax_url: ajaxurl = '' } = epDash; + // Main elements of sync page const syncBox = document.querySelector('.ep-sync-data'); const deleteAndSyncBox = document.querySelector('.ep-delete-data-and-sync'); @@ -307,7 +309,7 @@ function updateSyncDash() { */ function cancelSync() { apiFetch({ - path: ajaxurl, + url: ajaxurl, method: 'POST', body: new URLSearchParams({ action: 'ep_cancel_index', @@ -322,7 +324,7 @@ function cancelSync() { function cliSync() { const requestSettings = { - path: ajaxurl, + url: ajaxurl, method: 'POST', body: new URLSearchParams({ action: 'ep_cli_index', @@ -458,7 +460,7 @@ function shouldInterruptSync(value) { */ function sync(putMapping = false) { const requestSettings = { - path: ajaxurl, + url: ajaxurl, method: 'POST', body: new URLSearchParams({ action: 'ep_index', diff --git a/includes/classes/Screen/Sync.php b/includes/classes/Screen/Sync.php index 91c9eebeb3..8d2ede6773 100644 --- a/includes/classes/Screen/Sync.php +++ b/includes/classes/Screen/Sync.php @@ -182,6 +182,7 @@ public function admin_enqueue_scripts() { ] ); + $data['ajax_url'] = admin_url( 'admin-ajax.php' ); $data['install_sync'] = empty( $last_sync ); $data['install_complete_url'] = esc_url( $install_complete_url ); $data['sync_complete'] = esc_html__( 'Sync complete', 'elasticpress' );