| 1 |
<?php |
| 2 |
if (!defined('ABSPATH')) |
| 3 |
exit; |
| 4 |
|
| 5 |
$cached_pages = bwp_cached_pages_count(); |
| 6 |
$plugin_name = defined('BERQWP_PLUGIN_NAME') ? BERQWP_PLUGIN_NAME : 'BerqWP'; |
| 7 |
$berqconfigs = berqConfigs::getInstance(); |
| 8 |
$configs = $berqconfigs->get_configs(); |
| 9 |
$berqwp_can_use_cloud = berqwp_can_use_cloud(); |
| 10 |
?> |
| 11 |
<!--<link href="https://fonts.googleapis.com/css2?family=Source+Sans+3:wght@400;500;600;&display=swap" rel="stylesheet">--> |
| 12 |
<!--<link href="https://fonts.googleapis.com/css2?family=Lato:wght@400;700&display=swap" rel="stylesheet">--> |
| 13 |
<!--<link href="<?php echo esc_attr(optifer_URL . '/admin/css/dataTables.dataTables.min.css?v=' . BERQWP_VERSION); ?>" rel="stylesheet">--> |
| 14 |
<!--<link rel="stylesheet" href="<?php echo esc_attr(optifer_URL . '/admin/css/style.css?v=' . BERQWP_VERSION); ?>">--> |
| 15 |
<!--<link rel="stylesheet" href="<?php echo esc_attr(optifer_URL . '/admin/css/bootstrap-slider.min.css?v=' . BERQWP_VERSION); ?>">--> |
| 16 |
<!--<link rel="stylesheet" href="<?php echo esc_attr(optifer_URL . '/admin/css/bootstrap.min.css?v=' . BERQWP_VERSION); ?>">--> |
| 17 |
|
| 18 |
<div class="wrap1"> |
| 19 |
<!-- <h1 style="display:none">BerqWP</h1> |
| 20 |
<div></div> --> |
| 21 |
<div class="berqwp-dashbaord"> |
| 22 |
<div class="berqwp-header"> |
| 23 |
<img src="<?php |
| 24 |
|
| 25 |
if (defined('BERQWP_LOGO')) { |
| 26 |
echo esc_attr(BERQWP_LOGO); |
| 27 |
} else { |
| 28 |
echo esc_attr(optifer_URL . '/admin/img/logo.png'); |
| 29 |
} |
| 30 |
|
| 31 |
?>" alt="BerqWP Logo"> |
| 32 |
<div class="berqwp-header-right"> |
| 33 |
<?php if (empty(berqwp_get_license_key())) { ?> |
| 34 |
<a class="bwp-action-btn light bwp-upgrade-btn" href="https://berqwp.com/pricing/?referrer=plugin-installation" target="_blank"> |
| 35 |
<div class="icon"> |
| 36 |
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-rocket-icon lucide-rocket"><path d="M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5"/><path d="M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09"/><path d="M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z"/><path d="M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05"/></svg> |
| 37 |
</div> |
| 38 |
Upgrade Performance |
| 39 |
</a> |
| 40 |
<?php } ?> |
| 41 |
<div class="optimization-methods-switch <?php echo esc_attr($configs['optimization_method'])?>" title="Optimization method"> |
| 42 |
<a class="method-local" href="<?php echo esc_attr(wp_nonce_url(admin_url('admin-post.php?action=switch_optimization_method_local'), 'switch_optimization_method_local_action')); ?>"> |
| 43 |
<div class="icon"> |
| 44 |
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-server-icon lucide-server"> |
| 45 |
<rect width="20" height="8" x="2" y="2" rx="2" ry="2" /> |
| 46 |
<rect width="20" height="8" x="2" y="14" rx="2" ry="2" /> |
| 47 |
<line x1="6" x2="6.01" y1="6" y2="6" /> |
| 48 |
<line x1="6" x2="6.01" y1="18" y2="18" /> |
| 49 |
</svg> |
| 50 |
</div> |
| 51 |
Local (free) |
| 52 |
|
| 53 |
</a> |
| 54 |
|
| 55 |
<a class="method-cloud" href="<?php echo esc_attr(wp_nonce_url(admin_url('admin-post.php?action=switch_optimization_method_cloud'), 'switch_optimization_method_cloud_action')); ?>"> |
| 56 |
<div class="icon"> |
| 57 |
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-cloudy-icon lucide-cloudy"> |
| 58 |
<path d="M17.5 12a1 1 0 1 1 0 9H9.006a7 7 0 1 1 6.702-9z" /> |
| 59 |
<path d="M21.832 9A3 3 0 0 0 19 7h-2.207a5.5 5.5 0 0 0-10.72.61" /> |
| 60 |
</svg> |
| 61 |
</div> |
| 62 |
BerqWP Cloud |
| 63 |
</a> |
| 64 |
</div> |
| 65 |
|
| 66 |
<a class="bwp-action-btn light" href="<?php echo esc_attr(wp_nonce_url(admin_url('admin-post.php?action=clear_cache'), 'clear_cache_action')); ?>"> |
| 67 |
<div class="icon"> |
| 68 |
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-brush-cleaning-icon lucide-brush-cleaning"><path d="m16 22-1-4"/><path d="M19 14a1 1 0 0 0 1-1v-1a2 2 0 0 0-2-2h-3a1 1 0 0 1-1-1V4a2 2 0 0 0-4 0v5a1 1 0 0 1-1 1H6a2 2 0 0 0-2 2v1a1 1 0 0 0 1 1"/><path d="M19 14H5l-1.973 6.767A1 1 0 0 0 4 22h16a1 1 0 0 0 .973-1.233z"/><path d="m8 22 1-4"/></svg> |
| 69 |
</div> |
| 70 |
Flush cache |
| 71 |
</a> |
| 72 |
|
| 73 |
<?php if ($berqwp_can_use_cloud) { ?> |
| 74 |
<a class="bwp-action-btn" href="<?php echo esc_attr(wp_nonce_url(admin_url('admin-post.php?action=warmup_cache'), 'warmup_cache_action')); ?>"> |
| 75 |
|
| 76 |
<div class="icon"> |
| 77 |
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-refresh-ccw-icon lucide-refresh-ccw"><path d="M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><path d="M3 3v5h5"/><path d="M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16"/><path d="M16 16h5v5"/></svg> |
| 78 |
</div> |
| 79 |
Warmup cache |
| 80 |
</a> |
| 81 |
<?php } ?> |
| 82 |
|
| 83 |
<?php if (bwp_show_docs()) { ?> |
| 84 |
<!--<a href="https://wordpress.org/support/plugin/searchpro/reviews/#new-post" target="_blank" |
| 85 |
class="berqwp-support"> |
| 86 |
<?php esc_html_e('Write a review', 'searchpro'); ?> |
| 87 |
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"> |
| 88 |
<path |
| 89 |
d="M11.0001 3C10.7349 3 10.4805 3.10536 10.293 3.29289C10.1054 3.48043 10.0001 3.73478 10.0001 4C10.0001 4.26522 10.1054 4.51957 10.293 4.70711C10.4805 4.89464 10.7349 5 11.0001 5H13.5861L7.29308 11.293C7.19757 11.3852 7.12139 11.4956 7.06898 11.6176C7.01657 11.7396 6.98898 11.8708 6.98783 12.0036C6.98668 12.1364 7.01198 12.2681 7.06226 12.391C7.11254 12.5139 7.18679 12.6255 7.28069 12.7194C7.37458 12.8133 7.48623 12.8875 7.60913 12.9378C7.73202 12.9881 7.8637 13.0134 7.99648 13.0123C8.12926 13.0111 8.26048 12.9835 8.38249 12.9311C8.50449 12.8787 8.61483 12.8025 8.70708 12.707L15.0001 6.414V9C15.0001 9.26522 15.1054 9.51957 15.293 9.70711C15.4805 9.89464 15.7349 10 16.0001 10C16.2653 10 16.5197 9.89464 16.7072 9.70711C16.8947 9.51957 17.0001 9.26522 17.0001 9V4C17.0001 3.73478 16.8947 3.48043 16.7072 3.29289C16.5197 3.10536 16.2653 3 16.0001 3H11.0001Z" |
| 90 |
fill="#465774" /> |
| 91 |
<path |
| 92 |
d="M5 5C4.46957 5 3.96086 5.21071 3.58579 5.58579C3.21071 5.96086 3 6.46957 3 7V15C3 15.5304 3.21071 16.0391 3.58579 16.4142C3.96086 16.7893 4.46957 17 5 17H13C13.5304 17 14.0391 16.7893 14.4142 16.4142C14.7893 16.0391 15 15.5304 15 15V12C15 11.7348 14.8946 11.4804 14.7071 11.2929C14.5196 11.1054 14.2652 11 14 11C13.7348 11 13.4804 11.1054 13.2929 11.2929C13.1054 11.4804 13 11.7348 13 12V15H5V7H8C8.26522 7 8.51957 6.89464 8.70711 6.70711C8.89464 6.51957 9 6.26522 9 6C9 5.73478 8.89464 5.48043 8.70711 5.29289C8.51957 5.10536 8.26522 5 8 5H5Z" |
| 93 |
fill="#465774" /> |
| 94 |
</svg> |
| 95 |
|
| 96 |
</a>--> |
| 97 |
<?php } ?> |
| 98 |
|
| 99 |
</div> |
| 100 |
</div> |
| 101 |
<div class="berqwp-dashbord-body"> |
| 102 |
<div class="berqwp-tabs"> |
| 103 |
<div class="berqwp-tab <?php bwp_is_tab_nav('dashboard'); ?>" data-tab="dashboard"> |
| 104 |
<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-layout-dashboard-icon lucide-layout-dashboard"><rect width="7" height="9" x="3" y="3" rx="1"/><rect width="7" height="5" x="14" y="3" rx="1"/><rect width="7" height="9" x="14" y="12" rx="1"/><rect width="7" height="5" x="3" y="16" rx="1"/></svg></div> |
| 105 |
<?php esc_html_e('Dashboard', 'searchpro'); ?> |
| 106 |
</div> |
| 107 |
<div class="berqwp-tab <?php bwp_is_tab_nav('cache-management'); ?>" data-tab="cache-management"> |
| 108 |
<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-gauge-icon lucide-gauge"><path d="m12 14 4-4"/><path d="M3.34 19a10 10 0 1 1 17.32 0"/></svg></div> |
| 109 |
<?php esc_html_e('Cache Management', 'searchpro'); ?> |
| 110 |
</div> |
| 111 |
<div class="berqwp-tab <?php bwp_is_tab_nav('css-javascript'); ?>" data-tab="css-javascript"> |
| 112 |
<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-code-icon lucide-code"><path d="m16 18 6-6-6-6"/><path d="m8 6-6 6 6 6"/></svg></div> |
| 113 |
<?php esc_html_e('CSS & JavaScript', 'searchpro'); ?> |
| 114 |
</div> |
| 115 |
<div class="berqwp-tab <?php bwp_is_tab_nav('media-optimization'); ?>" data-tab="media-optimization"> |
| 116 |
<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-images-icon lucide-images"><path d="m22 11-1.296-1.296a2.4 2.4 0 0 0-3.408 0L11 16"/><path d="M4 8a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2"/><circle cx="13" cy="7" r="1" fill="currentColor"/><rect x="8" y="2" width="14" height="14" rx="2"/></svg></div> |
| 117 |
<?php esc_html_e('Media Optimization', 'searchpro'); ?> |
| 118 |
</div> |
| 119 |
<div class="berqwp-tab <?php bwp_is_tab_nav('content-delivery-network'); ?>" data-tab="content-delivery-network"> |
| 120 |
<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-earth-icon lucide-earth"><path d="M21.54 15H17a2 2 0 0 0-2 2v4.54"/><path d="M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17"/><path d="M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05"/><circle cx="12" cy="12" r="10"/></svg></div> |
| 121 |
<?php esc_html_e('CDN', 'searchpro'); ?> |
| 122 |
</div> |
| 123 |
<!--<div class="berqwp-tab <?php bwp_is_tab_nav('image-optimization'); ?>" data-tab="image-optimization"> |
| 124 |
<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-images-icon lucide-images"><path d="m22 11-1.296-1.296a2.4 2.4 0 0 0-3.408 0L11 16"/><path d="M4 8a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2"/><circle cx="13" cy="7" r="1" fill="currentColor"/><rect x="8" y="2" width="14" height="14" rx="2"/></svg></div> |
| 125 |
<?php esc_html_e('Image Optimization', 'searchpro'); ?> |
| 126 |
</div> |
| 127 |
<div class="berqwp-tab <?php bwp_is_tab_nav('script-manager'); ?>" data-tab="script-manager"> |
| 128 |
<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-file-code-corner-icon lucide-file-code-corner"><path d="M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35"/><path d="M14 2v5a1 1 0 0 0 1 1h5"/><path d="m5 16-3 3 3 3"/><path d="m9 22 3-3-3-3"/></svg></div> |
| 129 |
<?php esc_html_e('Script Manager', 'searchpro'); ?> |
| 130 |
</div>--> |
| 131 |
<div class="berqwp-tab <?php bwp_is_tab_nav('integration'); ?>" data-tab="integration"> |
| 132 |
<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-blocks-icon lucide-blocks"><path d="M10 22V7a1 1 0 0 0-1-1H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-5a1 1 0 0 0-1-1H2"/><rect x="14" y="2" width="8" height="8" rx="1"/></svg></div> |
| 133 |
<?php esc_html_e('Integration', 'searchpro'); ?> |
| 134 |
</div> |
| 135 |
<?php if ($berqwp_can_use_cloud) { ?> |
| 136 |
<div class="berqwp-tab <?php bwp_is_tab_nav('activate-license'); ?>" data-tab="activate-license"> |
| 137 |
<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-settings2-icon lucide-settings-2"><path d="M14 17H5"/><path d="M19 7h-9"/><circle cx="17" cy="17" r="3"/><circle cx="7" cy="7" r="3"/></svg></div> |
| 138 |
<?php esc_html_e('License', 'searchpro'); ?> |
| 139 |
</div> |
| 140 |
<?php } ?> |
| 141 |
<a class="berqwp-tab tab-link" target="_blank" href="https://www.facebook.com/groups/1660827728253423"> |
| 142 |
<div class="icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640" width="24"><!--!Font Awesome Free v7.2.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2026 Fonticons, Inc.--><path d="M576 320C576 178.6 461.4 64 320 64C178.6 64 64 178.6 64 320C64 440 146.7 540.8 258.2 568.5L258.2 398.2L205.4 398.2L205.4 320L258.2 320L258.2 286.3C258.2 199.2 297.6 158.8 383.2 158.8C399.4 158.8 427.4 162 438.9 165.2L438.9 236C432.9 235.4 422.4 235 409.3 235C367.3 235 351.1 250.9 351.1 292.2L351.1 320L434.7 320L420.3 398.2L351 398.2L351 574.1C477.8 558.8 576 450.9 576 320z"/></svg></svg></div> |
| 143 |
<?php esc_html_e('Join BerqWP Community', 'searchpro'); ?> |
| 144 |
</a> |
| 145 |
</div> |
| 146 |
<div class="berqwp-tab-content"> |
| 147 |
<?php do_action('berqwp_notices'); ?> |
| 148 |
<form action="" method="post"> |
| 149 |
<?php |
| 150 |
wp_nonce_field('berqwp_save_settings', 'berqwp_save_nonce'); |
| 151 |
?> |
| 152 |
<input type="hidden" name="bwp_current_tab_id" value="<?php echo !empty($_GET['tab_id']) ? esc_attr(sanitize_text_field(wp_unslash($_GET['tab_id']))) : 'dashboard'; ?>"> |
| 153 |
<?php |
| 154 |
require_once optifer_PATH . '/admin/tabs/dashboard.php'; |
| 155 |
require_once optifer_PATH . '/admin/tabs/cache-management.php'; |
| 156 |
require_once optifer_PATH . '/admin/tabs/content-delivery-network.php'; |
| 157 |
require_once optifer_PATH . '/admin/tabs/css-javascript.php'; |
| 158 |
// require_once optifer_PATH . '/admin/tabs/image-optimization.php'; |
| 159 |
require_once optifer_PATH . '/admin/tabs/media-optimization.php'; |
| 160 |
// require_once optifer_PATH . '/admin/tabs/script-manager.php'; |
| 161 |
require_once optifer_PATH . '/admin/tabs/integration.php'; |
| 162 |
|
| 163 |
if ($berqwp_can_use_cloud) { |
| 164 |
require_once optifer_PATH . '/admin/tabs/activate-license.php'; |
| 165 |
} |
| 166 |
|
| 167 |
?> |
| 168 |
</form> |
| 169 |
</div> |
| 170 |
</div> |
| 171 |
</div> |
| 172 |
</div> |
| 173 |
<!-- <p class="below-settings-panel">Explore <a href="https://berqier.com" target="_blank">Berqier Ltd</a>, the creators of |
| 174 |
BerqWP. Want to know more? Reach out—we love talking WordPress!</p> --> |
| 175 |
<!--<script src="<?php echo esc_attr(optifer_URL . '/admin/js/bootstrap-slider.js?v=' . BERQWP_VERSION); ?>"></script>--> |
| 176 |
<!--<script src="<?php echo esc_attr(optifer_URL . '/admin/js/dataTables.min.js?v=' . BERQWP_VERSION); ?>"></script>--> |
| 177 |
<script> |
| 178 |
(function($) { |
| 179 |
$(document).ready(function() { |
| 180 |
const bwp_controllers = []; |
| 181 |
// $('.bwp_feedback').hide(); |
| 182 |
let berq_nounce = '<?php echo esc_html(wp_create_nonce('wp_rest')); ?>'; |
| 183 |
let bwp_pages_nonce = '<?php echo esc_html(wp_create_nonce('berqwp_get_optimized_pages_nonce')); ?>'; |
| 184 |
|
| 185 |
window.addEventListener('beforeunload', () => { |
| 186 |
bwp_controllers.forEach(c => c.abort()); |
| 187 |
}); |
| 188 |
|
| 189 |
|
| 190 |
function numberWithCommas(x) { |
| 191 |
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); |
| 192 |
} |
| 193 |
|
| 194 |
function init_opt_slider() { |
| 195 |
let opt_slider = new Slider('#berq_opt_mode', { |
| 196 |
// min: 5, |
| 197 |
// max: 30, |
| 198 |
value: '<?php echo esc_html(get_option('berq_opt_mode', 4)); ?>', |
| 199 |
ticks_labels: ['Basic', 'Medium', 'Blaze', 'Aggressive'], |
| 200 |
ticks: [1, 2, 3, 4], |
| 201 |
// ticks_positions: [0, 50, 100], |
| 202 |
ticks_snap_bounds: 20, |
| 203 |
tooltip_position: 'bottom', |
| 204 |
// formatter: function (value) { |
| 205 |
// if (value == 1) { |
| 206 |
// // return '<div class="tooltip-title">Basic (stable)</div> <div class="tooltip-content">Basic optimizations like image lazy loading, page cache etc</div>'; |
| 207 |
// $("div.tooltip-inner").html('<div class="tooltip-title">Basic (stable)</div> <div class="tooltip-content">Basic optimizations like image lazy loading, page cache etc</div>') |
| 208 |
|
| 209 |
// return ''; |
| 210 |
// } |
| 211 |
// }, |
| 212 |
ticks_tooltip: true, |
| 213 |
// ticks_tooltip: true, |
| 214 |
// lock_to_ticks: true, |
| 215 |
// step: 1 |
| 216 |
}); |
| 217 |
|
| 218 |
$(".optimzation-slider").mousemove(function(event) { |
| 219 |
let val = $("#berq_opt_mode").val(); |
| 220 |
|
| 221 |
if ($(".slider-tick:nth-child(1)").is(":hover") || $('.tooltip-inner').html() == '1') { |
| 222 |
$("div.tooltip-inner").html('<div class="tooltip-title">Basic</div> <div class="tooltip-content">Basic optimizations like image lazy loading, page cache, URL prefectch etc.</div>') |
| 223 |
} |
| 224 |
|
| 225 |
if ($(".slider-tick:nth-child(2)").is(":hover") || $('.tooltip-inner').html() == '2') { |
| 226 |
$("div.tooltip-inner").html('<div class="tooltip-title">Medium</div> <div class="tooltip-content">Highly stable optimization mode for many cases.</div>') |
| 227 |
} |
| 228 |
|
| 229 |
if ($(".slider-tick:nth-child(3)").is(":hover") || $('.tooltip-inner').html() == '3') { |
| 230 |
$("div.tooltip-inner").html('<div class="tooltip-title">Blaze</div> <div class="tooltip-content">Balance between optimization and stability.</div>') |
| 231 |
} |
| 232 |
|
| 233 |
if ($(".slider-tick:nth-child(4)").is(":hover") || $('.tooltip-inner').html() == '4') { |
| 234 |
$("div.tooltip-inner").html('<div class="tooltip-title">Aggressive</div> <div class="tooltip-content">Provide the best possible speed scores.</div>') |
| 235 |
} |
| 236 |
}) |
| 237 |
|
| 238 |
$("#berq_opt_mode").on("slide slideStop", function(slideEvt) { |
| 239 |
let val = $("#berq_opt_mode").val(); |
| 240 |
|
| 241 |
if (val == 1) { |
| 242 |
$("div.tooltip-inner").html('<div class="tooltip-title">Basic (stable)</div> <div class="tooltip-content">Basic optimizations like image lazy loading, page cache etc</div>') |
| 243 |
} |
| 244 |
|
| 245 |
if (val == 2) { |
| 246 |
$("div.tooltip-inner").html('<div class="tooltip-title">Medium (stable)</div> <div class="tooltip-content">Basic optimizations like image lazy loading, page cache etc</div>') |
| 247 |
} |
| 248 |
|
| 249 |
if (val == 3) { |
| 250 |
$("div.tooltip-inner").html('<div class="tooltip-title">Blaze</div> <div class="tooltip-content">Basic optimizations like image lazy loading, page cache etc</div>') |
| 251 |
} |
| 252 |
|
| 253 |
if (val == 4) { |
| 254 |
$("div.tooltip-inner").html('<div class="tooltip-title">Aggressive</div> <div class="tooltip-content">Basic optimizations like image lazy loading, page cache etc</div>') |
| 255 |
} |
| 256 |
}) |
| 257 |
} |
| 258 |
|
| 259 |
function berq_clear_cache() { |
| 260 |
$.ajax({ |
| 261 |
url: '<?php echo esc_html(get_site_url()); ?>/wp-json/optifer/v1/clear-cache', |
| 262 |
method: 'POST', |
| 263 |
beforeSend: function(xhr) { |
| 264 |
xhr.setRequestHeader('X-WP-Nonce', berq_nounce); |
| 265 |
}, |
| 266 |
success: function(response) { |
| 267 |
|
| 268 |
} |
| 269 |
}) |
| 270 |
} |
| 271 |
|
| 272 |
function berq_refresh_cache_stats() { |
| 273 |
const controller = new AbortController(); |
| 274 |
bwp_controllers.push(controller); |
| 275 |
|
| 276 |
$.ajax({ |
| 277 |
url: ajaxurl, |
| 278 |
type: 'POST', |
| 279 |
data: { |
| 280 |
action: 'berqwp_refresh_cache_stats', |
| 281 |
nonce: berq_nounce, |
| 282 |
}, |
| 283 |
signal: controller.signal, |
| 284 |
beforeSend: function(xhr) { |
| 285 |
xhr.setRequestHeader('X-WP-Nonce', berq_nounce); |
| 286 |
}, |
| 287 |
success: function(data) { |
| 288 |
|
| 289 |
if (data.success) { |
| 290 |
|
| 291 |
$('.cache-percentage').html(`${data.data.cache_percentage}% (${data.data.cache_count}) of your pages are currently cached.`); |
| 292 |
|
| 293 |
$('.cached-pages-bar .progress-bar').css('width', `${data.data.cache_percentage}%`); |
| 294 |
|
| 295 |
// if (data.data.server_queue > 0) { |
| 296 |
// $('.bwp-pending-optimization').html(`${data.data.server_queue} pending optimization`); |
| 297 |
|
| 298 |
// } else { |
| 299 |
// $('.bwp-pending-optimization').html(''); |
| 300 |
// } |
| 301 |
} |
| 302 |
|
| 303 |
}, |
| 304 |
error: function() { |
| 305 |
console.log('Error in AJAX request.'); |
| 306 |
} |
| 307 |
}); |
| 308 |
} |
| 309 |
|
| 310 |
// init_opt_slider(); |
| 311 |
|
| 312 |
$('.berqwp-tab[data-tab]').click(function() { |
| 313 |
let tab = $(this).attr('data-tab'); |
| 314 |
$("html, body").animate({ |
| 315 |
scrollTop: $(".berqwp-dashbaord").offset().top - 30 |
| 316 |
}, 200); |
| 317 |
|
| 318 |
$('.berqwp-tab-content > form > div').css({ |
| 319 |
'visibility': 'hidden', |
| 320 |
'display': 'none', |
| 321 |
'opacity': 0, |
| 322 |
'height': '0px', |
| 323 |
'overflow': 'hidden' |
| 324 |
}); |
| 325 |
$('.berqwp-tab').removeClass('active'); |
| 326 |
$(this).addClass('active'); |
| 327 |
// $(`.berqwp-tab-content #${tab}`).show(); |
| 328 |
$(`.berqwp-tab-content #${tab}`).css({ |
| 329 |
'visibility': 'visible', |
| 330 |
'display': 'block', |
| 331 |
'opacity': 1, |
| 332 |
'height': 'auto' |
| 333 |
}); |
| 334 |
|
| 335 |
let tab_id = $(`.berqwp-tab-content #${tab}`).attr('id'); |
| 336 |
$('input[name="bwp_current_tab_id"]').val(tab_id); |
| 337 |
|
| 338 |
|
| 339 |
// Get the current URL and its parts |
| 340 |
const url = new URL(window.location.href); |
| 341 |
|
| 342 |
// Check if 'tab_id' is present |
| 343 |
if (url.searchParams.has('tab_id')) { |
| 344 |
// Update the 'tab_id' parameter value |
| 345 |
url.searchParams.set('tab_id', tab_id); |
| 346 |
|
| 347 |
// Update the address bar with the new URL (without reloading the page) |
| 348 |
window.history.replaceState(null, null, url.toString()); |
| 349 |
} |
| 350 |
|
| 351 |
|
| 352 |
|
| 353 |
}) |
| 354 |
|
| 355 |
// let tab_id = $('input[name="bwp_current_tab_id"]').val(); |
| 356 |
// $(`.berqwp-tab[data-tab="${tab_id}"]`).trigger('click'); |
| 357 |
let is_admin_page_active = true; |
| 358 |
|
| 359 |
// Visibility tracking - pause when tab hidden |
| 360 |
document.addEventListener('visibilitychange', function() { |
| 361 |
is_admin_page_active = !document.hidden; |
| 362 |
}); |
| 363 |
|
| 364 |
// berq_refresh_cache_stats(); |
| 365 |
|
| 366 |
// setInterval(function() { |
| 367 |
|
| 368 |
// if (!is_admin_page_active) return; |
| 369 |
|
| 370 |
// berq_refresh_cache_stats(); |
| 371 |
|
| 372 |
// }, 10000) |
| 373 |
|
| 374 |
|
| 375 |
}) |
| 376 |
})(jQuery) |
| 377 |
</script> |
| 378 |
<?php |
| 379 |
if (function_exists('pll_current_language')) { |
| 380 |
$lang = !empty(pll_current_language()) ? pll_current_language() : 'all'; |
| 381 |
echo "<script>ajaxurl = ajaxurl + '?lang=$lang';</script>"; |
| 382 |
} |
| 383 |
?> |
| 384 |
<script> |
| 385 |
(function($) { |
| 386 |
// $(document).ready(function () { |
| 387 |
// let table = new DataTable('.optimized-pages > table', { |
| 388 |
// // "paging": false, // Disable pagination |
| 389 |
// "searching": false, // Disable the search box |
| 390 |
// "pageLength": 5, |
| 391 |
// "info": false, // Disable the info text (e.g., "Showing 1 to 10 of 57 entries") |
| 392 |
// "lengthChange": false |
| 393 |
// }); |
| 394 |
// }) |
| 395 |
|
| 396 |
|
| 397 |
jQuery(document).ready(function($) { |
| 398 |
var dataTable = $('.optimized-pages > table').DataTable({ |
| 399 |
ordering: false, |
| 400 |
paging: true, |
| 401 |
searching: true, |
| 402 |
processing: true, |
| 403 |
serverSide: true, |
| 404 |
info: false, |
| 405 |
lengthChange: false, |
| 406 |
pageLength: 5, |
| 407 |
ajax: function(data, callback, settings) { |
| 408 |
var start = settings._iDisplayStart; |
| 409 |
var length = settings._iDisplayLength; |
| 410 |
|
| 411 |
$.ajax({ |
| 412 |
url: ajaxurl, // WordPress AJAX URL |
| 413 |
type: 'POST', |
| 414 |
data: { |
| 415 |
action: 'berqwp_get_optimized_pages', |
| 416 |
nonce: bwp_pages_nonce, |
| 417 |
start: start, |
| 418 |
length: length, |
| 419 |
search: data.search.value |
| 420 |
}, |
| 421 |
success: function(response) { |
| 422 |
if (response.success) { |
| 423 |
callback({ |
| 424 |
draw: data.draw, |
| 425 |
recordsTotal: response.data.total_entries, // Total number of records |
| 426 |
recordsFiltered: response.data.records_filtered, // Total after filtering |
| 427 |
data: response.data.optimized_pages // Data for the current page |
| 428 |
}); |
| 429 |
} else { |
| 430 |
console.error("Error fetching data:", response); |
| 431 |
} |
| 432 |
}, |
| 433 |
error: function(error) { |
| 434 |
console.error("AJAX error:", error); |
| 435 |
} |
| 436 |
}); |
| 437 |
}, |
| 438 |
columns: [{ |
| 439 |
data: 'url', |
| 440 |
title: "Page URL" |
| 441 |
}, // Map 'url' to the first column |
| 442 |
{ |
| 443 |
data: 'status', |
| 444 |
title: "Cache Status" |
| 445 |
}, // Map 'status' to the second column |
| 446 |
{ |
| 447 |
data: 'last_modified', |
| 448 |
title: "Last Optimized Date" |
| 449 |
} // Map 'last_modified' to the third column |
| 450 |
] |
| 451 |
}); |
| 452 |
}); |
| 453 |
|
| 454 |
$('[name="berqwp_lazyload_youtube_embed"]').on('change', function() { |
| 455 |
if ($(this).is(':checked')) { |
| 456 |
$('[name="berqwp_preload_yt_poster"]').parent().show(); |
| 457 |
} else { |
| 458 |
$('[name="berqwp_preload_yt_poster"]').parent().hide(); |
| 459 |
} |
| 460 |
}); |
| 461 |
|
| 462 |
// $(document).ready(function () { |
| 463 |
// const stickyDiv = $('.berqwp-dashbaord'); |
| 464 |
// const offset = stickyDiv.offset().top; |
| 465 |
|
| 466 |
// $(window).on('scroll', function () { |
| 467 |
// if ($(this).scrollTop() + 30 >= offset) { |
| 468 |
// stickyDiv.addClass('sticky'); |
| 469 |
// stickyDiv.parent().css('paddingBottom', '100vh'); |
| 470 |
// setTimeout(function() { |
| 471 |
// var resizeEvent = new Event('resize'); |
| 472 |
// window.dispatchEvent(resizeEvent); |
| 473 |
// document.dispatchEvent(resizeEvent); |
| 474 |
// }, 300) |
| 475 |
// } else { |
| 476 |
// stickyDiv.removeClass('sticky'); |
| 477 |
// stickyDiv.parent().css('paddingBottom', '0vh'); |
| 478 |
// setTimeout(function() { |
| 479 |
// var resizeEvent = new Event('resize'); |
| 480 |
// window.dispatchEvent(resizeEvent); |
| 481 |
// document.dispatchEvent(resizeEvent); |
| 482 |
// }, 300) |
| 483 |
// } |
| 484 |
// }); |
| 485 |
// }); |
| 486 |
|
| 487 |
|
| 488 |
|
| 489 |
|
| 490 |
|
| 491 |
|
| 492 |
|
| 493 |
})(jQuery) |
| 494 |
</script> |
| 495 |
<script> |
| 496 |
(function($) { |
| 497 |
$(document).ready(function() { |
| 498 |
let cache_lifespan_options = $('input[name="berqwp_cache_lifespan"], input[name="berq_opt_mode"]'); |
| 499 |
|
| 500 |
cache_lifespan_options.change(function() { |
| 501 |
cache_lifespan_options.parent('label').removeClass('selected'); |
| 502 |
$('input[name="berqwp_cache_lifespan"]:checked, input[name="berq_opt_mode"]:checked').parent('label').addClass('selected'); |
| 503 |
}) |
| 504 |
|
| 505 |
$('input[name="berqwp_cache_lifespan"]:checked, input[name="berq_opt_mode"]:checked').parent('label').addClass('selected'); |
| 506 |
}) |
| 507 |
})(jQuery) |
| 508 |
</script> |
| 509 |
<script> |
| 510 |
(function($) { |
| 511 |
$(document).ready(function() { |
| 512 |
let enable_compression_btn = $('a.berqwp-enable-page-compression'); |
| 513 |
let berq_nounce = '<?php echo esc_html(wp_create_nonce('wp_rest')); ?>'; |
| 514 |
|
| 515 |
enable_compression_btn.click(function(e) { |
| 516 |
e.preventDefault(); |
| 517 |
|
| 518 |
let loader = enable_compression_btn.find('.berqwp-loader'); |
| 519 |
$.ajax({ |
| 520 |
url: ajaxurl, |
| 521 |
type: 'POST', |
| 522 |
data: { |
| 523 |
action: 'berqwp_enable_page_compression', |
| 524 |
nonce: berq_nounce, |
| 525 |
}, |
| 526 |
beforeSend: function(xhr) { |
| 527 |
xhr.setRequestHeader('X-WP-Nonce', berq_nounce); |
| 528 |
loader.show(); |
| 529 |
}, |
| 530 |
success: function(data) { |
| 531 |
loader.hide(); |
| 532 |
|
| 533 |
if (data.success === true) { |
| 534 |
let currentUrl = window.location.href; |
| 535 |
let url = new URL(currentUrl); |
| 536 |
let params = new URLSearchParams(url.search); |
| 537 |
params.set('berqwp_page_compression_enabled', ''); |
| 538 |
url.search = params.toString(); |
| 539 |
window.location.href = url.toString(); |
| 540 |
} else { |
| 541 |
alert("Page compression test failed: Your web server doesn't support Gzip compression."); |
| 542 |
} |
| 543 |
|
| 544 |
|
| 545 |
}, |
| 546 |
error: function() { |
| 547 |
loader.hide(); |
| 548 |
alert("Page compression test failed: Please check your internet connection."); |
| 549 |
} |
| 550 |
}); |
| 551 |
}) |
| 552 |
}) |
| 553 |
})(jQuery) |
| 554 |
</script> |
| 555 |
|