Fix path for js scripts
This commit is contained in:
parent
8a47750818
commit
222f5efde1
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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},
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user