images
1 year ago
javascript
1 year ago
modals
1 year ago
stylesheet
1 year ago
templates
2 years ago
admin.php
1 year ago
connect-oneclick.php
1 year ago
connect.php
2 years ago
dashboard-oneclick.php
2 years ago
dashboard.php
1 year ago
oneclick.php
2 years ago
safemode.php
2 years ago
system-report.php
1 year ago
dashboard.php
621 lines
| 1 | <?php $processing = 0; |
| 2 | $usage = '0 MB'; |
| 3 | $max_usage = '1 GB'; |
| 4 | $page_views = '0'; |
| 5 | $max_page_views = '10000'; ?> |
| 6 | <?php nitropack_display_admin_notices(); ?> |
| 7 | <div class="grid grid-cols-2 gap-6 grid-col-1-tablet items-start"> |
| 8 | <div class="col-span-1"> |
| 9 | <!-- Optimized Pages Card --> |
| 10 | <div class="card card-optimized-pages"> |
| 11 | <div class="card-header"> |
| 12 | <h3><?php esc_html_e('Optimized pages', 'nitropack'); ?></h3> |
| 13 | <div class="flex flex-row items-center" style="display: none;" id="pending-optimizations-section"> |
| 14 | <img src="<?php echo plugin_dir_url(__FILE__) . 'images/loading.svg'; ?>" alt="loading" class="w-4 h-4"> |
| 15 | <span class="ml-2 mr-1 text-primary"> <?php esc_html_e('Processing', 'nitropack'); ?> |
| 16 | <span id="pending-optimizations-count">X</span> <?php esc_html_e('page(s) in the background', 'nitropack'); ?></span> |
| 17 | </div> |
| 18 | </div> |
| 19 | <div class="card-body"> |
| 20 | <div class="card-body-inner"> |
| 21 | <div class="optimized-pages"><span data-optimized-pages-total>0</span></div> |
| 22 | <div class="text-box"> |
| 23 | <div class="time-ago"><?php esc_html_e('Last cache purge', 'nitropack'); ?>: <span data-last-cache-purge><?php esc_html_e('Never', 'nitropack'); ?></span></div> |
| 24 | <div class="reason"><?php esc_html_e('Reason', 'nitropack'); ?>: <span data-purge-reason><?php esc_html_e('Unknown', 'nitropack'); ?></span></div> |
| 25 | </div> |
| 26 | <button id="optimizations-purge-cache" type="button" class="btn btn-secondary" data-modal-target="modal-purge-cache" data-modal-toggle="modal-purge-cache"><?php esc_html_e('Purge cache', 'nitropack'); ?></button> |
| 27 | </div> |
| 28 | </div> |
| 29 | <?php require_once NITROPACK_PLUGIN_DIR . 'view/modals/modal-purge-cache.php'; ?> |
| 30 | </div> |
| 31 | <!-- Optimized Pages Card End --> |
| 32 | <!-- Optimization Mode Card --> |
| 33 | <div class="card card-optimization-mode"> |
| 34 | <div class="card-header no-border mb-0"> |
| 35 | <div class="flex items-center"> |
| 36 | <h3 class="mb-0"><?php esc_html_e('Optimization mode', 'nitropack'); ?></h3> |
| 37 | <span class="tooltip-icon" data-tooltip-target="tooltip-optimization"> |
| 38 | <img src="<?php echo plugin_dir_url(__FILE__) . 'images/info.svg'; ?>"> |
| 39 | </span> |
| 40 | <div id="tooltip-optimization" role="tooltip" class="tooltip-container hidden"> |
| 41 | <?php esc_html_e('Select from our range of predefined optimization modes to boost your site\'s performance.', 'nitropack'); |
| 42 | ?> |
| 43 | <div class="tooltip-arrow" data-popper-arrow></div> |
| 44 | </div> |
| 45 | </div> |
| 46 | </div> |
| 47 | <?php $modes = array('standard' => esc_html__('Standard', 'nitropack'), 'medium' => esc_html__('Medium', 'nitropack'), 'strong' => esc_html__('Strong', 'nitropack'), 'ludicrous' => esc_html__('Ludicrous', 'nitropack'), 'custom' => esc_html__('Custom', 'nitropack')); ?> |
| 48 | <div class="tabs-wrapper"> |
| 49 | <div class="tabs" id="optimization-modes"> |
| 50 | <?php foreach ($modes as $mode_id => $mode) : ?> |
| 51 | <a class="btn tab-link btn-link" data-mode="<?php echo $mode_id; ?>" data-modal-target="modal-optimization-mode" data-modal-toggle="modal-optimization-mode"><?php echo $mode; ?></a> |
| 52 | <?php endforeach; ?> |
| 53 | </div> |
| 54 | <p><?php esc_html_e('Active Mode', 'nitropack'); ?>: <span class="active-mode"></span></p> |
| 55 | <div class="tab-content-wrapper"> |
| 56 | <div class="hidden tab-content" role="tabpanel" data-tab="standard-tab"> |
| 57 | <p class="text-secondary mt-2"> <?php esc_html_e('Standard optimization features enabled for your site. Ideal choice for maximum stability.', 'nitropack'); ?></p> |
| 58 | </div> |
| 59 | <div class="hidden tab-content" role="tabpanel" data-tab="medium-tab"> |
| 60 | <p class="text-secondary mt-2"> <?php esc_html_e('Adds image lazy loading to standard optimizations. Uses built-in browser techniques for loading resources.', 'nitropack'); ?></p> |
| 61 | </div> |
| 62 | <div class="hidden tab-content" role="tabpanel" data-tab="strong-tab"> |
| 63 | <p class="text-secondary mt-2"> <?php esc_html_e('Includes smart resource loading on top of Medium optimizations. Balances speed boost with stability.', 'nitropack'); ?></p> |
| 64 | </div> |
| 65 | <div class="hidden tab-content" role="tabpanel" data-tab="ludicrous-tab"> |
| 66 | <p class="text-secondary mt-2"> <?php esc_html_e('Applies deferred JS and advanced resource loading for optimal performance and Core Web Vitals.', 'nitropack'); ?></p> |
| 67 | </div> |
| 68 | <div class="hidden tab-content" role="tabpanel" data-tab="custom-tab"> |
| 69 | <p class="text-secondary mt-2"> <?php esc_html_e('Activated when manual setups are made. Ideal for advanced NitroPack optimizations.', 'nitropack'); ?></p> |
| 70 | </div> |
| 71 | </div> |
| 72 | </div> |
| 73 | <div class="card-footer"> |
| 74 | <div class="flex flex-row"> |
| 75 | <p class=""><?php esc_html_e('Which optimization mode to choose?', 'nitropack'); ?></p> |
| 76 | <a class="text-primary btn-link ml-auto see-modes" data-modal-target="modes-modal" data-modal-toggle="modes-modal"><?php esc_html_e('See modes comparison', 'nitropack'); ?></a> |
| 77 | <?php require_once NITROPACK_PLUGIN_DIR . 'view/modals/modal-modes.php'; ?> |
| 78 | </div> |
| 79 | </div> |
| 80 | <?php require_once NITROPACK_PLUGIN_DIR . 'view/modals/modal-optimization-mode.php'; ?> |
| 81 | </div> |
| 82 | <!-- Optimization Mode Card End --> |
| 83 | <!-- Automated Behavior Card --> |
| 84 | <div class="card card-automated-behavior"> |
| 85 | <div class="card-header"> |
| 86 | <h3><?php esc_html_e('Automated Behavior', 'nitropack'); ?></h3> |
| 87 | </div> |
| 88 | <div class="card-body"> |
| 89 | <div class="options-container"> |
| 90 | <div class="nitro-option" id="purge-cache-widget"> |
| 91 | <div class="nitro-option-main"> |
| 92 | <div class="text-box"> |
| 93 | <h6><?php esc_html_e('Purge cache', 'nitropack'); ?></h6> |
| 94 | <p><?php esc_html_e('Purge affected cache when content is updated or published', 'nitropack'); ?></p> |
| 95 | </div> |
| 96 | <label class="inline-flex items-center cursor-pointer ml-auto"> |
| 97 | <input type="checkbox" value="" class="sr-only peer" name="purge_cache" id="auto-purge-status" <?php if ($autoCachePurge) echo "checked"; ?>> |
| 98 | <div class="toggle"></div> |
| 99 | </label> |
| 100 | </div> |
| 101 | </div> |
| 102 | <div class="nitro-option" id="page-optimization-widget"> |
| 103 | <div class="nitro-option-main"> |
| 104 | <div class="text-box"> |
| 105 | <h6><?php esc_html_e('Page optimization', 'nitropack'); ?></h6> |
| 106 | <p><?php esc_html_e('Select what post/page types get optimized', 'nitropack'); ?></p> |
| 107 | </div> |
| 108 | <a data-modal-target="modal-posttypes" data-modal-toggle="modal-posttypes" class="btn btn-secondary btn-icon"> |
| 109 | <img src="<?php echo plugin_dir_url(__FILE__); ?>images/setting-icon.svg"> |
| 110 | </a> |
| 111 | </div> |
| 112 | <?php require_once NITROPACK_PLUGIN_DIR . 'view/modals/modal-posttypes.php'; ?> |
| 113 | </div> |
| 114 | </div> |
| 115 | </div> |
| 116 | </div> |
| 117 | <!-- Automated Behavior Card End --> |
| 118 | <!-- Go to app Card --> |
| 119 | <div class="card exclusion-card"> |
| 120 | <div class="card-header"> |
| 121 | <h3><?php esc_html_e('Exclusions', 'nitropack'); ?></h3> |
| 122 | </div> |
| 123 | <div class="card-body"> |
| 124 | <div class="options-container"> |
| 125 | <div class="nitro-option" id="ajax-shortcodes-widget"> |
| 126 | <div class="nitro-option-main"> |
| 127 | <div class="text-box"> |
| 128 | <h6><?php esc_html_e('Shortcodes exclusions', 'nitropack'); ?></h6> |
| 129 | <p><?php esc_html_e('Load widgets, feeds, and any shortcode with AJAX to bypass the cache and always show the latest content.', 'nitropack'); ?></p> |
| 130 | </div> |
| 131 | <?php |
| 132 | global $shortcode_tags; |
| 133 | $nitropack = get_nitropack(); |
| 134 | $siteConfig = $nitropack->Config->get(); |
| 135 | $configKey = \NitroPack\WordPress\NitroPack::getConfigKey(); |
| 136 | |
| 137 | $ajax_shortcodes = $siteConfig[$configKey]['options_cache']['ajaxShortcodes']; |
| 138 | $ajax_shortcodes_enabled = $ajax_shortcodes['enabled']; |
| 139 | $shortcode_container_shown = $ajax_shortcodes_enabled ? '' : 'hidden'; |
| 140 | |
| 141 | ?> |
| 142 | <label class="inline-flex items-center cursor-pointer ml-auto"> |
| 143 | <input type="checkbox" value="" class="sr-only peer" name="ajax_shortcodes" id="ajax-shortcodes" <?php if ($ajax_shortcodes_enabled) echo "checked"; ?>> |
| 144 | <div class="toggle"></div> |
| 145 | </label> |
| 146 | </div> |
| 147 | <div class="ajax-shortcodes <?php echo $shortcode_container_shown; ?>"> |
| 148 | <div class="select-wrapper"> |
| 149 | <select class="" name="nitropack-ajaxShortcodes" id="ajax-shortcodes-dropdown" multiple> |
| 150 | <?php |
| 151 | if (isset($ajax_shortcodes['shortcodes'])) { |
| 152 | $ajax_shortcodes_list = $ajax_shortcodes['shortcodes']; |
| 153 | $freely_added_shortcodes = array_diff($ajax_shortcodes_list, array_keys($shortcode_tags)); |
| 154 | } |
| 155 | foreach ($shortcode_tags as $shortcode => $function) { |
| 156 | $disable = ''; |
| 157 | if ($ajax_shortcodes_list && in_array($shortcode, $ajax_shortcodes_list)) $disable = 'selected="selected"'; |
| 158 | echo '<option value="' . $shortcode . '" ' . $disable . '>' . $shortcode . '</option>'; |
| 159 | } |
| 160 | if ($freely_added_shortcodes) { |
| 161 | foreach ($freely_added_shortcodes as $shortcode) { |
| 162 | echo '<option value="' . $shortcode . '" selected="selected">' . $shortcode . '</option>'; |
| 163 | } |
| 164 | } |
| 165 | ?> |
| 166 | </select> |
| 167 | <button class="btn btn-primary" id="save-shortcodes"><?php esc_html_e('Save', 'nitropack'); ?></button> |
| 168 | </div> |
| 169 | </div> |
| 170 | </div> |
| 171 | </div> |
| 172 | </div> |
| 173 | </div> |
| 174 | <!-- Go to app card End --> |
| 175 | |
| 176 | |
| 177 | </div> |
| 178 | <div class="col-span-1"> |
| 179 | <!-- Subscription Card --> |
| 180 | <div class="card card-subscription"> |
| 181 | <div class="card-header"> |
| 182 | <h3><?php esc_html_e('Subscription', 'nitropack'); ?></h3> |
| 183 | </div> |
| 184 | <div class="card-body"> |
| 185 | <div class="flex flex-row items-center"> |
| 186 | <div class="plan-name"><?php esc_html_e('Free', 'nitropack'); ?></div> |
| 187 | <a type="button" target="_blank" href="https://app.nitropack.io/account/billing" class="btn btn-secondary ml-auto" id="btn-manage-subscription"><?php esc_html_e('Manage subscription', 'nitropack'); ?></a> |
| 188 | </div> |
| 189 | <div class="table-wrapper"> |
| 190 | <table class="w-full"> |
| 191 | <tbody> |
| 192 | <tr> |
| 193 | <td class="key"><?php esc_html_e('Next reset', 'nitropack'); ?></td> |
| 194 | <td class="value" data-next-reset><?php esc_html_e('No ETA', 'nitropack'); ?></td> |
| 195 | </tr> |
| 196 | <tr> |
| 197 | <td class="key"><?php esc_html_e('Next billing', 'nitropack'); ?></td> |
| 198 | <td class="value" data-next-billing><?php esc_html_e('No ETA', 'nitropack'); ?></td> |
| 199 | </tr> |
| 200 | <tr> |
| 201 | <td class="key"><?php esc_html_e('Page views', 'nitropack'); ?></td> |
| 202 | <td class="value" data-page-views><?php printf(esc_html__('%1$s out of %2$s', 'nitropack'), $page_views, $max_page_views); ?></td> |
| 203 | </tr> |
| 204 | <tr> |
| 205 | <td class="key"><?php esc_html_e('CDN bandwidth', 'nitropack'); ?></td> |
| 206 | <td class="value" data-cdn-bandwidth><?php printf(esc_html__('%1$s out of %2$s', 'nitropack'), $usage, $max_usage); ?></td> |
| 207 | </tr> |
| 208 | </tbody> |
| 209 | </table> |
| 210 | </div> |
| 211 | </div> |
| 212 | <div class="card-footer"> |
| 213 | <p class="text-secondary text-smaller"><?php esc_html_e('You will be notified by email when your website reaches the subscription resource limits.', 'nitropack'); ?></p> |
| 214 | </div> |
| 215 | </div> |
| 216 | <!-- Subscription Card End --> |
| 217 | <!-- Basic Settings Card --> |
| 218 | <div class="card card-basic-settings"> |
| 219 | <div class="card-header"> |
| 220 | <h3><?php esc_html_e('Basic Settings', 'nitropack'); ?></h3> |
| 221 | </div> |
| 222 | <div class="card-body"> |
| 223 | <div class="options-container"> |
| 224 | <div class="nitro-option" id="cache-warmup-widget"> |
| 225 | <div class="nitro-option-main"> |
| 226 | <div class="text-box" id="warmup-status-slider"> |
| 227 | |
| 228 | <?php $sitemap = get_option('np_warmup_sitemap', false); |
| 229 | $toolTipDisplayState = $sitemap ? '' : 'hidden'; ?> |
| 230 | |
| 231 | <h6><?php esc_html_e('Cache warmup', 'nitropack'); ?> <span class="badge badge-primary ml-2"><?php esc_html_e('Recommended', 'nitropack'); ?></span> <span class="tooltip-icon <?php echo $toolTipDisplayState; ?>" data-tooltip-target="tooltip-sitemap"> |
| 232 | <img src="<?php echo plugin_dir_url(__FILE__) . 'images/info.svg'; ?>"> |
| 233 | </span></h6> |
| 234 | <div id="tooltip-sitemap" role="tooltip" class="tooltip-container hidden"> |
| 235 | <?php echo $sitemap; ?> |
| 236 | <div class="tooltip-arrow" data-popper-arrow></div> |
| 237 | </div> |
| 238 | <p><?php esc_html_e('Automatically pre-caches your website\'s page content', 'nitropack'); ?>. <a href="https://support.nitropack.io/en/articles/8390320-cache-warmup" class="text-blue" target="_blank"><?php esc_html_e('Learn more', 'nitropack'); ?></a></p> |
| 239 | </div> |
| 240 | <label class="inline-flex items-center cursor-pointer ml-auto"> |
| 241 | <input id="warmup-status" type="checkbox" class="sr-only peer"> |
| 242 | <div class="toggle"></div> |
| 243 | </label> |
| 244 | </div> |
| 245 | <div class="msg-container" id="loading-warmup-status"> |
| 246 | <img src="<?php echo plugin_dir_url(__FILE__) . 'images/loading.svg'; ?>" alt="loading" class="icon"> <span class="msg"><?php esc_html_e('Loading cache warmup status', 'nitropack'); ?></span> |
| 247 | </div> |
| 248 | </div> |
| 249 | <div class="nitro-option" id="test-mode-widget"> |
| 250 | <div class="nitro-option-main"> |
| 251 | <div class="text-box" id="safemode-status-slider"> |
| 252 | <h6><?php esc_html_e('Test Mode', 'nitropack'); ?></h6> |
| 253 | <p><?php esc_html_e('Test NitroPack\'s features without affecting your visitors\' experience', 'nitropack'); ?>. <a href="https://support.nitropack.io/en/articles/8390292-test-mode" class="text-blue" target="_blank"><?php esc_html_e('Learn more', 'nitropack'); ?></a></p> |
| 254 | </div> |
| 255 | |
| 256 | <label class="inline-flex items-center cursor-pointer ml-auto"> |
| 257 | <input type="checkbox" class="sr-only peer" id="safemode-status"> |
| 258 | |
| 259 | <div class="toggle"></div> |
| 260 | </label> |
| 261 | </div> |
| 262 | <div class="msg-container" id="loading-safemode-status"> |
| 263 | <img src="<?php echo plugin_dir_url(__FILE__) . 'images/loading.svg'; ?>" alt="loading" class="icon"> <?php esc_html_e('Loading test mode status', 'nitropack'); ?> |
| 264 | </div> |
| 265 | <?php require_once NITROPACK_PLUGIN_DIR . 'view/modals/modal-test-mode.php'; ?> |
| 266 | </div> |
| 267 | <div class="nitro-option" id="compression-widget"> |
| 268 | <div class="nitro-option-main"> |
| 269 | <div class="text-box"> |
| 270 | <h6><span id="detected-compression"><?php esc_html_e('HTML Compression', 'nitropack'); ?> </span></h6> |
| 271 | <p><?php esc_html_e('Compressing the structure of your HTML, ensures faster page rendering and an optimized browsing experience for your users.', 'nitropack'); ?> <a href="https://support.nitropack.io/en/articles/8390333-nitropack-plugin-settings-in-wordpress#h_29b7ab4836" class="text-blue" target="_blank"><?php esc_html_e('Learn more', 'nitropack'); ?></a></p> |
| 272 | </div> |
| 273 | <label class="inline-flex items-center cursor-pointer ml-auto"> |
| 274 | <input type="checkbox" id="compression-status" class="sr-only peer" <?php echo (int)$enableCompression === 1 ? "checked" : ""; ?>> |
| 275 | <div class="toggle"></div> |
| 276 | </label> |
| 277 | </div> |
| 278 | <div class="mt-4 text-primary"> |
| 279 | <a href="javascript:void(0);" id="compression-test-btn" class="text-primary"><?php esc_html_e('Run compression test', 'nitropack'); ?></a> |
| 280 | <div class="flex items-start msg-container hidden"> |
| 281 | <span class="msg"></span> |
| 282 | </div> |
| 283 | </div> |
| 284 | </div> |
| 285 | <?php if (\NitroPack\Integration\Plugin\BeaverBuilder::isActive()) { ?> |
| 286 | <div class="nitro-option" id="beaver-builder-widget"> |
| 287 | <div class="nitro-option-main"> |
| 288 | <div class="text-box"> |
| 289 | <h6><span id="detected-compression"><?php esc_html_e('Sync NitroPack Purge with Beaver Builder', 'nitropack'); ?> </span></h6> |
| 290 | <p><?php esc_html_e('When Beaver Builder cache is purged, NitroPack will perform a full cache purge keeping your site\'s content up-to-date.', 'nitropack'); ?></p> |
| 291 | </div> |
| 292 | <label class="inline-flex items-center cursor-pointer ml-auto"> |
| 293 | <input type="checkbox" class="sr-only peer" id="bb-purge-status" <?php if ($bbCacheSyncPurge) echo "checked"; ?>> |
| 294 | <div class="toggle"></div> |
| 295 | </label> |
| 296 | </div> |
| 297 | </div> |
| 298 | <?php } ?> |
| 299 | |
| 300 | <?php if (nitropack_render_woocommerce_cart_cache_option()) { ?> |
| 301 | <div class="nitro-option" id="cart-cache-widget"> |
| 302 | <div class="nitro-option-main"> |
| 303 | <div class="text-box"> |
| 304 | <h6><?php esc_html_e('Cart cache', 'nitropack'); ?> <span class="badge badge-success ml-2">New</span></h6> |
| 305 | <p><?php esc_html_e('Your visitors will enjoy full site speed while browsing with items in cart. Fully optimized page cache will be served.', 'nitropack'); ?></p> |
| 306 | |
| 307 | </div> |
| 308 | <label class="inline-flex items-center cursor-pointer ml-auto"> |
| 309 | <input type="checkbox" id="cart-cache-status" class="sr-only peer" <?php if (nitropack_is_cart_cache_active()) echo "checked"; ?> <?php if (!nitropack_is_cart_cache_available()) echo "disabled"; ?>> |
| 310 | <div class="toggle"></div> |
| 311 | </label> |
| 312 | </div> |
| 313 | <?php if (!nitropack_is_cart_cache_available()) : ?> |
| 314 | <div class="msg-container bg-success paid-msg"> |
| 315 | <p><svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg" class="text-success"> |
| 316 | <g clip-path="url(#clip0_1244_36215)"> |
| 317 | <path d="M10.0001 18.3333C14.6025 18.3333 18.3334 14.6023 18.3334 9.99996C18.3334 5.39759 14.6025 1.66663 10.0001 1.66663C5.39771 1.66663 1.66675 5.39759 1.66675 9.99996C1.66675 14.6023 5.39771 18.3333 10.0001 18.3333Z" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path> |
| 318 | <path d="M13.3334 9.99996L10.0001 6.66663L6.66675 9.99996" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path> |
| 319 | <path d="M10 13.3333V6.66663" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path> |
| 320 | </g> |
| 321 | <defs> |
| 322 | <clipPath id="clip0_1244_36215"> |
| 323 | <rect width="20" height="20" fill="white"></rect> |
| 324 | </clipPath> |
| 325 | </defs> |
| 326 | </svg> <?php esc_html_e('This feature is available on paid subscription.', 'nitropack'); ?> <a href="https://app.nitropack.io/subscription/buy" class="text-primary" target="_blank"><b><?php esc_html_e('Upgrade here', 'nitropack'); ?></b></a> |
| 327 | </p> |
| 328 | </div> |
| 329 | <?php endif; ?> |
| 330 | </div> |
| 331 | <div class="nitro-option" id="real-time-stock-refresh-widget"> |
| 332 | <div class="nitro-option-main"> |
| 333 | <div class="text-box"> |
| 334 | <h6><?php esc_html_e('Real-time Stock Refresh', 'nitropack'); ?></h6> |
| 335 | <p><?php esc_html_e('Keep accurate product availability on your WooCommerce site. Turn on this feature if you display stock quantities, and enjoy automatic cache clearance when stock decreases.', 'nitropack'); ?></p> |
| 336 | |
| 337 | </div> |
| 338 | <label class="inline-flex items-center cursor-pointer ml-auto"> |
| 339 | <input type="checkbox" id="woo-stock-reduce-status" class="sr-only peer" <?php echo (int)$stockReduceStatus === 1 ? "checked" : ""; ?>> |
| 340 | <div class="toggle"></div> |
| 341 | </label> |
| 342 | </div> |
| 343 | </div> |
| 344 | <?php } ?> |
| 345 | </div> |
| 346 | </div> |
| 347 | <div class="card-footer disconnect-container"> |
| 348 | <a class="text-primary btn-link" id="disconnect-btn"><?php esc_html_e('Disconnect NitroPack plugin', 'nitropack'); ?></a> |
| 349 | <?php require_once NITROPACK_PLUGIN_DIR . 'view/modals/modal-disconnect.php'; ?> |
| 350 | </div> |
| 351 | </div> |
| 352 | <!-- Basic Settings Card End --> |
| 353 | <!-- Go to app Card --> |
| 354 | <div class="card app-card"> |
| 355 | <div class="card-body"> |
| 356 | <div class="flex items-center justify-between"> |
| 357 | <p><?php esc_html_e('You can further configure how NitroPack\'s optimization behaves through your account', 'nitropack'); ?>.</p> |
| 358 | <?php |
| 359 | function getNitropackDashboardUrl() { |
| 360 | $siteId = nitropack_get_current_site_id(); |
| 361 | $dashboardUrl = 'https://app.nitropack.io/dashboard'; |
| 362 | |
| 363 | if ($siteId !== null) { |
| 364 | $dashboardUrl .= '?update_session_website_id=' . urlencode($siteId); |
| 365 | } |
| 366 | |
| 367 | return $dashboardUrl; |
| 368 | } |
| 369 | ?> |
| 370 | <a href="<?php echo esc_url(getNitropackDashboardUrl()); ?>" target="_blank" class="btn btn-primary ml-2 flex-shrink-0"><?php esc_html_e('Go to app', 'nitropack'); ?></a> |
| 371 | </div> |
| 372 | </div> |
| 373 | </div> |
| 374 | <!-- Go to app card End --> |
| 375 | </div> |
| 376 | <?php $notOptimizedCPTs = nitropack_filter_non_optimized(); |
| 377 | if (!get_option('nitropack-noticeOptimizeCPT') && !empty($notOptimizedCPTs)) require_once NITROPACK_PLUGIN_DIR . 'view/modals/modal-not-optimized-CPT.php'; ?> |
| 378 | </div> |
| 379 | <?php require_once NITROPACK_PLUGIN_DIR . 'view/modals/modal-unsaved-changes.php'; ?> |
| 380 | <script> |
| 381 | ($ => { |
| 382 | var getOptimizationsTimeout = null; |
| 383 | let isClearing = false; |
| 384 | var paid_plan = false; |
| 385 | $(window).on("load", function() { |
| 386 | getOptimizations(); |
| 387 | getPlan(); |
| 388 | <?php if ($checkedCompression != 1) { ?> |
| 389 | autoDetectCompression(); |
| 390 | <?php } ?> |
| 391 | }); |
| 392 | |
| 393 | /* Cache Purge begin */ |
| 394 | window.performCachePurge = () => { |
| 395 | purgeCache(); |
| 396 | } |
| 397 | |
| 398 | let purgeCache = () => { |
| 399 | let purgeEvent = new Event("cache.purge.request"); |
| 400 | window.dispatchEvent(purgeEvent); |
| 401 | } |
| 402 | |
| 403 | var getOptimizations = _ => { |
| 404 | var url = '<?php echo $optimizationDetailsUrl; ?>'; |
| 405 | ((s, e, f) => { |
| 406 | if (window.fetch) { |
| 407 | fetch(url) |
| 408 | .then(resp => resp.json()) |
| 409 | .then(s) |
| 410 | .catch(e) |
| 411 | .finally(f); |
| 412 | } else { |
| 413 | $.ajax({ |
| 414 | url: url, |
| 415 | type: 'GET', |
| 416 | dataType: 'json', |
| 417 | success: s, |
| 418 | error: e, |
| 419 | complete: f |
| 420 | }) |
| 421 | } |
| 422 | })(data => { |
| 423 | $('[data-last-cache-purge]').text(data.last_cache_purge.timeAgo); |
| 424 | if (data.last_cache_purge.reason) { |
| 425 | $('[data-purge-reason]').text(data.last_cache_purge.reason); |
| 426 | $('[data-purge-reason]').attr('title', data.last_cache_purge.reason); |
| 427 | $('#last-cache-purge-reason').show(); |
| 428 | } else { |
| 429 | $('#last-cache-purge-reason').hide(); |
| 430 | } |
| 431 | if (data.pending_count) { |
| 432 | $("#pending-optimizations-count").text(data.pending_count); |
| 433 | $("#pending-optimizations-section").show(); |
| 434 | } else { |
| 435 | $("#pending-optimizations-section").hide(); |
| 436 | } |
| 437 | |
| 438 | $('[data-optimized-pages-total]').text(data.optimized_pages.total); |
| 439 | |
| 440 | }, __ => { |
| 441 | console.error("An error occurred while fetching data for optimized pages"); |
| 442 | }, __ => { |
| 443 | if (!getOptimizationsTimeout) { |
| 444 | getOptimizationsTimeout = setTimeout(function() { |
| 445 | getOptimizationsTimeout = null; |
| 446 | getOptimizations(); |
| 447 | }, 60000); |
| 448 | } |
| 449 | }); |
| 450 | } |
| 451 | |
| 452 | var getPlan = _ => { |
| 453 | |
| 454 | var url = '<?php echo $planDetailsUrl; ?>'; |
| 455 | ((s, e, f) => { |
| 456 | if (window.fetch) { |
| 457 | fetch(url) |
| 458 | .then(resp => resp.json()) |
| 459 | .then(s) |
| 460 | .catch(e) |
| 461 | .finally(f); |
| 462 | } else { |
| 463 | $.ajax({ |
| 464 | url: url, |
| 465 | type: 'GET', |
| 466 | dataType: 'json', |
| 467 | success: s, |
| 468 | error: e, |
| 469 | complete: f |
| 470 | }) |
| 471 | } |
| 472 | })(data => { |
| 473 | |
| 474 | $('.plan-name').text(data.plan_title); |
| 475 | $('[data-next-billing]').text(data.next_billing ? data.next_billing : 'N/A'); |
| 476 | $('[data-next-reset]').text(data.next_reset ? data.next_reset : 'N/A'); |
| 477 | $('[data-page-views]').text(data.page_views ? data.page_views : 'N/A'); |
| 478 | $('[data-cdn-bandwidth]').text(data.cdn_bandwidth ? data.cdn_bandwidth + ' out of ' + data.max_cdn_bandwidth : 'N/A'); |
| 479 | |
| 480 | for (prop in data) { |
| 481 | if (prop.indexOf("show_") === 0) continue; |
| 482 | if (prop.indexOf("label_") === 0) continue; |
| 483 | if (prop.indexOf("max_") === 0) continue; |
| 484 | if ( |
| 485 | typeof data["show_" + prop] != "undefined" && |
| 486 | data["show_" + prop] && |
| 487 | typeof data["label_" + prop] != "undefined" && |
| 488 | typeof data["max_" + prop] != "undefined" |
| 489 | ) { |
| 490 | let propertyLabel = data["label_" + prop]; |
| 491 | let propertyValue = data[prop]; |
| 492 | let propertyLimit = data["max_" + prop]; |
| 493 | $("#plan-quotas").append('<li class="list-group-item px-0 d-flex justify-content-between align-items-center">' + propertyLabel + ' <span><span data-optimizations>' + propertyValue + '</span> out of <span data-max-optimizations>' + propertyLimit + '</span></span></li>'); |
| 494 | } |
| 495 | } |
| 496 | |
| 497 | }, __ => { |
| 498 | NitropackUI.triggerToast('error', '<?php esc_html_e('Error while fetching plan data', 'nitropack'); ?>'); |
| 499 | }, __ => {}); |
| 500 | } |
| 501 | |
| 502 | |
| 503 | $(document).on('click', "#compression-test-btn", e => { |
| 504 | e.preventDefault(); |
| 505 | autoDetectCompression(); |
| 506 | }); |
| 507 | /* Compression end */ |
| 508 | |
| 509 | /* HTML Compression begin */ |
| 510 | var autoDetectCompression = function() { |
| 511 | let msg_container = $('#compression-widget .msg-container'), |
| 512 | msg_icon = msg_container.find('.icon'), |
| 513 | msg_box = msg_container.find('.msg'), |
| 514 | compression_setting = $('#compression-status'), |
| 515 | compression_btn = $('#compression-test-btn'); |
| 516 | //add spinner here |
| 517 | msg_box.html('<img src="<?php echo plugin_dir_url(__FILE__) . 'images/loading.svg'; ?>" alt="loading" class="icon"> <?php esc_html_e('Testing current compression status', 'nitropack'); ?>'); |
| 518 | compression_btn.addClass('hidden'); |
| 519 | msg_container.removeClass('hidden'); |
| 520 | $.post(ajaxurl, { |
| 521 | action: 'nitropack_test_compression_ajax', |
| 522 | nonce: nitroNonce |
| 523 | }, function(response) { |
| 524 | var resp = JSON.parse(response); |
| 525 | |
| 526 | if (resp.status == "success") { |
| 527 | if (resp.hasCompression) { // compression already enabled |
| 528 | compression_setting.attr("checked", false); |
| 529 | |
| 530 | msg_box.text('<?php esc_html_e('Compression is already enabled on your server! There is no need to enable it in NitroPack.', 'nitropack'); ?>') |
| 531 | } else { |
| 532 | compression_setting.attr("checked", true); |
| 533 | msg_box.text('<?php esc_html_e('No compression was detected! We will now enable it in NitroPack.', 'nitropack'); ?>'); |
| 534 | } |
| 535 | NitropackUI.triggerToast(resp.type, resp.message); |
| 536 | } else { |
| 537 | msg_box.text('<?php esc_html_e('Could not determine compression status automatically. Please configure it manually.', 'nitropack'); ?>'); |
| 538 | } |
| 539 | setTimeout(function() { |
| 540 | msg_container.addClass('hidden'); |
| 541 | compression_btn.removeClass('hidden'); |
| 542 | }, 5000); |
| 543 | }); |
| 544 | } |
| 545 | |
| 546 | |
| 547 | $("#compression-status").on("click", function(e) { |
| 548 | $.post(ajaxurl, { |
| 549 | action: 'nitropack_set_compression_ajax', |
| 550 | nonce: nitroNonce, |
| 551 | data: { |
| 552 | compressionStatus: $(this).is(":checked") ? 1 : 0 |
| 553 | } |
| 554 | }, function(response) { |
| 555 | var resp = JSON.parse(response); |
| 556 | NitropackUI.triggerToast(resp.type, resp.message); |
| 557 | }); |
| 558 | }); |
| 559 | |
| 560 | $("#auto-purge-status").on("click", function(e) { |
| 561 | $.post(ajaxurl, { |
| 562 | action: 'nitropack_set_auto_cache_purge_ajax', |
| 563 | nonce: nitroNonce, |
| 564 | autoCachePurgeStatus: $(this).is(":checked") ? 1 : 0 |
| 565 | }, function(response) { |
| 566 | var resp = JSON.parse(response); |
| 567 | NitropackUI.triggerToast(resp.type, resp.message); |
| 568 | }); |
| 569 | }); |
| 570 | |
| 571 | $("#cart-cache-status").on("click", function(e) { |
| 572 | $.post(ajaxurl, { |
| 573 | action: 'nitropack_set_cart_cache_ajax', |
| 574 | nonce: nitroNonce, |
| 575 | cartCacheStatus: $(this).is(":checked") ? 1 : 0 |
| 576 | }, function(response) { |
| 577 | var resp = JSON.parse(response); |
| 578 | NitropackUI.triggerToast(resp.type, resp.message); |
| 579 | }); |
| 580 | }); |
| 581 | |
| 582 | |
| 583 | $("#woo-stock-reduce-status").on("click", function(e) { |
| 584 | $.post(ajaxurl, { |
| 585 | action: 'nitropack_set_stock_reduce_status', |
| 586 | nonce: nitroNonce, |
| 587 | data: { |
| 588 | stockReduceStatus: $(this).is(":checked") ? 1 : 0 |
| 589 | } |
| 590 | }, function(response) { |
| 591 | var resp = JSON.parse(response); |
| 592 | NitropackUI.triggerToast(resp.type, resp.message); |
| 593 | }); |
| 594 | }); |
| 595 | |
| 596 | $("#legacy-purge-status").on("click", function(e) { |
| 597 | $.post(ajaxurl, { |
| 598 | action: 'nitropack_set_legacy_purge_ajax', |
| 599 | nonce: nitroNonce, |
| 600 | legacyPurgeStatus: $(this).is(":checked") ? 1 : 0 |
| 601 | }, function(response) { |
| 602 | var resp = JSON.parse(response); |
| 603 | NitropackUI.triggerToast(resp.type, resp.message); |
| 604 | |
| 605 | }); |
| 606 | }); |
| 607 | |
| 608 | $("#bb-purge-status").on("click", function(e) { |
| 609 | $.post(ajaxurl, { |
| 610 | action: 'nitropack_set_bb_cache_purge_sync_ajax', |
| 611 | nonce: nitroNonce, |
| 612 | bbCachePurgeSyncStatus: $(this).is(":checked") ? 1 : 0 |
| 613 | }, function(response) { |
| 614 | var resp = JSON.parse(response); |
| 615 | NitropackUI.triggerToast(resp.type, resp.message); |
| 616 | }); |
| 617 | }); |
| 618 | |
| 619 | |
| 620 | })(jQuery); |
| 621 | </script> |