vivio-swift-cache-menu.php 23.2 KB
Newer Older
Jordan Michaels's avatar
Jordan Michaels committed
1 2 3 4 5 6 7 8 9 10
<?php

class Vivio_Swift_Cache_Menu extends Vivio_Swift_Admin_Messages
{
    var $cache_menu_page_slug = VIVIO_SWIFT_CACHE_MENU_SLUG;

    var $menu_tabs;

    var $menu_tabs_handler = array(
        'tab1' => 'render_tab1',
Jordan Michaels's avatar
Jordan Michaels committed
11 12 13
        'tab2' => 'render_tab2',
        'tab3' => 'render_tab3',
        'tab4' => 'render_tab4'
Jordan Michaels's avatar
Jordan Michaels committed
14 15 16 17 18 19 20 21 22 23
    );

    function __construct()
    {
        $this->render_menu_page();
    }

    function set_menu_tabs()
    {
        $this->menu_tabs = array(
Jordan Michaels's avatar
Jordan Michaels committed
24 25 26 27
            'tab1' => __('On-Access Cache', 'vivio-swift'),
            'tab2' => __('Preload Cache', 'vivio-swift'),
            'tab3' => __('Refresh Events', 'vivio-swift'),
            'tab4' => __('Extras', 'vivio-swift')
Jordan Michaels's avatar
Jordan Michaels committed
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
        );
    }

    function get_current_tab()
    {
        $tab_keys = array_keys($this->menu_tabs);
        $tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : $tab_keys[0];
        return $tab;
    }

    /*
     * Renders our tabs of this menu as nav items
     */
    function render_menu_tabs()
    {
        $current_tab = $this->get_current_tab();

        echo '<h2 class="nav-tab-wrapper">';
        foreach ($this->menu_tabs as $tab_key => $tab_caption) {
            $active = $current_tab == $tab_key ? 'nav-tab-active' : '';
            echo '<a class="nav-tab ' . $active . '" href="?page=' . $this->cache_menu_page_slug . '&tab=' . $tab_key . '">' . $tab_caption . '</a>';
        }
        echo '</h2>';
    }

    /*
     * The menu rendering goes here
     */
    function render_menu_page()
    {
        echo '<div class="wrap">';
        echo '<h2>' . __('Vivio Swift Cache', 'vivio-swift') . '</h2>';//Interface title
        $this->set_menu_tabs();
        $tab = $this->get_current_tab();
        $this->render_menu_tabs();
        ?>        
        <div id="poststuff"><div id="post-body">
        <?php
        //$tab_keys = array_keys($this->menu_tabs);
        call_user_func(array(&$this, $this->menu_tabs_handler[$tab]));
        ?>
        </div></div>
        </div><!-- end of wrap -->
        <?php
    }

