2025-07-16 03:48:47 +08:00
|
|
|
jQuery(document).ready(function($) {
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
if (typeof window.gtag !== 'undefined') {
|
|
|
|
delete window.gtag;
|
|
|
|
}
|
|
|
|
if (typeof window.fbq !== 'undefined') {
|
|
|
|
delete window.fbq;
|
|
|
|
}
|
|
|
|
if (typeof window.dataLayer !== 'undefined') {
|
|
|
|
delete window.dataLayer;
|
|
|
|
}
|
|
|
|
|
|
|
|
window.gtag = function() {
|
|
|
|
console.log('WPTag: gtag() calls are disabled in admin area');
|
|
|
|
};
|
|
|
|
window.fbq = function() {
|
|
|
|
console.log('WPTag: fbq() calls are disabled in admin area');
|
|
|
|
};
|
|
|
|
|
2025-07-16 03:48:47 +08:00
|
|
|
WPTagAdmin.init();
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
|
|
|
|
$(window).on('load', function() {
|
|
|
|
setTimeout(function() {
|
|
|
|
WPTagAdmin.initializing = false;
|
|
|
|
WPTagAdmin.changeTrackingEnabled = true;
|
|
|
|
}, 500);
|
|
|
|
});
|
2025-07-16 03:48:47 +08:00
|
|
|
});
|
Add initial WPTag admin and core plugin files
Introduce the main admin controllers, AJAX handlers, UI partials, and core classes for the WPTag plugin. This includes admin interface components, dashboard, settings, snippet management, asset files, and localization support. These files establish the foundation for managing code snippets, templates, and plugin settings within the WordPress admin.
2025-07-16 03:44:42 +08:00
|
|
|
|
2025-07-16 03:48:47 +08:00
|
|
|
var WPTagAdmin = {
|
|
|
|
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
formChanged: false,
|
|
|
|
changeTrackingEnabled: false,
|
|
|
|
initializing: true,
|
|
|
|
|
2025-07-16 03:48:47 +08:00
|
|
|
init: function() {
|
|
|
|
var $ = jQuery;
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
var self = this;
|
|
|
|
|
2025-07-16 03:48:47 +08:00
|
|
|
this.handleServiceToggle();
|
|
|
|
this.handleCodeTypeToggle();
|
|
|
|
this.handleValidation();
|
|
|
|
this.handlePreview();
|
|
|
|
this.handleExportImport();
|
|
|
|
this.handleModal();
|
|
|
|
this.handleFormSubmission();
|
|
|
|
this.handleServicesManagement();
|
|
|
|
this.handleReset();
|
|
|
|
this.handleTabSwitching();
|
|
|
|
this.handleAdvancedToggle();
|
|
|
|
this.handleCodeEditor();
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
this.initTooltips();
|
|
|
|
|
|
|
|
setTimeout(function() {
|
|
|
|
self.initializing = false;
|
|
|
|
self.handleFormChangeTracking();
|
|
|
|
}, 1000);
|
2025-07-16 03:48:47 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
handleServiceToggle: function() {
|
|
|
|
var $ = jQuery;
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
var self = this;
|
|
|
|
|
2025-07-16 03:48:47 +08:00
|
|
|
$('.wptag-service-card input[name*="[enabled]"]').on('change', function() {
|
|
|
|
var $card = $(this).closest('.wptag-service-card');
|
|
|
|
var isEnabled = $(this).is(':checked');
|
|
|
|
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
self.changeTrackingEnabled = false;
|
|
|
|
|
2025-07-16 03:48:47 +08:00
|
|
|
if (isEnabled) {
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
$card.removeClass('disabled').addClass('enabled');
|
2025-07-16 03:48:47 +08:00
|
|
|
$card.find('.wptag-service-content input, .wptag-service-content select, .wptag-service-content textarea, .wptag-service-content button').prop('disabled', false);
|
|
|
|
} else {
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
$card.removeClass('enabled').addClass('disabled');
|
2025-07-16 03:48:47 +08:00
|
|
|
$card.find('.wptag-service-content input, .wptag-service-content select, .wptag-service-content textarea, .wptag-service-content button').prop('disabled', true);
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
$card.find('.wptag-validation-result').hide();
|
2025-07-16 03:48:47 +08:00
|
|
|
}
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
|
|
|
|
setTimeout(function() {
|
|
|
|
self.changeTrackingEnabled = true;
|
|
|
|
if (!self.initializing) {
|
|
|
|
self.formChanged = true;
|
|
|
|
}
|
|
|
|
}, 100);
|
2025-07-16 03:48:47 +08:00
|
|
|
});
|
|
|
|
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
$('.wptag-service-card input[name*="[enabled]"]').each(function() {
|
|
|
|
$(this).trigger('change');
|
|
|
|
});
|
2025-07-16 03:48:47 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
handleCodeTypeToggle: function() {
|
|
|
|
var $ = jQuery;
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
var self = this;
|
|
|
|
|
2025-07-16 03:48:47 +08:00
|
|
|
$('input[name*="[use_template]"]').on('change', function() {
|
|
|
|
var $card = $(this).closest('.wptag-service-card');
|
|
|
|
var useTemplate = $(this).val() === '1' && $(this).is(':checked');
|
|
|
|
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
self.changeTrackingEnabled = false;
|
|
|
|
|
2025-07-16 03:48:47 +08:00
|
|
|
if (useTemplate) {
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
$card.find('.wptag-template-fields').slideDown(300);
|
|
|
|
$card.find('.wptag-custom-fields').slideUp(300);
|
2025-07-16 03:48:47 +08:00
|
|
|
} else {
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
$card.find('.wptag-template-fields').slideUp(300);
|
|
|
|
$card.find('.wptag-custom-fields').slideDown(300);
|
2025-07-16 03:48:47 +08:00
|
|
|
}
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
|
|
|
|
$card.find('.wptag-validation-result').hide();
|
|
|
|
|
|
|
|
setTimeout(function() {
|
|
|
|
self.changeTrackingEnabled = true;
|
|
|
|
if (!self.initializing) {
|
|
|
|
self.formChanged = true;
|
|
|
|
}
|
|
|
|
}, 100);
|
2025-07-16 03:48:47 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
$('input[name*="[use_template]"]:checked').trigger('change');
|
|
|
|
},
|
|
|
|
|
|
|
|
handleValidation: function() {
|
|
|
|
var $ = jQuery;
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
|
|
|
|
$('.wptag-validate-btn').on('click', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
|
2025-07-16 03:48:47 +08:00
|
|
|
var $btn = $(this);
|
|
|
|
var $card = $btn.closest('.wptag-service-card');
|
|
|
|
var service = $card.data('service');
|
|
|
|
var $result = $card.find('.wptag-validation-result');
|
Add initial WPTag admin and core plugin files
Introduce the main admin controllers, AJAX handlers, UI partials, and core classes for the WPTag plugin. This includes admin interface components, dashboard, settings, snippet management, asset files, and localization support. These files establish the foundation for managing code snippets, templates, and plugin settings within the WordPress admin.
2025-07-16 03:44:42 +08:00
|
|
|
|
2025-07-16 03:48:47 +08:00
|
|
|
var useTemplate = $card.find('input[name*="[use_template]"]:checked').val() === '1';
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
var idValue = $card.find('input[type="text"]').first().val().trim();
|
|
|
|
var customCode = $card.find('textarea').val().trim();
|
2025-07-16 03:48:47 +08:00
|
|
|
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
if (useTemplate && !idValue) {
|
|
|
|
WPTagAdmin.showValidationResult($result, 'invalid', 'Please enter an ID value first');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!useTemplate && !customCode) {
|
|
|
|
WPTagAdmin.showValidationResult($result, 'invalid', 'Please enter custom code first');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$btn.addClass('wptag-button-loading').prop('disabled', true);
|
|
|
|
WPTagAdmin.showValidationResult($result, 'loading', wptagAdmin.strings.validating);
|
Add initial WPTag admin and core plugin files
Introduce the main admin controllers, AJAX handlers, UI partials, and core classes for the WPTag plugin. This includes admin interface components, dashboard, settings, snippet management, asset files, and localization support. These files establish the foundation for managing code snippets, templates, and plugin settings within the WordPress admin.
2025-07-16 03:44:42 +08:00
|
|
|
|
|
|
|
$.ajax({
|
2025-07-16 03:48:47 +08:00
|
|
|
url: wptagAdmin.ajax_url,
|
Add initial WPTag admin and core plugin files
Introduce the main admin controllers, AJAX handlers, UI partials, and core classes for the WPTag plugin. This includes admin interface components, dashboard, settings, snippet management, asset files, and localization support. These files establish the foundation for managing code snippets, templates, and plugin settings within the WordPress admin.
2025-07-16 03:44:42 +08:00
|
|
|
type: 'POST',
|
|
|
|
data: {
|
2025-07-16 03:48:47 +08:00
|
|
|
action: 'wptag_validate_code',
|
|
|
|
nonce: wptagAdmin.nonce,
|
|
|
|
service: service,
|
|
|
|
use_template: useTemplate ? '1' : '0',
|
|
|
|
id_value: idValue,
|
|
|
|
custom_code: customCode
|
Add initial WPTag admin and core plugin files
Introduce the main admin controllers, AJAX handlers, UI partials, and core classes for the WPTag plugin. This includes admin interface components, dashboard, settings, snippet management, asset files, and localization support. These files establish the foundation for managing code snippets, templates, and plugin settings within the WordPress admin.
2025-07-16 03:44:42 +08:00
|
|
|
},
|
|
|
|
success: function(response) {
|
|
|
|
if (response.success) {
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
WPTagAdmin.showValidationResult($result, 'valid', '✓ ' + response.data.message);
|
Add initial WPTag admin and core plugin files
Introduce the main admin controllers, AJAX handlers, UI partials, and core classes for the WPTag plugin. This includes admin interface components, dashboard, settings, snippet management, asset files, and localization support. These files establish the foundation for managing code snippets, templates, and plugin settings within the WordPress admin.
2025-07-16 03:44:42 +08:00
|
|
|
} else {
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
WPTagAdmin.showValidationResult($result, 'invalid', '✗ ' + response.data.message);
|
Add initial WPTag admin and core plugin files
Introduce the main admin controllers, AJAX handlers, UI partials, and core classes for the WPTag plugin. This includes admin interface components, dashboard, settings, snippet management, asset files, and localization support. These files establish the foundation for managing code snippets, templates, and plugin settings within the WordPress admin.
2025-07-16 03:44:42 +08:00
|
|
|
}
|
|
|
|
},
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
error: function(xhr, status, error) {
|
|
|
|
console.error('Validation error:', error);
|
|
|
|
WPTagAdmin.showValidationResult($result, 'invalid', '✗ Validation failed. Please try again.');
|
2025-07-16 03:48:47 +08:00
|
|
|
},
|
|
|
|
complete: function() {
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
$btn.removeClass('wptag-button-loading').prop('disabled', false);
|
Add initial WPTag admin and core plugin files
Introduce the main admin controllers, AJAX handlers, UI partials, and core classes for the WPTag plugin. This includes admin interface components, dashboard, settings, snippet management, asset files, and localization support. These files establish the foundation for managing code snippets, templates, and plugin settings within the WordPress admin.
2025-07-16 03:44:42 +08:00
|
|
|
}
|
|
|
|
});
|
2025-07-16 03:48:47 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
$('input[type="text"], textarea').on('input', function() {
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
$(this).closest('.wptag-service-card').find('.wptag-validation-result').hide();
|
|
|
|
if (WPTagAdmin.changeTrackingEnabled && !WPTagAdmin.initializing) {
|
|
|
|
WPTagAdmin.formChanged = true;
|
|
|
|
}
|
2025-07-16 03:48:47 +08:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
showValidationResult: function($result, type, message) {
|
|
|
|
$result.removeClass('valid invalid loading')
|
|
|
|
.addClass(type)
|
|
|
|
.text(message)
|
|
|
|
.show();
|
|
|
|
},
|
|
|
|
|
2025-07-16 03:48:47 +08:00
|
|
|
handlePreview: function() {
|
|
|
|
var $ = jQuery;
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
|
|
|
|
$('.wptag-preview-btn').on('click', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
|
2025-07-16 03:48:47 +08:00
|
|
|
var $btn = $(this);
|
|
|
|
var $card = $btn.closest('.wptag-service-card');
|
|
|
|
var service = $card.data('service');
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
var idValue = $card.find('input[type="text"]').first().val().trim();
|
Add initial WPTag admin and core plugin files
Introduce the main admin controllers, AJAX handlers, UI partials, and core classes for the WPTag plugin. This includes admin interface components, dashboard, settings, snippet management, asset files, and localization support. These files establish the foundation for managing code snippets, templates, and plugin settings within the WordPress admin.
2025-07-16 03:44:42 +08:00
|
|
|
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
if (!idValue) {
|
2025-07-16 03:48:47 +08:00
|
|
|
alert('Please enter an ID value to preview');
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
$card.find('input[type="text"]').first().focus();
|
Add initial WPTag admin and core plugin files
Introduce the main admin controllers, AJAX handlers, UI partials, and core classes for the WPTag plugin. This includes admin interface components, dashboard, settings, snippet management, asset files, and localization support. These files establish the foundation for managing code snippets, templates, and plugin settings within the WordPress admin.
2025-07-16 03:44:42 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
$btn.addClass('wptag-button-loading').prop('disabled', true);
|
Add initial WPTag admin and core plugin files
Introduce the main admin controllers, AJAX handlers, UI partials, and core classes for the WPTag plugin. This includes admin interface components, dashboard, settings, snippet management, asset files, and localization support. These files establish the foundation for managing code snippets, templates, and plugin settings within the WordPress admin.
2025-07-16 03:44:42 +08:00
|
|
|
|
|
|
|
$.ajax({
|
2025-07-16 03:48:47 +08:00
|
|
|
url: wptagAdmin.ajax_url,
|
Add initial WPTag admin and core plugin files
Introduce the main admin controllers, AJAX handlers, UI partials, and core classes for the WPTag plugin. This includes admin interface components, dashboard, settings, snippet management, asset files, and localization support. These files establish the foundation for managing code snippets, templates, and plugin settings within the WordPress admin.
2025-07-16 03:44:42 +08:00
|
|
|
type: 'POST',
|
|
|
|
data: {
|
2025-07-16 03:48:47 +08:00
|
|
|
action: 'wptag_preview_code',
|
|
|
|
nonce: wptagAdmin.nonce,
|
|
|
|
service: service,
|
|
|
|
id_value: idValue
|
Add initial WPTag admin and core plugin files
Introduce the main admin controllers, AJAX handlers, UI partials, and core classes for the WPTag plugin. This includes admin interface components, dashboard, settings, snippet management, asset files, and localization support. These files establish the foundation for managing code snippets, templates, and plugin settings within the WordPress admin.
2025-07-16 03:44:42 +08:00
|
|
|
},
|
|
|
|
success: function(response) {
|
|
|
|
if (response.success) {
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
var previewCode = response.data.preview;
|
|
|
|
$('#wptag-preview-code').text(previewCode);
|
|
|
|
$('#wptag-preview-modal').fadeIn(300);
|
|
|
|
$('body').addClass('modal-open');
|
Add initial WPTag admin and core plugin files
Introduce the main admin controllers, AJAX handlers, UI partials, and core classes for the WPTag plugin. This includes admin interface components, dashboard, settings, snippet management, asset files, and localization support. These files establish the foundation for managing code snippets, templates, and plugin settings within the WordPress admin.
2025-07-16 03:44:42 +08:00
|
|
|
} else {
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
WPTagAdmin.showNotice('error', 'Preview Error: ' + response.data.message);
|
Add initial WPTag admin and core plugin files
Introduce the main admin controllers, AJAX handlers, UI partials, and core classes for the WPTag plugin. This includes admin interface components, dashboard, settings, snippet management, asset files, and localization support. These files establish the foundation for managing code snippets, templates, and plugin settings within the WordPress admin.
2025-07-16 03:44:42 +08:00
|
|
|
}
|
|
|
|
},
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
error: function(xhr, status, error) {
|
|
|
|
console.error('Preview error:', error);
|
|
|
|
WPTagAdmin.showNotice('error', 'Failed to generate preview. Please try again.');
|
2025-07-16 03:48:47 +08:00
|
|
|
},
|
|
|
|
complete: function() {
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
$btn.removeClass('wptag-button-loading').prop('disabled', false);
|
Add initial WPTag admin and core plugin files
Introduce the main admin controllers, AJAX handlers, UI partials, and core classes for the WPTag plugin. This includes admin interface components, dashboard, settings, snippet management, asset files, and localization support. These files establish the foundation for managing code snippets, templates, and plugin settings within the WordPress admin.
2025-07-16 03:44:42 +08:00
|
|
|
}
|
|
|
|
});
|
2025-07-16 03:48:47 +08:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
handleExportImport: function() {
|
|
|
|
var $ = jQuery;
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
|
|
|
|
$('#wptag-export-btn').on('click', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
|
2025-07-16 03:48:47 +08:00
|
|
|
var $btn = $(this);
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
$btn.addClass('wptag-button-loading').prop('disabled', true);
|
Add initial WPTag admin and core plugin files
Introduce the main admin controllers, AJAX handlers, UI partials, and core classes for the WPTag plugin. This includes admin interface components, dashboard, settings, snippet management, asset files, and localization support. These files establish the foundation for managing code snippets, templates, and plugin settings within the WordPress admin.
2025-07-16 03:44:42 +08:00
|
|
|
|
|
|
|
$.ajax({
|
2025-07-16 03:48:47 +08:00
|
|
|
url: wptagAdmin.ajax_url,
|
Add initial WPTag admin and core plugin files
Introduce the main admin controllers, AJAX handlers, UI partials, and core classes for the WPTag plugin. This includes admin interface components, dashboard, settings, snippet management, asset files, and localization support. These files establish the foundation for managing code snippets, templates, and plugin settings within the WordPress admin.
2025-07-16 03:44:42 +08:00
|
|
|
type: 'POST',
|
|
|
|
data: {
|
2025-07-16 03:48:47 +08:00
|
|
|
action: 'wptag_export_settings',
|
Add initial WPTag admin and core plugin files
Introduce the main admin controllers, AJAX handlers, UI partials, and core classes for the WPTag plugin. This includes admin interface components, dashboard, settings, snippet management, asset files, and localization support. These files establish the foundation for managing code snippets, templates, and plugin settings within the WordPress admin.
2025-07-16 03:44:42 +08:00
|
|
|
nonce: wptagAdmin.nonce
|
|
|
|
},
|
|
|
|
success: function(response) {
|
|
|
|
if (response.success) {
|
2025-07-16 03:48:47 +08:00
|
|
|
WPTagAdmin.downloadFile(response.data.data, response.data.filename);
|
|
|
|
WPTagAdmin.showNotice('success', wptagAdmin.strings.export_success);
|
|
|
|
} else {
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
WPTagAdmin.showNotice('error', 'Export failed: ' + response.data.message);
|
Add initial WPTag admin and core plugin files
Introduce the main admin controllers, AJAX handlers, UI partials, and core classes for the WPTag plugin. This includes admin interface components, dashboard, settings, snippet management, asset files, and localization support. These files establish the foundation for managing code snippets, templates, and plugin settings within the WordPress admin.
2025-07-16 03:44:42 +08:00
|
|
|
}
|
2025-07-16 03:48:47 +08:00
|
|
|
},
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
error: function(xhr, status, error) {
|
|
|
|
console.error('Export error:', error);
|
|
|
|
WPTagAdmin.showNotice('error', 'Export failed. Please try again.');
|
2025-07-16 03:48:47 +08:00
|
|
|
},
|
|
|
|
complete: function() {
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
$btn.removeClass('wptag-button-loading').prop('disabled', false);
|
Add initial WPTag admin and core plugin files
Introduce the main admin controllers, AJAX handlers, UI partials, and core classes for the WPTag plugin. This includes admin interface components, dashboard, settings, snippet management, asset files, and localization support. These files establish the foundation for managing code snippets, templates, and plugin settings within the WordPress admin.
2025-07-16 03:44:42 +08:00
|
|
|
}
|
|
|
|
});
|
2025-07-16 03:48:47 +08:00
|
|
|
});
|
|
|
|
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
$('#wptag-import-btn').on('click', function(e) {
|
|
|
|
e.preventDefault();
|
2025-07-16 03:48:47 +08:00
|
|
|
$('#wptag-import-file').click();
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#wptag-import-file').on('change', function() {
|
|
|
|
var file = this.files[0];
|
|
|
|
if (!file) return;
|
Add initial WPTag admin and core plugin files
Introduce the main admin controllers, AJAX handlers, UI partials, and core classes for the WPTag plugin. This includes admin interface components, dashboard, settings, snippet management, asset files, and localization support. These files establish the foundation for managing code snippets, templates, and plugin settings within the WordPress admin.
2025-07-16 03:44:42 +08:00
|
|
|
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
if (!file.name.endsWith('.json')) {
|
|
|
|
WPTagAdmin.showNotice('error', 'Please select a valid JSON file.');
|
|
|
|
this.value = '';
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2025-07-16 03:48:47 +08:00
|
|
|
if (!confirm(wptagAdmin.strings.confirm_import)) {
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
this.value = '';
|
2025-07-16 03:48:47 +08:00
|
|
|
return;
|
|
|
|
}
|
Add initial WPTag admin and core plugin files
Introduce the main admin controllers, AJAX handlers, UI partials, and core classes for the WPTag plugin. This includes admin interface components, dashboard, settings, snippet management, asset files, and localization support. These files establish the foundation for managing code snippets, templates, and plugin settings within the WordPress admin.
2025-07-16 03:44:42 +08:00
|
|
|
|
2025-07-16 03:48:47 +08:00
|
|
|
var reader = new FileReader();
|
|
|
|
reader.onload = function(e) {
|
|
|
|
var importData = e.target.result;
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
url: wptagAdmin.ajax_url,
|
|
|
|
type: 'POST',
|
|
|
|
data: {
|
|
|
|
action: 'wptag_import_settings',
|
|
|
|
nonce: wptagAdmin.nonce,
|
|
|
|
import_data: importData
|
|
|
|
},
|
|
|
|
success: function(response) {
|
|
|
|
if (response.success) {
|
|
|
|
WPTagAdmin.showNotice('success', wptagAdmin.strings.import_success);
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
WPTagAdmin.formChanged = false;
|
|
|
|
WPTagAdmin.initializing = true;
|
2025-07-16 03:48:47 +08:00
|
|
|
setTimeout(function() {
|
|
|
|
location.reload();
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
}, 1500);
|
2025-07-16 03:48:47 +08:00
|
|
|
} else {
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
WPTagAdmin.showNotice('error', 'Import failed: ' + response.data.message);
|
2025-07-16 03:48:47 +08:00
|
|
|
}
|
|
|
|
},
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
error: function(xhr, status, error) {
|
|
|
|
console.error('Import error:', error);
|
|
|
|
WPTagAdmin.showNotice('error', 'Import failed. Please try again.');
|
2025-07-16 03:48:47 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
Add initial WPTag admin and core plugin files
Introduce the main admin controllers, AJAX handlers, UI partials, and core classes for the WPTag plugin. This includes admin interface components, dashboard, settings, snippet management, asset files, and localization support. These files establish the foundation for managing code snippets, templates, and plugin settings within the WordPress admin.
2025-07-16 03:44:42 +08:00
|
|
|
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
reader.onerror = function() {
|
|
|
|
WPTagAdmin.showNotice('error', 'Failed to read the file.');
|
|
|
|
};
|
|
|
|
|
|
|
|
reader.readAsText(file);
|
2025-07-16 03:48:47 +08:00
|
|
|
this.value = '';
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
handleReset: function() {
|
|
|
|
var $ = jQuery;
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
|
|
|
|
$('#wptag-reset-btn').on('click', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
|
2025-07-16 03:48:47 +08:00
|
|
|
if (!confirm(wptagAdmin.strings.confirm_reset)) {
|
|
|
|
return;
|
|
|
|
}
|
Add initial WPTag admin and core plugin files
Introduce the main admin controllers, AJAX handlers, UI partials, and core classes for the WPTag plugin. This includes admin interface components, dashboard, settings, snippet management, asset files, and localization support. These files establish the foundation for managing code snippets, templates, and plugin settings within the WordPress admin.
2025-07-16 03:44:42 +08:00
|
|
|
|
2025-07-16 03:48:47 +08:00
|
|
|
var $btn = $(this);
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
$btn.addClass('wptag-button-loading').prop('disabled', true);
|
Add initial WPTag admin and core plugin files
Introduce the main admin controllers, AJAX handlers, UI partials, and core classes for the WPTag plugin. This includes admin interface components, dashboard, settings, snippet management, asset files, and localization support. These files establish the foundation for managing code snippets, templates, and plugin settings within the WordPress admin.
2025-07-16 03:44:42 +08:00
|
|
|
|
|
|
|
$.ajax({
|
2025-07-16 03:48:47 +08:00
|
|
|
url: wptagAdmin.ajax_url,
|
Add initial WPTag admin and core plugin files
Introduce the main admin controllers, AJAX handlers, UI partials, and core classes for the WPTag plugin. This includes admin interface components, dashboard, settings, snippet management, asset files, and localization support. These files establish the foundation for managing code snippets, templates, and plugin settings within the WordPress admin.
2025-07-16 03:44:42 +08:00
|
|
|
type: 'POST',
|
|
|
|
data: {
|
2025-07-16 03:48:47 +08:00
|
|
|
action: 'wptag_reset_settings',
|
Add initial WPTag admin and core plugin files
Introduce the main admin controllers, AJAX handlers, UI partials, and core classes for the WPTag plugin. This includes admin interface components, dashboard, settings, snippet management, asset files, and localization support. These files establish the foundation for managing code snippets, templates, and plugin settings within the WordPress admin.
2025-07-16 03:44:42 +08:00
|
|
|
nonce: wptagAdmin.nonce
|
|
|
|
},
|
|
|
|
success: function(response) {
|
|
|
|
if (response.success) {
|
2025-07-16 03:48:47 +08:00
|
|
|
WPTagAdmin.showNotice('success', wptagAdmin.strings.reset_success);
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
WPTagAdmin.formChanged = false;
|
|
|
|
WPTagAdmin.initializing = true;
|
2025-07-16 03:48:47 +08:00
|
|
|
setTimeout(function() {
|
|
|
|
location.reload();
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
}, 1500);
|
Add initial WPTag admin and core plugin files
Introduce the main admin controllers, AJAX handlers, UI partials, and core classes for the WPTag plugin. This includes admin interface components, dashboard, settings, snippet management, asset files, and localization support. These files establish the foundation for managing code snippets, templates, and plugin settings within the WordPress admin.
2025-07-16 03:44:42 +08:00
|
|
|
} else {
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
WPTagAdmin.showNotice('error', 'Reset failed: ' + response.data.message);
|
Add initial WPTag admin and core plugin files
Introduce the main admin controllers, AJAX handlers, UI partials, and core classes for the WPTag plugin. This includes admin interface components, dashboard, settings, snippet management, asset files, and localization support. These files establish the foundation for managing code snippets, templates, and plugin settings within the WordPress admin.
2025-07-16 03:44:42 +08:00
|
|
|
}
|
2025-07-16 03:48:47 +08:00
|
|
|
},
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
error: function(xhr, status, error) {
|
|
|
|
console.error('Reset error:', error);
|
|
|
|
WPTagAdmin.showNotice('error', 'Reset failed. Please try again.');
|
2025-07-16 03:48:47 +08:00
|
|
|
},
|
|
|
|
complete: function() {
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
$btn.removeClass('wptag-button-loading').prop('disabled', false);
|
Add initial WPTag admin and core plugin files
Introduce the main admin controllers, AJAX handlers, UI partials, and core classes for the WPTag plugin. This includes admin interface components, dashboard, settings, snippet management, asset files, and localization support. These files establish the foundation for managing code snippets, templates, and plugin settings within the WordPress admin.
2025-07-16 03:44:42 +08:00
|
|
|
}
|
|
|
|
});
|
2025-07-16 03:48:47 +08:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
handleServicesManagement: function() {
|
|
|
|
var $ = jQuery;
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
var self = this;
|
|
|
|
|
|
|
|
$('#wptag-enable-all').on('click', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
self.changeTrackingEnabled = false;
|
|
|
|
$('input[name="enabled_services[]"]').prop('checked', true).trigger('change');
|
|
|
|
setTimeout(function() {
|
|
|
|
self.changeTrackingEnabled = true;
|
|
|
|
self.formChanged = true;
|
|
|
|
}, 100);
|
2025-07-16 03:48:47 +08:00
|
|
|
});
|
|
|
|
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
$('#wptag-disable-all').on('click', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
self.changeTrackingEnabled = false;
|
|
|
|
$('input[name="enabled_services[]"]').prop('checked', false).trigger('change');
|
|
|
|
setTimeout(function() {
|
|
|
|
self.changeTrackingEnabled = true;
|
|
|
|
self.formChanged = true;
|
|
|
|
}, 100);
|
2025-07-16 03:48:47 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
$('.wptag-service-item input[type="checkbox"]').on('change', function() {
|
|
|
|
var $item = $(this).closest('.wptag-service-item');
|
|
|
|
var isChecked = $(this).is(':checked');
|
Add initial WPTag admin and core plugin files
Introduce the main admin controllers, AJAX handlers, UI partials, and core classes for the WPTag plugin. This includes admin interface components, dashboard, settings, snippet management, asset files, and localization support. These files establish the foundation for managing code snippets, templates, and plugin settings within the WordPress admin.
2025-07-16 03:44:42 +08:00
|
|
|
|
2025-07-16 03:48:47 +08:00
|
|
|
if (isChecked) {
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
$item.removeClass('disabled').addClass('enabled');
|
2025-07-16 03:48:47 +08:00
|
|
|
} else {
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
$item.removeClass('enabled').addClass('disabled');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (self.changeTrackingEnabled && !self.initializing) {
|
|
|
|
self.formChanged = true;
|
2025-07-16 03:48:47 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$('.wptag-service-item input[type="checkbox"]').trigger('change');
|
|
|
|
},
|
|
|
|
|
|
|
|
handleModal: function() {
|
|
|
|
var $ = jQuery;
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
|
|
|
|
$('.wptag-modal-close, .wptag-modal-backdrop').on('click', function(e) {
|
2025-07-16 03:48:47 +08:00
|
|
|
if (e.target === this) {
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
WPTagAdmin.closeModal();
|
2025-07-16 03:48:47 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$('.wptag-modal-content').on('click', function(e) {
|
|
|
|
e.stopPropagation();
|
|
|
|
});
|
|
|
|
|
|
|
|
$(document).on('keydown', function(e) {
|
|
|
|
if (e.keyCode === 27 && $('#wptag-preview-modal').is(':visible')) {
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
WPTagAdmin.closeModal();
|
2025-07-16 03:48:47 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
closeModal: function() {
|
|
|
|
var $ = jQuery;
|
|
|
|
$('#wptag-preview-modal').fadeOut(300, function() {
|
|
|
|
$('body').removeClass('modal-open');
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2025-07-16 03:48:47 +08:00
|
|
|
handleFormSubmission: function() {
|
|
|
|
var $ = jQuery;
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
var self = this;
|
|
|
|
|
2025-07-16 03:48:47 +08:00
|
|
|
$('.wptag-settings-form').on('submit', function(e) {
|
|
|
|
var hasErrors = false;
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
var $form = $(this);
|
Add initial WPTag admin and core plugin files
Introduce the main admin controllers, AJAX handlers, UI partials, and core classes for the WPTag plugin. This includes admin interface components, dashboard, settings, snippet management, asset files, and localization support. These files establish the foundation for managing code snippets, templates, and plugin settings within the WordPress admin.
2025-07-16 03:44:42 +08:00
|
|
|
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
$('.wptag-service-card.enabled').each(function() {
|
2025-07-16 03:48:47 +08:00
|
|
|
var $card = $(this);
|
|
|
|
var useTemplate = $card.find('input[name*="[use_template]"]:checked').val() === '1';
|
|
|
|
|
|
|
|
if (useTemplate) {
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
var $idInput = $card.find('input[type="text"]').first();
|
|
|
|
if ($idInput.val().trim() === '') {
|
|
|
|
WPTagAdmin.showNotice('error', 'Please enter an ID for all enabled services or disable them.');
|
|
|
|
$idInput.focus();
|
2025-07-16 03:48:47 +08:00
|
|
|
hasErrors = true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
var $customCodeTextarea = $card.find('textarea');
|
|
|
|
if ($customCodeTextarea.val().trim() === '') {
|
|
|
|
WPTagAdmin.showNotice('error', 'Please enter custom code for all enabled services or disable them.');
|
|
|
|
$customCodeTextarea.focus();
|
2025-07-16 03:48:47 +08:00
|
|
|
hasErrors = true;
|
|
|
|
return false;
|
Add initial WPTag admin and core plugin files
Introduce the main admin controllers, AJAX handlers, UI partials, and core classes for the WPTag plugin. This includes admin interface components, dashboard, settings, snippet management, asset files, and localization support. These files establish the foundation for managing code snippets, templates, and plugin settings within the WordPress admin.
2025-07-16 03:44:42 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2025-07-16 03:48:47 +08:00
|
|
|
if (hasErrors) {
|
Add initial WPTag admin and core plugin files
Introduce the main admin controllers, AJAX handlers, UI partials, and core classes for the WPTag plugin. This includes admin interface components, dashboard, settings, snippet management, asset files, and localization support. These files establish the foundation for managing code snippets, templates, and plugin settings within the WordPress admin.
2025-07-16 03:44:42 +08:00
|
|
|
e.preventDefault();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
var $saveBtn = $form.find('#wptag-save-btn');
|
|
|
|
$saveBtn.addClass('wptag-button-loading').prop('disabled', true).val('Saving...');
|
|
|
|
self.formChanged = false;
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#wptag-services-form').on('submit', function() {
|
|
|
|
var $saveBtn = $(this).find('input[type="submit"]');
|
|
|
|
$saveBtn.addClass('wptag-button-loading').prop('disabled', true).val('Saving...');
|
|
|
|
WPTagAdmin.formChanged = false;
|
2025-07-16 03:48:47 +08:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
handleTabSwitching: function() {
|
|
|
|
var $ = jQuery;
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
var self = this;
|
|
|
|
|
2025-07-16 03:48:47 +08:00
|
|
|
$('.nav-tab').on('click', function(e) {
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
if (self.formChanged && !self.initializing) {
|
|
|
|
var confirmed = confirm('You have unsaved changes. Do you want to continue without saving?');
|
|
|
|
if (!confirmed) {
|
|
|
|
e.preventDefault();
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
self.formChanged = false;
|
|
|
|
}
|
2025-07-16 03:48:47 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
handleAdvancedToggle: function() {
|
|
|
|
var $ = jQuery;
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
|
2025-07-16 03:48:47 +08:00
|
|
|
$('.wptag-toggle-advanced').on('click', function(e) {
|
|
|
|
e.preventDefault();
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
|
2025-07-16 03:48:47 +08:00
|
|
|
var $btn = $(this);
|
|
|
|
var $card = $btn.closest('.wptag-service-card');
|
|
|
|
var $advanced = $card.find('.wptag-advanced-settings');
|
|
|
|
var $icon = $btn.find('.dashicons');
|
|
|
|
|
|
|
|
if ($advanced.is(':visible')) {
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
$advanced.slideUp(300);
|
2025-07-16 03:48:47 +08:00
|
|
|
$icon.removeClass('dashicons-arrow-up-alt2').addClass('dashicons-arrow-down-alt2');
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
$btn.html('<span class="dashicons dashicons-arrow-down-alt2"></span>' + wptagAdmin.strings.advanced_settings);
|
2025-07-16 03:48:47 +08:00
|
|
|
} else {
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
$advanced.slideDown(300);
|
2025-07-16 03:48:47 +08:00
|
|
|
$icon.removeClass('dashicons-arrow-down-alt2').addClass('dashicons-arrow-up-alt2');
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
$btn.html('<span class="dashicons dashicons-arrow-up-alt2"></span>' + wptagAdmin.strings.hide_advanced);
|
Add initial WPTag admin and core plugin files
Introduce the main admin controllers, AJAX handlers, UI partials, and core classes for the WPTag plugin. This includes admin interface components, dashboard, settings, snippet management, asset files, and localization support. These files establish the foundation for managing code snippets, templates, and plugin settings within the WordPress admin.
2025-07-16 03:44:42 +08:00
|
|
|
}
|
2025-07-16 03:48:47 +08:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
handleCodeEditor: function() {
|
|
|
|
var $ = jQuery;
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
|
2025-07-16 03:48:47 +08:00
|
|
|
$('.wptag-code-editor').each(function() {
|
|
|
|
var $editor = $(this);
|
|
|
|
|
|
|
|
$editor.on('input', function() {
|
|
|
|
WPTagAdmin.updateEditorHeight(this);
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
if (WPTagAdmin.changeTrackingEnabled && !WPTagAdmin.initializing) {
|
|
|
|
WPTagAdmin.formChanged = true;
|
|
|
|
}
|
2025-07-16 03:48:47 +08:00
|
|
|
});
|
Add initial WPTag admin and core plugin files
Introduce the main admin controllers, AJAX handlers, UI partials, and core classes for the WPTag plugin. This includes admin interface components, dashboard, settings, snippet management, asset files, and localization support. These files establish the foundation for managing code snippets, templates, and plugin settings within the WordPress admin.
2025-07-16 03:44:42 +08:00
|
|
|
|
2025-07-16 03:48:47 +08:00
|
|
|
$editor.on('keydown', function(e) {
|
|
|
|
if (e.keyCode === 9) {
|
|
|
|
e.preventDefault();
|
|
|
|
var start = this.selectionStart;
|
|
|
|
var end = this.selectionEnd;
|
|
|
|
var value = this.value;
|
|
|
|
this.value = value.substring(0, start) + " " + value.substring(end);
|
|
|
|
this.selectionStart = this.selectionEnd = start + 2;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
WPTagAdmin.updateEditorHeight(this);
|
|
|
|
});
|
|
|
|
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
$('.wptag-format-code').on('click', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
|
2025-07-16 03:48:47 +08:00
|
|
|
var $btn = $(this);
|
|
|
|
var $editor = $btn.closest('.wptag-code-editor-wrapper').find('.wptag-code-editor');
|
|
|
|
var code = $editor.val();
|
|
|
|
|
|
|
|
if (code.trim()) {
|
|
|
|
try {
|
|
|
|
var formatted = WPTagAdmin.formatCode(code);
|
|
|
|
$editor.val(formatted);
|
|
|
|
WPTagAdmin.updateEditorHeight($editor[0]);
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
if (WPTagAdmin.changeTrackingEnabled && !WPTagAdmin.initializing) {
|
|
|
|
WPTagAdmin.formChanged = true;
|
|
|
|
}
|
|
|
|
WPTagAdmin.showNotice('success', 'Code formatted successfully.');
|
2025-07-16 03:48:47 +08:00
|
|
|
} catch (e) {
|
|
|
|
console.log('Code formatting failed:', e);
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
WPTagAdmin.showNotice('error', 'Code formatting failed. Please check your code syntax.');
|
2025-07-16 03:48:47 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
$('.wptag-clear-code').on('click', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
|
2025-07-16 03:48:47 +08:00
|
|
|
if (confirm('Are you sure you want to clear the code?')) {
|
|
|
|
var $btn = $(this);
|
|
|
|
var $editor = $btn.closest('.wptag-code-editor-wrapper').find('.wptag-code-editor');
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
$editor.val('').focus();
|
2025-07-16 03:48:47 +08:00
|
|
|
WPTagAdmin.updateEditorHeight($editor[0]);
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
if (WPTagAdmin.changeTrackingEnabled && !WPTagAdmin.initializing) {
|
|
|
|
WPTagAdmin.formChanged = true;
|
|
|
|
}
|
2025-07-16 03:48:47 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
handleFormChangeTracking: function() {
|
|
|
|
var $ = jQuery;
|
|
|
|
var self = this;
|
|
|
|
|
|
|
|
self.changeTrackingEnabled = true;
|
|
|
|
|
|
|
|
$(document).on('input keyup', 'input[type="text"], textarea', function() {
|
|
|
|
if ($(this).closest('.wptag-admin').length > 0 && self.changeTrackingEnabled && !self.initializing) {
|
|
|
|
self.formChanged = true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$(document).on('change', 'select, input[type="radio"], input[type="checkbox"]:not([name*="enabled_services"]):not([name*="[enabled]"]):not([name*="[use_template]"])', function() {
|
|
|
|
if ($(this).closest('.wptag-admin').length > 0 && self.changeTrackingEnabled && !self.initializing) {
|
|
|
|
self.formChanged = true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
window.addEventListener('beforeunload', function(e) {
|
|
|
|
if (self.formChanged && !self.initializing) {
|
|
|
|
e.preventDefault();
|
|
|
|
e.returnValue = 'You have unsaved changes. Are you sure you want to leave?';
|
|
|
|
return e.returnValue;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
initTooltips: function() {
|
|
|
|
var $ = jQuery;
|
|
|
|
|
|
|
|
$('[title]').each(function() {
|
|
|
|
var $el = $(this);
|
|
|
|
var title = $el.attr('title');
|
|
|
|
|
|
|
|
$el.removeAttr('title').on('mouseenter', function() {
|
|
|
|
$('<div class="wptag-tooltip">' + title + '</div>')
|
|
|
|
.appendTo('body')
|
|
|
|
.fadeIn(200);
|
|
|
|
}).on('mouseleave', function() {
|
|
|
|
$('.wptag-tooltip').remove();
|
|
|
|
}).on('mousemove', function(e) {
|
|
|
|
$('.wptag-tooltip').css({
|
|
|
|
top: e.pageY + 10,
|
|
|
|
left: e.pageX + 10
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2025-07-16 03:48:47 +08:00
|
|
|
updateEditorHeight: function(editor) {
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
var $ = jQuery;
|
|
|
|
var $editor = $(editor);
|
|
|
|
|
2025-07-16 03:48:47 +08:00
|
|
|
editor.style.height = 'auto';
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
var newHeight = Math.max(editor.scrollHeight, 120);
|
|
|
|
editor.style.height = newHeight + 'px';
|
2025-07-16 03:48:47 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
formatCode: function(code) {
|
|
|
|
try {
|
|
|
|
return code
|
|
|
|
.replace(/></g, '>\n<')
|
|
|
|
.replace(/^\s+|\s+$/g, '')
|
|
|
|
.split('\n')
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
.map(function(line, index, array) {
|
|
|
|
line = line.trim();
|
|
|
|
if (line.length === 0) return '';
|
|
|
|
|
|
|
|
var indent = 0;
|
|
|
|
for (var i = 0; i < index; i++) {
|
|
|
|
var prevLine = array[i].trim();
|
|
|
|
if (prevLine.match(/<[^\/][^>]*[^\/]>$/)) {
|
|
|
|
indent += 2;
|
|
|
|
}
|
|
|
|
if (prevLine.match(/<\/[^>]+>$/)) {
|
|
|
|
indent -= 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (line.match(/^<\/[^>]+>$/)) {
|
|
|
|
indent -= 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
indent = Math.max(0, indent);
|
|
|
|
return ' '.repeat(indent) + line;
|
2025-07-16 03:48:47 +08:00
|
|
|
})
|
|
|
|
.filter(function(line) {
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
return line.trim().length > 0;
|
2025-07-16 03:48:47 +08:00
|
|
|
})
|
|
|
|
.join('\n');
|
|
|
|
} catch (e) {
|
|
|
|
console.log('Code formatting error:', e);
|
|
|
|
return code;
|
Add initial WPTag admin and core plugin files
Introduce the main admin controllers, AJAX handlers, UI partials, and core classes for the WPTag plugin. This includes admin interface components, dashboard, settings, snippet management, asset files, and localization support. These files establish the foundation for managing code snippets, templates, and plugin settings within the WordPress admin.
2025-07-16 03:44:42 +08:00
|
|
|
}
|
2025-07-16 03:48:47 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
downloadFile: function(data, filename) {
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
try {
|
|
|
|
var blob = new Blob([data], { type: 'application/json' });
|
|
|
|
|
|
|
|
if (window.navigator && window.navigator.msSaveOrOpenBlob) {
|
|
|
|
window.navigator.msSaveOrOpenBlob(blob, filename);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var url = window.URL.createObjectURL(blob);
|
|
|
|
var a = document.createElement('a');
|
|
|
|
a.href = url;
|
|
|
|
a.download = filename;
|
|
|
|
a.style.display = 'none';
|
|
|
|
document.body.appendChild(a);
|
|
|
|
a.click();
|
|
|
|
|
|
|
|
setTimeout(function() {
|
|
|
|
window.URL.revokeObjectURL(url);
|
|
|
|
document.body.removeChild(a);
|
|
|
|
}, 100);
|
|
|
|
} catch (e) {
|
|
|
|
console.error('Download failed:', e);
|
|
|
|
WPTagAdmin.showNotice('error', 'Download failed. Please try again.');
|
|
|
|
}
|
2025-07-16 03:48:47 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
showNotice: function(type, message) {
|
|
|
|
var $ = jQuery;
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
|
|
|
|
$('.wptag-admin .notice').remove();
|
|
|
|
|
|
|
|
var $notice = $('<div class="notice notice-' + type + ' is-dismissible"><p>' + message + '</p><button type="button" class="notice-dismiss"><span class="screen-reader-text">Dismiss this notice.</span></button></div>');
|
2025-07-16 03:48:47 +08:00
|
|
|
$('.wptag-admin h1').after($notice);
|
|
|
|
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
$notice.find('.notice-dismiss').on('click', function() {
|
|
|
|
$notice.fadeOut(300, function() {
|
2025-07-16 03:48:47 +08:00
|
|
|
$(this).remove();
|
|
|
|
});
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
});
|
2025-07-16 03:48:47 +08:00
|
|
|
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
setTimeout(function() {
|
|
|
|
$notice.fadeOut(300, function() {
|
2025-07-16 03:48:47 +08:00
|
|
|
$(this).remove();
|
|
|
|
});
|
Enhance admin UI and UX for WPTag plugin
Improves the admin interface with refined CSS for better layout, accessibility, and responsiveness. Adds robust JS logic for disabling tracking scripts, change tracking, validation, preview, import/export, reset, tooltips, and modal handling. These changes provide a more user-friendly experience, prevent accidental data loss, and ensure tracking scripts do not run in the admin area.
2025-07-26 05:47:24 +08:00
|
|
|
}, 5000);
|
|
|
|
|
|
|
|
$('html, body').animate({
|
|
|
|
scrollTop: $('.wptag-admin').offset().top - 50
|
|
|
|
}, 500);
|
2025-07-16 03:48:47 +08:00
|
|
|
}
|
|
|
|
};
|