Skip to content

Commit

Permalink
Merge pull request #2501 from 10up/fix/sync-page-ajax-url-subsite
Browse files Browse the repository at this point in the history
Fix AJAX URL on subsite
  • Loading branch information
felipeelia authored Dec 8, 2021
2 parents 4f01012 + 816ada1 commit 238ab89
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
10 changes: 6 additions & 4 deletions assets/js/sync.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down Expand Up @@ -307,7 +309,7 @@ function updateSyncDash() {
*/
function cancelSync() {
apiFetch({
path: ajaxurl,
url: ajaxurl,
method: 'POST',
body: new URLSearchParams({
action: 'ep_cancel_index',
Expand All @@ -322,7 +324,7 @@ function cancelSync() {

function cliSync() {
const requestSettings = {
path: ajaxurl,
url: ajaxurl,
method: 'POST',
body: new URLSearchParams({
action: 'ep_cli_index',
Expand Down Expand Up @@ -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',
Expand Down
1 change: 1 addition & 0 deletions includes/classes/Screen/Sync.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand Down

0 comments on commit 238ab89

Please sign in to comment.