    function render_tab1()
    {
        global $vivio_swift_global;
Jordan Michaels's avatar
Jordan Michaels committed
77 78
    
        echo '<div class="message_standard">';
79
        echo '<p>' . __('On-Access Cache creates a cache whenever a cachable PHP page is accessed. It is recommended to keep this on unless there is a conflict with another plugin.', 'vivio-swift') . '</p>';
Jordan Michaels's avatar
Jordan Michaels committed
80
        echo '</div>';
Jordan Michaels's avatar
Jordan Michaels committed
81 82 83 84 85 86 87 88

        // process cache settings
        if (isset($_POST['vivio_swift_save_cache_settings']))
        {
            $error = '';

            // verify nonce
            $nonce = $_REQUEST['_wpnonce'];
Jordan Michaels's avatar
Jordan Michaels committed
89
            if (!wp_verify_nonce($nonce, 'vivio_swift_simple_settings_nonce')) {
Jordan Michaels's avatar
Jordan Michaels committed
90 91 92 93
                $vivio_swift_global->debug_logger->log_debug("Nonce check failed on cache settings.", 4);
                wp_die("Error: Nonce check failed on cache settings.");
            }

Jordan Michaels's avatar
Jordan Michaels committed
94 95 96 97 98
            if($error)
            {
                $this->show_msg_error(__('Attention!','vivio-swift').$error);
            }

Jordan Michaels's avatar
Jordan Michaels committed
99 100 101 102 103 104 105
            // set and save settings
            if (isset($_POST["vivio_swift_cache_enabled"])){
                Vivio_Swift_Cache_OnAccess::enable();
            } else {
                Vivio_Swift_Cache_OnAccess::disable();
            }

Jordan Michaels's avatar
Jordan Michaels committed
106 107
            
            $this->show_msg_settings_updated();
Jordan Michaels's avatar
Jordan Michaels committed
108 109
        }

Jordan Michaels's avatar
Jordan Michaels committed
110 111 112 113 114 115
        if (isset($_POST['vivio_swift_cache_clear_submit']))
        {
            Vivio_Swift_Cache_OnAccess::clear();
            $this->show_msg_settings_updated();
        }

Jordan Michaels's avatar
Jordan Michaels committed
116 117 118 119 120
        ?>
        <div id="vivio-swift-container">

            <div class="postbox">
                <h3 class="hndle">
Jordan Michaels's avatar
Jordan Michaels committed
121
                    <label for="title"><?php _e('On-Access Cache', 'vivio-swift');?></label>
Jordan Michaels's avatar
Jordan Michaels committed
122 123 124
                </h3>

                <div class="inside">
Jordan Michaels's avatar
Jordan Michaels committed
125 126 127
                    <form action=""
                        id="vivio_swift_cache_simple_settings"
                        method="POST">
Jordan Michaels's avatar
Jordan Michaels committed
128
                        <?php wp_nonce_field('vivio_swift_simple_settings_nonce'); ?>
Jordan Michaels's avatar
Jordan Michaels committed
129 130
                        <table class="form-table">
                            <tr valign="top">
Jordan Michaels's avatar
Jordan Michaels committed
131
                                <th scope="row"><?php _e('Enable On-Access Cache', 'vivio-swift')?>:</th>
Jordan Michaels's avatar
Jordan Michaels committed
132
                                <td>
Jordan Michaels's avatar
Jordan Michaels committed
133 134 135 136
                                    <label class="switch">
                                        <input name="vivio_swift_cache_enabled" type="checkbox"<?php if($vivio_swift_global->configs->get_value('vivio_swift_cache_enabled')=='1') echo ' checked="checked"'; ?> value="1"/>
                                        <span class="slider round"></span>
                                    </label>
Jordan Michaels's avatar
Jordan Michaels committed
137
                                <span class="description"><?php _e('(Recommended: ON) Enable on-access caching using Vivio Swift.', 'vivio-swift'); ?></span>
Jordan Michaels's avatar
Jordan Michaels committed
138 139 140
                                </td>
                            </tr>
                        </table>
Jordan Michaels's avatar
Jordan Michaels committed
141
                        <input type="submit" name="vivio_swift_save_cache_settings" value="<?php _e('Save Settings', 'vivio-swift')?>" class="pure-button" />
Jordan Michaels's avatar
Jordan Michaels committed
142 143 144
                    </form>
                </div>
            </div>
Jordan Michaels's avatar
Jordan Michaels committed
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168

            <div class="postbox">
                <h3 class="hndle">
                    <label for="title"><?php _e('Clear Cache', 'vivio-swift');?></label>
                </h3>

                <div class="inside">
                    <form action=""
                        id="vivio_swift_cache_clear"
                        method="POST">
                        <?php wp_nonce_field('vivio_swift_cache_clear_nonce'); ?>
                        <table class="form-table">
                            <tr valign="top">
                                <th scope="row"><?php _e('Current Cache', 'vivio-swift')?>:</th>
                                <td>
                                <span class="description"><?php echo Vivio_Swift_Utility_File::get_file_count().' Files ('.Vivio_Swift_Utility_File::get_directory_size().')'; ?></span>
                                </td>
                            </tr>
                        </table>
                        <input type="submit" name="vivio_swift_cache_clear_submit" value="<?php _e('Clear Cache', 'vivio-swift')?>" class="pure-button button-error" />
                    </form>
                </div>
            </div>
        </div>
Jordan Michaels's avatar
Jordan Michaels committed
169 170 171 172 173 174
        <?php
    }

