| 1 |
<?php |
| 2 |
/** |
| 3 |
* Media Optimization Image Library Tab View |
| 4 |
* |
| 5 |
* @package Search Atlas SEO |
| 6 |
* @copyright Copyright (C) 2021-2025, Search Atlas Group - support@searchatlas.com |
| 7 |
* @since 2.6.0 |
| 8 |
* |
| 9 |
* Variables expected: |
| 10 |
* @var Metasync_Media_Library_List_Table $list_table |
| 11 |
* @var array $stats |
| 12 |
* @var array $batch_progress |
| 13 |
*/ |
| 14 |
|
| 15 |
if (!defined('WPINC')) { |
| 16 |
die; |
| 17 |
} |
| 18 |
?> |
| 19 |
|
| 20 |
<!-- Stats Bar --> |
| 21 |
<div class="metasync-card metasync-stats-card"> |
| 22 |
<div class="metasync-stats-row"> |
| 23 |
<div class="metasync-stat-item"> |
| 24 |
<span class="metasync-stat-number"><?php echo esc_html(number_format_i18n($stats['total'])); ?></span> |
| 25 |
<span class="metasync-stat-label"><?php esc_html_e('Total Images', 'metasync'); ?></span> |
| 26 |
</div> |
| 27 |
<div class="metasync-stat-item metasync-stat-success"> |
| 28 |
<span class="metasync-stat-number"><?php echo esc_html(number_format_i18n($stats['optimized'])); ?></span> |
| 29 |
<span class="metasync-stat-label"><?php esc_html_e('Optimized', 'metasync'); ?></span> |
| 30 |
</div> |
| 31 |
<div class="metasync-stat-item metasync-stat-pending"> |
| 32 |
<span class="metasync-stat-number"><?php echo esc_html(number_format_i18n($stats['unoptimized'])); ?></span> |
| 33 |
<span class="metasync-stat-label"><?php esc_html_e('Unoptimized', 'metasync'); ?></span> |
| 34 |
</div> |
| 35 |
<div class="metasync-stat-item metasync-stat-rate"> |
| 36 |
<div class="metasync-stat-progress-wrap"> |
| 37 |
<div class="metasync-stat-progress-bar"> |
| 38 |
<div class="metasync-stat-progress-fill" style="width: <?php echo esc_attr($stats['percentage']); ?>%;"></div> |
| 39 |
</div> |
| 40 |
<span class="metasync-stat-percentage"><?php echo esc_html($stats['percentage']); ?>%</span> |
| 41 |
</div> |
| 42 |
<span class="metasync-stat-label"><?php esc_html_e('Optimization Rate', 'metasync'); ?></span> |
| 43 |
</div> |
| 44 |
</div> |
| 45 |
</div> |
| 46 |
|
| 47 |
<!-- Batch Progress (visible when running) --> |
| 48 |
<div class="metasync-card metasync-batch-card" id="metasync-batch-progress" |
| 49 |
style="<?php echo ($batch_progress['status'] !== 'running') ? 'display:none;' : ''; ?>"> |
| 50 |
<div class="metasync-batch-header"> |
| 51 |
<div class="metasync-batch-info"> |
| 52 |
<span class="metasync-batch-spinner"></span> |
| 53 |
<span class="metasync-batch-text" id="metasync-batch-text"> |
| 54 |
<?php |
| 55 |
if ($batch_progress['status'] === 'running') { |
| 56 |
printf( |
| 57 |
esc_html__('Optimizing %1$d of %2$d images...', 'metasync'), |
| 58 |
$batch_progress['processed'], |
| 59 |
$batch_progress['total'] |
| 60 |
); |
| 61 |
} |
| 62 |
?> |
| 63 |
</span> |
| 64 |
</div> |
| 65 |
<button type="button" class="button button-small" id="metasync-cancel-batch"> |
| 66 |
<?php esc_html_e('Cancel', 'metasync'); ?> |
| 67 |
</button> |
| 68 |
</div> |
| 69 |
<div class="metasync-batch-progress-bar"> |
| 70 |
<div class="metasync-batch-progress-fill" id="metasync-batch-fill" |
| 71 |
style="width: <?php |
| 72 |
echo $batch_progress['total'] > 0 |
| 73 |
? esc_attr(round(($batch_progress['processed'] / $batch_progress['total']) * 100)) |
| 74 |
: '0'; |
| 75 |
?>%;"></div> |
| 76 |
</div> |
| 77 |
<div class="metasync-batch-details"> |
| 78 |
<span id="metasync-batch-processed"><?php echo esc_html($batch_progress['processed']); ?></span> / |
| 79 |
<span id="metasync-batch-total"><?php echo esc_html($batch_progress['total']); ?></span> |
| 80 |
<?php esc_html_e('images processed', 'metasync'); ?> |
| 81 |
<?php if ($batch_progress['failed'] > 0): ?> |
| 82 |
· <span class="metasync-batch-failed" id="metasync-batch-failed"><?php echo esc_html($batch_progress['failed']); ?></span> <?php esc_html_e('failed', 'metasync'); ?> |
| 83 |
<?php endif; ?> |
| 84 |
</div> |
| 85 |
</div> |
| 86 |
|
| 87 |
<!-- Batch Completed Notice --> |
| 88 |
<div class="metasync-card metasync-batch-complete-card" id="metasync-batch-complete" style="display:none;"> |
| 89 |
<span class="dashicons dashicons-yes-alt" style="color: var(--dashboard-success);"></span> |
| 90 |
<span id="metasync-batch-complete-text"></span> |
| 91 |
<button type="button" class="metasync-dismiss-btn" id="metasync-dismiss-complete"> |
| 92 |
<span class="dashicons dashicons-dismiss"></span> |
| 93 |
</button> |
| 94 |
</div> |
| 95 |
|
| 96 |
<!-- List Table --> |
| 97 |
<form method="get" id="metasync-image-library-form"> |
| 98 |
<input type="hidden" name="page" value="<?php echo esc_attr($_REQUEST['page'] ?? ''); ?>" /> |
| 99 |
<input type="hidden" name="tab" value="image-library" /> |
| 100 |
|
| 101 |
<!-- Unified Toolbar: Optimize All + Search --> |
| 102 |
<div class="metasync-table-toolbar"> |
| 103 |
<div class="metasync-toolbar-left"> |
| 104 |
<button type="button" class="button button-primary" id="metasync-optimize-all" |
| 105 |
<?php disabled($batch_progress['status'] === 'running' || $stats['unoptimized'] === 0); ?>> |
| 106 |
<span class="dashicons dashicons-performance"></span> |
| 107 |
<?php esc_html_e('Optimize All', 'metasync'); ?> |
| 108 |
<?php if ($stats['unoptimized'] > 0): ?> |
| 109 |
<span class="metasync-count-badge"><?php echo esc_html(number_format_i18n($stats['unoptimized'])); ?></span> |
| 110 |
<?php endif; ?> |
| 111 |
</button> |
| 112 |
</div> |
| 113 |
<div class="metasync-toolbar-right"> |
| 114 |
<?php $list_table->search_box(__('Search', 'metasync'), 'metasync-image-search'); ?> |
| 115 |
</div> |
| 116 |
</div> |
| 117 |
|
| 118 |
<?php $list_table->display(); ?> |
| 119 |
</form> |
| 120 |
|