1
0
mirror of synced 2025-01-18 08:51:41 +03:00

Fix path for js scripts

This commit is contained in:
Dima Uryvskiy 2022-09-30 12:36:41 +03:00 committed by GitHub
parent 8a47750818
commit 222f5efde1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 14 deletions

View File

@ -17,10 +17,12 @@ jQuery(function () {
this.inventories = 0;
this.messageSuccessful = '';
this.adminUrl = AdminUrl.url;
let _this = this;
jQuery.ajax({
url: window.location.origin + '/wp-admin/admin-ajax.php?action=cron_info',
url: this.adminUrl + '/admin-ajax.php?action=cron_info',
method: "POST",
timeout: 0,
data: {ajax: 1},
@ -61,7 +63,7 @@ jQuery(function () {
jQuery.ajax({
type: "POST",
url: window.location.origin + '/wp-admin/admin-ajax.php?action=clear_cron_tasks',
url: this.adminUrl + '/admin-ajax.php?action=clear_cron_tasks',
success: function (response) {
alert(_this.messageSuccessful);
}

View File

@ -25,10 +25,13 @@ jQuery(function () {
this.ordersCount = 0;
this.customersCount = 0;
this.adminUrl = AdminUrl.url;
let _this = this;
jQuery.ajax({
url: window.location.origin + '/wp-admin/admin-ajax.php?action=content_upload',
url: this.adminUrl + '/admin-ajax.php?action=content_upload',
method: "POST",
timeout: 0,
data: {ajax: 1},
@ -101,7 +104,7 @@ jQuery(function () {
let _this = this;
jQuery.ajax({
url: window.location.origin + '/wp-admin/admin-ajax.php?action=do_upload',
url: this.adminUrl + '/admin-ajax.php?action=do_upload',
method: "POST",
timeout: 0,
data: data
@ -167,7 +170,7 @@ jQuery(function () {
jQuery.ajax({
type: "POST",
url: window.location.origin + '/wp-admin/admin-ajax.php?action=upload_selected_orders&order_ids_retailcrm=' + ids,
url: this.adminUrl + '/admin-ajax.php?action=upload_selected_orders&order_ids_retailcrm=' + ids,
success: function (response) {
alert(_this.messageSuccessful);
}

View File

@ -36,7 +36,7 @@ jQuery(function () {
}
jQuery.ajax({
url: window.location.origin + '/wp-admin/admin-ajax.php?action=set_meta_fields',
url: AdminUrl.url + '/admin-ajax.php?action=set_meta_fields',
method: 'POST',
timeout: 0,
data: {ajax: 1},

View File

@ -503,16 +503,17 @@ if (!class_exists('WC_Retailcrm_Base')) {
*/
private function include_js_scripts_for_admin()
{
$path = plugins_url() . '/woo-retailcrm/assets/js/';
$jsScripts = ['retailcrm-export', 'retailcrm-cron-info','retailcrm-meta-fields'];
$wpAdminUrl = ['url' => get_admin_url()];
$jsScriptsPath = plugins_url() . '/woo-retailcrm/assets/js/';
wp_register_script('retailcrm-export', $path . 'retailcrm-export.js', false, '0.1');
wp_enqueue_script('retailcrm-export', $path . 'retailcrm-export.js', '', '', true);
foreach ($jsScripts as $scriptName) {
wp_register_script($scriptName, $jsScriptsPath . $scriptName . '.js', false, '0.1');
wp_enqueue_script($scriptName, $jsScriptsPath . $scriptName . '.js', '', '', true);
wp_register_script('retailcrm-cron-info', $path . 'retailcrm-cron-info.js', false, '0.1');
wp_enqueue_script('retailcrm-cron-info', $path . 'retailcrm-export.js', '', '', true);
wp_register_script('retailcrm-meta-fields', $path . 'retailcrm-meta-fields.js', false, '0.1');
wp_enqueue_script('retailcrm-meta-fields', $path . 'retailcrm-meta-fields.js', '', '', true);
// In this method transfer wp-admin url in JS scripts.
wp_localize_script($scriptName, 'AdminUrl', $wpAdminUrl);
}
}
/**