PluginProbe
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript / 4.0.16
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript v4.0.16
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 / dashboard.php

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

349 lines 18.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if (!defined('ABSPATH')) exit;
3
4 use BerqWP\BerqWP;
5
6 $post_types = get_option('berqwp_optimize_post_types');
7 $args = array(
8 'post_type' => $post_types,
9 'posts_per_page' => -1,
10 'fields' => 'ids',
11 'post_status' => 'publish'
12 );
13 $query = new WP_Query($args);
14 $pages_to_exclude = get_option('berq_exclude_urls', []);
15 $total_pages = (int) $query->found_posts - count($pages_to_exclude);
16 $optimized_pages = bwp_cached_pages_count();
17
18 if (get_option('show_on_front') !== 'page') {
19 $total_pages++;
20 }
21
22 if (empty($total_pages) || $total_pages <= 0) {
23 $cached_percentage = 0;
24 } else {
25 $cached_percentage = round(($optimized_pages / $total_pages) * 100, 2);
26
27 }
28 if ($cached_percentage > 100) {
29 $cached_percentage = 100;
30 }
31
32 if ($cached_percentage < 0) {
33 $cached_percentage = 0;
34 }
35
36 ?>
37 <div id="dashboard" <?php bwp_is_tab('dashboard'); ?>>
38 <h2 class="berq-tab-title">Dashboard</h2>
39
40 <?php if (bwp_show_docs()) { ?>
41 <!--<div class="berq-info-box guide">
42 <div class="berq-box-content">
43 <div class="icon"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-book-marked-icon lucide-book-marked"><path d="M10 2v8l3-3 3 3V2"/><path d="M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20"/></svg></div>
44 <p><?php esc_html_e('Guide:', 'searchpro'); ?> <a href="https://berqwp.com/help-center/get-started-with-berqwp/" target="_blank"><?php esc_html_e('Get Started With BerqWP', 'searchpro'); ?></a></p>
45 </div>
46
47 </div>-->
48 <?php } ?>
49
50 <?php
51 if ($configs['optimization_method'] == 'cloud' && !bwp_is_home_cached()) {
52 bwp_dash_notification("We're currently building the cache for this website's homepage, which may take up to 5 minutes. Thank you for your patience, good things are worth the wait.", 'warning');
53 }
54 ?>
55
56 <div class="berq-info-box">
57 <h3 class="berq-box-title"><?php esc_html_e('Optimization Mode', 'searchpro'); ?></h3>
58 <div class="berq-box-content">
59 <p><?php esc_html_e("Optimization modes are optimization presets that allow you to balance your website between the best optimization score and website functionality stability.", 'searchpro'); ?>
60
61 <?php if (bwp_show_docs()) { ?>
62 <a href="https://berqwp.com/help-center/berqwp-optimization-modes/" target="_blank"><?php esc_html_e("Learn more", 'searchpro'); ?></a>
63 <?php } ?>
64 </p>
65
66 <div class="berqwp-optimization-modes-container">
67 <div class="berqwp-inline-radio-select">
68 <label>
69 <input type="radio" name="berq_opt_mode" value="1" <?php echo get_option('berq_opt_mode') == '1' ? 'checked' : ''; ?>>
70 <div>
71 <?php esc_html_e('Standard', 'searchpro'); ?>
72 <p>Standard optimizations like image optimization, page cache, URL prefectch.</p>
73 </div>
74 </label>
75 <label>
76 <input type="radio" name="berq_opt_mode" value="2" <?php echo get_option('berq_opt_mode') == '2' ? 'checked' : ''; ?>>
77 <div>
78 <?php esc_html_e('Smart', 'searchpro'); ?>
79 <p>Highly stable mode for many cases with JavaScipt & CSS aynchronouse loading</p>
80 </div>
81 </label>
82 <label>
83 <input type="radio" name="berq_opt_mode" value="3" <?php echo get_option('berq_opt_mode') == '3' ? 'checked' : ''; ?>>
84 <div>
85 <?php esc_html_e('Blaze', 'searchpro'); ?>
86 <p>Design first optimization with proritized CSS loading and delayed JavaScript</p>
87 </div>
88 </label>
89 <label class="berqwp-best-performance">
90 <input type="radio" name="berq_opt_mode" value="4" <?php echo get_option('berq_opt_mode') == '4' ? 'checked' : ''; ?>>
91 <div>
92 <?php esc_html_e('Turbo', 'searchpro'); ?>
93 <p>Delivers best performance possible by using minimal requests on initial page load</p>
94 </div>
95 </label>
96 </div>
97
98 </div>
99 <!--<div class="optimzation-slider">
100 <input id="berq_opt_mode" name="berq_opt_mode" type="text" value="<?php echo esc_attr( get_option('berq_opt_mode') ); ?>" style="display:none" />
101 </div>-->
102
103 </div>
104 </div>
105 <div class="berq-info-box before-after-comparision" style="display: none;">
106 <h3 class="berq-box-title"><?php esc_html_e('Google PageSpeed Score', 'searchpro'); ?></h3>
107 <div class="without-berqwp">
108 <?php
109 if (get_option('berqwp_enable_sandbox')) {
110 echo '<div class="berqw-sandbox">Sandbox Optimization</div>';
111 }
112 ?>
113 <div class="berq-speed-score"></div>
114 <p class="device-type"><?php esc_html_e('Device: Mobile', 'searchpro'); ?></p>
115 <p class="website-url">
116 <?php
117 $cache_directory = bwp_get_cache_dir();
118 // $home_slug = bwp_url_into_path(bwp_admin_home_url('/'));
119 $home_url = bwp_admin_home_url('/');
120 $is_home_ready = file_exists($cache_directory . md5($home_url) . '.gz');
121 $msg = '';
122
123 if (get_option('berqwp_enable_sandbox')) {
124 $msg .= '?berqwp';
125 }
126
127 if ($is_home_ready == false) {
128 $msg .= '<br>We\'re currently optimizing this page.';
129 }
130 echo wp_kses_post(bwp_admin_home_url('/') . $msg); ?>
131 </p>
132 <h4><?php esc_html_e('Mobile Score', 'searchpro'); ?></h4>
133 </div>
134 <div class="with-berqwp">
135 <?php
136 if (get_option('berqwp_enable_sandbox')) {
137 echo '<div class="berqw-sandbox">Sandbox Optimization</div>';
138 }
139 ?>
140 <div class="berq-speed-score"></div>
141 <p class="device-type"><?php esc_html_e('Device: Desktop', 'searchpro'); ?></p>
142 <p class="website-url">
143 <?php
144 $cache_directory = bwp_get_cache_dir();
145 // $home_slug = bwp_url_into_path(bwp_admin_home_url('/'));
146 $home_url = bwp_admin_home_url('/');
147 $is_home_ready = file_exists($cache_directory . md5($home_url) . '.gz');
148 $msg = '';
149
150 if (get_option('berqwp_enable_sandbox')) {
151 $msg .= '?berqwp';
152 }
153
154 if ($is_home_ready == false) {
155 $msg .= '<br>We\'re currently optimizing this page.';
156 }
157 echo wp_kses_post(bwp_admin_home_url('/') . $msg); ?>
158 </p>
159 <h4><?php esc_html_e('Desktop Score', 'searchpro'); ?></h4>
160 </div>
161 </div>
162
163
164 <div class="berq-triple-boxes">
165 <div class="berq-info-box" style="position: relative;">
166 <a class="berq-stat-refresh" href="#" style="display:none;"><svg xmlns="http://www.w3.org/2000/svg" height="20px" viewBox="0 -960 960 960" width="20px" fill="#29ac20"><path d="M229.08-205.08v-52H310l-13.08-13.84q-42.3-39.62-68.61-92.62-26.31-53-26.31-115.69 0-93.69 55.23-165.96 55.23-72.27 140.77-98.96v54.23q-63.39 25.3-103.69 81.73Q254-551.77 254-479.23q0 49.92 20.27 92.65 20.27 42.73 54.81 73.27l15.38 15.39v-74.54h52v167.38H229.08ZM562-215.85v-54.23q63.39-25.3 103.69-81.73Q706-408.23 706-480.77q0-49.92-20.27-92.65-20.27-42.73-54.81-73.27l-15.38-15.39v74.54h-52v-167.38h167.38v52H650l13.08 13.84q43.46 38.47 69.19 92.04Q758-543.46 758-480.77q0 93.69-55.23 165.96-55.23 72.27-140.77 98.96Z"></path></svg></a>
167 <h3 class="berq-box-title"><?php esc_html_e('Pages in Queue', 'searchpro'); ?></h3>
168 <div class="berq-box-content">
169 <p><?php esc_html_e("Pages pending in cloud", 'searchpro'); ?></p>
170 <div class="berq-stats-count">
171 <?php
172 if ($berqwp_can_use_cloud) {
173 $berqwp = new BerqWP(get_option('berqwp_license_key'), null, optifer_cache);
174 $queue_count = $berqwp->queue_count($configs['site_id']);
175 echo $queue_count;
176 } else {
177 echo "0";
178 }
179 ?>
180 </div>
181 </div>
182 </div>
183 <div class="berq-info-box" style="position: relative;">
184 <a class="berq-stat-refresh" href="#" style="display:none;"><svg xmlns="http://www.w3.org/2000/svg" height="20px" viewBox="0 -960 960 960" width="20px" fill="#29ac20"><path d="M229.08-205.08v-52H310l-13.08-13.84q-42.3-39.62-68.61-92.62-26.31-53-26.31-115.69 0-93.69 55.23-165.96 55.23-72.27 140.77-98.96v54.23q-63.39 25.3-103.69 81.73Q254-551.77 254-479.23q0 49.92 20.27 92.65 20.27 42.73 54.81 73.27l15.38 15.39v-74.54h52v167.38H229.08ZM562-215.85v-54.23q63.39-25.3 103.69-81.73Q706-408.23 706-480.77q0-49.92-20.27-92.65-20.27-42.73-54.81-73.27l-15.38-15.39v74.54h-52v-167.38h167.38v52H650l13.08 13.84q43.46 38.47 69.19 92.04Q758-543.46 758-480.77q0 93.69-55.23 165.96-55.23 72.27-140.77 98.96Z"></path></svg></a>
185 <h3 class="berq-box-title"><?php esc_html_e('Cached Pages', 'searchpro'); ?></h3>
186 <div class="berq-box-content">
187 <p><?php esc_html_e("Optimized pages", 'searchpro'); ?></p>
188 <div class="berq-stats-count"><?php echo $optimized_pages; ?></div>
189 </div>
190 </div>
191 <?php if ($berqwp_can_use_cloud) { ?>
192 <div class="berq-info-box" style="position:relative;">
193 <a title="Refresh license key" href="<?php echo esc_attr(wp_nonce_url(admin_url('admin-post.php?action=bwp_refresh_license'), 'bwp_refresh_license_action')); ?>" class="berq-stat-refresh">
194 <svg xmlns="http://www.w3.org/2000/svg" height="20px" viewBox="0 -960 960 960" width="20px" fill="#29ac20"><path d="M229.08-205.08v-52H310l-13.08-13.84q-42.3-39.62-68.61-92.62-26.31-53-26.31-115.69 0-93.69 55.23-165.96 55.23-72.27 140.77-98.96v54.23q-63.39 25.3-103.69 81.73Q254-551.77 254-479.23q0 49.92 20.27 92.65 20.27 42.73 54.81 73.27l15.38 15.39v-74.54h52v167.38H229.08ZM562-215.85v-54.23q63.39-25.3 103.69-81.73Q706-408.23 706-480.77q0-49.92-20.27-92.65-20.27-42.73-54.81-73.27l-15.38-15.39v74.54h-52v-167.38h167.38v52H650l13.08 13.84q43.46 38.47 69.19 92.04Q758-543.46 758-480.77q0 93.69-55.23 165.96-55.23 72.27-140.77 98.96Z"/></svg>
195 </a>
196 <h3 class="berq-box-title"><?php esc_html_e('My Account', 'searchpro'); ?></h3>
197 <div class="berq-box-content">
198
199 <?php if (!empty($this->key_response->product_ref) && $this->key_response->product_ref !== 'AppSumo Deal') { ?>
200 <p>
201 <?php esc_html_e('License:', 'searchpro'); ?>
202 <?php echo esc_html( $this->key_response->product_ref ); ?>
203 </p>
204 <?php } ?>
205
206 <p><?php esc_html_e('Status:', 'searchpro'); ?>
207 <?php echo esc_html( $this->key_response->status ); ?>
208 </p>
209
210 <?php if (!empty($this->key_response->product_ref) && !empty($this->key_response->date_expiry) && $this->key_response->product_ref !== 'AppSumo Deal' && $this->key_response->product_ref !== 'Free Account') { ?>
211 <p><?php esc_html_e('Renewal:', 'searchpro'); ?>
212 <?php echo esc_html( $this->key_response->date_expiry ); ?>
213 </p>
214 <?php } ?>
215
216 </div>
217 </div>
218 <?php } ?>
219 </div>
220
221 <div class="berq-info-box" style="display: none;">
222 <h3 class="berq-box-title"><?php esc_html_e('Cached Pages', 'searchpro'); ?></h3>
223 <div class="berq-box-content">
224 <div class="cache-percentage"><p><b><?php echo $cached_percentage; ?>%</b> (<?php echo $optimized_pages; ?>) of your pages are currently cached. <span class="bwp-cache-count"></span><span class="bwp-pending-optimization"></span></p></div>
225 <div class="cached-pages-bar">
226 <div class="progress-bar" style="width:<?php echo $cached_percentage; ?>%"></div>
227 </div>
228
229 <?php
230 if (!empty($this->key_response->product_ref) && $this->key_response->product_ref == 'Free Account' && bwp_cached_pages_count() >= 10) {
231 bwp_dash_notification("You've reached the limit of 10 optimized pages for your free BerqWP account. Upgrade now to optimize unlimited pages and get the best performance for your entire site!", "warning");
232 }
233 ?>
234
235 <div class="optimized-pages">
236 <table>
237 <thead>
238 <tr>
239 <th>Page URL</th>
240 <th>Cache Status</th>
241 <th>Last Optimized Date</th>
242 </tr>
243 </thead>
244 <tbody>
245 <?php
246 // if (!empty($optimized_pages)) {
247 // foreach ($optimized_pages as $page) {
248 // $row_html = "<tr>";
249 // $row_html .= "<td>";
250 // $row_html .= $page['url'];
251 // $row_html .= "</td>";
252 // $row_html .= "<td>";
253 // $row_html .= $page['status'];
254 // $row_html .= "</td>";
255 // $row_html .= "<td>";
256 // $row_html .= date('Y-m-d H:i:s', $page['last_modified']);
257 // $row_html .= "</td>";
258 // $row_html .= "</tr>";
259 // echo $row_html;
260 // }
261 // }
262 ?>
263
264 </tbody>
265 </table>
266 </div>
267 </div>
268 </div>
269 <div class="berq-dual-box" style="display:none">
270
271 <?php if (bwp_show_account()) { ?>
272 <div class="berq-info-box" style="position:relative;">
273 <a title="Refresh license key" href="<?php echo esc_attr(wp_nonce_url(admin_url('admin-post.php?action=bwp_refresh_license'), 'bwp_refresh_license_action')); ?>" class="berqwp-refresh-license-btn">
274 <svg xmlns="http://www.w3.org/2000/svg" height="20px" viewBox="0 -960 960 960" width="20px" fill="#29ac20"><path d="M229.08-205.08v-52H310l-13.08-13.84q-42.3-39.62-68.61-92.62-26.31-53-26.31-115.69 0-93.69 55.23-165.96 55.23-72.27 140.77-98.96v54.23q-63.39 25.3-103.69 81.73Q254-551.77 254-479.23q0 49.92 20.27 92.65 20.27 42.73 54.81 73.27l15.38 15.39v-74.54h52v167.38H229.08ZM562-215.85v-54.23q63.39-25.3 103.69-81.73Q706-408.23 706-480.77q0-49.92-20.27-92.65-20.27-42.73-54.81-73.27l-15.38-15.39v74.54h-52v-167.38h167.38v52H650l13.08 13.84q43.46 38.47 69.19 92.04Q758-543.46 758-480.77q0 93.69-55.23 165.96-55.23 72.27-140.77 98.96Z"/></svg>
275 </a>
276 <h3 class="berq-box-title"><?php esc_html_e('My Account', 'searchpro'); ?></h3>
277 <div class="berq-box-content">
278
279 <?php if (!empty($this->key_response->product_ref) && $this->key_response->product_ref !== 'AppSumo Deal') { ?>
280 <p>
281 <?php esc_html_e('License:', 'searchpro'); ?>
282 <?php echo esc_html( $this->key_response->product_ref ); ?>
283 </p>
284 <?php } ?>
285
286 <p><?php esc_html_e('License status:', 'searchpro'); ?>
287 <?php echo esc_html( $this->key_response->status ); ?>
288 </p>
289
290 <?php if (!empty($this->key_response->product_ref) && $this->key_response->product_ref !== 'AppSumo Deal' && $this->key_response->product_ref !== 'Free Account') { ?>
291 <p><?php esc_html_e('Expiration date:', 'searchpro'); ?>
292 <?php echo esc_html( $this->key_response->date_expiry ); ?>
293 </p>
294 <?php } ?>
295
296 </div>
297 </div>
298 <?php } ?>
299 <div class="berq-info-box">
300 <h3 class="berq-box-title"><?php esc_html_e('Quick Actions', 'searchpro'); ?></h3>
301 <div class="berq-box-content">
302 <a href="<?php echo esc_attr(wp_nonce_url(admin_url('admin-post.php?action=clear_cache'), 'clear_cache_action')); ?>" class="berq-btn"><?php esc_html_e('Flush cache', 'searchpro'); ?></a>
303
304 <?php if (bwp_show_docs()) { ?>
305 <a href="https://berqwp.com/help-center/" target="_blank" class="berq-btn"><?php esc_html_e('Visit help center', 'searchpro'); ?></a>
306 <?php } ?>
307
308 </div>
309 </div>
310
311 </div>
312 <div class="berq-info-box">
313 <h3 class="berq-box-title"><?php esc_html_e('Sandbox', 'searchpro'); ?></h3>
314 <div class="berq-box-content berq-setting-toggle">
315 <div class="berq-option-content">
316 <p><?php esc_html_e("The Sandbox feature allows you to test $plugin_name's optimizations without impacting real visitors. Note that pages will load slower when sandbox mode is enabled.", 'searchpro'); ?>
317
318 <?php if (bwp_show_docs()) { ?>
319 <a href="https://berqwp.com/help-center/sandbox-mode-and-how-to-use-it/" target="_blank"><?php esc_html_e("Learn more", 'searchpro'); ?></a>
320 <?php } ?>
321
322 </p>
323
324 </div>
325
326 <?php berqwp_render_toggle('berqwp_enable_sandbox', get_option('berqwp_enable_sandbox')); ?>
327
328 </div>
329 </div>
330
331 <div class="berq-info-box">
332 <h3 class="berq-box-title <?php echo !$berqwp_can_use_cloud ? 'cloud-exclusive' : ''; ?>"><?php esc_html_e("Monitor Core Web Vitals", 'searchpro'); ?></h3>
333 <div class="berq-box-content berq-setting-toggle">
334 <div class="berq-option-content">
335 <p><?php esc_html_e("Anonymously track and monitor Core Web Vitals metrics in real time using our Web Vitals Analytics. It may cause a little drop in PageSpeed score.", 'searchpro'); ?></p>
336
337 </div>
338 <?php berqwp_render_toggle('berqwp_enable_cwv', get_option('berqwp_enable_cwv')); ?>
339 </div>
340 </div>
341
342 <button type="submit" class="berqwp-save"><svg width="20" height="20" viewBox="0 0 20 20" fill="none"
343 xmlns="http://www.w3.org/2000/svg">
344 <path d="M4.16663 10.8333L7.49996 14.1667L15.8333 5.83334" stroke="white" stroke-width="2"
345 stroke-linecap="round" stroke-linejoin="round" />
346 </svg>
347 <?php esc_html_e('Save changes', 'searchpro'); ?></button>
348 </div>
349