Commit 52286481 authored by Jordan Michaels's avatar Jordan Michaels

alpha release 2018011901

parent 93f96a7c
No preview for this file type
This diff is collapsed.
......@@ -6,6 +6,7 @@ class Vivio_Swift_Admin {
var $dashboard_menu;
var $cache_menu;
var $compress_menu;
var $exclusions_menu;
public function __construct() {
require_once('vivio-swift-admin-messages.php');
......@@ -45,7 +46,8 @@ class Vivio_Swift_Admin {
$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'));
add_submenu_page(VIVIO_SWIFT_MAIN_MENU_SLUG, __('Compression', 'vivio-swift'), __('Compression', 'vivio-swift') , VIVIO_SWIFT_CAPABILITY, VIVIO_SWIFT_COMPRESS_MENU_SLUG, array(&$this, 'handle_compress_menu_rendering'));
//add_submenu_page(VIVIO_SWIFT_MAIN_MENU_SLUG, __('Compression', 'vivio-swift'), __('Compression', 'vivio-swift') , VIVIO_SWIFT_CAPABILITY, VIVIO_SWIFT_COMPRESS_MENU_SLUG, array(&$this, 'handle_compress_menu_rendering'));
add_submenu_page(VIVIO_SWIFT_MAIN_MENU_SLUG, __('Exclusions', 'vivio-swift'), __('Exclusions', 'vivio-swift') , VIVIO_SWIFT_CAPABILITY, VIVIO_SWIFT_EXCLUSIONS_MENU_SLUG, array(&$this, 'handle_exclusions_menu_rendering'));
}
function handle_dashboard_menu_rendering()
......@@ -65,5 +67,11 @@ class Vivio_Swift_Admin {
include_once('vivio-swift-compress-menu.php');
$this->compress_menu = new Vivio_Swift_Compress_Menu();
}
function handle_exclusions_menu_rendering()
{
include_once('vivio-swift-exclusions-menu.php');
$this->exclusions_menu = new Vivio_Swift_Exclusions_Menu();
}
}
......@@ -86,7 +86,7 @@ class Vivio_Swift_Compress_Menu extends Vivio_Swift_Admin_Messages
<div class="inside">
</div>
</div>
</div><!-- End of Site Info -->
</div>
<?php
}
......@@ -107,7 +107,7 @@ class Vivio_Swift_Compress_Menu extends Vivio_Swift_Admin_Messages
<div class="inside">
</div>
</div>
</div><!-- End of Site Info -->
</div>
<?php
}
......
This diff is collapsed.
......@@ -13,6 +13,14 @@ class Vivio_Swift_Activator{
// set default configs
Vivio_Swift_Config_Settings::add_value_configs();
// configure cron handlers
if ( !wp_next_scheduled('vivio_swift_hourly_cron_event') ) {
wp_schedule_event(time(), 'hourly', 'vivio_swift_hourly_cron_event'); //schedule an hourly cron event
}
if ( !wp_next_scheduled('vivio_swift_daily_cron_event') ) {
wp_schedule_event(time(), 'daily', 'vivio_swift_daily_cron_event'); //schedule an daily cron event
}
}
}
<?php
class Vivio_Swift_Cache_Excludes
{
function __construct()
{
global $vivio_swift_global;
}
function get_cookie_values()
{
global $vivio_swift_global;
$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();}
return array_values($arr_cookie_values);
}
function add_cookie_value($val)
{
global $vivio_swift_global;
$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(!in_array($val,$arr_cookie_values)){
array_push($arr_cookie_values, $val);
$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_Utility_Htaccess::write_to_htaccess();
}
function remove_cookie_value($val)
{
global $vivio_swift_global;
$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();}
foreach ($arr_cookie_values as $i => $value) {
if ($value==$val){
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->save_config();
Vivio_Swift_Utility_Htaccess::write_to_htaccess();
}
//returns true if passed cookie value is listed in required cookie exclusions
function cookie_check_required_value($val)
{
$required_cookie_exclusions = array("comment_author_", "wordpress_logged_in", "wp-postpass_");
foreach ($required_cookie_exclusions as $i => $value) {
if($value==$val){
return true;
}
}
return false;
}
function get_path_is_values()
{
global $vivio_swift_global;
$arr_path_is_values = $vivio_swift_global->configs->get_value('vivio_swift_cache_exclude_path_is_values');
if(!is_array($arr_path_is_values)){$arr_path_is_values = array();}
return array_values($arr_path_is_values);
}
function add_path_is_value($val)
{
global $vivio_swift_global;
$arr_path_is_values = $vivio_swift_global->configs->get_value('vivio_swift_cache_exclude_path_is_values');
if(!is_array($arr_path_is_values)){$arr_path_is_values = array();}
if(!in_array($val,$arr_path_is_values)){
array_push($arr_path_is_values, $val);
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Excludes::add_path_is_value() - saving $val to array: ".$val, 1);
$vivio_swift_global->configs->set_value('vivio_swift_cache_exclude_path_is_values',array_values($arr_path_is_values));
$vivio_swift_global->configs->save_config();
}
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Excludes::add_path_is_value() - writing .htaccess file...", 1);
Vivio_Swift_Utility_Htaccess::write_to_htaccess();
}
function remove_path_is_value($val)
{
global $vivio_swift_global;
$arr_path_is_values = $vivio_swift_global->configs->get_value('vivio_swift_cache_exclude_path_is_values');
if(!is_array($arr_path_is_values)){$arr_path_is_values = array();}
foreach ($arr_path_is_values as $i => $value) {
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Excludes::remove_path_is_value() - value=val: ".$value."=".$val, 0);
if ($value==$val){
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Excludes::remove_path_is_value() - unset i: ".$i, 0);
unset($arr_path_is_values[$i]);
}
}
$vivio_swift_global->configs->set_value('vivio_swift_cache_exclude_path_is_values',array_values($arr_path_is_values));
$vivio_swift_global->configs->save_config();
Vivio_Swift_Utility_Htaccess::write_to_htaccess();
}
function get_path_ends_with_values()
{
global $vivio_swift_global;
$arr_path_ends_with_values = $vivio_swift_global->configs->get_value('vivio_swift_cache_exclude_path_ends_with_values');
if(!is_array($arr_path_ends_with_values)){$arr_path_ends_with_values = array();}
return array_values($arr_path_ends_with_values);
}
function add_path_ends_with_value($val)
{
global $vivio_swift_global;
$arr_path_ends_with_values = $vivio_swift_global->configs->get_value('vivio_swift_cache_exclude_path_ends_with_values');
if(!is_array($arr_path_ends_with_values)){$arr_path_ends_with_values = array();}
if(!in_array($val,$arr_path_ends_with_values)){
array_push($arr_path_ends_with_values, $val);
$vivio_swift_global->configs->set_value('vivio_swift_cache_exclude_path_ends_with_values',array_values($arr_path_ends_with_values));
$vivio_swift_global->configs->save_config();
}
Vivio_Swift_Utility_Htaccess::write_to_htaccess();
}
function remove_path_ends_with_value($val)
{
global $vivio_swift_global;
$arr_path_ends_with_values = $vivio_swift_global->configs->get_value('vivio_swift_cache_exclude_path_ends_with_values');
if(!is_array($arr_path_ends_with_values)){$arr_path_ends_with_values = array();}
foreach ($arr_path_ends_with_values as $i => $value) {
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Excludes::remove_path_ends_with_value() - value=val: ".$value."=".$val, 0);
if ($value==$val){
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Excludes::remove_path_ends_with_value() - unset i: ".$i, 0);
unset($arr_path_ends_with_values[$i]);
}
}
$vivio_swift_global->configs->set_value('vivio_swift_cache_exclude_path_ends_with_values',array_values($arr_path_ends_with_values));
$vivio_swift_global->configs->save_config();
Vivio_Swift_Utility_Htaccess::write_to_htaccess();
}
function get_path_contains_values()
{
global $vivio_swift_global;
$arr_path_contains_values = $vivio_swift_global->configs->get_value('vivio_swift_cache_exclude_path_contains_values');
if(!is_array($arr_path_contains_values)){$arr_path_contains_values = array();}
return array_values($arr_path_contains_values);
}
function add_path_contains_value($val)
{
global $vivio_swift_global;
$arr_path_contains_values = $vivio_swift_global->configs->get_value('vivio_swift_cache_exclude_path_contains_values');
if(!is_array($arr_path_contains_values)){$arr_path_contains_values = array();}
if(!in_array($val,$arr_path_contains_values)){
array_push($arr_path_contains_values, $val);
$vivio_swift_global->configs->set_value('vivio_swift_cache_exclude_path_contains_values',array_values($arr_path_contains_values));
$vivio_swift_global->configs->save_config();
}
Vivio_Swift_Utility_Htaccess::write_to_htaccess();
}
function remove_path_contains_value($val)
{
global $vivio_swift_global;
$arr_path_contains_values = $vivio_swift_global->configs->get_value('vivio_swift_cache_exclude_path_contains_values');
if(!is_array($arr_path_contains_values)){$arr_path_contains_values = array();}
foreach ($arr_path_contains_values as $i => $value) {
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Excludes::remove_path_contains_value() - value=val: ".$value."=".$val, 0);
if ($value==$val){
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Excludes::remove_path_contains_value() - unset i: ".$i, 0);
unset($arr_path_contains_values[$i]);
}
}
$vivio_swift_global->configs->set_value('vivio_swift_cache_exclude_path_contains_values',array_values($arr_path_contains_values));
$vivio_swift_global->configs->save_config();
Vivio_Swift_Utility_Htaccess::write_to_htaccess();
}
// returns true if URL should be cached
// usage: if (process_cache_excludes()) create_cache;
function process_cache_excludes($url='',$force=0)
{
global $vivio_swift_global;
if(!$url){$url=$_SERVER[REQUEST_URI];}
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Excludes::process_cache_excludes() - processing excludes for: ".$url, 1);
// user agent excludes
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);
return false;
}
// POST requests exclude
if(!is_admin() && $_SERVER['REQUEST_METHOD']=="POST"){
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Excludes::process_cache_excludes() - HTTP POST rule hit [SKIPPING]", 2);
return false;
}
// query string excludes
if ($vivio_swift_global->configs->get_value('vivio_swift_cache_exclude_query_strings')=='1')
{
if(parse_url($url, PHP_URL_QUERY)){
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Excludes::process_cache_excludes() - URL query stings rule hit [SKIPPING]", 2);
return false;
}
}
// cookie excludes
// forced refreshes do not need to process cookies
if(!$force){
$arr_cookie_values=Vivio_Swift_Cache_Excludes::get_cookie_values();
foreach ($arr_cookie_values as $i => $value) {
foreach ((array)$_COOKIE as $cookie_key => $cookie_value){
$searchval='/'.$value.'/i';
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Excludes::process_cache_excludes() - Testing Cookie: ".$cookie_key, 0);
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Excludes::process_cache_excludes() - Against Cookie Exclude: ".$value, 0);
if (preg_match($searchval,$cookie_key)){
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Excludes::process_cache_excludes() - Exclude Cookie rule hit for cookie contains value: '".$value."' [SKIPPING]", 2);
return false;
} else {
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Excludes::process_cache_excludes() - NO MATCH", 0);
}
}
}
} else {
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Excludes::process_cache_excludes() - Forced refresh, skipping cookie checks.", 1);
}
/*
if($_COOKIE["comment_author_"]||$_COOKIE["wordpress_logged_in"]||$_COOKIE["wp-postpass_"]||$_COOKIE["wp_woocommerce_session"]){
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Excludes::process_cache_excludes() - Exclude Cookie rule hit [SKIPPING]", 1);
return false;
}
*/
if ($vivio_swift_global->configs->get_value('vivio_swift_cache_exclude_path_is')=='1')
{
$arr_path_is_values=Vivio_Swift_Cache_Excludes::get_path_is_values();
foreach ($arr_path_is_values as $i => $value) {
$value = '/'.$value.'/';
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Excludes::process_cache_excludes() - Testing URL: ".$url, 0);
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Excludes::process_cache_excludes() - Against Path-Is Exclude: ".$value, 0);
if ($url==$value){
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Excludes::process_cache_excludes() - Exclude 'Path Is' rule hit for path value: '".$value."' [SKIPPING]", 2);
return false;
} else {
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Excludes::process_cache_excludes() - NO MATCH", 0);
}
}
}
$vivio_swift_global->configs->add_value('vivio_swift_cache_exclude_path_contains','');//Checkbox
if ($vivio_swift_global->configs->get_value('vivio_swift_cache_exclude_path_ends_with')=='1')
{
$arr_path_ends_with_values=Vivio_Swift_Cache_Excludes::get_path_ends_with_values();
foreach ($arr_path_ends_with_values as $i => $value) {
$searchval='/\.('.$value.')$/';
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Excludes::process_cache_excludes() - Testing URL: ".$url, 0);
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Excludes::process_cache_excludes() - Against Ends-With Exclude: ".$searchval, 0);
if (preg_match($searchval,$url)){
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Excludes::process_cache_excludes() - Exclude 'Path Ends With' rule hit for value: '".$value."' [SKIPPING]", 2);
return false;
} else {
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Excludes::process_cache_excludes() - NO MATCH", 0);
}
}
}
if ($vivio_swift_global->configs->get_value('vivio_swift_cache_exclude_path_contains')=='1')
{
$arr_path_contains_values=Vivio_Swift_Cache_Excludes::get_path_contains_values();
foreach ($arr_path_contains_values as $i => $value) {
$searchval='/^.*('.$value.').*$/';
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Excludes::process_cache_excludes() - Testing URL: ".$url, 0);
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Excludes::process_cache_excludes() - Against Path-Contains Exclude: ".$searchval, 0);
if (preg_match($searchval,$url)){
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Excludes::process_cache_excludes() - Exclude 'Path Contains' rule hit for value: '".$value."' [SKIPPING]", 2);
return false;
} else {
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Excludes::process_cache_excludes() - NO MATCH", 0);
}
}
}
// tests passed. return true.
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Excludes::process_cache_excludes() - Exclude tests passed.", 1);
return true;
}
}
\ No newline at end of file
<?php
class Vivio_Swift_Cache_Extras
{
function __construct()
{
// remove query strings
$this->remove_query_strings();
add_action('vivio_swift_create_preload_cache', array(&$this, 'schedule_create_preload_cache'));
}
function remove_query_strings_qmark($src)
{
$rqs = explode('?ver', $src);
return $rqs[0];
}
function remove_query_strings_amp($src)
{
$rqs = explode('&ver', $src);
return $rqs[0];
}
function remove_query_strings()
{
global $vivio_swift_global;
if( ($vivio_swift_global->configs->get_value('vivio_swift_remove_query_strings')=='1') && (! is_admin()) ){
add_filter( 'script_loader_src', array(&$this,'remove_query_strings_qmark'), 15, 1 );
add_filter( 'style_loader_src', array(&$this,'remove_query_strings_qmark'), 15, 1 );
add_filter( 'script_loader_src', array(&$this,'remove_query_strings_amp'), 15, 1 );
add_filter( 'style_loader_src', array(&$this,'remove_query_strings_amp'), 15, 1 );
}
}
}
\ No newline at end of file
<?php
class Vivio_Swift_Cache_OnAccess
{
function __construct()
{
}
function enable()
{
global $vivio_swift_global;
// set config option to enabled
$vivio_swift_global->configs->set_value('vivio_swift_cache_enabled','1');//Checkbox
$vivio_swift_global->configs->save_config();
// update htaccess
Vivio_Swift_Utility_Htaccess::write_to_htaccess();
// log it
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_OnAccess::enable() - OnAccess Cache enabled.", 0);
}
function disable()
{
global $vivio_swift_global;
$vivio_swift_global->configs->set_value('vivio_swift_cache_enabled','');//Checkbox
$vivio_swift_global->configs->save_config();
// update htaccess
Vivio_Swift_Utility_Htaccess::write_to_htaccess();
// log it
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_OnAccess::enable() - OnAccess Cache disabled.", 0);
}
function clear()
{
global $vivio_swift_global;
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_OnAccess::clear() - Clearing OnAccess Cache...", 1);
Vivio_Swift_Utility_File::clear_cache_dir();
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_OnAccess::clear() - Resetting Preload Cache Last Run date...", 1);
$vivio_swift_global->configs->set_value('vivio_swift_preload_last_run_date','');
$vivio_swift_global->configs->save_config();
}
function create_page_cache()
{
global $vivio_swift_global;
$error = '';
// TODO manually excluded cookies, URI's, useragents, pages
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_OnAccess::create_page_cache() - creating page cache...",0);
// process exclusions
if (!Vivio_Swift_Cache_Excludes::process_cache_excludes($url)){
// if the url matches one of our excludes, don't cache it, just move on.
$error = 1;
}
if ($error==''){
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_OnAccess::create_page_cache() - loading page....",0);
ob_start(array($this, "create_page_cache_closer"));
}
}
function create_page_cache_closer($response)
{
global $vivio_swift_global;
global $wp;
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_OnAccess::create_page_cache_closer() - Initializing closer...",0);
// don't cache certain responses
if((function_exists("http_response_code")) && (http_response_code() != 200))
{
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_OnAccess::create_page_cache_closer() - 200 HTTP response not found. [SKIPPING]",2);
return $response;
}
// TODO add this to page excludes
if($GLOBALS["pagenow"] == "wp-login.php")
{
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_OnAccess::create_page_cache_closer() - current page is on exclude list. [SKIPPING]",2);
return $response;
}
// TODO add post-processors here (compression, combination, etc)
// grab the current page URL
// $url = home_url(add_query_arg(array(),$wp->request)); // doesn't include index.php
$url = $_SERVER[REQUEST_URI];
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_OnAccess::create_page_cache_closer() - URL pulled as: ".$url,0);
// parse the URI
if ( ! $uri = $vivio_swift_global->cache_obj->parse_uri($url) ){
// failed to parse URI
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_OnAccess::create_page_cache_closer() - Failed to parse: ".$url."[SKIPPING]", 4);
return $response;
}
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_OnAccess::create_page_cache_closer() - Passing off to save_cached_page()...",0);
// send page off to save util
if ($vivio_swift_global->cache_obj->save_cached_page($uri,$response,1))return $response."<!-- [Vivio Swift] cached page will be displayed next request. -->";
}
}
\ No newline at end of file
<?php
class Vivio_Swift_Cache_Preload
{
function __construct()
{
}
function enable()
{
global $vivio_swift_global;
// set config option to enabled
$vivio_swift_global->configs->set_value('vivio_swift_preload_cache_enabled','1');//Checkbox
$vivio_swift_global->configs->save_config();
// update htaccess
Vivio_Swift_Utility_Htaccess::write_to_htaccess();
// log it
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Preload::enable() - Preload Cache enabled.", 1);
}
function disable()
{
global $vivio_swift_global;
$vivio_swift_global->configs->set_value('vivio_swift_preload_cache_enabled','');//Checkbox
$vivio_swift_global->configs->save_config();
// update htaccess
Vivio_Swift_Utility_Htaccess::write_to_htaccess();
// log it
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Preload::enable() - Preload Cache disabled.", 1);
}
function clear()
{
global $vivio_swift_global;
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Preload::clear() - Clearing Preload Cache...", 1);
Vivio_Swift_Utility_File::clear_cache_dir();
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Preload::clear() - Resetting Preload Cache Last Run date...", 1);
$vivio_swift_global->configs->set_value('vivio_swift_preload_last_run_date','');
$vivio_swift_global->configs->save_config();
}
function create_preload_cache($force=0)
{
global $vivio_swift_global;
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Preload::create_preload_cache() - Create Preload Cache Init.", 0);
$urls = array();
// make sure the specified amount of time has passed before we do another run
if ( $this->verify_preload_cache_expired() || $force ) {
// TODO Add option to select mobile cache as well
// TODO Add options to select what we want to cache. For now, CACHE ALL THE THINGS
// home page URI
$home_url = rtrim(get_option("home"), '/').'/';
array_push($urls, $home_url);
// log it
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Preload::create_preload_cache() - Added HOME URI: ".get_option("home"), 1);
// post URI's
$posts = get_posts(array('post_type'=>'post','numberposts'=>'-1','post_status'=>'publish'));
if (count($posts) > 0){
foreach ($posts as $p){
if ($post_permalink = get_permalink($p)){
// if we're using permalinks, use the permalink uri
array_push($urls, $post_permalink);
// log it
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Preload::create_preload_cache() - Added POST URI: ".$post_permalink, 1);
} else {
// otherwise just log it as incompatible
$vivio_swift_global->debug_logger->log_debug("Vivio_Swift_Cache_Preload::create_preload_cache() - Failed to get Permalink for Post ID:".$p->ID."[SKIPPING]", 4);
}
} // end foreach
}
// attachment URI's
$posts = get_posts(array('post_type'=>'attachment','numberposts'=>'-1','post_status'=>'publish','post_parent' => null));
if (count($posts) > 0){
foreach ($posts as $p){
if ($post_permalink = get_permalink($p)){
// if we're using permalinks, use the permalink uri
array_push($urls, $post_permalink);