Commit 3aa1bbdf authored by Jordan Michaels's avatar Jordan Michaels

release 2020032401

parent 9a1400d7
......@@ -2,11 +2,15 @@
Versions are recorded in YYYYMMDDnn format. Please include latest versions at the top.
## 2017112801
* Initial Release.
## 2020032401
* [UPGRADE] Added proper images for Vivio Swift Icons and Header images
* [FIX] A few minor layout issues have been corrected
* [NEW] Added Browser Caching feature using the Cache-Control header (requires Apache mod_header) - Issue 5
## 2018011901
* Initial alpha release for internal testing of caching system.
## 2018021901
* [UPGRADE] The Vivio Swift Preload Cache is now a non-blocking event, and runs quietly in the background - Issue 9
* [FIX] The Preload Cache process should now actually run on plugin activation - Issue 8
* [NEW] Vivio Swift now offers a Browser Cache option, which currently gives you control over the cache-control max-age HTTP Header.
## 2018021301
* [NEW] Update Vivio-Swift HTML footer message to state if page was not cached due to exclude rule - Issue 1
......@@ -14,6 +18,8 @@ Versions are recorded in YYYYMMDDnn format. Please include latest versions at th
* [NEW] Refresh Events now re-create preload cache if preload caching is enabled - Issue 7
* [NEW] The Preload Cache process should now run on plugin activation - Issue 8
## 2018021901
* [UPGRADE] The Vivio Swift Preload Cache is now a non-blocking event, and runs quietly in the background - Issue 9
* [FIX] The Preload Cache process should now actually run on plugin activation - Issue 8
## 2018011901
* Initial alpha release for internal testing of caching system.
## 2017112801
* Initial Release.
\ No newline at end of file
<?php
class Vivio_Swift_Admin_Links
{
var $arr_links = array(
"help_mod_headers" => "https://kb.viviotech.net/display/KB/How+to+Install+mod_headers",
);
function get_link($name='')
{
return $this->arr_links[$name];
}
}
\ No newline at end of file
......@@ -42,7 +42,7 @@ class Vivio_Swift_Admin {
function create_admin_menus()
{
$vivio_swift_icon = 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PHN2ZyAgIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIgICB4bWxuczpjYz0iaHR0cD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kwrH5TW+q++jxhMqpeZiYnal+xueP/WE+YzKtv1Lfqu7w4pP5OGKjWK7b0JEvci7qcELbUtQrxQ/U0473uBCZKnF/AakR8TBkAP4CvwDjwuAa0Cs0G8CIXq93qnBo5ISIEPmXTWg04Bf4A68AscKQuqbvAOXAIvC+l+HI3qnX1g7qgbheuqogr9UHhHBbzWmdEnKk3wEHFngF6gDpwnM1ngJ2I+Jk7PlK/V1xljqlCgk114J8lbD/Xs3sajCRzZuexZfvzlDGa0kSqmMV7BYxlpSawFxG3Ze5fNDWhFVEs0JAAAAAASUVORK5CYII=';
$this->main_menu_page = add_menu_page(__('Vivio Swift', 'vivio-swift'), __('Vivio Swift', 'vivio-swift'), VIVIO_SWIFT_CAPABILITY, VIVIO_SWIFT_MAIN_MENU_SLUG , array(&$this, 'handle_dashboard_menu_rendering'), $vivio_swift_icon);
add_submenu_page(VIVIO_SWIFT_MAIN_MENU_SLUG, __('Dashboard', 'vivio-swift'), __('Dashboard', 'vivio-swift') , VIVIO_SWIFT_CAPABILITY, VIVIO_SWIFT_MAIN_MENU_SLUG, array(&$this, 'handle_dashboard_menu_rendering'));
add_submenu_page(VIVIO_SWIFT_MAIN_MENU_SLUG, __('Cache', 'vivio-swift'), __('Cache', 'vivio-swift') , VIVIO_SWIFT_CAPABILITY, VIVIO_SWIFT_CACHE_MENU_SLUG, array(&$this, 'handle_cache_menu_rendering'));
......
......@@ -10,7 +10,8 @@ class Vivio_Swift_Cache_Menu extends Vivio_Swift_Admin_Messages
'tab1' => 'render_tab1',
'tab2' => 'render_tab2',
'tab3' => 'render_tab3',
'tab4' => 'render_tab4'
'tab4' => 'render_tab4',
'tab5' => 'render_tab5'
);
function __construct()
......@@ -23,8 +24,9 @@ class Vivio_Swift_Cache_Menu extends Vivio_Swift_Admin_Messages
$this->menu_tabs = array(
'tab1' => __('On-Access Cache', 'vivio-swift'),
'tab2' => __('Preload Cache', 'vivio-swift'),
'tab3' => __('Refresh Events', 'vivio-swift'),
'tab4' => __('Extras', 'vivio-swift')
'tab3' => __('Browser Cache', 'vivio-swift'),
'tab4' => __('Refresh Events', 'vivio-swift'),
'tab5' => __('Extras', 'vivio-swift')
);
}
......@@ -331,6 +333,321 @@ class Vivio_Swift_Cache_Menu extends Vivio_Swift_Admin_Messages
}
function render_tab3()
{
echo '<div class="message_standard">';
echo '<p>' . __('This feature modifies your HTTP response headers to include a Cache-Control Max-Age value, which gives you control over how your site is cached in a browser.', 'vivio-swift') . '</p>';
echo '</div>';
global $vivio_swift_global;
$cache_control_groups = $vivio_swift_global->configs->get_value('vivio_swift_cache_control_headers_values');
$error='';
// process the cache control switch
if (isset($_POST['vivio_swift_cache_control_save']))
{
$nonce = $_REQUEST['_wpnonce'];
if (!wp_verify_nonce($nonce, 'vivio_swift_control_group_nonce')) {
$vivio_swift_global->debug_logger->log_debug("Nonce check failed in cache-control options.", 4);
wp_die("Error: Nonce check failed in cache-control options.");
}
$vivio_swift_global->configs->set_value('vivio_swift_cache_control_headers_enable',isset($_POST["vivio_swift_cache_control_headers_enable"])?'1':'');
$vivio_swift_global->configs->save_config();
$vivio_swift_global->util_htaccess->write_to_htaccess();
$this->show_msg_settings_updated();
}
if (isset($_POST['vivio_swift_control_group_add_group_button']))
{
$nonce = $_REQUEST['_wpnonce'];
if (!wp_verify_nonce($nonce, 'vivio_swift_control_group_nonce')) {
$vivio_swift_global->debug_logger->log_debug("Nonce check failed in cache-control options.", 4);
wp_die("Error: Nonce check failed in cache-control options.");
}
$new_group_name = sanitize_text_field($_POST['vivio_swift_control_group_add_group']);
if ($new_group_name==''){
$error = 'Group name cannot be empty.';
}
// verify group name doesn't already exist
foreach($cache_control_groups as $index=>$group){
if ($group['name']==$new_group_name){
$error = 'That group name already exists.';
}
}
// create a simple array to house our new group
if ($error==''){
$arr_new_group = array(
'name' => $new_group_name,
'max-age' => '0',
'enable-cache' => '0',
'extensions' => array()
);
// add the new group to the existing $cache_control_groups array
array_push($cache_control_groups,$arr_new_group);
$vivio_swift_global->configs->set_value('vivio_swift_cache_control_headers_values',$cache_control_groups);
$vivio_swift_global->configs->save_config();
$vivio_swift_global->util_htaccess->write_to_htaccess();
// get the new group index
foreach($cache_control_groups as $index=>$group){
if ($group['name']==$new_group_name){
$new_group_index = $index;
}
}
// forcably set post field to new group index so that it will show as selected
$_POST['vivio_swift_control_group_id'] = $new_group_index;
// also set the view group button so that it acts as if it were pressed
$_POST['vivio_swift_cache_control_select_group'] = "View Group";
} else {
$this->show_msg_error(__('Error: ','vivio-swift').$error);
}
}
$arr_control = '';
if (isset($_POST['vivio_swift_control_group_id']) && (is_numeric($_POST['vivio_swift_control_group_id'])) && ($error==''))
{
$nonce = $_REQUEST['_wpnonce'];
if (!wp_verify_nonce($nonce, 'vivio_swift_control_group_nonce')) {
$vivio_swift_global->debug_logger->log_debug("Nonce check failed on control group select.", 4);
wp_die("Error! Nonce check failed on control group select.");
}
// validate id being passed
$post_group = intval(sanitize_text_field($_POST['vivio_swift_control_group_id']));
if ($post_group < 0){
$error .= '<br />'.__('The group value cannot have a value of lower than 0.','vivio-swift');
} elseif (in_array($post_group, $cache_control_groups, true)){
$error .= '<br />'.__('The group value was not found in the current groups. Please try again.','vivio-swift');
}
if(sanitize_text_field($_POST['vivio_swift_cache_control_save'])=="2"){
$cache_control_groups[$post_group]['max-age'] = intval(sanitize_text_field($_POST['vivio_swift_cache_control_max_age_value']));
$cache_control_groups[$post_group]['enable-cache'] = isset($_POST["vivio_swift_cache_control_group_enabled"])?'1':'';
$vivio_swift_global->configs->set_value('vivio_swift_cache_control_headers_values',$cache_control_groups);
$vivio_swift_global->configs->save_config();
$vivio_swift_global->util_htaccess->write_to_htaccess();
}
if(isset($_POST['vivio_swift_add_control_group_extension_add'])){
$new_extension = sanitize_text_field($_POST['vivio_swift_control_group_extension']);
if($new_extension==""){
$error .= '<br />'.__('The New File Extension cannot be blank.','vivio-swift');
} elseif (!ctype_alnum($new_extension)){
$error .= '<br />'.__('The New File Extension must be alphanumeric.','vivio-swift');
} elseif (in_array($new_extension, $cache_control_groups[$post_group]['extensions'])){
// TODO check all extensions in every group
$error .= '<br />'.__('The New File Extension you entered already exists in this group.','vivio-swift');
}
if($error==""){
array_push($cache_control_groups[$post_group]['extensions'], $new_extension);
$vivio_swift_global->configs->set_value('vivio_swift_cache_control_headers_values',$cache_control_groups);
$vivio_swift_global->configs->save_config();
$vivio_swift_global->util_htaccess->write_to_htaccess();
}
}
if(isset($_POST["vivio_swift_control_group_extension_delete"])){
$arr_extensions = $cache_control_groups[$post_group]['extensions'];
$ext_to_remove = sanitize_text_field($_POST["vivio_swift_control_group_extension_delete"]);
foreach ($arr_extensions as $index=>$extension) {
if($extension==$ext_to_remove){
unset($cache_control_groups[$post_group]['extensions'][$index]);
}
}
$vivio_swift_global->configs->set_value('vivio_swift_cache_control_headers_values',$cache_control_groups);
$vivio_swift_global->configs->save_config();
$vivio_swift_global->util_htaccess->write_to_htaccess();
}
if($error){$this->show_msg_error(__('Attention!','vivio-swift').$error);}
$arr_control = $cache_control_groups[$post_group];
// group delete
if ((sanitize_text_field($_POST['vivio_swift_control_group_delete']))=="1")
{
unset($cache_control_groups[$post_group]);
$cache_control_groups = array_values($cache_control_groups);
$vivio_swift_global->configs->set_value('vivio_swift_cache_control_headers_values',$cache_control_groups);
$vivio_swift_global->configs->save_config();
$vivio_swift_global->util_htaccess->write_to_htaccess();
unset($_POST['vivio_swift_control_group_id']);
unset($post_group);
unset($arr_control);
$this->show_msg_record_deleted_st();
}
}
?>
<div id="vivio-swift-container">
<form action=""
id="vivio_swift_control_group_form"
method="POST">
<?php wp_nonce_field('vivio_swift_control_group_nonce'); ?>
<div class="postbox">
<h3 class="hndle">
<label for="title"><?php _e('Browser Cache', 'vivio-swift');?></label>
</h3>
<div class="inside">
<table class="form-table">
<tr valign="top">
<th scope="row"><?php _e('Enable Browser Cache', 'vivio-swift')?>:</th>
<td>
<label class="switch">
<input name="vivio_swift_cache_control_headers_enable"
id="vivio_swift_cache_control_headers_enable"
type="checkbox"<?php if($vivio_swift_global->configs->get_value('vivio_swift_cache_control_headers_enable')=='1') echo ' checked="checked"'; ?> value="1"/>
<span class="slider round"></span>
</label>
<span class="description"><?php _e('Production sites should enable this for best performance. Do not enable cache-control for sites still in development.', 'vivio-swift'); ?></span>
</td>
</tr>
</table>
<button type="submit" name="vivio_swift_cache_control_save" value="1" class="pure-button"><?php _e('Save Settings', 'vivio-swift')?></button>
</div>
</div>
<div class="postbox">
<h3 class="hndle">
<label for="title"><?php _e('Control Groups', 'vivio-swift');?></label>
</h3>
<div class="inside">
<table class="form-table">
<tr valign="top">
<th scope="row"><?php _e('Add New Control Group', 'vivio-swift')?>:</th>
<td>
<input type="text" size="10"
id="vivio_swift_control_group_add_group"
name="vivio_swift_control_group_add_group"
value=""
/>
<button type="submit" name="vivio_swift_control_group_add_group_button" class="pure-button"><?php _e('Add', 'vivio-swift')?></button>
<span class="description"><?php _e('Add a new Control Group. Control Groups enable you to set specific cache times for specific groups of files.', 'vivio-swift'); ?></span>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php _e('Control Groups', 'vivio-swift')?>:</th>
<td>
<select id="vivio_swift_control_group_id" name="vivio_swift_control_group_id">
<option
value=""><?php _e('--Select a Group--', 'vivio-swift')?></option>
<?php
foreach($cache_control_groups as $index=>$group){
echo '<option value="'.$index.'"';
if(isset($post_group)&&($index==$post_group)){echo ' selected';}
echo '>'.$group['name'].'</option>';
}
?>
</select>
<span class="description"><?php _e('Control Groups give you the ability to group specific file types so they can be cached for different lengths of time.', 'all-in-one-wp-security-and-firewall'); ?></span>
</td>
</tr>
</table>
<?php if (!is_numeric($_POST['vivio_swift_control_group_id'])){?>
<button type="submit" name="vivio_swift_cache_control_save" value="1" class="pure-button"><?php _e('Save Settings', 'vivio-swift')?></button>
<?php } ?>
</div>
</div>
<?php
if (isset($_POST['vivio_swift_control_group_id']) && is_array($arr_control))
{
?>
<input
type="hidden"
id="vivio_swift_control_group_delete"
name="vivio_swift_control_group_delete"
value="0">
<div class="postbox">
<h3 class="hndle">
<label for="title"><?php echo $arr_control['name'];?></label>
</h3>
<div class="inside">
<table class="form-table">
<tr valign="top">
<th scope="row"><?php _e('Enable This Group', 'vivio-swift')?>:</th>
<td>
<label class="switch">
<input name="vivio_swift_cache_control_group_enabled"
id="vivio_swift_cache_control_group_enabled"
type="checkbox"<?php if($arr_control['enable-cache']=='1') echo ' checked="checked"'; ?> value="1"/>
<span class="slider round"></span>
</label>
<span class="description"><?php _e('Enable or Disable Cache-Control headers for this group. Browser Cache option (above) must also be enabled.', 'vivio-swift'); ?></span>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php _e('Max-Age', 'vivio-swift')?>:</th>
<td>
<input type="text" size="10"
id="vivio_swift_cache_control_max_age_value"
name="vivio_swift_cache_control_max_age_value"
value="<?php echo $arr_control['max-age']; ?>"
/>
<span class="description"><?php _e('Number of seconds that the file can be stored in a browser cache.', 'vivio-swift'); ?></span>
</td>
</tr>
</table>
<button type="submit" name="vivio_swift_cache_control_save" value="2" class="pure-button"><?php _e('Save Settings', 'vivio-swift')?></button>
<table class="form-table">
<tr valign="top">
<th scope="row"><?php _e('Add New File Extension', 'vivio-swift')?>:</th>
<td>
<input type="text" size="10"
id="vivio_swift_control_group_extension"
name="vivio_swift_control_group_extension"
value=""
/>
<button type="submit" name="vivio_swift_add_control_group_extension_add" class="pure-button"><?php _e('Add', 'vivio-swift')?></button>
<span class="description"><?php _e('Add a new file extension to this control group', 'vivio-swift'); ?></span>
</td>
</tr>
</table>
<table class="widefat">
<thead>
<tr>
<th><?php _e('File Extension', 'vivio-swift') ?></th>
<th><?php _e('Delete', 'vivio-swift') ?></th>
</tr>
</thead>
<tbody>
<?php
$arr_group_extensions = $arr_control["extensions"];
foreach ($arr_group_extensions as $i => $value) {
echo '<tr>';
echo '<td class="pattern_cell">' . $value . "</td>";
echo '<td class="action_cell"><button name="vivio_swift_control_group_extension_delete" class="pure-button button-error" type="submit"';
echo 'value="'.$value.'">';
echo '<span class="dashicons dashicons-no"></span></button></td>';
echo '</tr>';
}
?>
</tbody>
<tfoot>
<tr>
<th><?php _e('File Extension', 'vivio-swift') ?></th>
<th><?php _e('Delete', 'vivio-swift') ?></th>
</tr>
</tfoot>
</table>
<input type="button" id="vivio_swift_remove_control_group_submit" value="<?php _e('Delete Group', 'vivio-swift')?>" class="pure-button button-error" />
<?php
}
?>
</div>
</div>
</form>
</div>
<?php
}
function render_tab4()
{
global $vivio_swift_global;
......@@ -430,7 +747,7 @@ class Vivio_Swift_Cache_Menu extends Vivio_Swift_Admin_Messages
<?php
}
function render_tab4()
function render_tab5()
{
echo '<div class="message_standard">';
......@@ -489,7 +806,7 @@ class Vivio_Swift_Cache_Menu extends Vivio_Swift_Admin_Messages
</div>
</div>
</form>
</div><!-- End of Exclusions -->
</div>
<?php
}
......
......@@ -3,9 +3,7 @@
class Vivio_Swift_Dashboard_Menu extends Vivio_Swift_Admin_Messages
{
var $dashboard_menu_page_slug = VIVIO_SWIFT_MAIN_MENU_SLUG;
var $menu_tabs;
var $menu_tabs_handler = array(
'tab1' => 'render_tab1',
'tab2' => 'render_tab2',
......@@ -17,6 +15,8 @@ class Vivio_Swift_Dashboard_Menu extends Vivio_Swift_Admin_Messages
function __construct()
{
require_once('vivio-swift-admin-links.php');
$this->links = new Vivio_Swift_Admin_Links;
$this->render_menu_page();
}
......@@ -54,6 +54,13 @@ class Vivio_Swift_Dashboard_Menu extends Vivio_Swift_Admin_Messages
echo '</h2>';
}
function render_notifications()
{
global $vivio_swift_global;
// TODO check for global messages and post them here.
}
/*
* The menu rendering goes here
*/
......@@ -78,7 +85,7 @@ class Vivio_Swift_Dashboard_Menu extends Vivio_Swift_Admin_Messages
function render_tab1()
{
echo '<div class="message_standard">';
echo '<div class="message_success">';
echo '<p>' . __('Thank you for trying Vivio Swift (beta). Please report bugs or issues <a href="https://viviotech.net/contactus.html" target="_blank">HERE</a>.', 'vivio-swift') . '</p>';
echo '<p><a href="https://twitter.com/viviotech/" target="_blank">' . __('Follow us on Twitter', 'vivio-swift') . '</a> ' . __('to stay up to date on new and improved features of this plugin.', 'vivio-swift') . '</p>';
echo '</div>';
......@@ -135,6 +142,7 @@ class Vivio_Swift_Dashboard_Menu extends Vivio_Swift_Admin_Messages
// set and save submitted settings
$vivio_swift_global->configs->set_value('vivio_swift_cache_enabled',isset($_POST["vivio_swift_cache_enabled"])?'1':'');
$vivio_swift_global->configs->set_value('vivio_swift_preload_cache_enabled',isset($_POST["vivio_swift_preload_cache_enabled"])?'1':'');
$vivio_swift_global->configs->set_value('vivio_swift_cache_control_headers_enable',isset($_POST["vivio_swift_cache_control_headers_enable"])?'1':'');
$vivio_swift_global->configs->save_config();
$this->show_msg_settings_updated();
......@@ -145,7 +153,7 @@ class Vivio_Swift_Dashboard_Menu extends Vivio_Swift_Admin_Messages
<div class="dashboard_box_small">
<div class="postbox">
<h3 class="hndle">
<label for="title"><?php _e('Quick Cache', 'vivio-swift');?></label>
<label for="title"><?php _e('Quick Settings', 'vivio-swift');?></label>
</h3>
<div class="inside">
......@@ -174,6 +182,17 @@ class Vivio_Swift_Dashboard_Menu extends Vivio_Swift_Admin_Messages
</label>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php _e('Browser Cache', 'vivio-swift')?>:</th>
<td>
<label class="switch">
<input name="vivio_swift_cache_control_headers_enable"
id="vivio_swift_cache_control_headers_enable"
type="checkbox"<?php if($vivio_swift_global->configs->get_value('vivio_swift_cache_control_headers_enable')=='1') echo ' checked="checked"'; ?> value="1"/>
<span class="slider round"></span>
</label>
</td>
</tr>
</table>
<input type="submit" name="vivio_swift_cache_dashboard_submit" id="vivio_swift_cache_dashboard_submit" value="<?php _e('Save Settings', 'vivio-swift')?>" class="pure-button" />
</form>
......@@ -248,8 +267,8 @@ class Vivio_Swift_Dashboard_Menu extends Vivio_Swift_Admin_Messages
<div class="inside">
<p><?php _e('Has this plugin helped you? Let others know!', 'vivio-swift');?></p>
<p><a href="https://www.facebook.com/viviotech" target="_blank">Like us on Facebook</a></p>
<p><a href="http://twitter.com/intent/tweet?url=https://viviotech.net/&text=Using the Vivio Swift Wordpress plugin from @viviotech has really helped speed up my site! Check it out!" target="_blank">Post to Twitter</a></p>
<p><a href="#" target="_blank">Give a Good Rating on Wordpress</a></p>
<p><a href="https://twitter.com/intent/tweet?url=https://viviotech.net/&text=Using the Vivio Swift Wordpress plugin from @viviotech has really helped speed up my site! Check it out!" target="_blank">Post to Twitter</a></p>
<p><a href="https://wordpress.org/support/plugin/vivio-swift" target="_blank">Give a Good Rating on Wordpress</a></p>
</div>
</div>
</div>
......@@ -273,7 +292,6 @@ class Vivio_Swift_Dashboard_Menu extends Vivio_Swift_Admin_Messages
<?php
}
function render_tab2()
{
......@@ -305,7 +323,26 @@ class Vivio_Swift_Dashboard_Menu extends Vivio_Swift_Admin_Messages
: </strong><code><?php echo VIVIO_SWIFT_CACHE_BOT_NAME; ?></code><br/>
</div>
</div><!-- End of Site Info -->
</div>
<div class="postbox">
<h3 class="hndle">
<label for="title"><?php _e('Apache Environment', 'vivio-swift');?></label>
</h3>
<div class="inside">
<strong><?php _e('VERSION', 'vivio-swift');?>
: </strong><code><?php echo ($vivio_swift_global->util_apache->apache_version()) ? $vivio_swift_global->util_apache->apache_version() : "Unknown"; ?></code>
<?php if(!$vivio_swift_global->util_apache->apache_version()){echo '<font color="red">WARNING</font>';} ?><br/>
<strong><?php _e('mod_rewrite', 'vivio-swift');?>
: </strong><code><?php echo ($vivio_swift_global->util_apache->test_mod_rewrite()) ? "Yes" : "Unknown"; ?></code>
<?php if(!$vivio_swift_global->util_apache->test_mod_rewrite()){echo '<font color="red">WARNING</font>';} ?><br/>
<strong><?php _e('mod_headers', 'vivio-swift');?>
: </strong><code><?php echo ($vivio_swift_global->util_apache->test_mod_headers()) ? "Yes" : "Unknown"; ?></code>
<?php if(!$vivio_swift_global->util_apache->test_mod_headers()){echo '<font color="red">WARNING</font> <a href="'.$this->links->get_link("help_mod_headers").'" target="_blank" style="text-decoration: none;"><span class="dashicons dashicons-editor-help"></span></a>';} ?><br/>
</div>
</div>
<div class="postbox">
<h3 class="hndle">
......@@ -333,14 +370,14 @@ class Vivio_Swift_Dashboard_Menu extends Vivio_Swift_Admin_Messages
<strong>CURL <?php _e('Library Present', 'vivio-swift');?>
: </strong><code><?php echo (function_exists('curl_init')) ? "Yes" : "No"; ?></code><br/>
<strong><?php _e('Debug File Write Permissions', 'vivio-swift');?>
: </strong><code><?php echo (is_writable(VIVIO_SWIFT_PATH)) ? "Writable" : "Not Writable"; ?></code><br/>
: </strong><code><?php echo (is_writable(VIVIO_SWIFT_PATH."/logs/".VIVIO_SWIFT_LOG_FILE)) ? "Writable</code>" : "Not Writable</code> "."<font color='red'>WARNING</font>" ?><br/>
</div>
</div><!-- End of Site Info -->
</div>
<div class="postbox">
<h3 class="hndle">
<label for="title"><?php _e('PHP Info', 'vivio-swift');?></label>
<label for="title"><?php _e('PHP Environment', 'vivio-swift');?></label>
</h3>
<div class="inside">
......@@ -726,6 +763,8 @@ class Vivio_Swift_Dashboard_Menu extends Vivio_Swift_Admin_Messages
</form>
</div>
</div>
<?php
}
......@@ -791,11 +830,10 @@ class Vivio_Swift_Dashboard_Menu extends Vivio_Swift_Admin_Messages
$vivio_swift_global->debug_logger->reset_log_file('1');
//$vivio_swift_global->debug_logger->reset_log_file('2');//cron
$preload_enabled = ($this->configs->get_value('vivio_swift_preload_cache_enabled')=='1')?true:false;
$preload_enabled = ($vivio_swift_global->configs->get_value('vivio_swift_preload_cache_enabled')=='1')?true:false;
if ($preload_enabled){wp_schedule_single_event(time(), 'vivio_swift_schedule_preload_cache');}
$this->show_msg_settings_updated();
}
?>
<div class="postbox">
......
......@@ -377,6 +377,45 @@ class Vivio_Swift_Exclusions_Menu extends Vivio_Swift_Admin_Messages
</form>
</div>
</div>
<div class="postbox closed">
<h3 class="hndle">
<label for="title"><?php _e('Cookie Viewer', 'vivio-swift');?></label><small style="margin-left: 20px;"><?php _e('[Show/Hide]', 'vivio-swift');?></small>
</h3>
<div class="inside">
<form action="" method="POST">
<?php wp_nonce_field('vivio_swift_cookie_viewer_nonce'); ?>
<table class="widefat">
<thead>
<tr>
<th><?php _e('Cookie Name (sanitized)', 'vivio-swift') ?></th>
<!-- <th><?php _e('Delete', 'vivio-swift') ?></th> -->
</tr>
</thead>
<tbody>
<?php
foreach ((array)$_COOKIE as $cookie_key => $cookie_value){
echo '<tr>';
echo '<td class="pattern_cell">' . sanitize_text_field($cookie_key) . "</td>";
//echo '<td class="action_cell"><button name="vivio_swift_delete_cookie" class="pure-button button-error" type="submit"';
//echo 'value="'.sanitize_text_field($cookie_key).'"';
//echo '>';
//echo '<span class="dashicons dashicons-no"></span></button></td>';
echo '</tr>';
}
?>
</tbody>