| 1 |
<?php |
| 2 |
/** |
| 3 |
* Partial: Database module card. |
| 4 |
*/ |
| 5 |
|
| 6 |
if (!defined('ABSPATH')) die('No direct access allowed'); |
| 7 |
|
| 8 |
$active = !empty($database['active']); |
| 9 |
$scheduled = !empty($database['scheduled']); |
| 10 |
$backup_before = !empty($database['backup_before_cleanup']); |
| 11 |
$schedule_count = (int) ($database['schedule_count'] ?? 0); |
| 12 |
$schedule_label = !empty($database['schedule_label']) ? $database['schedule_label'] : __('Not scheduled', 'wp-optimize'); |
| 13 |
$next_run_human = !empty($database['next_run_human']) ? $database['next_run_human'] : __('Not scheduled', 'wp-optimize'); |
| 14 |
$last_run_human = empty($database['last_run_human']) ? '' : $database['last_run_human']; |
| 15 |
$schedules_summary = is_array($database['schedules_summary']) ? $database['schedules_summary'] : array(); |
| 16 |
$updraftplus_active = !empty($database['updraftplus_active']); |
| 17 |
$last_cleaned_human = empty($database['last_cleaned_human']) ? '' : $database['last_cleaned_human']; |
| 18 |
|
| 19 |
?> |
| 20 |
|
| 21 |
<div class="wpo-mod-card"> |
| 22 |
|
| 23 |
<div class="wpo-mod-header"> |
| 24 |
<div class="wpo-mod-icon-title"> |
| 25 |
<?php global $wp_version; ?> |
| 26 |
<span class="wpo-dash-icon dashicons <?php echo version_compare($wp_version, '5.5', '>=') ? 'dashicons-database' : 'dashicons-admin-tools'; ?>"></span> |
| 27 |
<?php esc_html_e('Database', 'wp-optimize'); ?> |
| 28 |
</div> |
| 29 |
<?php if ($scheduled) : ?> |
| 30 |
<span class="wpo-badge scheduled"> |
| 31 |
<?php esc_html_e('Scheduled', 'wp-optimize'); ?> |
| 32 |
</span> |
| 33 |
<?php elseif ($active) : ?> |
| 34 |
<span class="wpo-badge active"> |
| 35 |
<?php esc_html_e('Active', 'wp-optimize'); ?> |
| 36 |
</span> |
| 37 |
<?php else : ?> |
| 38 |
<span class="wpo-badge inactive"><?php esc_html_e('Inactive', 'wp-optimize'); ?></span> |
| 39 |
<?php endif; ?> |
| 40 |
</div> |
| 41 |
|
| 42 |
<div> |
| 43 |
<?php if ($scheduled) : ?> |
| 44 |
<div class="wpo-mod-big"> |
| 45 |
<?php if ($schedule_count > 1) : ?> |
| 46 |
<span style="font-size:20px;font-weight:500"><?php echo esc_html(number_format_i18n($schedule_count)); ?></span> |
| 47 |
<span><?php esc_html_e('cleanups active', 'wp-optimize'); ?></span> |
| 48 |
<?php else : ?> |
| 49 |
<span style="font-size:20px;font-weight:500"><?php echo esc_html($schedule_label); ?></span> |
| 50 |
<span><?php esc_html_e('cleanup active', 'wp-optimize'); ?></span> |
| 51 |
<?php endif; ?> |
| 52 |
</div> |
| 53 |
<?php else : ?> |
| 54 |
<div class="wpo-mod-big"><?php esc_html_e('No cleanups run yet', 'wp-optimize'); ?></div> |
| 55 |
<?php endif; ?> |
| 56 |
<p class="wpo-mod-desc"> |
| 57 |
<?php esc_html_e('Clears out old drafts, spam, and temporary data on a schedule, like taking out the trash with a backup first.', 'wp-optimize'); ?> |
| 58 |
</p> |
| 59 |
</div> |
| 60 |
|
| 61 |
<div class="wpo-feature-list"> |
| 62 |
|
| 63 |
<div class="wpo-feat-row wpo-backup-before-cleanup"> |
| 64 |
<span class="wpo-feat-name"> |
| 65 |
<span class="wpo-dot <?php echo ($backup_before && $updraftplus_active) ? 'wpo-dot-on' : 'wpo-dot-off'; ?>">●</span> |
| 66 |
<a href="<?php echo esc_url(WP_Optimize()->get_options()->admin_page_url('wpo_database') . '&tab=wp_optimize_settings'); ?>" class="wpo-dash-link"> |
| 67 |
<?php esc_html_e('Backup before cleanup', 'wp-optimize'); ?> |
| 68 |
</a> |
| 69 |
</span> |
| 70 |
<span class="wpo-feat-val <?php echo ($backup_before && $updraftplus_active) ? 'on' : 'off'; ?>"> |
| 71 |
<?php |
| 72 |
if ($backup_before && $updraftplus_active) : |
| 73 |
esc_html_e('Active', 'wp-optimize'); |
| 74 |
elseif (!$updraftplus_active) : |
| 75 |
$udp_status = WP_Optimize()->is_installed('UpdraftPlus - Backup/Restore'); |
| 76 |
if (!empty($udp_status['installed'])) : |
| 77 |
$action_url = wp_nonce_url(network_admin_url('plugins.php?action=activate&plugin=updraftplus/updraftplus.php'), 'activate-plugin_updraftplus/updraftplus.php'); |
| 78 |
$action_text = __('Activate UpdraftPlus', 'wp-optimize'); |
| 79 |
else : |
| 80 |
$action_url = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=updraftplus'), 'install-plugin_updraftplus'); |
| 81 |
$action_text = __('Install UpdraftPlus', 'wp-optimize'); |
| 82 |
endif; |
| 83 |
?> |
| 84 |
<a href="<?php echo esc_url($action_url); ?>" class="wpo-warn"><?php echo esc_html($action_text); ?><span class="dashicons dashicons-arrow-right-alt"></span></a> |
| 85 |
<?php |
| 86 |
else : |
| 87 |
echo '–'; |
| 88 |
endif; |
| 89 |
?> |
| 90 |
</span> |
| 91 |
</div> |
| 92 |
|
| 93 |
<div class="wpo-feat-row"> |
| 94 |
<span class="wpo-feat-name"> |
| 95 |
<span class="wpo-dot <?php echo $scheduled ? 'wpo-dot-on' : 'wpo-dot-off'; ?>">●</span> |
| 96 |
<?php esc_html_e('Scheduled cleanup', 'wp-optimize'); ?> |
| 97 |
</span> |
| 98 |
<span class="wpo-feat-val <?php echo $scheduled ? 'on' : 'off'; ?>"> |
| 99 |
<?php echo $scheduled ? esc_html($next_run_human) : '–'; ?> |
| 100 |
</span> |
| 101 |
</div> |
| 102 |
|
| 103 |
<?php foreach ($schedules_summary as $row) : ?> |
| 104 |
<div class="wpo-feat-row"> |
| 105 |
<span class="wpo-feat-name wpo-feat-name--truncate" title="<?php echo esc_attr($row['frequency'] . ': ' . $row['tasks_label']); ?>"> |
| 106 |
<span class="wpo-dot wpo-dot-on">●</span> |
| 107 |
<strong><?php echo esc_html($row['frequency']); ?>:</strong> |
| 108 |
<span class="wpo-feat-tasks"><?php echo esc_html($row['tasks_label'] ?: ''); ?></span> |
| 109 |
</span> |
| 110 |
<span class="wpo-feat-val on"> |
| 111 |
<?php echo esc_html__('Active', 'wp-optimize'); ?> |
| 112 |
</span> |
| 113 |
</div> |
| 114 |
<?php endforeach; ?> |
| 115 |
|
| 116 |
</div> |
| 117 |
|
| 118 |
<div class="wpo-mod-footer"> |
| 119 |
<span> |
| 120 |
<?php |
| 121 |
if (($active || $scheduled) && $last_run_human) : |
| 122 |
if ($last_cleaned_human) : |
| 123 |
/* translators: %1$s = size cleaned, %2$s = time ago */ |
| 124 |
printf(esc_html__('%1$s cleaned · %2$s', 'wp-optimize'), esc_html($last_cleaned_human), esc_html($last_run_human)); |
| 125 |
else : |
| 126 |
/* translators: %s = time ago */ |
| 127 |
printf(esc_html__('Last cleaned: %s', 'wp-optimize'), esc_html($last_run_human)); |
| 128 |
endif; |
| 129 |
endif; |
| 130 |
?> |
| 131 |
</span> |
| 132 |
<a href="<?php echo esc_url(WP_Optimize()->get_options()->admin_page_url('wpo_database')); ?>" class="wpo-dash-link"> |
| 133 |
<?php esc_html_e('Manage database', 'wp-optimize'); ?><span class="dashicons dashicons-arrow-right-alt"></span> |
| 134 |
</a> |
| 135 |
</div> |
| 136 |
|
| 137 |
</div> |