| 1 |
<?php |
| 2 |
/** |
| 3 |
* Partial: Media / Images module card. |
| 4 |
*/ |
| 5 |
|
| 6 |
if (!defined('ABSPATH')) die('No direct access allowed'); |
| 7 |
|
| 8 |
$active = !empty($images['active']); |
| 9 |
$optimised_count = number_format_i18n((int) ($images['optimised_count'] ?? 0)); |
| 10 |
$saved_human = empty($images['saved_human']) ? '0 B' : $images['saved_human']; |
| 11 |
$auto_optimize = !empty($images['auto_optimize']); |
| 12 |
$webp_conversion = !empty($images['webp_conversion']); |
| 13 |
$unused_count = (int) ($images['unused_count'] ?? 0); |
| 14 |
$is_premium = !empty($images['is_premium']); |
| 15 |
?> |
| 16 |
|
| 17 |
<div class="wpo-mod-card<?php echo !$active ? ' wpo-inactive-card' : ''; ?>"> |
| 18 |
|
| 19 |
<div class="wpo-mod-header"> |
| 20 |
<div class="wpo-mod-icon-title"> |
| 21 |
<span class="wpo-dash-icon dashicons dashicons-format-image"></span> |
| 22 |
<?php esc_html_e('Media', 'wp-optimize'); ?> |
| 23 |
</div> |
| 24 |
<?php if ($active) : ?> |
| 25 |
<span class="wpo-badge active"> |
| 26 |
<?php esc_html_e('Active', 'wp-optimize'); ?> |
| 27 |
</span> |
| 28 |
<?php else : ?> |
| 29 |
<span class="wpo-badge inactive"><?php esc_html_e('Inactive', 'wp-optimize'); ?></span> |
| 30 |
<?php endif; ?> |
| 31 |
</div> |
| 32 |
|
| 33 |
<div> |
| 34 |
<?php if ($active) : ?> |
| 35 |
<div class="wpo-mod-big"> |
| 36 |
<?php echo esc_html($optimised_count); ?> |
| 37 |
<span><?php esc_html_e('images compressed', 'wp-optimize'); ?></span> |
| 38 |
</div> |
| 39 |
<?php else : ?> |
| 40 |
<div class="wpo-mod-big"><?php esc_html_e('No images compressed yet', 'wp-optimize'); ?></div> |
| 41 |
<?php endif; ?> |
| 42 |
<p class="wpo-mod-desc"> |
| 43 |
<?php esc_html_e('Shrinks images automatically without visible quality loss, like packing a suitcase more efficiently.', 'wp-optimize'); ?> |
| 44 |
</p> |
| 45 |
</div> |
| 46 |
|
| 47 |
<div class="wpo-feature-list"> |
| 48 |
|
| 49 |
<div class="wpo-feat-row"> |
| 50 |
<span class="wpo-feat-name"> |
| 51 |
<span class="wpo-dot <?php echo $auto_optimize ? 'wpo-dot-on' : 'wpo-dot-off'; ?>">●</span> |
| 52 |
<?php esc_html_e('Auto optimization', 'wp-optimize'); ?> |
| 53 |
</span> |
| 54 |
<span class="wpo-feat-val <?php echo $auto_optimize ? 'on' : 'off'; ?>"> |
| 55 |
<?php echo $auto_optimize ? esc_html__('Active', 'wp-optimize') : '–'; ?> |
| 56 |
</span> |
| 57 |
</div> |
| 58 |
|
| 59 |
<div class="wpo-feat-row"> |
| 60 |
<span class="wpo-feat-name"> |
| 61 |
<span class="wpo-dot <?php echo $webp_conversion ? 'wpo-dot-on' : 'wpo-dot-off'; ?>">●</span> |
| 62 |
<?php esc_html_e('WebP conversion', 'wp-optimize'); ?> |
| 63 |
</span> |
| 64 |
<span class="wpo-feat-val <?php echo $webp_conversion ? 'on' : 'off'; ?>"> |
| 65 |
<?php echo $webp_conversion ? esc_html__('Active', 'wp-optimize') : '–'; ?> |
| 66 |
</span> |
| 67 |
</div> |
| 68 |
|
| 69 |
<div class="wpo-feat-row"> |
| 70 |
<span class="wpo-feat-name"> |
| 71 |
<span class="wpo-dot <?php echo $is_premium ? 'wpo-dot-on' : 'wpo-dot-off'; ?>">●</span> |
| 72 |
<?php esc_html_e('Remove unused images', 'wp-optimize'); ?> |
| 73 |
</span> |
| 74 |
<?php if ($is_premium) : ?> |
| 75 |
<?php if ($unused_count > 0) : ?> |
| 76 |
<span class="wpo-feat-val wpo-unused-images-count"> |
| 77 |
<?php |
| 78 |
/* translators: %d = number of unused images */ |
| 79 |
printf(esc_html(_n('%d unused', '%d unused', $unused_count, 'wp-optimize')), (int) $unused_count); |
| 80 |
?> |
| 81 |
</span> |
| 82 |
<?php else : ?> |
| 83 |
<?php $unused_url = WP_Optimize()->get_options()->admin_page_url('wpo_images') . '&tab=wp_optimize_unused'; ?> |
| 84 |
<span class="wpo-feat-val on"> |
| 85 |
<a href="<?php echo esc_url($unused_url); ?>" class="wpo-dash-link"><?php esc_html_e('Available', 'wp-optimize'); ?><span class="dashicons dashicons-arrow-right-alt"></span></a> |
| 86 |
</span> |
| 87 |
<?php endif; ?> |
| 88 |
<?php else : ?> |
| 89 |
<span class="wpo-feat-val premium"><?php esc_html_e('Premium', 'wp-optimize'); ?></span> |
| 90 |
<?php endif; ?> |
| 91 |
</div> |
| 92 |
|
| 93 |
</div> |
| 94 |
|
| 95 |
<?php if (!$is_premium) : ?> |
| 96 |
<div class="wpo-notice"> |
| 97 |
<span class="wpo-dash-icon dashicons dashicons-images-alt2"></span> |
| 98 |
<span> |
| 99 |
<?php esc_html_e('Find and remove unused images to free up storage with Premium.', 'wp-optimize'); ?> |
| 100 |
<a href="<?php echo esc_url(WP_Optimize()->premium_version_link . '&utm_content=dashboard-images-unused'); ?>" target="_blank"> |
| 101 |
<?php esc_html_e('Learn more', 'wp-optimize'); ?> |
| 102 |
</a>. |
| 103 |
</span> |
| 104 |
</div> |
| 105 |
<?php endif; ?> |
| 106 |
|
| 107 |
<div class="wpo-mod-footer"> |
| 108 |
<span> |
| 109 |
<?php |
| 110 |
if ($active) : |
| 111 |
/* translators: %s = bytes saved */ |
| 112 |
printf(esc_html__('%s saved', 'wp-optimize'), esc_html($saved_human)); |
| 113 |
endif; |
| 114 |
?> |
| 115 |
</span> |
| 116 |
<a href="<?php echo esc_url(WP_Optimize()->get_options()->admin_page_url('wpo_images')); ?>" class="wpo-dash-link"> |
| 117 |
<?php esc_html_e('Manage media', 'wp-optimize'); ?><span class="dashicons dashicons-arrow-right-alt"></span> |
| 118 |
</a> |
| 119 |
</div> |
| 120 |
</div> |