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