Commit 7a9f154c authored by Jordan Michaels's avatar Jordan Michaels

Release 2018021301. Addressed issues 1,6,7,8

parent bf56db5a
No preview for this file type
...@@ -327,7 +327,7 @@ class Vivio_Swift_Cache_Menu extends Vivio_Swift_Admin_Messages ...@@ -327,7 +327,7 @@ class Vivio_Swift_Cache_Menu extends Vivio_Swift_Admin_Messages
global $vivio_swift_global; global $vivio_swift_global;
echo '<div class="message_standard">'; echo '<div class="message_standard">';
echo '<p>' . __('Refresh events clear your existing cache when they occur. It is highly recommend to use On-Access Cache with Refresh Events.', 'vivio-swift') . '</p>'; 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>';
echo '</div>'; echo '</div>';
if (isset($_POST['vivio_swift_refresh_events_submit'])) if (isset($_POST['vivio_swift_refresh_events_submit']))
...@@ -349,6 +349,8 @@ class Vivio_Swift_Cache_Menu extends Vivio_Swift_Admin_Messages ...@@ -349,6 +349,8 @@ class Vivio_Swift_Cache_Menu extends Vivio_Swift_Admin_Messages
// set and save submitted settings // 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_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':''); $vivio_swift_global->configs->set_value('vivio_swift_refresh_on_post_update',isset($_POST["vivio_swift_refresh_on_post_update_enabled"])?'1':'');
$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':'');
$vivio_swift_global->configs->save_config(); $vivio_swift_global->configs->save_config();
$this->show_msg_settings_updated(); $this->show_msg_settings_updated();
...@@ -376,7 +378,7 @@ class Vivio_Swift_Cache_Menu extends Vivio_Swift_Admin_Messages ...@@ -376,7 +378,7 @@ class Vivio_Swift_Cache_Menu extends Vivio_Swift_Admin_Messages
<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"/> <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> <span class="slider round"></span>
</label> </label>
<span class="description"><?php _e('(Recommended: ON) Clear cache whenever a new post is made.', 'vivio-swift'); ?></span> <span class="description"><?php _e('(Recommended: ON) Clear cache whenever a new post or page is made.', 'vivio-swift'); ?></span>
</td> </td>
</tr> </tr>
<tr valign="top"> <tr valign="top">
...@@ -386,7 +388,27 @@ class Vivio_Swift_Cache_Menu extends Vivio_Swift_Admin_Messages ...@@ -386,7 +388,27 @@ class Vivio_Swift_Cache_Menu extends Vivio_Swift_Admin_Messages
<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"/> <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> <span class="slider round"></span>
</label> </label>
<span class="description"><?php _e('(Recommended: ON) Clear cache whenever a post is updated.', 'vivio-swift'); ?></span> <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>
</td> </td>
</tr> </tr>
</table> </table>
......
...@@ -75,17 +75,71 @@ class Vivio_Swift_Compress_Menu extends Vivio_Swift_Admin_Messages ...@@ -75,17 +75,71 @@ class Vivio_Swift_Compress_Menu extends Vivio_Swift_Admin_Messages
echo '</div>'; echo '</div>';
global $vivio_swift_global; global $vivio_swift_global;
if (isset($_POST['vivio_swift_save_compression_settings']))
{
$error = '';
// verify nonce
$nonce = $_REQUEST['_wpnonce'];
if (!wp_verify_nonce($nonce, 'vivio_swift_compression_settings_nonce')) {
$vivio_swift_global->debug_logger->log_debug("Nonce check failed on compression settings.", 4);
wp_die("Error: Nonce check failed on compression settings.");
}
if($error)
{
$this->show_msg_error(__('Attention!','vivio-swift').$error);
}
// save settings
$vivio_swift_global->configs->set_value('vivio_swift_combine_css',isset($_POST["vivio_swift_combine_css"])?'1':'');
$vivio_swift_global->configs->set_value('vivio_swift_combine_js',isset($_POST["vivio_swift_combine_js"])?'1':'');
$vivio_swift_global->configs->save_config();
$this->show_msg_settings_updated();
}
?> ?>
<div id="vivio-swift-container"> <div id="vivio-swift-container">
<div class="postbox"> <div class="postbox">
<h3 class="hndle"> <h3 class="hndle">
<label for="title"><?php _e('Settings', 'vivio-swift');?></label> <label for="title"><?php _e('Compression Settings', 'vivio-swift');?></label>
</h3> </h3>
<div class="inside"> <div class="inside">
<form action=""
id="vivio_swift_compression_settings"
method="POST">
<?php wp_nonce_field('vivio_swift_compression_settings_nonce'); ?>
<table class="form-table">
<tr valign="top">
<th scope="row"><?php _e('Combine Multiple CSS Files', 'vivio-swift')?>:</th>
<td>
<label class="switch">
<input name="vivio_swift_combine_css" type="checkbox"<?php if($vivio_swift_global->configs->get_value('vivio_swift_combine_css')=='1') echo ' checked="checked"'; ?> value="1"/>
<span class="slider round"></span>
</label>
<span class="description"><?php _e('(Recommended: ON) Combining CSS files reduces the number of requests sent to your server and speeds up load time.', 'vivio-swift'); ?></span>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php _e('Combine Multiple JS Files', 'vivio-swift')?>:</th>
<td>
<label class="switch">
<input name="vivio_swift_combine_js" type="checkbox"<?php if($vivio_swift_global->configs->get_value('vivio_swift_combine_js')=='1') echo ' checked="checked"'; ?> value="1"/>
<span class="slider round"></span>
</label>
<span class="description"><?php _e('(Recommended: ON) Combining JavaScript files reduces the number of requests sent to your server and speeds up load time.', 'vivio-swift'); ?></span>
</td>
</tr>
</table>
<input type="submit" name="vivio_swift_save_compression_settings" value="<?php _e('Save Settings', 'vivio-swift')?>" class="pure-button" />
</form>
</div> </div>
</div> </div>
</div> </div>
<?php <?php
...@@ -105,6 +159,9 @@ class Vivio_Swift_Compress_Menu extends Vivio_Swift_Admin_Messages ...@@ -105,6 +159,9 @@ class Vivio_Swift_Compress_Menu extends Vivio_Swift_Admin_Messages
</h3> </h3>
<div class="inside"> <div class="inside">
<pre>
<?php global $wp_scripts; var_dump($wp_scripts); ?>
</pre>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -79,7 +79,7 @@ class Vivio_Swift_Dashboard_Menu extends Vivio_Swift_Admin_Messages ...@@ -79,7 +79,7 @@ class Vivio_Swift_Dashboard_Menu extends Vivio_Swift_Admin_Messages
{ {
echo '<div class="message_standard">'; echo '<div class="message_standard">';
echo '<p>' . __('Vivio Swift (Alpha) released on January 19, 2018. Please report bugs or issues <a href="https://viviotech.net/contactus.html" target="_blank">HERE</a>.', 'vivio-swift') . '</p>'; 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 '<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>'; echo '</div>';
...@@ -480,6 +480,7 @@ class Vivio_Swift_Dashboard_Menu extends Vivio_Swift_Admin_Messages ...@@ -480,6 +480,7 @@ class Vivio_Swift_Dashboard_Menu extends Vivio_Swift_Admin_Messages
$vivio_swift_global->configs->save_config(); $vivio_swift_global->configs->save_config();
// set and save debug settings // set and save debug settings
$vivio_swift_global->configs->set_value('vivio_swift_enable_cache_comment',isset($_POST["vivio_swift_enable_cache_comment"])?'1':'');
$vivio_swift_global->configs->set_value('vivio_swift_enable_debug',isset($_POST["vivio_swift_enable_debug"])?'1':''); $vivio_swift_global->configs->set_value('vivio_swift_enable_debug',isset($_POST["vivio_swift_enable_debug"])?'1':'');
$vivio_swift_global->configs->set_value('vivio_swift_debug_level',$loglevel_selected); $vivio_swift_global->configs->set_value('vivio_swift_debug_level',$loglevel_selected);
$vivio_swift_global->configs->save_config(); $vivio_swift_global->configs->save_config();
...@@ -523,6 +524,18 @@ class Vivio_Swift_Dashboard_Menu extends Vivio_Swift_Admin_Messages ...@@ -523,6 +524,18 @@ class Vivio_Swift_Dashboard_Menu extends Vivio_Swift_Admin_Messages
method="POST"> method="POST">
<?php wp_nonce_field('vivio-swift-debug-settings-nonce'); ?> <?php wp_nonce_field('vivio-swift-debug-settings-nonce'); ?>
<table class="form-table"> <table class="form-table">
<tr valign="top">
<th scope="row"><?php _e('Enable HTML Comment', 'vivio-swift')?>:</th>
<td>
<label class="switch">
<input name="vivio_swift_enable_cache_comment"
id="vivio_swift_enable_cache_comment"
type="checkbox"<?php if($vivio_swift_global->configs->get_value('vivio_swift_enable_cache_comment')=='1') echo ' checked="checked"'; ?> value="1"/>
<span class="slider round"></span>
</label>
<span class="description"><?php _e('Adds a cache timestamp or other information to an HTML comment at the bottom of processed requests.', 'vivio-swift'); ?></span>
</td>
</tr>
<tr valign="top"> <tr valign="top">
<th scope="row"><?php _e('Enable Debug Logging', 'vivio-swift')?>:</th> <th scope="row"><?php _e('Enable Debug Logging', 'vivio-swift')?>:</th>
<td> <td>
......
...@@ -11,7 +11,8 @@ class Vivio_Swift_Exclusions_Menu extends Vivio_Swift_Admin_Messages ...@@ -11,7 +11,8 @@ class Vivio_Swift_Exclusions_Menu extends Vivio_Swift_Admin_Messages
'tab2' => 'render_tab2', 'tab2' => 'render_tab2',
'tab3' => 'render_tab3', 'tab3' => 'render_tab3',
'tab4' => 'render_tab4', 'tab4' => 'render_tab4',
'tab5' => 'render_tab5' 'tab5' => 'render_tab5',
'tab6' => 'render_tab6'
); );
function __construct() function __construct()
...@@ -24,9 +25,10 @@ class Vivio_Swift_Exclusions_Menu extends Vivio_Swift_Admin_Messages ...@@ -24,9 +25,10 @@ class Vivio_Swift_Exclusions_Menu extends Vivio_Swift_Admin_Messages
$this->menu_tabs = array( $this->menu_tabs = array(
'tab1' => __('Settings', 'vivio-swift'), 'tab1' => __('Settings', 'vivio-swift'),
'tab2' => __('Cookies', 'vivio-swift'), 'tab2' => __('Cookies', 'vivio-swift'),
'tab3' => __('Exact Paths', 'vivio-swift'), 'tab3' => __('User Agents', 'vivio-swift'),
'tab4' => __('Paths Ending With', 'vivio-swift'), 'tab4' => __('Exact Paths', 'vivio-swift'),
'tab5' => __('Paths Containing', 'vivio-swift'), 'tab5' => __('Paths Ending With', 'vivio-swift'),
'tab6' => __('Paths Containing', 'vivio-swift'),
); );
} }
...@@ -144,6 +146,18 @@ class Vivio_Swift_Exclusions_Menu extends Vivio_Swift_Admin_Messages ...@@ -144,6 +146,18 @@ class Vivio_Swift_Exclusions_Menu extends Vivio_Swift_Admin_Messages
<span class="description"><?php _e("(Required) The existance of some cookies may indicate a user will need a dynamic response.", 'vivio-swift'); ?></span> <span class="description"><?php _e("(Required) The existance of some cookies may indicate a user will need a dynamic response.", 'vivio-swift'); ?></span>
</td> </td>
</tr> </tr>
<tr valign="top">
<th scope="row"><?php _e('Exclude User Agents', 'vivio-swift')?>:</th>
<td>
<label class="switch">
<input name="exclude_user_agents_enabled"
id="exclude_user_agents_enabled"
type="checkbox"<?php if($vivio_swift_global->configs->get_value('vivio_swift_cache_exclude_user_agent')=='1') echo ' checked="checked"'; ?> value="1" disabled/>
<span class="slider round"></span>
</label>
<span class="description"><?php _e("(Required) Some user agents will require a dynamic response.", 'vivio-swift'); ?></span>
</td>
</tr>
<tr valign="top"> <tr valign="top">
<th scope="row"><?php _e('Exclude Query Strings', 'vivio-swift')?>:</th> <th scope="row"><?php _e('Exclude Query Strings', 'vivio-swift')?>:</th>
<td> <td>
...@@ -367,8 +381,150 @@ class Vivio_Swift_Exclusions_Menu extends Vivio_Swift_Admin_Messages ...@@ -367,8 +381,150 @@ class Vivio_Swift_Exclusions_Menu extends Vivio_Swift_Admin_Messages
<?php <?php
} }
function render_tab3() function render_tab3()
{
global $vivio_swift_global;
if (isset($_POST['vivio_swift_add_user_agent']))
{
$error = '';
// verify nonce
$nonce = $_REQUEST['_wpnonce'];
if (!wp_verify_nonce($nonce, 'vivio_swift_exclude_user_agent_nonce')) {
$vivio_swift_global->debug_logger->log_debug("Nonce check failed on user agent exclusions.", 4);
wp_die("Error: Nonce check failed on user agent exclusions.");
}
$new_user_agent_value = sanitize_text_field($_REQUEST['vivio_swift_user_agent_value']);
if($new_user_agent_value){
Vivio_Swift_Cache_Excludes::add_user_agent_value($new_user_agent_value);
}
if($error)
{
$this->show_msg_error(__('Attention!','vivio-swift').$error);
}
}
if(isset($_POST['vivio_swift_delete_user_agent_value']))
{
$error = '';
// verify nonce
$nonce = $_REQUEST['_wpnonce'];
if (!wp_verify_nonce($nonce, 'vivio_swift_exclude_user_agent_nonce')) {
$vivio_swift_global->debug_logger->log_debug("Nonce check failed on user agent exclusions.", 4);
wp_die("Error: Nonce check failed on user agent exclusions.");
}
$delete_user_agent_value = sanitize_text_field($_REQUEST['vivio_swift_delete_user_agent_value']);
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Exclusions_Menu - delete_user_agent_value: ".$delete_user_agent_value, 1);
if($delete_user_agent_value){
Vivio_Swift_Cache_Excludes::remove_user_agent_value($delete_user_agent_value);
}
if($error)
{
$this->show_msg_error(__('Attention!','vivio-swift').$error);
}
}
?>
<div id="vivio-swift-container">
<form action=""
id="vivio_swift_exclusion_settings"
method="POST">
<?php wp_nonce_field('vivio_swift_exclusion_nonce'); ?>
<div class="postbox">
<h3 class="hndle">
<label for="title"><?php _e('Enable User Agent Exclusions', 'vivio-swift');?></label>
</h3>
<div class="inside">
<table class="form-table">
<tr valign="top">
<th scope="row"><?php _e('Exclude User Agent', 'vivio-swift')?>:</th>
<td>
<label class="switch">
<input name="exclude_user_agent_enabled"
id="exclude_user_agent_enabled"
type="checkbox"<?php if($vivio_swift_global->configs->get_value('vivio_swift_cache_exclude_user_agent')=='1') echo ' checked="checked"'; ?> value="1" disabled/>
<span class="slider round"></span>
</label>
<span class="description"><?php _e("(Required) Some user agents will require a dynamic response.", 'vivio-swift'); ?></span>
</td>
</tr>
</table>
<input type="submit" id="vivio_swift_exclusion_settings_submit" name="vivio_swift_exclusion_settings_submit" value="<?php _e('Save Settings', 'vivio-swift')?>" class="pure-button" />
</div>
</div>
</form>
<div class="postbox">
<h3 class="hndle">
<label for="title"><?php _e("Current 'User Agent' Exclusions", 'vivio-swift');?></label>
</h3>
<div class="inside">
<form action="" method="POST">
<?php wp_nonce_field('vivio_swift_exclude_user_agent_nonce'); ?>
<table class="form-table">
<tr valign="top">
<th scope="row"><?php _e('Add New', 'vivio-swift')?>:</th>
<td>
<input type="text" size="10"
id="vivio_swift_user_agent_value"
name="vivio_swift_user_agent_value"
value=""
/>
<button type="submit" name="vivio_swift_add_user_agent">Add</button>
<span class="description"><?php _e('A visitor with a user agent that contains this value will not use cache.', 'vivio-swift'); ?></span>
</td>
</tr>
</table>
<table class="widefat">
<thead>
<tr>
<th><?php _e('User Agent', 'vivio-swift') ?></th>
<th><?php _e('Delete', 'vivio-swift') ?></th>
</tr>
</thead>
<tbody>
<?php
$arr_user_agent_values = Vivio_Swift_Cache_Excludes::get_user_agent_values();
foreach ($arr_user_agent_values as $i => $value) {
echo '<tr>';
echo '<td class="pattern_cell">' . $value . "</td>";
echo '<td class="action_cell"><button name="vivio_swift_delete_user_agent_value" class="pure-button button-error" type="submit"';
echo 'value="'.$value.'"';
if(Vivio_Swift_Cache_Excludes::user_agent_check_required_value($value)){echo ' disabled';}
echo '>';
echo '<span class="dashicons dashicons-no"></span></button></td>';
echo '</tr>';
}
?>
</tbody>
<tfoot>
<tr>
<th><?php _e('User Agent', 'vivio-swift') ?></th>
<th><?php _e('Delete', 'vivio-swift') ?></th>
</tr>
</tfoot>
</table>
</form>
</div>
</div>
</div>
<?php
}
function render_tab4()
{ {
global $vivio_swift_global; global $vivio_swift_global;
...@@ -539,7 +695,7 @@ class Vivio_Swift_Exclusions_Menu extends Vivio_Swift_Admin_Messages ...@@ -539,7 +695,7 @@ class Vivio_Swift_Exclusions_Menu extends Vivio_Swift_Admin_Messages
} }
function render_tab4() function render_tab5()
{ {
global $vivio_swift_global; global $vivio_swift_global;
...@@ -710,7 +866,7 @@ class Vivio_Swift_Exclusions_Menu extends Vivio_Swift_Admin_Messages ...@@ -710,7 +866,7 @@ class Vivio_Swift_Exclusions_Menu extends Vivio_Swift_Admin_Messages
} }
function render_tab5() function render_tab6()
{ {
global $vivio_swift_global; global $vivio_swift_global;
......
...@@ -6,14 +6,26 @@ class Vivio_Swift_Activator{ ...@@ -6,14 +6,26 @@ class Vivio_Swift_Activator{
public static function activate() public static function activate()
{ {
global $wpdb; // hold-off on multi-site support for now.
/*
global $wpdb;
if (function_exists('is_multisite') && is_multisite()) { if (function_exists('is_multisite') && is_multisite()) {
// hold-off on multi-site support for now. $current_blog = $wpdb->blogid;
// loop over each blog in the multisite
$blogids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");
foreach ($blogids as $blog_id){
switch_to_blog($blog_id);
Vivio_Swift_Config_Settings::add_value_configs();
}
switch_to_blog($current_blog);
return;
} }
*/
// set default configs // set default configs
Vivio_Swift_Config_Settings::add_value_configs(); Vivio_Swift_Config_Settings::add_value_configs();
// configure cron handlers // configure cron handlers
if ( !wp_next_scheduled('vivio_swift_hourly_cron_event') ) { if ( !wp_next_scheduled('vivio_swift_hourly_cron_event') ) {
wp_schedule_event(time(), 'hourly', 'vivio_swift_hourly_cron_event'); //schedule an hourly cron event wp_schedule_event(time(), 'hourly', 'vivio_swift_hourly_cron_event'); //schedule an hourly cron event
......
...@@ -34,9 +34,7 @@ class Vivio_Swift_Cache_Excludes ...@@ -34,9 +34,7 @@ class Vivio_Swift_Cache_Excludes
$arr_cookie_values = $vivio_swift_global->configs->get_value('vivio_swift_cache_exclude_cookie_values'); $arr_cookie_values = $vivio_swift_global->configs->get_value('vivio_swift_cache_exclude_cookie_values');
if(!is_array($arr_cookie_values)){$arr_cookie_values = array();} if(!is_array($arr_cookie_values)){$arr_cookie_values = array();}
foreach ($arr_cookie_values as $i => $value) { foreach ($arr_cookie_values as $i => $value) {
if ($value==$val){ if ($value==$val){unset($arr_cookie_values[$i]);}
unset($arr_cookie_values[$i]);
}
} }
$vivio_swift_global->configs->set_value('vivio_swift_cache_exclude_cookie_values',array_values($arr_cookie_values)); $vivio_swift_global->configs->set_value('vivio_swift_cache_exclude_cookie_values',array_values($arr_cookie_values));
$vivio_swift_global->configs->save_config(); $vivio_swift_global->configs->save_config();
...@@ -48,9 +46,51 @@ class Vivio_Swift_Cache_Excludes ...@@ -48,9 +46,51 @@ class Vivio_Swift_Cache_Excludes
{ {
$required_cookie_exclusions = array("comment_author_", "wordpress_logged_in", "wp-postpass_"); $required_cookie_exclusions = array("comment_author_", "wordpress_logged_in", "wp-postpass_");
foreach ($required_cookie_exclusions as $i => $value) { foreach ($required_cookie_exclusions as $i => $value) {
if($value==$val){ if($value==$val){return true;}
return true; }
} return false;
}
function get_user_agent_values()
{
global $vivio_swift_global;
$arr_user_agent_values = $vivio_swift_global->configs->get_value('vivio_swift_cache_exclude_user_agent_values');
if(!is_array($arr_user_agent_values)){$arr_user_agent_values = array();}
return array_values($arr_user_agent_values);
}
function add_user_agent_value($val)
{
global $vivio_swift_global;
$arr_user_agent_values = $vivio_swift_global->configs->get_value('vivio_swift_cache_exclude_user_agent_values');
if(!is_array($arr_user_agent_values)){$arr_user_agent_values = array();}
if(!in_array($val,$arr_user_agent_values)){
array_push($arr_user_agent_values, $val);
$vivio_swift_global->configs->set_value('vivio_swift_cache_exclude_user_agent_values',array_values($arr_user_agent_values));
$vivio_swift_global->configs->save_config();
}
Vivio_Swift_Utility_Htaccess::write_to_htaccess();
}
function remove_user_agent_value($val)
{
global $vivio_swift_global;
$arr_user_agent_values = $vivio_swift_global->configs->get_value('vivio_swift_cache_exclude_user_agent_values');
if(!is_array($arr_user_agent_values)){$arr_user_agent_values = array();}
foreach ($arr_user_agent_values as $i => $value) {
if ($value==$val){unset($arr_user_agent_values[$i]);}
}
$vivio_swift_global->configs->set_value('vivio_swift_cache_exclude_user_agent_values',array_values($arr_user_agent_values));
$vivio_swift_global->configs->save_config();
Vivio_Swift_Utility_Htaccess::write_to_htaccess();
}
//returns true if passed user_agent value is listed in required user_agent exclusions
function user_agent_check_required_value($val)
{
$required_user_agent_exclusions = array(VIVIO_SWIFT_CACHE_BOT_NAME);
foreach ($required_user_agent_exclusions as $i => $value) {
if($value==$val){return true;}
} }
return false; return false;
} }
...@@ -171,8 +211,7 @@ class Vivio_Swift_Cache_Excludes ...@@ -171,8 +211,7 @@ class Vivio_Swift_Cache_Excludes
Vivio_Swift_Utility_Htaccess::write_to_htaccess(); Vivio_Swift_Utility_Htaccess::write_to_htaccess();
} }
// returns true if URL should be cached // returns error message is condition is hit. otherwise simply returns false.
// usage: if (process_cache_excludes()) create_cache;
function process_cache_excludes($url='',$force=0) function process_cache_excludes($url='',$force=0)
{ {
global $vivio_swift_global; global $vivio_swift_global;
...@@ -181,15 +220,17 @@ class Vivio_Swift_Cache_Excludes ...@@ -181,15 +220,17 @@ class Vivio_Swift_Cache_Excludes
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Excludes::process_cache_excludes() - processing excludes for: ".$url, 1); $vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Excludes::process_cache_excludes() - processing excludes for: ".$url, 1);
// user agent excludes // user agent excludes
/*
if(strpos($_SERVER['HTTP_USER_AGENT'],VIVIO_SWIFT_CACHE_BOT_NAME)!==false){ if(strpos($_SERVER['HTTP_USER_AGENT'],VIVIO_SWIFT_CACHE_BOT_NAME)!==false){
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Excludes::process_cache_excludes() - bot rule hit [SKIPPING]", 2); $vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Excludes::process_cache_excludes() - bot rule hit [SKIPPING]", 2);
return false; return false;
} }
*/
// POST requests exclude