| 1 |
<?php |
| 2 |
/** |
| 3 |
* Partial: File optimization / Minify module card. |
| 4 |
*/ |
| 5 |
|
| 6 |
if (!defined('ABSPATH')) die('No direct access allowed'); |
| 7 |
|
| 8 |
$active = !empty($minify['active']); |
| 9 |
$is_premium = !empty($minify['is_premium']); |
| 10 |
$js_enabled = !empty($minify['js_enabled']); |
| 11 |
$css_enabled = !empty($minify['css_enabled']); |
| 12 |
$js_count = (int) ($minify['js_file_count'] ?? 0); |
| 13 |
$css_count = (int) ($minify['css_file_count'] ?? 0); |
| 14 |
$total_files = $js_count + $css_count; |
| 15 |
$fonts_cached_locally = !empty($minify['fonts_cached_locally']); |
| 16 |
$analytics_local = !empty($minify['analytics_hosted_locally']); |
| 17 |
$last_rebuilt_ts = (int) ($minify['last_rebuilt_ts'] ?? 0); |
| 18 |
$last_rebuilt_human = empty($minify['last_rebuilt_human']) ? null : $minify['last_rebuilt_human']; |
| 19 |
$saved_human = empty($minify['saved_human']) ? '' : $minify['saved_human']; |
| 20 |
?> |
| 21 |
|
| 22 |
<div class="wpo-mod-card<?php echo !$active ? ' wpo-inactive-card' : ''; ?>"> |
| 23 |
|
| 24 |
<div class="wpo-mod-header"> |
| 25 |
<div class="wpo-mod-icon-title"> |
| 26 |
<span class="wpo-dash-icon dashicons dashicons-editor-contract"></span> |
| 27 |
<?php esc_html_e('File optimisation', 'wp-optimize'); ?> |
| 28 |
</div> |
| 29 |
<?php if ($active) : ?> |
| 30 |
<span class="wpo-badge active"> |
| 31 |
<?php esc_html_e('Active', 'wp-optimize'); ?> |
| 32 |
</span> |
| 33 |
<?php else : ?> |
| 34 |
<span class="wpo-badge inactive"><?php esc_html_e('Inactive', 'wp-optimize'); ?></span> |
| 35 |
<?php endif; ?> |
| 36 |
</div> |
| 37 |
|
| 38 |
<div> |
| 39 |
<?php if ($active) : ?> |
| 40 |
<div class="wpo-mod-big"> |
| 41 |
<?php echo esc_html(number_format_i18n($total_files)); ?> |
| 42 |
<span><?php esc_html_e('files minified', 'wp-optimize'); ?></span> |
| 43 |
</div> |
| 44 |
<?php else : ?> |
| 45 |
<div class="wpo-mod-big"><?php esc_html_e('Not set up yet', 'wp-optimize'); ?></div> |
| 46 |
<?php endif; ?> |
| 47 |
<p class="wpo-mod-desc"> |
| 48 |
<?php esc_html_e('Strips unnecessary code from JavaScript and CSS files, like removing packaging so only the product gets delivered.', 'wp-optimize'); ?> |
| 49 |
</p> |
| 50 |
</div> |
| 51 |
|
| 52 |
<div class="wpo-feature-list"> |
| 53 |
|
| 54 |
<div class="wpo-feat-row"> |
| 55 |
<span class="wpo-feat-name"> |
| 56 |
<span class="wpo-dot <?php echo ($active && $js_enabled) ? 'wpo-dot-on' : 'wpo-dot-off'; ?>">●</span> |
| 57 |
<?php esc_html_e('Optimise JavaScript', 'wp-optimize'); ?> |
| 58 |
</span> |
| 59 |
<span class="wpo-feat-val files"> |
| 60 |
<?php |
| 61 |
if ($active && $js_enabled && $js_count > 0) : |
| 62 |
/* translators: %d = number of files */ |
| 63 |
printf(esc_html(_n('%d file', '%d files', $js_count, 'wp-optimize')), (int) $js_count); |
| 64 |
else : |
| 65 |
echo '–'; |
| 66 |
endif; |
| 67 |
?> |
| 68 |
</span> |
| 69 |
</div> |
| 70 |
|
| 71 |
<div class="wpo-feat-row"> |
| 72 |
<span class="wpo-feat-name"> |
| 73 |
<span class="wpo-dot <?php echo ($active && $css_enabled) ? 'wpo-dot-on' : 'wpo-dot-off'; ?>">●</span> |
| 74 |
<?php esc_html_e('Optimise CSS', 'wp-optimize'); ?> |
| 75 |
</span> |
| 76 |
<span class="wpo-feat-val files"> |
| 77 |
<?php |
| 78 |
if ($active && $css_enabled && $css_count > 0) : |
| 79 |
/* translators: %d = number of files */ |
| 80 |
printf(esc_html(_n('%d file', '%d files', $css_count, 'wp-optimize')), (int) $css_count); |
| 81 |
else : |
| 82 |
echo '–'; |
| 83 |
endif; |
| 84 |
?> |
| 85 |
</span> |
| 86 |
</div> |
| 87 |
|
| 88 |
<div class="wpo-feat-row"> |
| 89 |
<span class="wpo-feat-name"> |
| 90 |
<span class="wpo-dot <?php echo $fonts_cached_locally ? 'wpo-dot-on' : 'wpo-dot-off'; ?>">●</span> |
| 91 |
<?php esc_html_e('Fonts cached locally', 'wp-optimize'); ?> |
| 92 |
</span> |
| 93 |
<?php if ($is_premium) : ?> |
| 94 |
<span class="wpo-feat-val <?php echo $fonts_cached_locally ? 'on' : 'off'; ?>"> |
| 95 |
<?php echo $fonts_cached_locally ? esc_html__('Active', 'wp-optimize') : '–'; ?> |
| 96 |
</span> |
| 97 |
<?php else : ?> |
| 98 |
<span class="wpo-feat-val premium"><?php esc_html_e('Premium', 'wp-optimize'); ?></span> |
| 99 |
<?php endif; ?> |
| 100 |
</div> |
| 101 |
|
| 102 |
<div class="wpo-feat-row"> |
| 103 |
<span class="wpo-feat-name"> |
| 104 |
<span class="wpo-dot <?php echo $analytics_local ? 'wpo-dot-on' : 'wpo-dot-off'; ?>">●</span> |
| 105 |
<?php esc_html_e('Analytics hosted locally', 'wp-optimize'); ?> |
| 106 |
</span> |
| 107 |
<?php if ($is_premium) : ?> |
| 108 |
<span class="wpo-feat-val <?php echo $analytics_local ? 'on' : 'off'; ?>"> |
| 109 |
<?php echo $analytics_local ? esc_html__('Active', 'wp-optimize') : '–'; ?> |
| 110 |
</span> |
| 111 |
<?php else : ?> |
| 112 |
<span class="wpo-feat-val premium"><?php esc_html_e('Premium', 'wp-optimize'); ?></span> |
| 113 |
<?php endif; ?> |
| 114 |
</div> |
| 115 |
|
| 116 |
</div> |
| 117 |
|
| 118 |
<div class="wpo-mod-footer"> |
| 119 |
<span> |
| 120 |
<?php |
| 121 |
if ($active && $last_rebuilt_ts > 0) : |
| 122 |
if ($saved_human) : |
| 123 |
/* translators: %1$s = bytes saved, %2$s = time ago */ |
| 124 |
printf(esc_html__('%1$s saved · %2$s', 'wp-optimize'), esc_html($saved_human), esc_html($last_rebuilt_human)); |
| 125 |
else : |
| 126 |
/* translators: %s = time ago */ |
| 127 |
printf(esc_html__('Last rebuilt: %s', 'wp-optimize'), esc_html($last_rebuilt_human)); |
| 128 |
endif; |
| 129 |
endif; |
| 130 |
?> |
| 131 |
</span> |
| 132 |
<a href="<?php echo esc_url(WP_Optimize()->get_options()->admin_page_url('wpo_minify')); ?>" class="wpo-dash-link"> |
| 133 |
<?php esc_html_e('Manage minification', 'wp-optimize'); ?><span class="dashicons dashicons-arrow-right-alt"></span> |
| 134 |
</a> |
| 135 |
</div> |
| 136 |
</div> |