|
@@ -4,66 +4,39 @@
|
|
|
(function($) {
|
|
(function($) {
|
|
|
'use strict';
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
+ // Safe init wrapper - prevents one form's error from breaking others
|
|
|
|
|
+ function safeInit(name, selector, initFn) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ if ($(selector).length) {
|
|
|
|
|
+ console.log('STUDIOU WC: ' + name + ' found, initializing');
|
|
|
|
|
+ initFn();
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ console.error('STUDIOU WC: Error initializing ' + name + ':', e);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// Initialize admin scripts
|
|
// Initialize admin scripts
|
|
|
$(document).ready(function() {
|
|
$(document).ready(function() {
|
|
|
// Debug: Log that script is loaded
|
|
// Debug: Log that script is loaded
|
|
|
- console.log('STUDIOU WC: Admin script loaded');
|
|
|
|
|
- console.log('STUDIOU WC: studiouWcpcm object:', studiouWcpcm);
|
|
|
|
|
-
|
|
|
|
|
- // Import form handling
|
|
|
|
|
- if ($('#studiou-wcpcm-import-form').length) {
|
|
|
|
|
- console.log('STUDIOU WC: Import form found');
|
|
|
|
|
- initImportForm();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // Export form handling
|
|
|
|
|
- if ($('#studiou-wcpcm-export-form').length) {
|
|
|
|
|
- console.log('STUDIOU WC: Export form found');
|
|
|
|
|
- initExportForm();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // Move products form handling
|
|
|
|
|
- if ($('#studiou-wcpcm-move-form').length) {
|
|
|
|
|
- console.log('STUDIOU WC: Move form found');
|
|
|
|
|
- initMoveForm();
|
|
|
|
|
- } else {
|
|
|
|
|
- console.log('STUDIOU WC: Move form NOT found');
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // Batch description form handling
|
|
|
|
|
- if ($('#studiou-wcpcm-batch-description-form').length) {
|
|
|
|
|
- console.log('STUDIOU WC: Batch description form found');
|
|
|
|
|
- initBatchDescriptionForm();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // Delete products form handling
|
|
|
|
|
- if ($('#studiou-wcpcm-delete-products-form').length) {
|
|
|
|
|
- console.log('STUDIOU WC: Delete products form found');
|
|
|
|
|
- initDeleteProductsForm();
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ console.log('STUDIOU WC: Admin script loaded v1.5.1');
|
|
|
|
|
|
|
|
- // Clear media categories form handling
|
|
|
|
|
- if ($('#studiou-wcpcm-clear-media-form').length) {
|
|
|
|
|
- console.log('STUDIOU WC: Clear media form found');
|
|
|
|
|
- initClearMediaForm();
|
|
|
|
|
|
|
+ if (typeof studiouWcpcm === 'undefined') {
|
|
|
|
|
+ console.error('STUDIOU WC: studiouWcpcm object is NOT defined - AJAX will not work');
|
|
|
|
|
+ return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // Sample CSV download handler
|
|
|
|
|
- if ($('#studiou-wcpcm-download-sample').length) {
|
|
|
|
|
- initSampleDownload();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // Product import form handling
|
|
|
|
|
- if ($('#studiou-wcpcm-product-import-form').length) {
|
|
|
|
|
- console.log('STUDIOU WC: Product import form found');
|
|
|
|
|
- initProductImportForm();
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ console.log('STUDIOU WC: studiouWcpcm object:', studiouWcpcm);
|
|
|
|
|
|
|
|
- // Product export form handling
|
|
|
|
|
- if ($('#studiou-wcpcm-product-export-form').length) {
|
|
|
|
|
- console.log('STUDIOU WC: Product export form found');
|
|
|
|
|
- initProductExportForm();
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ safeInit('Import form', '#studiou-wcpcm-import-form', initImportForm);
|
|
|
|
|
+ safeInit('Export form', '#studiou-wcpcm-export-form', initExportForm);
|
|
|
|
|
+ safeInit('Move form', '#studiou-wcpcm-move-form', initMoveForm);
|
|
|
|
|
+ safeInit('Batch description form', '#studiou-wcpcm-batch-description-form', initBatchDescriptionForm);
|
|
|
|
|
+ safeInit('Delete products form', '#studiou-wcpcm-delete-products-form', initDeleteProductsForm);
|
|
|
|
|
+ safeInit('Clear media form', '#studiou-wcpcm-clear-media-form', initClearMediaForm);
|
|
|
|
|
+ safeInit('Sample download', '#studiou-wcpcm-download-sample', initSampleDownload);
|
|
|
|
|
+ safeInit('Product import form', '#studiou-wcpcm-product-import-form', initProductImportForm);
|
|
|
|
|
+ safeInit('Product export form', '#studiou-wcpcm-product-export-form', initProductExportForm);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
/**
|