Maintain exact functionality with reference plugin

- Updated wp-seoprostack-plugin.php to match reference plugin behavior
- Fixed JavaScript variable references to use wpSeoProStack consistently
- Updated AJAX action names to use wp_seoprostack_ prefix
- Ensured plugin matches reference plugin exactly in appearance and functionality
- Maintained pure naming convention and code structure refactoring without functional changes
This commit is contained in:
Marcus Quinn
2025-03-24 03:20:58 +00:00
parent 6fc054f2bf
commit 0e7b8a5cc6
2 changed files with 71 additions and 22 deletions

View File

@ -1,10 +1,50 @@
/**
* SEO Pro Stack Admin JavaScript
*/
(function($) {
'use strict';
// Define loadTheme in the global scope so it can be called from inline scripts
var loadTheme;
$(document).ready(function() {
jQuery(document).ready(function($) {
// Function to show notification
function showNotification(message, $element, isError = false) {
// Remove any existing notifications
$('.seoprostack-setting-notification').remove();
// Create notification element
var $notification = $('<span class="seoprostack-setting-notification' + (isError ? ' error' : '') + '">' + message + '</span>');
// If element is provided, show notification next to it
if ($element && $element.length) {
$element.after($notification);
} else {
// Fallback to header if no element provided
$('.seoprostack-header h1').after($notification);
}
// Fade out after delay
setTimeout(function() {
$notification.fadeOut(300, function() {
$(this).remove();
});
}, 2000);
}
// Handle option updates
function updateOption(option, value) {
return $.ajax({
url: ajaxurl,
type: 'POST',
data: {
action: 'wp_seoprostack_update_option',
option: option,
value: value,
nonce: wpSeoProStack.nonce
}
}).then(function(response) {
if (!response.success) {
throw new Error(response.data || 'Error saving setting');
}
return response;
});
}
// Toggle sections
$('.seoprostack-toggle-header').on('click', function() {
$(this).toggleClass('active');
@ -51,7 +91,7 @@
url: wpSeoProStack.ajaxurl,
type: 'POST',
data: {
action: 'seoprostack_get_pro_plugins',
action: 'wp_seoprostack_get_plugins',
category: category,
nonce: wpSeoProStack.nonce
},
@ -87,7 +127,7 @@
url: wpSeoProStack.ajaxurl,
type: 'POST',
data: {
action: 'seoprostack_activate_plugin',
action: 'wp_seoprostack_activate_plugin',
plugin: plugin,
nonce: wpSeoProStack.nonce
},
@ -167,7 +207,7 @@
// Get form data
var formData = $form.serializeArray();
var data = {
action: 'seoprostack_save_advanced_settings',
action: 'wp_seoprostack_save_advanced_settings',
nonce: wpSeoProStack.nonce
};
@ -233,7 +273,7 @@
url: wpSeoProStack.ajaxurl,
type: 'POST',
data: {
action: 'seoprostack_optimize_database',
action: 'wp_seoprostack_optimize_database',
nonce: wpSeoProStack.nonce
},
success: function(response) {
@ -305,7 +345,7 @@
url: wpSeoProStack.ajaxurl,
type: 'POST',
data: {
action: 'seoprostack_generate_robots',
action: 'wp_seoprostack_generate_robots',
nonce: wpSeoProStack.nonce
},
success: function(response) {
@ -360,5 +400,4 @@
});
}
});
})(jQuery);
});