    function render_tab2()
    {
        global $vivio_swift_global;
Jordan Michaels's avatar
Jordan Michaels committed
175 176
    
        echo '<div class="message_standard">';
177
        echo '<p>' . __('Preload cache will cache your entire site and refresh that cache when it expires. It is recommended that you run both On-Access and Preload Cache together.', 'vivio-swift') . '</p>';
Jordan Michaels's avatar
Jordan Michaels committed
178
        echo '</div>';
Jordan Michaels's avatar
Jordan Michaels committed
179

Jordan Michaels's avatar
Jordan Michaels committed
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201
        if (isset($_POST['vivio_swift_cache_clear_submit']))
        {
            Vivio_Swift_Cache_Preload::clear();
            $this->show_msg_settings_updated();
        }

        $cache_expires_in_txt = '';
        $preload_cache_enabled = $vivio_swift_global->configs->get_value('vivio_swift_preload_cache_enabled');
        $preload_last_run_date = $vivio_swift_global->configs->get_value('vivio_swift_preload_last_run_date');
        $preload_last_run_datetime = new DateTime( $vivio_swift_global->configs->get_value('vivio_swift_preload_last_run_date') );

        // if preload is enabled, calc the expiration date
        if (($preload_cache_enabled=='1') && ($preload_last_run_date!='')){
            $cache_expires_in_txt = Vivio_Swift_Utility_Date::format_interval($preload_last_run_datetime);
        } else {
            $cache_expires_in_txt = "No Preload Cache on record.";
        }

        if (
            isset($_POST['vivio_swift_save_preload_cache_settings']) ||
            isset($_POST['vivio_swift_preload_force_refresh'])
           )
Jordan Michaels's avatar
Jordan Michaels committed
202 203 204 205 206
        {
            $error = '';

            // verify nonce
            $nonce = $_REQUEST['_wpnonce'];
Jordan Michaels's avatar
Jordan Michaels committed
207 208 209 210 211 212 213 214
            if (!wp_verify_nonce($nonce, 'vivio_swift_preload_cache_nonce')) {
                $vivio_swift_global->debug_logger->log_debug("Nonce check failed in preload settings.", 4);
                wp_die("Error: Nonce check failed in preload settings.");
            }

            if (isset($_POST['vivio_swift_preload_force_refresh'])){
                // force a preload cache refresh
                $vivio_swift_global->cache_obj->cache_preload->create_preload_cache(1);
Jordan Michaels's avatar
Jordan Michaels committed
215
            }
Jordan Michaels's avatar
Jordan Michaels committed
216

Jordan Michaels's avatar
Jordan Michaels committed
217 218
            $vivio_swift_preload_cache_expire_hours_val = sanitize_text_field($_POST['vivio_swift_preload_cache_expire_hours']);
            if(!is_numeric($vivio_swift_preload_cache_expire_hours_val))
Jordan Michaels's avatar
Jordan Michaels committed
219 220
            {
                $error .= '<br />'.__('You entered a non numeric value for the cache expires field. It has been set to the default value.','vivio-swift');
Jordan Michaels's avatar
Jordan Michaels committed
221 222
                $vivio_swift_preload_cache_expire_hours_val = '1';//Set it to the default value for this field
            } elseif ($vivio_swift_preload_cache_expire_hours_val < 1)
Jordan Michaels's avatar
Jordan Michaels committed
223
            {
Jordan Michaels's avatar
Jordan Michaels committed
224 225
                $error .= '<br />'.__('The Cache Expires field cannot have a value of less than 1. It has been set to the default value.','vivio-swift');
                $vivio_swift_preload_cache_expire_hours_val = '1';//Set it to the default value for this field
Jordan Michaels's avatar
Jordan Michaels committed
226 227 228 229 230 231 232
            }

            if($error)
            {
                $this->show_msg_error(__('Attention!','vivio-swift').$error);
            }

Jordan Michaels's avatar
Jordan Michaels committed
233 234 235 236 237 238 239 240
            // set and save settings
            if (isset($_POST["vivio_swift_preload_cache_enabled"])){
                Vivio_Swift_Cache_Preload::enable();
            } else {
                Vivio_Swift_Cache_Preload::disable();
            }

            $vivio_swift_global->configs->set_value('vivio_swift_preload_cache_expire_hours',absint($vivio_swift_preload_cache_expire_hours_val));
Jordan Michaels's avatar
Jordan Michaels committed
241 242 243 244 245 246 247 248 249
            $vivio_swift_global->configs->save_config();

            $this->show_msg_settings_updated();
        }

        ?>
        <div id="vivio-swift-container">

            <form action=""
Jordan Michaels's avatar
Jordan Michaels committed
250
                id="vivio_swift_cache_preload_settings"
Jordan Michaels's avatar
Jordan Michaels committed
251
                method="POST">
Jordan Michaels's avatar
Jordan Michaels committed
252
                <?php wp_nonce_field('vivio_swift_preload_cache_nonce'); ?>
Jordan Michaels's avatar
Jordan Michaels committed
253 254 255 256 257

                <div class="postbox">
                    <h3 class="hndle">
                        <label for="title"><?php _e('Preload Cache', 'vivio-swift');?></label>
                    </h3>
Jordan Michaels's avatar
Jordan Michaels committed
258
                    <div class="inside">
Jordan Michaels's avatar
Jordan Michaels committed
259 260 261 262 263 264 265 266 267 268
                        <table class="form-table">
                            <tr valign="top">
                                <th scope="row"><?php _e('Enable Preload Cache', 'vivio-swift')?>:</th>                
                                <td>
                                    <label class="switch">
                                        <input name="vivio_swift_preload_cache_enabled"
                                            id="vivio_swift_preload_cache_enabled"
                                            type="checkbox"<?php if($vivio_swift_global->configs->get_value('vivio_swift_preload_cache_enabled')=='1') echo ' checked="checked"'; ?> value="1"/>
                                        <span class="slider round"></span>
                                    </label>
Jordan Michaels's avatar
Jordan Michaels committed
269
                                <span class="description"><?php _e("(Recommended: ON) Enable a process that will cache your site at regular intervals (based on when they're set to expire).", 'vivio-swift'); ?></span>
Jordan Michaels's avatar
Jordan Michaels committed
270 271 272
                                </td>
                            </tr>
                            <tr valign="top">
Jordan Michaels's avatar
Jordan Michaels committed
273
                                <th scope="row"><?php _e('Cache Valid Hours', 'vivio-swift')?>:</th>                
Jordan Michaels's avatar
Jordan Michaels committed
274 275
                                <td>
                                <input type="text" size="6"
Jordan Michaels's avatar
Jordan Michaels committed
276 277 278
                                    id="vivio_swift_preload_cache_expire_hours"
                                    name="vivio_swift_preload_cache_expire_hours"
                                    value="<?php echo $vivio_swift_global->configs->get_value('vivio_swift_preload_cache_expire_hours'); ?>"
Jordan Michaels's avatar
Jordan Michaels committed
279
                                    />
Jordan Michaels's avatar
Jordan Michaels committed
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295
                                <span class="description"><?php _e('(Recommended: 1) Number of hours that the Preload Cache will remain valid.', 'vivio-swift'); ?></span>
                                </td>
                            </tr>
                            <tr valign="top">
                                <th scope="row"><?php _e('Current Preload Cache Age', 'vivio-swift')?>:</th>                
                                <td>
                                <span class="description"><?php echo $cache_expires_in_txt; //echo ' ('.$preload_last_run_date.')' ?></span>
                                </td>
                            </tr>
                            <tr valign="top">
                                <th scope="row"><?php _e('Force Refresh', 'vivio-swift')?>:</th>                
                                <td>
                                    <label>
                                        <input type="submit" name="vivio_swift_preload_force_refresh" value="<?php _e('Force Refresh', 'vivio-swift')?>" class="pure-button button-small" />
                                    </label>
                                <span class="description"><?php _e('Force a refresh of the preload cache.', 'vivio-swift'); ?></span>
Jordan Michaels's avatar
Jordan Michaels committed
296 297 298
                                </td>
                            </tr>
                        </table>
Jordan Michaels's avatar
Jordan Michaels committed
299
                        <input type="submit" id="vivio_swift_save_preload_cache_settings" name="vivio_swift_save_preload_cache_settings" value="<?php _e('Save Settings', 'vivio-swift')?>" class="pure-button" />
Jordan Michaels's avatar
Jordan Michaels committed
300 301 302 303 304
                    </div>
                </div>

                <div class="postbox">
                    <h3 class="hndle">
Jordan Michaels's avatar
Jordan Michaels committed
305
                        <label for="title"><?php _e('Clear Cache', 'vivio-swift');?></label>
Jordan Michaels's avatar
Jordan Michaels committed
306
                    </h3>
Jordan Michaels's avatar
Jordan Michaels committed
307 308

                    <div class="inside">
Jordan Michaels's avatar
Jordan Michaels committed
309 310
                        <table class="form-table">
                            <tr valign="top">
Jordan Michaels's avatar
Jordan Michaels committed
311
                                <th scope="row"><?php _e('Current Cache', 'vivio-swift')?>:</th>
Jordan Michaels's avatar
Jordan Michaels committed
312
                                <td>
Jordan Michaels's avatar
Jordan Michaels committed
313
                                <span class="description"><?php echo Vivio_Swift_Utility_File::get_file_count().' Files ('.Vivio_Swift_Utility_File::get_directory_size().')'; ?></span>
Jordan Michaels's avatar
Jordan Michaels committed
314 315 316
                                </td>
                            </tr>
                        </table>
Jordan Michaels's avatar
Jordan Michaels committed
317
                        <input type="submit" name="vivio_swift_cache_clear_submit" value="<?php _e('Clear Cache', 'vivio-swift')?>" class="pure-button button-error" />
Jordan Michaels's avatar
Jordan Michaels committed
318 319 320 321 322
                    </div>
                </div>
            </form>
        </div><!-- End of Extra Settings -->
        <?php
Jordan Michaels's avatar
Jordan Michaels committed
323
    }
Jordan Michaels's avatar
Jordan Michaels committed
324

Jordan Michaels's avatar
Jordan Michaels committed
325 326 327
    function render_tab3()
    {
        global $vivio_swift_global;
Jordan Michaels's avatar
Jordan Michaels committed
328 329
    
        echo '<div class="message_standard">';
330
        echo '<p>' . __('Refresh events clear your existing cache when they occur. If you have pre-load cache enabled, these events will also refresh your preload cache.', 'vivio-swift') . '</p>';
Jordan Michaels's avatar
Jordan Michaels committed
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351
        echo '</div>';

        if (isset($_POST['vivio_swift_refresh_events_submit']))
        {
            $error = '';

            // verify nonce
            $nonce = $_REQUEST['_wpnonce'];
            if (!wp_verify_nonce($nonce, 'vivio_swift_refresh_events_nonce')) {
                $vivio_swift_global->debug_logger->log_debug("Nonce check failed in refresh events.", 4);
                wp_die("Error: Nonce check failed in refresh events.");
            }

            if($error)
            {
                $this->show_msg_error(__('Attention!','vivio-swift').$error);
            }

            // set and save submitted settings
            $vivio_swift_global->configs->set_value('vivio_swift_refresh_on_post_new',isset($_POST["vivio_swift_refresh_on_post_new_enabled"])?'1':'');
            $vivio_swift_global->configs->set_value('vivio_swift_refresh_on_post_update',isset($_POST["vivio_swift_refresh_on_post_update_enabled"])?'1':'');
352 353
            $vivio_swift_global->configs->set_value('vivio_swift_refresh_on_category_change',isset($_POST["vivio_swift_refresh_on_category_change_enabled"])?'1':'');
            $vivio_swift_global->configs->set_value('vivio_swift_refresh_on_tag_change',isset($_POST["vivio_swift_refresh_on_tag_change_enabled"])?'1':'');
Jordan Michaels's avatar
Jordan Michaels committed
354 355 356 357 358
            $vivio_swift_global->configs->save_config();

            $this->show_msg_settings_updated();
        }

Jordan Michaels's avatar
Jordan Michaels committed
359

Jordan Michaels's avatar
Jordan Michaels committed
360 361
        ?>
        <div id="vivio-swift-container">
Jordan Michaels's avatar
Jordan Michaels committed
362

Jordan Michaels's avatar
Jordan Michaels committed
363 364
            <div class="postbox">
                <h3 class="hndle">
Jordan Michaels's avatar
Jordan Michaels committed
365
                    <label for="title"><?php _e('Refresh Events', 'vivio-swift');?></label>
Jordan Michaels's avatar
Jordan Michaels committed
366 367 368
                </h3>

                <div class="inside">
Jordan Michaels's avatar
Jordan Michaels committed
369 370 371 372 373 374 375 376 377 378 379 380
                    <form action=""
                        id="vivio_swift_refresh_events_settings"
                        method="POST">
                        <?php wp_nonce_field('vivio_swift_refresh_events_nonce'); ?>
                        <table class="form-table">
                            <tr valign="top">
                                <th scope="row"><?php _e('Refresh on New Post', 'vivio-swift')?>:</th>
                                <td>
                                    <label class="switch">
                                        <input name="vivio_swift_refresh_on_post_new_enabled" type="checkbox"<?php if($vivio_swift_global->configs->get_value('vivio_swift_refresh_on_post_new')=='1') echo ' checked="checked"'; ?> value="1"/>
                                        <span class="slider round"></span>
                                    </label>
381
                                <span class="description"><?php _e('(Recommended: ON) Clear cache whenever a new post or page is made.', 'vivio-swift'); ?></span>
Jordan Michaels's avatar
Jordan Michaels committed
382 383 384 385 386 387 388 389 390
                                </td>
                            </tr>
                            <tr valign="top">
                                <th scope="row"><?php _e('Refresh on Post Update', 'vivio-swift')?>:</th>
                                <td>
                                    <label class="switch">
                                        <input name="vivio_swift_refresh_on_post_update_enabled" type="checkbox"<?php if($vivio_swift_global->configs->get_value('vivio_swift_refresh_on_post_update')=='1') echo ' checked="checked"'; ?> value="1"/>
                                        <span class="slider round"></span>
                                    </label>
391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411
                                <span class="description"><?php _e('(Recommended: ON) Clear cache whenever a post or page is updated.', 'vivio-swift'); ?></span>
                                </td>
                            </tr>
                            <tr valign="top">
                                <th scope="row"><?php _e('Refresh on Cetegory Change', 'vivio-swift')?>:</th>
                                <td>
                                    <label class="switch">
                                        <input name="vivio_swift_refresh_on_category_change_enabled" type="checkbox"<?php if($vivio_swift_global->configs->get_value('vivio_swift_refresh_on_category_change')=='1') echo ' checked="checked"'; ?> value="1"/>
                                        <span class="slider round"></span>
                                    </label>
                                <span class="description"><?php _e('(Recommended: ON) Clear cache whenever a category is added, updated, or removed.', 'vivio-swift'); ?></span>
                                </td>
                            </tr>
                            <tr valign="top">
                                <th scope="row"><?php _e('Refresh on Tag Change', 'vivio-swift')?>:</th>
                                <td>
                                    <label class="switch">
                                        <input name="vivio_swift_refresh_on_tag_change_enabled" type="checkbox"<?php if($vivio_swift_global->configs->get_value('vivio_swift_refresh_on_tag_change')=='1') echo ' checked="checked"'; ?> value="1"/>
                                        <span class="slider round"></span>
                                    </label>
                                <span class="description"><?php _e('(Recommended: ON) Clear cache whenever a Tag (term) is added, updated, or removed.', 'vivio-swift'); ?></span>
Jordan Michaels's avatar
Jordan Michaels committed
412 413 414 415 416
                                </td>
                            </tr>
                        </table>
                        <input type="submit" name="vivio_swift_refresh_events_submit" value="<?php _e('Save Settings', 'vivio-swift')?>" class="pure-button" />
                    </form>
Jordan Michaels's avatar
Jordan Michaels committed
417 418
                </div>
            </div>
Jordan Michaels's avatar
Jordan Michaels committed
419 420 421 422
            </div>
        </div>

    <?php
Jordan Michaels's avatar
Jordan Michaels committed
423 424 425
    }

