PluginProbe
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript / 4.1.13
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript v4.1.13
4.1.16 4.1.15 4.1.14 4.1.13 4.1.12 4.1.11 4.1.10 4.0.30 4.0.29 4.0.28 4.0.27 4.0.26 4.0.24 4.0.25 4.0.23 4.0.22 4.0.21 4.0.19 4.0.18 4.0.17 4.0.16 1.9.3 1.9.4 1.9.5 1.9.6 All 170 releases
searchpro / admin / tabs / database.php

database.php in BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript 4.1.13, at admin/tabs/database.php

179 lines 8.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if (!defined('ABSPATH'))
3 exit;
4
5 $db_schedule_enabled = get_option('berqwp_db_schedule_enabled', 0);
6 $db_schedule_frequency = get_option('berqwp_db_schedule_frequency', 'weekly');
7 $db_revision_limit = get_option('berqwp_db_revision_limit', 5);
8 $db_scheduled_tasks = get_option('berqwp_db_scheduled_tasks', ['revisions', 'transients', 'spam_comments']);
9 $db_last_run = get_option('berqwp_db_optimize_last_run', 0);
10
11 $db_task_labels = [
12 'revisions' => __('Post revisions', 'searchpro'),
13 'auto_drafts' => __('Auto-drafts & trashed posts', 'searchpro'),
14 'transients' => __('Expired transients', 'searchpro'),
15 'spam_comments' => __('Spam & trashed comments', 'searchpro'),
16 'orphaned_meta' => __('Orphaned post meta', 'searchpro'),
17 'optimize_tables' => __('Optimize database tables', 'searchpro'),
18 ];
19 ?>
20 <div id="database" <?php bwp_is_tab('database'); ?>>
21 <h2 class="berq-tab-title">
22 <?php esc_html_e('Database', 'searchpro'); ?>
23 </h2>
24
25 <div class="berq-info-box">
26 <h3 class="berq-box-title">
27 <?php esc_html_e('Cleanup Actions', 'searchpro'); ?>
28 </h3>
29 <div class="berq-box-content">
30 <p>
31 <?php esc_html_e('Run these actions manually at any time. Each action reports how many rows were affected.', 'searchpro'); ?>
32 </p>
33
34 <div class="berqwp-db-actions">
35 <div class="berqwp-db-action" data-task="revisions">
36 <span>
37 <?php esc_html_e('Post revisions', 'searchpro'); ?>
38 (<?php esc_html_e('keep last', 'searchpro'); ?>
39 <input type="number" name="berqwp_db_revision_limit" min="0" max="50" value="<?php echo esc_attr($db_revision_limit); ?>" class="berqwp-inline-number">)
40 </span>
41 <a href="#" class="berq-btn berqwp-db-run-action"><?php esc_html_e('Clean now', 'searchpro'); ?></a>
42 </div>
43 <div class="berqwp-db-action" data-task="auto_drafts">
44 <span><?php esc_html_e('Auto-drafts & trashed posts', 'searchpro'); ?></span>
45 <a href="#" class="berq-btn berqwp-db-run-action"><?php esc_html_e('Clean now', 'searchpro'); ?></a>
46 </div>
47 <div class="berqwp-db-action" data-task="transients">
48 <span><?php esc_html_e('Expired transients', 'searchpro'); ?></span>
49 <a href="#" class="berq-btn berqwp-db-run-action"><?php esc_html_e('Clean now', 'searchpro'); ?></a>
50 </div>
51 <div class="berqwp-db-action" data-task="spam_comments">
52 <span><?php esc_html_e('Spam & trashed comments', 'searchpro'); ?></span>
53 <a href="#" class="berq-btn berqwp-db-run-action"><?php esc_html_e('Clean now', 'searchpro'); ?></a>
54 </div>
55 <div class="berqwp-db-action" data-task="orphaned_meta">
56 <span><?php esc_html_e('Orphaned post meta', 'searchpro'); ?></span>
57 <a href="#" class="berq-btn berqwp-db-run-action"><?php esc_html_e('Clean now', 'searchpro'); ?></a>
58 </div>
59 <div class="berqwp-db-action" data-task="optimize_tables">
60 <span><?php esc_html_e('Optimize database tables', 'searchpro'); ?></span>
61 <a href="#" class="berq-btn berqwp-db-run-action"><?php esc_html_e('Optimize now', 'searchpro'); ?></a>
62 </div>
63 </div>
64 </div>
65 </div>
66
67 <div class="berq-info-box berq-setting-group">
68 <div class="group-container">
69 <h3 class="berq-box-title">
70 <?php esc_html_e('Scheduled Optimization', 'searchpro'); ?>
71 </h3>
72 <div class="berq-box-content berq-setting-toggle">
73 <div class="berq-option-content">
74 <p>
75 <?php esc_html_e('Automatically run database cleanup on a recurring schedule.', 'searchpro'); ?>
76 </p>
77 </div>
78 <?php berqwp_render_toggle('berqwp_db_schedule_enabled', $db_schedule_enabled); ?>
79 </div>
80 </div>
81
82 <div class="group-container">
83 <h3 class="berq-box-title">
84 <?php esc_html_e('Frequency', 'searchpro'); ?>
85 </h3>
86 <div class="berq-box-content">
87 <p>
88 <?php esc_html_e('Choose how often scheduled optimization should run.', 'searchpro'); ?>
89 </p>
90 <div class="berqwp-lifespan-options">
91 <label>
92 <input type="radio" name="berqwp_db_schedule_frequency" value="daily" <?php echo $db_schedule_frequency === 'daily' ? 'checked' : ''; ?>>
93 <?php esc_html_e('Daily', 'searchpro'); ?>
94 </label>
95 <label>
96 <input type="radio" name="berqwp_db_schedule_frequency" value="weekly" <?php echo $db_schedule_frequency === 'weekly' ? 'checked' : ''; ?>>
97 <?php esc_html_e('Weekly', 'searchpro'); ?>
98 </label>
99 <label>
100 <input type="radio" name="berqwp_db_schedule_frequency" value="monthly" <?php echo $db_schedule_frequency === 'monthly' ? 'checked' : ''; ?>>
101 <?php esc_html_e('Monthly', 'searchpro'); ?>
102 </label>
103 </div>
104 </div>
105 </div>
106
107 <div class="group-container">
108 <h3 class="berq-box-title">
109 <?php esc_html_e('Tasks to Run on Schedule', 'searchpro'); ?>
110 </h3>
111 <div class="berq-box-content">
112 <p>
113 <?php esc_html_e('Select which cleanup actions should run automatically.', 'searchpro'); ?>
114 </p>
115 <div class="berqwp-db-scheduled-tasks">
116 <?php foreach ($db_task_labels as $task_key => $task_label) { ?>
117 <label class="berq-check">
118 <input type="checkbox" name="berqwp_db_scheduled_tasks[]" value="<?php echo esc_attr($task_key); ?>" <?php checked(1, in_array($task_key, $db_scheduled_tasks, true), true); ?>>
119 <?php echo esc_html($task_label); ?>
120 </label>
121 <?php } ?>
122 </div>
123 </div>
124 </div>
125
126 <div class="group-container">
127 <h3 class="berq-box-title">
128 <?php esc_html_e('Last Run', 'searchpro'); ?>
129 </h3>
130 <div class="berq-box-content">
131 <?php if ($db_last_run) { ?>
132 <p>
133 <?php
134 printf(
135 /* translators: %s: human-readable time since last run */
136 esc_html__('%s ago', 'searchpro'),
137 esc_html(human_time_diff((int) $db_last_run))
138 );
139 ?>
140 </p>
141 <?php } else { ?>
142 <p><?php esc_html_e('Never run yet.', 'searchpro'); ?></p>
143 <?php } ?>
144 </div>
145 </div>
146
147 <div class="group-container">
148 <h3 class="berq-box-title">
149 <?php esc_html_e('Next Run', 'searchpro'); ?>
150 </h3>
151 <div class="berq-box-content">
152 <?php
153 $db_next_run = $db_schedule_enabled ? wp_next_scheduled('berqwp_db_scheduled_optimize') : false;
154 ?>
155 <?php if ($db_next_run) { ?>
156 <p>
157 <?php
158 printf(
159 /* translators: %s: human-readable time until next scheduled run */
160 esc_html__('In %s', 'searchpro'),
161 esc_html(human_time_diff(time(), (int) $db_next_run))
162 );
163 ?>
164 </p>
165 <?php } else { ?>
166 <p><?php esc_html_e('Not scheduled.', 'searchpro'); ?></p>
167 <?php } ?>
168 </div>
169 </div>
170 </div>
171
172 <button type="submit" class="berqwp-save"><svg width="20" height="20" viewBox="0 0 20 20" fill="none"
173 xmlns="http://www.w3.org/2000/svg">
174 <path d="M4.16663 10.8333L7.49996 14.1667L15.8333 5.83334" stroke="white" stroke-width="2"
175 stroke-linecap="round" stroke-linejoin="round" />
176 </svg>
177 <?php esc_html_e("Save changes", "searchpro"); ?></button>
178 </div>
179