PluginProbe
Search Atlas SEO – OTTO AI SEO Automation for WordPress / 2.7.2
Search Atlas SEO – OTTO AI SEO Automation for WordPress v2.7.2
2.7.1 2.7.2 2.7.0 2.6.26 2.6.25 2.6.24 2.6.23 2.6.22 2.6.21 2.6.20 2.6.19 2.6.18 2.6.17 2.6.16 2.6.15 2.6.14 2.6.13 2.6.12 2.6.11 2.6.10 2.6.9 2.6.8 2.6.7 2.6.6 2.6.5 All 141 releases
← All changes | robots-txt/views/scripts.php +66 -20 2.6.11 → 2.7.2 View file →
@@ -15,8 +15,54 @@
15 15 <script>
16 16 jQuery(document).ready(function($) {
17 17 let allowSave = false;
18 18
19 + // Nonce for fetching a paginated page of backups.
20 + const backupsPageNonce = '<?php echo esc_js(wp_create_nonce('metasync_get_robots_backups')); ?>';
21 +
22 + // Load a page of the Backup History panel and swap it in place. Keeps the
23 + // list, its total count, and pagination consistent with backend storage
24 + // after navigation or deletion. Clamps to a valid page if the requested
25 + // one no longer exists (e.g. the last item on a page was deleted).
26 + function loadBackupsPage(page) {
27 + const $panel = $('#metasync-backups-panel');
28 + if (!$panel.length) {
29 + return;
30 + }
31 + $panel.css('opacity', 0.5);
32 + $.ajax({
33 + url: ajaxurl,
34 + type: 'POST',
35 + data: {
36 + action: 'metasync_get_robots_backups',
37 + nonce: backupsPageNonce,
38 + page: page
39 + },
40 + success: function(response) {
41 + if (response.success && response.data && typeof response.data.html === 'string') {
42 + $panel.replaceWith(response.data.html);
43 + } else {
44 + $panel.css('opacity', 1);
45 + }
46 + },
47 + error: function() {
48 + $panel.css('opacity', 1);
49 + }
50 + });
51 + }
52 +
53 + // Pagination controls (Prev/Next).
54 + $(document).on('click', '.metasync-backup-page', function() {
55 + const $btn = $(this);
56 + if ($btn.prop('disabled')) {
57 + return;
58 + }
59 + const page = parseInt($btn.data('page'), 10);
60 + if (!isNaN(page) && page >= 1) {
61 + loadBackupsPage(page);
62 + }
63 + });
64 +
19 65 // Check for restore success message after page reload
20 66 const restoreMessage = sessionStorage.getItem('metasync_robots_restore_message');
21 67 if (restoreMessage) {
22 68 // Remove the message from sessionStorage
@@ -119,9 +165,9 @@
119 165 url: ajaxurl,
120 166 type: 'POST',
121 167 data: {
122 168 action: 'metasync_validate_robots',
123 - nonce: '<?php echo wp_create_nonce('metasync_nonce'); ?>',
169 + nonce: '<?php echo esc_js(wp_create_nonce('metasync_nonce')); ?>',
124 170 content: content
125 171 },
126 172 success: function(response) {
127 173 if (response.success && response.data) {
@@ -233,9 +279,9 @@
233 279 url: ajaxurl,
234 280 type: 'POST',
235 281 data: {
236 282 action: 'metasync_get_default_robots',
237 - nonce: '<?php echo wp_create_nonce('metasync_nonce'); ?>'
283 + nonce: '<?php echo esc_js(wp_create_nonce('metasync_nonce')); ?>'
238 284 },
239 285 success: function(response) {
240 286 if (response.success) {
241 287 $('#robots-txt-editor').val(response.data.content);
@@ -253,9 +299,9 @@
253 299 url: ajaxurl,
254 300 type: 'POST',
255 301 data: {
256 302 action: 'metasync_validate_robots',
257 - nonce: '<?php echo wp_create_nonce('metasync_nonce'); ?>',
303 + nonce: '<?php echo esc_js(wp_create_nonce('metasync_nonce')); ?>',
258 304 content: content
259 305 },
260 306 success: function(response) {
261 307 const $results = $('#validation-results');
@@ -299,9 +345,9 @@
299 345 this.style.height = (this.scrollHeight) + 'px';
300 346 });
301 347
302 348 // Preview backup content
303 - $('.metasync-preview-backup').on('click', function(e) {
349 + $(document).on('click', '.metasync-preview-backup', function(e) {
304 350 e.preventDefault();
305 351 const backupId = $(this).data('backup-id');
306 352
307 353 // Show loading state
@@ -313,9 +359,9 @@
313 359 url: ajaxurl,
314 360 type: 'POST',
315 361 data: {
316 362 action: 'metasync_preview_robots_backup',
317 - nonce: '<?php echo wp_create_nonce('metasync_nonce'); ?>',
363 + nonce: '<?php echo esc_js(wp_create_nonce('metasync_nonce')); ?>',
318 364 backup_id: backupId
319 365 },
320 366 success: function(response) {
321 367 if (response.success && response.data) {
@@ -356,9 +402,9 @@
356 402 $confirmBtn.html('<span class="dashicons dashicons-backup"></span> <?php esc_html_e('Restore', 'metasync'); ?>')
357 403 .removeClass('button-primary')
358 404 .addClass('button-restore')
359 405 .data('backup-id', backupId)
360 - .data('nonce', '<?php echo wp_create_nonce('metasync_restore_robots_backup'); ?>')
406 + .data('nonce', '<?php echo esc_js(wp_create_nonce('metasync_restore_robots_backup')); ?>')
361 407 .show();
362 408
363 409 // Hide close button for preview
364 410 $cancelBtn.hide();
@@ -441,10 +487,9 @@
441 487
442 488 const $button = $(this);
443 489 const backupId = $button.data('backup-id');
444 490 const nonce = $button.data('nonce');
445 - const $backupItem = $button.closest('.metasync-backup-item');
446 -
491 +
447 492 // Show loading state
448 493 const originalHtml = $button.html();
449 494 $button.prop('disabled', true).html('<span class="dashicons dashicons-update dashicons-spin"></span>');
450 495
@@ -457,24 +502,25 @@
457 502 nonce: nonce
458 503 },
459 504 success: function(response) {
460 505 if (response.success) {
461 - // Fade out and remove the backup item
462 - $backupItem.fadeOut(300, function() {
463 - $(this).remove();
464 -
465 - // Check if there are any backups left
466 - if ($('.metasync-backup-item').length === 0) {
467 - $('.metasync-backups-list').html('<p class="description" style="text-align: center; padding: 20px;"><?php esc_html_e('No backups available yet. Backups are created automatically when you save changes.', 'metasync'); ?></p>');
468 - }
469 - });
470 -
471 - // Show success message (you can add a notification system here)
506 + // Refresh the panel so the count and pagination reflect the
507 + // new backend state. Stay on the current page, but if the
508 + // deleted entry was the last one on it, fall back a page.
509 + const $panel = $('#metasync-backups-panel');
510 + let currentPage = parseInt($panel.data('page'), 10) || 1;
511 + const remainingOnPage = $panel.find('.metasync-backup-item').length - 1;
512 + if (remainingOnPage <= 0 && currentPage > 1) {
513 + currentPage -= 1;
514 + }
515 + loadBackupsPage(currentPage);
516 +
517 + // Show success message
472 518 if (response.data && response.data.message) {
473 519 // Create a temporary success notice
474 520 const $notice = $('<div class="notice notice-success is-dismissible" style="margin: 20px 0;"><p>' + response.data.message + '</p></div>');
475 521 $('.metasync-robots-txt-page').prepend($notice);
476 -
522 +
477 523 // Auto-dismiss after 3 seconds
478 524 setTimeout(function() {
479 525 $notice.fadeOut(300, function() {
480 526 $(this).remove();