    function render_tab4()
Jordan Michaels's avatar
Jordan Michaels committed
426
    {
Jordan Michaels's avatar
Jordan Michaels committed
427 428 429 430 431
    
        echo '<div class="message_standard">';
        echo '<p>' . __('The following options can provide additional speed boosts in some situations.', 'vivio-swift') . '</p>';
        echo '</div>';

Jordan Michaels's avatar
Jordan Michaels committed
432 433
        global $vivio_swift_global;

Jordan Michaels's avatar
Jordan Michaels committed
434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452
        // process advanced settings
        if (isset($_POST['vivio_swift_save_extra_options']))
        {
            $error = '';

            // verify nonce
            $nonce = $_REQUEST['_wpnonce'];
            if (!wp_verify_nonce($nonce, 'vivio_swift_extra_options_nonce')) {
                $vivio_swift_global->debug_logger->log_debug("Nonce check failed in extra options.", 4);
                wp_die("Error: Nonce check failed in extra options.");
            }

            // set and save submitted settings
            $vivio_swift_global->configs->set_value('vivio_swift_remove_query_strings',isset($_POST["vivio_swift_remove_query_strings"])?'1':'');
            $vivio_swift_global->configs->save_config();

            $this->show_msg_settings_updated();
        }

Jordan Michaels's avatar
Jordan Michaels committed
453 454 455
        ?>
        <div id="vivio-swift-container">

Jordan Michaels's avatar
Jordan Michaels committed
456 457 458 459
            <form action=""
                id="vivio_swift_cache_extra_settings"
                method="POST">
                <?php wp_nonce_field('vivio_swift_extra_options_nonce'); ?>
Jordan Michaels's avatar
Jordan Michaels committed
460

Jordan Michaels's avatar
Jordan Michaels committed
461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481
                <div class="postbox">
                    <h3 class="hndle">
                        <label for="title"><?php _e('Extras', 'vivio-swift');?></label>
                    </h3>
                    <div class="inside">
                        <table class="form-table">
                            <tr valign="top">
                                <th scope="row"><?php _e('Remove Query Strings', 'vivio-swift')?>:</th>
                                <td>
                                    <label class="switch">
                                        <input name="vivio_swift_remove_query_strings"
                                            id="vivio_swift_remove_query_strings"
                                            type="checkbox"<?php if($vivio_swift_global->configs->get_value('vivio_swift_remove_query_strings')=='1') echo ' checked="checked"'; ?> value="1"/>
                                        <span class="slider round"></span>
                                    </label>
                                <span class="description"><?php _e('(Recommended: ON) Remove version number query strings from static files so they can be cached more easily by 3rd-party services like CDN\'s.', 'vivio-swift'); ?></span>
                                </td>
                            </tr>
                        </table>
                        <input type="submit" name="vivio_swift_save_extra_options" value="<?php _e('Save Settings', 'vivio-swift')?>" class="pure-button" />
                    </div>
Jordan Michaels's avatar
Jordan Michaels committed
482
                </div>
Jordan Michaels's avatar
Jordan Michaels committed
483 484
            </form>
        </div><!-- End of Exclusions -->
Jordan Michaels's avatar
Jordan Michaels committed
485
        <?php
Jordan Michaels's avatar
Jordan Michaels committed
486 487 488
    }

} //end class