| 1 |
<?php |
| 2 |
/** |
| 3 |
* Robots.txt Backup History — list + pagination partial |
| 4 |
* |
| 5 |
* Rendered both on initial page load (robots-txt/views/admin-page.php) and by |
| 6 |
* the AJAX pagination/refresh endpoint (ajax_get_robots_backups), so the markup |
| 7 |
* lives in a single place. |
| 8 |
* |
| 9 |
* Expected variables (set by the includer): |
| 10 |
* array $backups Backups for the current page. |
| 11 |
* int $backup_total Total number of stored backups. |
| 12 |
* int $backup_page Current page (1-based). |
| 13 |
* int $backup_per_page Backups shown per page. |
| 14 |
* int $backup_total_pages Total number of pages. |
| 15 |
* |
| 16 |
* @package Search Atlas SEO |
| 17 |
* @copyright Copyright (C) 2021-2025, Search Atlas Group - [email protected] |
| 18 |
* @since 2.5.6 |
| 19 |
*/ |
| 20 |
|
| 21 |
// If this file is called directly, abort. |
| 22 |
if (!defined('WPINC')) { |
| 23 |
die; |
| 24 |
} |
| 25 |
|
| 26 |
$backup_total = isset($backup_total) ? (int) $backup_total : 0; |
| 27 |
$backup_per_page = isset($backup_per_page) ? (int) $backup_per_page : 10; |
| 28 |
$backup_page = isset($backup_page) ? max(1, (int) $backup_page) : 1; |
| 29 |
$backup_total_pages = isset($backup_total_pages) ? max(1, (int) $backup_total_pages) : 1; |
| 30 |
$backups = isset($backups) && is_array($backups) ? $backups : array(); |
| 31 |
|
| 32 |
// Range of records shown on this page (e.g. "1–10 of 45"). |
| 33 |
$range_start = $backup_total > 0 ? (($backup_page - 1) * $backup_per_page) + 1 : 0; |
| 34 |
$range_end = min($backup_page * $backup_per_page, $backup_total); |
| 35 |
?> |
| 36 |
<div id="metasync-backups-panel" data-page="<?php echo esc_attr((string) $backup_page); ?>" data-total-pages="<?php echo esc_attr((string) $backup_total_pages); ?>"> |
| 37 |
<?php if ($backup_total > 0): ?> |
| 38 |
<div class="metasync-backups-summary"> |
| 39 |
<?php |
| 40 |
printf( |
| 41 |
/* translators: 1: first record on page, 2: last record on page, 3: total records */ |
| 42 |
esc_html__('Showing %1$s–%2$s of %3$s backups', 'metasync'), |
| 43 |
esc_html(number_format_i18n($range_start)), |
| 44 |
esc_html(number_format_i18n($range_end)), |
| 45 |
esc_html(number_format_i18n($backup_total)) |
| 46 |
); |
| 47 |
?> |
| 48 |
</div> |
| 49 |
|
| 50 |
<div class="metasync-backups-list"> |
| 51 |
<?php foreach ($backups as $backup): ?> |
| 52 |
<div class="metasync-backup-item"> |
| 53 |
<div class="metasync-backup-info"> |
| 54 |
<strong><?php echo esc_html(get_date_from_gmt($backup['created_at'], get_option('date_format') . ' ' . get_option('time_format'))); ?></strong> |
| 55 |
<?php if (!empty($backup['created_by_name'])): ?> |
| 56 |
<span class="metasync-backup-author"> |
| 57 |
<?php /* translators: %s: name of the user who created the backup. */ ?> |
| 58 |
<?php printf(esc_html__('by %s', 'metasync'), esc_html($backup['created_by_name'])); ?> |
| 59 |
</span> |
| 60 |
<?php endif; ?> |
| 61 |
</div> |
| 62 |
<div class="metasync-backup-actions"> |
| 63 |
<button type="button" |
| 64 |
class="button button-small metasync-preview-backup" |
| 65 |
data-backup-id="<?php echo esc_attr($backup['id']); ?>" |
| 66 |
title="<?php esc_attr_e('Preview', 'metasync'); ?>"> |
| 67 |
<span class="dashicons dashicons-visibility"></span> |
| 68 |
<?php esc_html_e('Preview', 'metasync'); ?> |
| 69 |
</button> |
| 70 |
<button type="button" |
| 71 |
class="button button-small metasync-restore-backup" |
| 72 |
data-backup-id="<?php echo esc_attr($backup['id']); ?>" |
| 73 |
data-nonce="<?php echo esc_attr(wp_create_nonce('metasync_restore_robots_backup')); ?>" |
| 74 |
title="<?php esc_attr_e('Restore', 'metasync'); ?>"> |
| 75 |
<span class="dashicons dashicons-backup"></span> |
| 76 |
<?php esc_html_e('Restore', 'metasync'); ?> |
| 77 |
</button> |
| 78 |
<button type="button" |
| 79 |
class="button button-small button-link-delete metasync-delete-backup" |
| 80 |
data-backup-id="<?php echo esc_attr($backup['id']); ?>" |
| 81 |
data-nonce="<?php echo esc_attr(wp_create_nonce('metasync_delete_robots_backup')); ?>" |
| 82 |
title="<?php esc_attr_e('Delete', 'metasync'); ?>"> |
| 83 |
<span class="dashicons dashicons-trash"></span> |
| 84 |
</button> |
| 85 |
</div> |
| 86 |
</div> |
| 87 |
<?php endforeach; ?> |
| 88 |
</div> |
| 89 |
|
| 90 |
<?php if ($backup_total_pages > 1): ?> |
| 91 |
<div class="metasync-backups-pagination"> |
| 92 |
<button type="button" |
| 93 |
class="button button-small metasync-backup-page" |
| 94 |
data-page="<?php echo esc_attr((string) ($backup_page - 1)); ?>" |
| 95 |
<?php disabled($backup_page <= 1); ?>> |
| 96 |
<span class="dashicons dashicons-arrow-left-alt2"></span> |
| 97 |
<?php esc_html_e('Prev', 'metasync'); ?> |
| 98 |
</button> |
| 99 |
<span class="metasync-backups-page-indicator"> |
| 100 |
<?php |
| 101 |
printf( |
| 102 |
/* translators: 1: current page, 2: total pages */ |
| 103 |
esc_html__('Page %1$s of %2$s', 'metasync'), |
| 104 |
esc_html(number_format_i18n($backup_page)), |
| 105 |
esc_html(number_format_i18n($backup_total_pages)) |
| 106 |
); |
| 107 |
?> |
| 108 |
</span> |
| 109 |
<button type="button" |
| 110 |
class="button button-small metasync-backup-page" |
| 111 |
data-page="<?php echo esc_attr((string) ($backup_page + 1)); ?>" |
| 112 |
<?php disabled($backup_page >= $backup_total_pages); ?>> |
| 113 |
<?php esc_html_e('Next', 'metasync'); ?> |
| 114 |
<span class="dashicons dashicons-arrow-right-alt2"></span> |
| 115 |
</button> |
| 116 |
</div> |
| 117 |
<?php endif; ?> |
| 118 |
<?php else: ?> |
| 119 |
<p class="description"><?php esc_html_e('No backups available yet. Backups are created automatically when you save changes.', 'metasync'); ?></p> |
| 120 |
<?php endif; ?> |
| 121 |
</div> |
| 122 |
|