Esempio n. 1
0
function domain_mapping_gc_cache($function, $directory)
{
    global $cache_path;
    if (!function_exists('domain_mapping_warning')) {
        return false;
    }
    $siteurl = domain_mapping_siteurl(false);
    if (!$siteurl) {
        return false;
    }
    $protocol = 'on' == strtolower($_SERVER['HTTPS']) ? 'https://' : 'http://';
    $siteurl = trailingslashit(str_replace($protocol, '', $siteurl));
    if ($directory == 'homepage') {
        $directory = '';
    }
    switch ($function) {
        case "rebuild":
            @wp_cache_rebuild_or_delete($cache_path . 'supercache/' . $siteurl . $directory . 'index.html');
            @wp_cache_rebuild_or_delete($cache_path . 'supercache/' . $siteurl . $directory . 'index.html.gz');
            break;
        case "prune":
            prune_super_cache($cache_path . 'supercache/' . $siteurl . $directory . 'index.html', true, true);
            prune_super_cache($cache_path . 'supercache/' . $siteurl . $directory . 'index.html.gz', true, true);
            break;
    }
    return $directory;
}
Esempio n. 2
0
/**
 * REQUIRES WP-SUPER-CACHE
 *
 * When wp-super-cache is installed this function will clear cached pages
 * so that success/error messages are not cached, or time sensitive content.
 *
 * @package BuddyPress Core
 */
function bp_core_clear_cache()
{
    global $cache_path, $cache_filename;
    if (function_exists('prune_super_cache')) {
        do_action('bp_core_clear_cache');
        return prune_super_cache($cache_path, true);
    }
}
 function reset_caches()
 {
     global $cache_path, $file_prefix;
     if (function_exists('prune_super_cache')) {
         prune_super_cache($cache_path, true);
     }
     if (function_exists('wp_cache_clean_cache')) {
         wp_cache_clean_cache($file_prefix);
     }
 }
Esempio n. 4
0
/**
 * Prune the WP Super Cache.
 *
 * @see prune_super_cache()
 *
 * When wp-super-cache is installed this function will clear cached pages
 * so that success/error messages are not cached, or time sensitive content.
 *
 * @return int
 */
function bp_core_clear_cache()
{
    global $cache_path;
    if (function_exists('prune_super_cache')) {
        /**
         * Fires before the pruning of WP Super Cache.
         *
         * @since BuddyPress (1.0.0)
         */
        do_action('bp_core_clear_cache');
        return prune_super_cache($cache_path, true);
    }
}
function wppa_clear_cache($force = false)
{
    global $cache_path;
    // If wp-super-cache is on board, clear cache
    if (function_exists('prune_super_cache')) {
        prune_super_cache($cache_path . 'supercache/', true);
        prune_super_cache($cache_path, true);
    }
    // W3 Total cache
    if (function_exists('w3tc_pgcache_flush')) {
        w3tc_pgcache_flush();
    }
    // SG_CachePress
    /*
    if ( class_exists( 'SG_CachePress_Supercacher' ) ) {
    	$c = new SG_CachePress_Supercacher();
    	@ $c->purge_cache();
    }
    */
    // Quick cache
    if (isset($GLOBALS['quick_cache'])) {
        $GLOBALS['quick_cache']->clear_cache();
    }
    // At a setup or update operation
    // Manually remove the content of wp-content/cache/
    if ($force) {
        if (is_dir(WPPA_CONTENT_PATH . '/cache/')) {
            wppa_tree_empty(WPPA_CONTENT_PATH . '/cache');
        }
    }
}
Esempio n. 6
0
function wp_cache_post_change($post_id)
{
    global $file_prefix, $cache_path, $blog_id, $super_cache_enabled, $blog_cache_dir, $blogcacheid, $wp_cache_refresh_single_only, $wp_cache_object_cache;
    static $last_processed = -1;
    if ($post_id == $last_processed) {
        wp_cache_debug("wp_cache_post_change: Already processed post {$post_id}.", 4);
        return $post_id;
    }
    $post = get_post($post_id);
    // Some users are inexplicibly seeing this error on scheduled posts.
    // define this constant to disable the post status check.
    if (false == defined('WPSCFORCEUPDATE') && is_object($post) && $post->post_status != 'publish') {
        wp_cache_debug("wp_cache_post_change: draft post, not deleting any cache files.", 4);
        return $post_id;
    }
    $last_processed = $post_id;
    if (!wp_cache_writers_entry()) {
        return $post_id;
    }
    if (isset($wp_cache_refresh_single_only) && $wp_cache_refresh_single_only && (strpos($_SERVER['HTTP_REFERER'], 'edit-comments.php') || strpos($_SERVER['REQUEST_URI'], 'wp-comments-post.php'))) {
        if (defined('DONOTDELETECACHE')) {
            wp_cache_debug("wp_cache_post_change: comment detected and it's moderated or spam. Not deleting cached files.", 4);
            return $post_id;
        } else {
            wp_cache_debug("wp_cache_post_change: comment detected. only deleting post page.", 4);
            $all = false;
        }
    } else {
        $all = true;
    }
    if ($wp_cache_object_cache) {
        reset_oc_version();
    }
    $permalink = trailingslashit(str_replace(get_option('siteurl'), '', post_permalink($post_id)));
    if ($super_cache_enabled) {
        $dir = get_supercache_dir();
        $siteurl = trailingslashit(strtolower(preg_replace('/:.*$/', '', str_replace('https://', '', str_replace('http://', '', get_option('home'))))));
        // make sure the front page has a rebuild file
        wp_cache_post_id_gc($siteurl, $post_id);
        if ($all == true) {
            wp_cache_debug("Post change: supercache enabled: deleting cache files in " . $cache_path . 'supercache/' . $siteurl, 4);
            $files_to_check = get_all_supercache_filenames($dir);
            foreach ($files_to_check as $cache_file) {
                wp_cache_debug("Post change: deleting cache file: " . $dir . $cache_file, 4);
                prune_super_cache($dir . $cache_file, true, true);
            }
            do_action('gc_cache', 'prune', 'homepage');
        } else {
            wp_cache_debug("wp_cache_post_change: not deleting all pages.", 4);
        }
        if ($all == true && get_option('show_on_front') == 'page') {
            wp_cache_debug("Post change: deleting page_on_front and page_for_posts pages.", 4);
            wp_cache_debug("Post change: page_on_front " . get_option('page_on_front'), 4);
            wp_cache_post_id_gc($siteurl, get_option('page_on_front'), 'single');
            $permalink = trailingslashit(str_replace(get_option('home'), '', post_permalink(get_option('page_for_posts'))));
            $files_to_check = get_all_supercache_filenames($dir . $permalink);
            foreach ($files_to_check as $cache_file) {
                prune_super_cache($dir . $permalink . $cache_file, true, true);
            }
            do_action('gc_cache', 'prune', $permalink);
        } else {
            wp_cache_debug("wp_cache_post_change: not deleting front static page.", 4);
        }
    }
    wp_cache_debug("wp_cache_post_change: checking {$blog_cache_dir}meta/", 4);
    $matches = array();
    if ($handle = @opendir($blog_cache_dir . 'meta/')) {
        while (false !== ($file = readdir($handle))) {
            if (preg_match("/^({$file_prefix}{$blogcacheid}.*)\\.meta/", $file, $matches)) {
                $meta_pathname = $blog_cache_dir . 'meta/' . $file;
                $content_pathname = $blog_cache_dir . $matches[1] . ".html";
                $meta = unserialize(@file_get_contents($meta_pathname));
                if (false == is_array($meta)) {
                    wp_cache_debug("Post change cleaning up stray file: {$content_pathname}", 4);
                    @unlink($meta_pathname);
                    @unlink($content_pathname);
                    continue;
                }
                if ($post_id > 0 && $meta) {
                    $permalink = trailingslashit(str_replace(get_option('home'), '', post_permalink($post_id)));
                    if ($meta['blog_id'] == $blog_id && ($all == true && !$meta['post'] || $meta['post'] == $post_id)) {
                        wp_cache_debug("Post change: deleting post cache files for {$meta['uri']}: {$content_pathname}", 4);
                        @unlink($meta_pathname);
                        @unlink($content_pathname);
                        if ($super_cache_enabled == true) {
                            @prune_super_cache($dir . $permalink, true, true);
                            do_action('gc_cache', 'rebuild', $permalink);
                        }
                    }
                } elseif ($meta['blog_id'] == $blog_id) {
                    wp_cache_debug("Post change: deleting cache files for {$meta['uri']}: {$content_pathname}", 4);
                    @unlink($meta_pathname);
                    @unlink($content_pathname);
                    if ($super_cache_enabled == true) {
                        $files_to_check = get_all_supercache_filenames($dir . $meta['uri']);
                        foreach ($files_to_check as $cache_file) {
                            @wp_cache_rebuild_or_delete($dir . trailingslashit($meta['uri']) . $cache_file);
                        }
                        do_action('gc_cache', 'rebuild', trailingslashit($meta['uri']));
                    }
                }
            }
        }
        closedir($handle);
    }
    wp_cache_writers_exit();
    return $post_id;
}
Esempio n. 7
0
 private function clear_cache_wpsupercache()
 {
     $all = true;
     global $updraftplus, $cache_path, $wp_cache_object_cache;
     if ($wp_cache_object_cache && function_exists("reset_oc_version")) {
         reset_oc_version();
     }
     // Removed check: && wpsupercache_site_admin()
     if ($all == true && function_exists('prune_super_cache')) {
         if (!empty($cache_path)) {
             $updraftplus->log_e("Clearing cached pages (%s)...", 'WP Super Cache');
             prune_super_cache($cache_path, true);
         }
         return true;
     }
 }
Esempio n. 8
0
 public function clearCache()
 {
     if (SAM_WPSC) {
         global $blog_cache_dir, $wp_cache_object_cache;
         if ($wp_cache_object_cache) {
             reset_oc_version();
         } else {
             prune_super_cache($blog_cache_dir, true);
             prune_super_cache(get_supercache_dir(), true);
         }
         return __('Cache of WP Super Cache plugin is flushed.', SAM_DOMAIN);
     } elseif (SAM_W3TC) {
         if (function_exists('w3tc_pgcache_flush')) {
             w3tc_pgcache_flush();
         }
         if (function_exists('w3tc_dbcache_flush')) {
             w3tc_dbcache_flush();
         }
         return __('Cache of W3 Total Cache plugin is flushed.', SAM_DOMAIN);
     } else {
         return '';
     }
 }
 static function clearall()
 {
     //Cache not available :(
     if (!autoptimizeCache::cacheavail()) {
         return false;
     }
     //Clean the cachedir
     $scan = scandir(AUTOPTIMIZE_CACHE_DIR);
     foreach ($scan as $file) {
         if (!in_array($file, array('.', '..')) && strpos($file, 'autoptimize') !== false && is_file(AUTOPTIMIZE_CACHE_DIR . $file)) {
             @unlink(AUTOPTIMIZE_CACHE_DIR . $file);
         }
     }
     //Do we need to clean WP Super Cache's cache files?
     if (function_exists('wp_cache_clear_cache')) {
         //Newer WP-Super-Cache
         //See http://ocaoimh.ie/wp-super-cache-developers/
         wp_cache_clear_cache();
     } elseif (file_exists(WP_CONTENT_DIR . '/wp-cache-config.php') && function_exists('prune_super_cache')) {
         //Old WP-Super-Cache
         global $cache_path;
         prune_super_cache($cache_path . 'supercache/', true);
         prune_super_cache($cache_path, true);
     }
     return true;
 }
Esempio n. 10
0
 /**
  *
  *  Flush rewrites/cached css
  *
  *  @package PageLines DMS
  *  @since 2.2
  */
 static function flush_version($rules = true)
 {
     $types = array('sections', 'core', 'custom');
     $folder = trailingslashit(pl_get_css_dir('path'));
     if ('1' == pl_setting('alternative_css')) {
         $file = 'compiled-css-core.css';
     } else {
         $file = sprintf('compiled-css-core-%s.css', get_theme_mod('pl_save_version'));
     }
     if (is_file($folder . $file)) {
         @unlink($folder . $file);
     }
     if ('1' == pl_setting('alternative_css')) {
         $file = 'compiled-css-sections.css';
     } else {
         $file = sprintf('compiled-css-sections-%s.css', get_theme_mod('pl_save_version'));
     }
     if (is_file($folder . $file)) {
         @unlink($folder . $file);
     }
     // Attempt to flush super-cache and w3 cache.
     if (function_exists('prune_super_cache')) {
         global $cache_path;
         $GLOBALS["super_cache_enabled"] = 1;
         prune_super_cache($cache_path . 'supercache/', true);
         prune_super_cache($cache_path, true);
     }
     if ($rules) {
         flush_rewrite_rules(true);
     }
     set_theme_mod('pl_save_version', time());
     $types = array('sections', 'core', 'custom');
     foreach ($types as $t) {
         $compiled = get_transient("pagelines_{$t}_css");
         $backup = get_transient("pagelines_{$t}_css_backup");
         if (!is_array($backup) && is_array($compiled) && strpos($compiled[$t], 'PARSE ERROR') === false) {
             set_transient("pagelines_{$t}_css_backup", $compiled, 604800);
         }
         delete_transient("pagelines_{$t}_css");
     }
 }
Esempio n. 11
0
 function a_clear_super_cache()
 {
     if (function_exists('prune_super_cache')) {
         prune_super_cache(WP_CONTENT_DIR . '/cache/', true);
     }
 }
Esempio n. 12
0
 /**
  *
  *  Flush rewrites/cached css
  *
  *  @package PageLines Framework
  *  @since 2.2
  */
 public static function flush_version($rules = true)
 {
     // Attempt to flush super-cache.
     if (function_exists('prune_super_cache')) {
         global $cache_path;
         $GLOBALS["super_cache_enabled"] = 1;
         prune_super_cache($cache_path . 'supercache/', true);
         prune_super_cache($cache_path, true);
     }
     // Attempt to flush w3 cache.
     if (class_exists('W3_Plugin_TotalCacheAdmin')) {
         $plugin_totalcacheadmin =& w3_instance('W3_Plugin_TotalCacheAdmin');
         $plugin_totalcacheadmin->flush_all();
     }
     if ($rules) {
         flush_rewrite_rules(true);
     }
     foreach (self::$types as $t) {
         $css_path = self::get_css_dir('path');
         foreach (array($t, "{$t}.min") as $type) {
             $filename = self::get_compiled_filename($type);
             $filepath = path_join($css_path, $filename);
             if (is_file($filepath)) {
                 @unlink($filepath);
             }
         }
         $compiled = get_transient("pagelines_{$t}_css");
         $backup = get_transient("pagelines_{$t}_css_backup");
         if (!is_array($backup) && is_array($compiled) && strpos($compiled[$t], 'PARSE ERROR') === false) {
             set_transient("pagelines_{$t}_css_backup", $compiled, 604800);
         }
         delete_transient("pagelines_{$t}_css");
     }
     set_theme_mod('pl_save_version', time());
 }
 /**
  * ์บ์‹œ ํ”Œ๋Ÿฌ๊ทธ์ธ์˜ ์บ์‹œ๋ฅผ ์‚ญ์ œํ•œ๋‹ค.
  * @return boolen
  */
 public function clearCache()
 {
     global $cache_path;
     // WP-SUPER-CACHE
     if (function_exists('prune_super_cache')) {
         prune_super_cache($cache_path . 'supercache/', true);
         prune_super_cache($cache_path, true);
     }
 }
Esempio n. 14
0
 /**
  * Flush Super Cache and W3 Total Cache
  * 
  * @return void
  **/
 public static function flush_plugin_caches()
 {
     if (function_exists('prune_super_cache')) {
         global $cache_path;
         prune_super_cache($cache_path . 'supercache/', true);
         prune_super_cache($cache_path, true);
     }
     if (class_exists('W3_Plugin_TotalCache')) {
         if (function_exists('w3_instance')) {
             $w3_plugin_totalcache =& w3_instance('W3_Plugin_TotalCache');
         } elseif (is_callable(array('W3_Plugin_TotalCache', 'instance'))) {
             $w3_plugin_totalcache =& W3_Plugin_TotalCache::instance();
         }
         if (method_exists($w3_plugin_totalcache, 'flush')) {
             $w3_plugin_totalcache->flush();
         } elseif (method_exists($w3_plugin_totalcache, 'flush_all')) {
             $w3_plugin_totalcache->flush_all();
         }
         /* Flush varnish */
         if (function_exists('w3tc_varnish_flush')) {
             w3tc_varnish_flush();
         }
     }
 }
Esempio n. 15
0
function wp_cache_post_change($post_id)
{
    global $file_prefix, $cache_path, $blog_id, $blogcacheid, $super_cache_enabled;
    static $last_processed = -1;
    if ($post_id == $last_processed) {
        return $post_id;
    }
    $last_processed = $post_id;
    if (!wp_cache_writers_entry()) {
        return $post_id;
    }
    $permalink = trailingslashit(str_replace(get_option('siteurl'), '', post_permalink($post_id)));
    if ($super_cache_enabled) {
        $siteurl = trailingslashit(strtolower(preg_replace('/:.*$/', '', str_replace('http://', '', get_option('home')))));
        // make sure the front page has a rebuild file
        prune_super_cache($cache_path . 'supercache/' . $siteurl . 'index.html', true, true);
        prune_super_cache($cache_path . 'supercache/' . $siteurl . 'index.html.gz', true, true);
        if ($post_id != 0) {
            $permalink = trailingslashit(str_replace(get_option('home'), '', post_permalink($post_id)));
            $dir = $cache_path . 'supercache/' . $siteurl;
            prune_super_cache($dir . $permalink, true, true);
            @rmdir($dir . $permalink);
            prune_super_cache($dir . 'page/', true);
        }
    }
    $meta = new CacheMeta();
    $matches = array();
    if ($handle = opendir($cache_path . 'meta/')) {
        while (false !== ($file = readdir($handle))) {
            if (preg_match("/^({$file_prefix}{$blogcacheid}.*)\\.meta/", $file, $matches)) {
                $meta_pathname = $cache_path . 'meta/' . $file;
                $content_pathname = $cache_path . $matches[1] . ".html";
                $meta = unserialize(@file_get_contents($meta_pathname));
                if ($post_id > 0 && $meta) {
                    if ($meta->blog_id == $blog_id && (!$meta->post || $meta->post == $post_id)) {
                        @unlink($meta_pathname);
                        @unlink($content_pathname);
                    }
                } elseif ($meta->blog_id == $blog_id) {
                    @unlink($meta_pathname);
                    @unlink($content_pathname);
                }
            }
        }
        closedir($handle);
    }
    wp_cache_writers_exit();
    return $post_id;
}
Esempio n. 16
0
function wp_cron_preload_cache()
{
    global $wpdb, $wp_cache_preload_interval, $wp_cache_preload_posts, $wp_cache_preload_email_me, $wp_cache_preload_email_volume, $cache_path;
    if (get_option('preload_cache_stop')) {
        delete_option('preload_cache_stop');
        return true;
    }
    $mutex = $cache_path . "preload_mutex.tmp";
    sleep(3 + mt_rand(1, 5));
    if (@file_exists($mutex)) {
        if (@filemtime($mutex) > time() - 600) {
            return true;
        } else {
            @unlink($mutex);
        }
    }
    $fp = @fopen($mutex, 'w');
    @fclose($fp);
    $counter = get_option('preload_cache_counter');
    if (is_array($counter) == false) {
        $counter = array('c' => 0, 't' => time());
        update_option('preload_cache_counter', $counter);
    }
    $c = $counter['c'];
    if ($wp_cache_preload_email_me && $c == 0) {
        wp_mail(get_option('admin_email'), sprintf(__('[%1$s] Cache Preload Started', 'wp-super-cache'), site_url(), ''), ' ');
    }
    $taxonomies = apply_filters('wp_cache_preload_taxonomies', array('post_tag' => 'tag', 'category' => 'category'));
    $finished = false;
    $permalink_counter_msg = $cache_path . "preload_permalink.txt";
    foreach ($taxonomies as $taxonomy => $path) {
        $taxonomy_filename = $cache_path . "taxonomy_" . $taxonomy . ".txt";
        if ($c == 0) {
            @unlink($taxonomy_filename);
        }
        if (false == @file_exists($taxonomy_filename)) {
            $out = '';
            $records = get_terms($taxonomy);
            foreach ($records as $term) {
                $out .= site_url($path . "/" . $term->slug . "/") . "\n";
            }
            $fp = fopen($taxonomy_filename, 'w');
            if ($fp) {
                fwrite($fp, $out);
                fclose($fp);
            }
            $details = explode("\n", $out);
        } else {
            $details = explode("\n", file_get_contents($taxonomy_filename));
        }
        if (count($details) != 1 && $details[0] != '') {
            $rows = array_splice($details, 0, 50);
            if ($wp_cache_preload_email_me && $wp_cache_preload_email_volume == 'many') {
                wp_mail(get_option('admin_email'), sprintf(__('[%1$s] Refreshing %2$s taxonomy from %3$d to %4$d', 'wp-super-cache'), site_url(), $taxonomy, $c, $c + 100), 'Refreshing: ' . print_r($rows, 1));
            }
            foreach ((array) $rows as $url) {
                set_time_limit(60);
                if ($url == '') {
                    continue;
                }
                $url_info = parse_url($url);
                $dir = get_supercache_dir() . $url_info['path'];
                prune_super_cache($dir);
                $fp = @fopen($permalink_counter_msg, 'w');
                if ($fp) {
                    @fwrite($fp, "{$taxonomy}: {$url}");
                    @fclose($fp);
                }
                wp_remote_get($url, array('timeout' => 60, 'blocking' => true));
                sleep(1);
            }
            $fp = fopen($taxonomy_filename, 'w');
            if ($fp) {
                fwrite($fp, implode("\n", $details));
                fclose($fp);
            }
        }
    }
    if ($wp_cache_preload_posts == 'all' || $c <= $wp_cache_preload_posts) {
        $posts = $wpdb->get_col("SELECT ID FROM {$wpdb->posts} WHERE ( post_type != 'revision' AND post_type != 'nav_menu_item' ) AND post_status = 'publish' ORDER BY post_date DESC LIMIT {$c}, 100");
    } else {
        $posts = false;
    }
    if (!isset($wp_cache_preload_email_volume)) {
        $wp_cache_preload_email_volume = 'medium';
    }
    update_option('preload_cache_counter', array('c' => $c + 100, 't' => time()));
    if ($posts) {
        if ($wp_cache_preload_email_me && $wp_cache_preload_email_volume == 'many') {
            wp_mail(get_option('admin_email'), sprintf(__('[%1$s] Refreshing posts from %2$d to %3$d', 'wp-super-cache'), site_url(), $c, $c + 100), ' ');
        }
        $msg = '';
        $count = $c + 1;
        $permalink_counter_msg = $cache_path . "preload_permalink.txt";
        foreach ($posts as $post_id) {
            set_time_limit(60);
            clear_post_supercache($post_id);
            $url = get_permalink($post_id);
            $fp = @fopen($permalink_counter_msg, 'w');
            if ($fp) {
                @fwrite($fp, $count . " " . $url);
                @fclose($fp);
            }
            if (@file_exists($cache_path . "stop_preload.txt")) {
                @unlink($mutex);
                @unlink($cache_path . "stop_preload.txt");
                update_option('preload_cache_counter', array('c' => 0, 't' => time()));
                if ($wp_cache_preload_email_me) {
                    wp_mail(get_option('admin_email'), sprintf(__('[%1$s] Cache Preload Stopped', 'wp-super-cache'), site_url(), ''), ' ');
                }
                return true;
            }
            $msg .= "{$url}\n";
            wp_remote_get($url, array('timeout' => 60, 'blocking' => true));
            sleep(1);
            $count++;
        }
        if ($wp_cache_preload_email_me && $wp_cache_preload_email_volume != 'less') {
            wp_mail(get_option('admin_email'), sprintf(__('[%1$s] %2$d posts refreshed', 'wp-super-cache'), $_SERVER['HTTP_HOST'], $c + 100), __("Refreshed the following posts:", 'wp-super-cache') . "\n{$msg}");
        }
        if (defined('DOING_CRON')) {
            wp_schedule_single_event(time() + 30, 'wp_cache_preload_hook');
        }
    } else {
        $msg = '';
        update_option('preload_cache_counter', array('c' => 0, 't' => time()));
        if ((int) $wp_cache_preload_interval && defined('DOING_CRON')) {
            if ($wp_cache_preload_email_me) {
                $msg = sprintf(__('Scheduling next preload refresh in %d minutes.', 'wp-super-cache'), (int) $wp_cache_preload_interval);
            }
            wp_schedule_single_event(time() + (int) $wp_cache_preload_interval * 60, 'wp_cache_full_preload_hook');
        }
        global $file_prefix, $cache_max_time;
        if ($wp_cache_preload_interval > 0) {
            $cache_max_time = (int) $wp_cache_preload_interval * 60;
            // fool the GC into expiring really old files
        } else {
            $cache_max_time = 86400;
            // fool the GC into expiring really old files
        }
        if ($wp_cache_preload_email_me) {
            wp_mail(get_option('admin_email'), sprintf(__('[%s] Cache Preload Completed', 'wp-super-cache'), site_url()), __("Cleaning up old supercache files.", 'wp-super-cache') . "\n" . $msg);
        }
        wp_cache_phase2_clean_expired($file_prefix, true);
        // force cleanup of old files.
    }
    @unlink($mutex);
}
Esempio n. 17
0
 static function clearall()
 {
     if (!autoptimizeCache::cacheavail()) {
         return false;
     }
     // scan the cachedirs
     foreach (array("", "js", "css") as $scandirName) {
         $scan[$scandirName] = scandir(AUTOPTIMIZE_CACHE_DIR . $scandirName);
     }
     // clear the cachedirs
     foreach ($scan as $scandirName => $scanneddir) {
         $thisAoCacheDir = rtrim(AUTOPTIMIZE_CACHE_DIR . $scandirName, "/") . "/";
         foreach ($scanneddir as $file) {
             if (!in_array($file, array('.', '..')) && strpos($file, 'autoptimize') !== false && is_file($thisAoCacheDir . $file)) {
                 @unlink($thisAoCacheDir . $file);
             }
         }
     }
     @unlink(AUTOPTIMIZE_CACHE_DIR . "/.htaccess");
     // Do we need to clean any caching plugins cache-files?
     if (function_exists('wp_cache_clear_cache')) {
         if (is_multisite()) {
             $blog_id = get_current_blog_id();
             wp_cache_clear_cache($blog_id);
         } else {
             wp_cache_clear_cache();
         }
     } else {
         if (function_exists('w3tc_pgcache_flush')) {
             w3tc_pgcache_flush();
             // w3 total cache
         } else {
             if (function_exists('hyper_cache_invalidate')) {
                 hyper_cache_invalidate();
                 // hypercache
             } else {
                 if (function_exists('wp_fast_cache_bulk_delete_all')) {
                     wp_fast_cache_bulk_delete_all();
                     // wp fast cache
                 } else {
                     if (class_exists("WpFastestCache")) {
                         $wpfc = new WpFastestCache();
                         // wp fastest cache
                         $wpfc->deleteCache();
                     } else {
                         if (class_exists("c_ws_plugin__qcache_purging_routines")) {
                             c_ws_plugin__qcache_purging_routines::purge_cache_dir();
                             // quick cache
                         } else {
                             if (file_exists(WP_CONTENT_DIR . '/wp-cache-config.php') && function_exists('prune_super_cache')) {
                                 // fallback for WP-Super-Cache
                                 global $cache_path;
                                 if (is_multisite()) {
                                     $blog_id = get_current_blog_id();
                                     prune_super_cache(get_supercache_dir($blog_id), true);
                                     prune_super_cache($cache_path . 'blogs/', true);
                                 } else {
                                     prune_super_cache($cache_path . 'supercache/', true);
                                     prune_super_cache($cache_path, true);
                                 }
                             } else {
                                 // fallback; schedule event and try to clear there
                                 wp_schedule_single_event(time() + 1, 'ao_flush_pagecache', array(time()));
                             }
                         }
                     }
                 }
             }
         }
     }
     return true;
 }
Esempio n. 18
0
function autoptimize_flush_pagecache($nothing)
{
    if (function_exists('wp_cache_clear_cache')) {
        if (is_multisite()) {
            $blog_id = get_current_blog_id();
            wp_cache_clear_cache($blog_id);
        } else {
            wp_cache_clear_cache();
        }
    } else {
        if (has_action('cachify_flush_cache')) {
            do_action('cachify_flush_cache');
        } else {
            if (function_exists('w3tc_pgcache_flush')) {
                w3tc_pgcache_flush();
                // w3 total cache
            } else {
                if (function_exists('hyper_cache_invalidate')) {
                    hyper_cache_invalidate();
                    // hypercache
                } else {
                    if (function_exists('wp_fast_cache_bulk_delete_all')) {
                        wp_fast_cache_bulk_delete_all();
                        // wp fast cache
                    } else {
                        if (class_exists("WpFastestCache")) {
                            $wpfc = new WpFastestCache();
                            // wp fastest cache
                            $wpfc->deleteCache();
                        } else {
                            if (class_exists("c_ws_plugin__qcache_purging_routines")) {
                                c_ws_plugin__qcache_purging_routines::purge_cache_dir();
                                // quick cache
                            } else {
                                if (file_exists(WP_CONTENT_DIR . '/wp-cache-config.php') && function_exists('prune_super_cache')) {
                                    // fallback for WP-Super-Cache
                                    global $cache_path;
                                    if (is_multisite()) {
                                        $blog_id = get_current_blog_id();
                                        prune_super_cache(get_supercache_dir($blog_id), true);
                                        prune_super_cache($cache_path . 'blogs/', true);
                                    } else {
                                        prune_super_cache($cache_path . 'supercache/', true);
                                        prune_super_cache($cache_path, true);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
function wp_cache_post_change($post_id)
{
    global $file_prefix, $cache_path, $blog_id, $super_cache_enabled, $blog_cache_dir, $blogcacheid, $wp_cache_refresh_single_only;
    static $last_processed = -1;
    if ($post_id == $last_processed) {
        return $post_id;
    }
    $last_processed = $post_id;
    $post = get_post($post_id);
    if ($post->post_status == 'draft') {
        if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
            wp_cache_debug("wp_cache_post_change: draft post, not deleting any cache files.", 4);
        }
        return $post_id;
    }
    if (!wp_cache_writers_entry()) {
        return $post_id;
    }
    if (isset($wp_cache_refresh_single_only) && $wp_cache_refresh_single_only && strpos($_SERVER['REQUEST_URI'], 'wp-comments-post.php')) {
        if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
            wp_cache_debug("wp_cache_post_change: comment detected. only deleting post page.", 4);
        }
        $all = false;
    } else {
        $all = true;
    }
    if ($wp_cache_object_cache) {
        reset_oc_version();
    }
    $permalink = trailingslashit(str_replace(get_option('siteurl'), '', post_permalink($post_id)));
    if ($super_cache_enabled) {
        $dir = get_supercache_dir();
        $siteurl = trailingslashit(strtolower(preg_replace('/:.*$/', '', str_replace('http://', '', get_option('home')))));
        // make sure the front page has a rebuild file
        wp_cache_post_id_gc($siteurl, $post_id);
        // make sure the front page has a rebuild file
        if ($all == true) {
            if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
                wp_cache_debug("Post change: deleting cache files in " . $cache_path . 'supercache/' . $siteurl, 4);
            }
            $files_to_check = get_all_supercache_filenames($dir);
            foreach ($files_to_check as $cache_file) {
                prune_super_cache($dir . $cache_file, true, true);
            }
            do_action('gc_cache', 'prune', 'homepage');
        }
        wp_cache_post_id_gc($siteurl, $post_id);
        if ($all == true && get_option('show_on_front') == 'page') {
            if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
                wp_cache_debug("Post change: deleting page_on_front and page_for_posts pages.", 4);
            }
            if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
                wp_cache_debug("Post change: page_on_front " . get_option('page_on_front'), 4);
            }
            wp_cache_post_id_gc($siteurl, get_option('page_on_front'), 'single');
            $permalink = trailingslashit(str_replace(get_option('home'), '', post_permalink(get_option('page_for_posts'))));
            $files_to_check = get_all_supercache_filenames($dir . $permalink);
            foreach ($files_to_check as $cache_file) {
                prune_super_cache($dir . $permalink . $cache_file, true, true);
            }
            do_action('gc_cache', 'prune', $permalink);
        }
    }
    $matches = array();
    if ($handle = @opendir($blog_cache_dir . 'meta/')) {
        while (false !== ($file = readdir($handle))) {
            if (preg_match("/^({$file_prefix}{$blogcacheid}.*)\\.meta/", $file, $matches)) {
                $meta_pathname = $blog_cache_dir . 'meta/' . $file;
                $content_pathname = $blog_cache_dir . $matches[1] . ".html";
                $meta = unserialize(@file_get_contents($meta_pathname));
                if (false == is_array($meta)) {
                    if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
                        wp_cache_debug("Post change cleaning up stray file: {$content_pathname}", 4);
                    }
                    @unlink($meta_pathname);
                    @unlink($content_pathname);
                    continue;
                }
                if ($post_id > 0 && $meta) {
                    $permalink = trailingslashit(str_replace(get_option('home'), '', post_permalink($post_id)));
                    if ($meta['blog_id'] == $blog_id && ($all == true && !$meta['post'] || $meta['post'] == $post_id)) {
                        if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
                            wp_cache_debug("Post change: deleting post cache files for {$meta['uri']}: {$content_pathname}", 4);
                        }
                        @unlink($meta_pathname);
                        @unlink($content_pathname);
                        if ($super_cache_enabled == true) {
                            @prune_super_cache($dir . $permalink, true, true);
                            do_action('gc_cache', 'rebuild', $permalink);
                        }
                    }
                } elseif ($meta['blog_id'] == $blog_id) {
                    if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
                        wp_cache_debug("Post change: deleting cache files for {$meta['uri']}: {$content_pathname}", 4);
                    }
                    @unlink($meta_pathname);
                    @unlink($content_pathname);
                    if ($super_cache_enabled == true) {
                        $files_to_check = get_all_supercache_filenames($dir . $meta['uri']);
                        foreach ($files_to_check as $cache_file) {
                            @wp_cache_rebuild_or_delete($dir . trailingslashit($meta['uri']) . $cache_file);
                        }
                        do_action('gc_cache', 'rebuild', trailingslashit($meta['uri']));
                    }
                }
            }
        }
        closedir($handle);
    }
    wp_cache_writers_exit();
    return $post_id;
}
Esempio n. 20
0
function wp_cache_post_change($post_id)
{
    global $file_prefix, $cache_path, $blog_id, $super_cache_enabled, $blog_cache_dir, $blogcacheid;
    static $last_processed = -1;
    if ($post_id == $last_processed) {
        return $post_id;
    }
    $last_processed = $post_id;
    if (!wp_cache_writers_entry()) {
        return $post_id;
    }
    $permalink = trailingslashit(str_replace(get_option('siteurl'), '', post_permalink($post_id)));
    if ($super_cache_enabled) {
        $siteurl = trailingslashit(strtolower(preg_replace('/:.*$/', '', str_replace('http://', '', get_option('home')))));
        // make sure the front page has a rebuild file
        if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
            wp_cache_debug("Post change: deleting cache files in " . $cache_path . 'supercache/' . $siteurl, 4);
        }
        prune_super_cache($cache_path . 'supercache/' . $siteurl . 'index.html', true, true);
        prune_super_cache($cache_path . 'supercache/' . $siteurl . 'index.html.gz', true, true);
        wp_cache_post_id_gc($siteurl, $post_id);
        if (get_option('show_on_front') == 'page') {
            wp_cache_post_id_gc($siteurl, get_option('page_on_front'));
            wp_cache_post_id_gc($siteurl, get_option('page_for_posts'));
        }
    }
    $matches = array();
    if ($handle = @opendir($blog_cache_dir . 'meta/')) {
        while (false !== ($file = readdir($handle))) {
            if (preg_match("/^({$file_prefix}{$blogcacheid}.*)\\.meta/", $file, $matches)) {
                $meta_pathname = $blog_cache_dir . 'meta/' . $file;
                $content_pathname = $blog_cache_dir . $matches[1] . ".html";
                $meta = unserialize(@file_get_contents($meta_pathname));
                if (false == is_array($meta)) {
                    @unlink($meta_pathname);
                    @unlink($content_pathname);
                    continue;
                }
                if ($post_id > 0 && $meta) {
                    if ($meta['blog_id'] == $blog_id && (!$meta['post'] || $meta['post'] == $post_id)) {
                        @unlink($meta_pathname);
                        @unlink($content_pathname);
                        @wp_cache_rebuild_or_delete($cache_path . 'supercache/' . trailingslashit($meta['uri']) . 'index.html');
                        @wp_cache_rebuild_or_delete($cache_path . 'supercache/' . trailingslashit($meta['uri']) . 'index.html.gz');
                    }
                } elseif ($meta['blog_id'] == $blog_id) {
                    @unlink($meta_pathname);
                    @unlink($content_pathname);
                    @wp_cache_rebuild_or_delete($cache_path . 'supercache/' . trailingslashit($meta['uri']) . 'index.html');
                    @wp_cache_rebuild_or_delete($cache_path . 'supercache/' . trailingslashit($meta['uri']) . 'index.html.gz');
                }
            }
        }
        closedir($handle);
    }
    wp_cache_writers_exit();
    return $post_id;
}
function autoptimize_flush_pagecache()
{
    if (function_exists('wp_cache_clear_cache')) {
        if (is_multisite()) {
            $blog_id = get_current_blog_id();
            wp_cache_clear_cache($blog_id);
        } else {
            wp_cache_clear_cache();
        }
    } else {
        if (has_action('cachify_flush_cache')) {
            do_action('cachify_flush_cache');
        } else {
            if (function_exists('w3tc_pgcache_flush')) {
                w3tc_pgcache_flush();
            } else {
                if (function_exists('wp_fast_cache_bulk_delete_all')) {
                    wp_fast_cache_bulk_delete_all();
                    // still to retest
                } else {
                    if (class_exists("WpFastestCache")) {
                        $wpfc = new WpFastestCache();
                        $wpfc->deleteCache();
                    } else {
                        if (class_exists("c_ws_plugin__qcache_purging_routines")) {
                            c_ws_plugin__qcache_purging_routines::purge_cache_dir();
                            // quick cache, still to retest
                        } else {
                            if (class_exists("zencache")) {
                                zencache::clear();
                            } else {
                                if (class_exists("comet_cache")) {
                                    comet_cache::clear();
                                } else {
                                    if (class_exists("WpeCommon")) {
                                        if (apply_filters('autoptimize_flush_wpengine_aggressive', false)) {
                                            if (method_exists("WpeCommon", "purge_memcached")) {
                                                WpeCommon::purge_memcached();
                                            }
                                            if (method_exists("WpeCommon", "clear_maxcdn_cache")) {
                                                WpeCommon::clear_maxcdn_cache();
                                            }
                                        }
                                        if (method_exists("WpeCommon", "purge_varnish_cache")) {
                                            WpeCommon::purge_varnish_cache();
                                        }
                                    } else {
                                        if (file_exists(WP_CONTENT_DIR . '/wp-cache-config.php') && function_exists('prune_super_cache')) {
                                            // fallback for WP-Super-Cache
                                            global $cache_path;
                                            if (is_multisite()) {
                                                $blog_id = get_current_blog_id();
                                                prune_super_cache(get_supercache_dir($blog_id), true);
                                                prune_super_cache($cache_path . 'blogs/', true);
                                            } else {
                                                prune_super_cache($cache_path . 'supercache/', true);
                                                prune_super_cache($cache_path, true);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
Esempio n. 22
0
function wp_cache_clean_expired($file_prefix)
{
    global $cache_path, $cache_max_time;
    // If phase2 was compiled, use its function to avoid race-conditions
    if (function_exists('wp_cache_phase2_clean_expired')) {
        if (function_exists('prune_super_cache')) {
            $dir = $cache_path . 'supercache/' . preg_replace('/:.*$/', '', $_SERVER["HTTP_HOST"]);
            if (is_dir($dir)) {
                prune_super_cache($dir);
            } elseif (is_dir($dir . '.disabled')) {
                prune_super_cache($dir . '.disabled');
            }
            $_POST['super_cache_stats'] = 1;
            // regenerate super cache stats;
        }
        return wp_cache_phase2_clean_expired($file_prefix);
    }
    $expr = "/^{$file_prefix}/";
    $now = time();
    if ($handle = opendir($cache_path)) {
        while (false !== ($file = readdir($handle))) {
            if (preg_match($expr, $file) && filemtime($cache_path . $file) + $cache_max_time <= $now) {
                unlink($cache_path . $file);
                unlink($cache_path . 'meta/' . str_replace('.html', '.term', $file));
            }
        }
        closedir($handle);
    }
}
Esempio n. 23
0
 /**
  *
  *  Flush rewrites/cached css
  *
  *  @package PageLines DMS
  *  @since 2.2
  */
 static function flush_version($rules = true)
 {
     $types = array('sections', 'core', 'custom');
     $folder = trailingslashit(pl_get_css_dir('path'));
     // clean css files
     self::prune_css_files();
     // Attempt to flush super-cache and w3 cache.
     if (function_exists('prune_super_cache')) {
         global $cache_path;
         $GLOBALS["super_cache_enabled"] = 1;
         prune_super_cache($cache_path . 'supercache/', true);
         prune_super_cache($cache_path, true);
     }
     if ($rules) {
         flush_rewrite_rules(true);
     }
     set_theme_mod('pl_save_version', time());
     $types = array('sections', 'core', 'custom');
     foreach ($types as $t) {
         $compiled = get_transient("pagelines_{$t}_css");
         $backup = get_transient("pagelines_{$t}_css_backup");
         if (!is_array($backup) && is_array($compiled) && strpos($compiled[$t], 'PARSE ERROR') === false) {
             set_transient("pagelines_{$t}_css_backup", $compiled, 604800);
         }
         delete_transient("pagelines_{$t}_css");
     }
 }
function wp_cron_preload_cache()
{
    global $wpdb, $wp_cache_preload_interval, $wp_cache_preload_posts, $wp_cache_preload_email_me, $wp_cache_preload_email_volume, $cache_path, $wp_cache_preload_taxonomies;
    if (get_option('preload_cache_stop')) {
        delete_option('preload_cache_stop');
        wp_cache_debug("wp_cron_preload_cache: preload cancelled", 1);
        return true;
    }
    $mutex = $cache_path . "preload_mutex.tmp";
    sleep(3 + mt_rand(1, 5));
    if (@file_exists($mutex)) {
        if (@filemtime($mutex) > time() - 600) {
            wp_cache_debug("wp_cron_preload_cache: preload mutex found and less than 600 seconds old. Aborting preload.", 1);
            return true;
        } else {
            wp_cache_debug("wp_cron_preload_cache: old preload mutex found and deleted. Preload continues.", 1);
            @unlink($mutex);
        }
    }
    $fp = @fopen($mutex, 'w');
    @fclose($fp);
    $counter = get_option('preload_cache_counter');
    if (is_array($counter) == false) {
        wp_cache_debug("wp_cron_preload_cache: setting up preload for the first time!", 5);
        $counter = array('c' => 0, 't' => time());
        update_option('preload_cache_counter', $counter);
    }
    $c = $counter['c'];
    update_option('preload_cache_counter', array('c' => $c + 100, 't' => time()));
    if ($wp_cache_preload_email_me && $c == 0) {
        wp_mail(get_option('admin_email'), sprintf(__('[%1$s] Cache Preload Started', 'wp-super-cache'), home_url(), ''), ' ');
    }
    if ($wp_cache_preload_posts == 'all' || $c < $wp_cache_preload_posts) {
        wp_cache_debug("wp_cron_preload_cache: doing taxonomy preload.", 5);
        $permalink_counter_msg = $cache_path . "preload_permalink.txt";
        if (isset($wp_cache_preload_taxonomies) && $wp_cache_preload_taxonomies) {
            $taxonomies = apply_filters('wp_cache_preload_taxonomies', array('post_tag' => 'tag', 'category' => 'category'));
            foreach ($taxonomies as $taxonomy => $path) {
                $taxonomy_filename = $cache_path . "taxonomy_" . $taxonomy . ".txt";
                if ($c == 0) {
                    @unlink($taxonomy_filename);
                }
                if (false == @file_exists($taxonomy_filename)) {
                    $out = '';
                    $records = get_terms($taxonomy);
                    foreach ($records as $term) {
                        $out .= get_term_link($term) . "\n";
                    }
                    $fp = fopen($taxonomy_filename, 'w');
                    if ($fp) {
                        fwrite($fp, $out);
                        fclose($fp);
                    }
                    $details = explode("\n", $out);
                } else {
                    $details = explode("\n", file_get_contents($taxonomy_filename));
                }
                if (count($details) != 1 && $details[0] != '') {
                    $rows = array_splice($details, 0, 50);
                    if ($wp_cache_preload_email_me && $wp_cache_preload_email_volume == 'many') {
                        wp_mail(get_option('admin_email'), sprintf(__('[%1$s] Refreshing %2$s taxonomy from %3$d to %4$d', 'wp-super-cache'), home_url(), $taxonomy, $c, $c + 100), 'Refreshing: ' . print_r($rows, 1));
                    }
                    foreach ((array) $rows as $url) {
                        set_time_limit(60);
                        if ($url == '') {
                            continue;
                        }
                        $url_info = parse_url($url);
                        $dir = get_supercache_dir() . $url_info['path'];
                        wp_cache_debug("wp_cron_preload_cache: delete {$dir}", 5);
                        prune_super_cache($dir);
                        $fp = @fopen($permalink_counter_msg, 'w');
                        if ($fp) {
                            @fwrite($fp, "{$taxonomy}: {$url}");
                            @fclose($fp);
                        }
                        wp_remote_get($url, array('timeout' => 60, 'blocking' => true));
                        wp_cache_debug("wp_cron_preload_cache: fetched {$url}", 5);
                        sleep(1);
                    }
                    $fp = fopen($taxonomy_filename, 'w');
                    if ($fp) {
                        fwrite($fp, implode("\n", $details));
                        fclose($fp);
                    }
                }
            }
        }
    }
    if ($wp_cache_preload_posts == 'all' || $c < $wp_cache_preload_posts) {
        $types = get_post_types(array('public' => true, 'publicly_queryable' => true), 'names', 'or');
        $types = array_map('esc_sql', $types);
        $types = "'" . implode("','", $types) . "'";
        $posts = $wpdb->get_col("SELECT ID FROM {$wpdb->posts} WHERE ( post_type IN ( {$types} ) ) AND post_status = 'publish' ORDER BY ID ASC LIMIT {$c}, 100");
        wp_cache_debug("wp_cron_preload_cache: got 100 posts from position {$c}.", 5);
    } else {
        wp_cache_debug("wp_cron_preload_cache: no more posts to get. Limit ({$wp_cache_preload_posts}) reached.", 5);
        $posts = false;
    }
    if (!isset($wp_cache_preload_email_volume)) {
        $wp_cache_preload_email_volume = 'medium';
    }
    if ($posts) {
        if (get_option('show_on_front') == 'page') {
            $page_on_front = get_option('page_on_front');
            $page_for_posts = get_option('page_for_posts');
        } else {
            $page_on_front = $page_for_posts = 0;
        }
        if ($wp_cache_preload_email_me && $wp_cache_preload_email_volume == 'many') {
            wp_mail(get_option('admin_email'), sprintf(__('[%1$s] Refreshing posts from %2$d to %3$d', 'wp-super-cache'), home_url(), $c, $c + 100), ' ');
        }
        $msg = '';
        $count = $c + 1;
        $permalink_counter_msg = $cache_path . "preload_permalink.txt";
        foreach ($posts as $post_id) {
            set_time_limit(60);
            if ($page_on_front != 0 && ($post_id == $page_on_front || $post_id == $page_for_posts)) {
                continue;
            }
            clear_post_supercache($post_id);
            $url = get_permalink($post_id);
            $fp = @fopen($permalink_counter_msg, 'w');
            if ($fp) {
                @fwrite($fp, $count . " " . $url);
                @fclose($fp);
            }
            if (@file_exists($cache_path . "stop_preload.txt")) {
                wp_cache_debug("wp_cron_preload_cache: cancelling preload. stop_preload.txt found.", 5);
                @unlink($mutex);
                @unlink($cache_path . "stop_preload.txt");
                update_option('preload_cache_counter', array('c' => 0, 't' => time()));
                if ($wp_cache_preload_email_me) {
                    wp_mail(get_option('admin_email'), sprintf(__('[%1$s] Cache Preload Stopped', 'wp-super-cache'), home_url(), ''), ' ');
                }
                return true;
            }
            $msg .= "{$url}\n";
            wp_remote_get($url, array('timeout' => 60, 'blocking' => true));
            wp_cache_debug("wp_cron_preload_cache: fetched {$url}", 5);
            sleep(1);
            $count++;
        }
        if ($wp_cache_preload_email_me && $wp_cache_preload_email_volume != 'less') {
            wp_mail(get_option('admin_email'), sprintf(__('[%1$s] %2$d posts refreshed', 'wp-super-cache'), home_url(), $c + 100), __("Refreshed the following posts:", 'wp-super-cache') . "\n{$msg}");
        }
        if (defined('DOING_CRON')) {
            wp_cache_debug("wp_cron_preload_cache: scheduling the next preload in 30 seconds.", 5);
            wp_schedule_single_event(time() + 30, 'wp_cache_preload_hook');
        }
    } else {
        $msg = '';
        update_option('preload_cache_counter', array('c' => 0, 't' => time()));
        if ((int) $wp_cache_preload_interval && defined('DOING_CRON')) {
            if ($wp_cache_preload_email_me) {
                $msg = sprintf(__('Scheduling next preload refresh in %d minutes.', 'wp-super-cache'), (int) $wp_cache_preload_interval);
            }
            wp_cache_debug("wp_cron_preload_cache: no more posts. scheduling next preload in {$wp_cache_preload_interval} minutes.", 5);
            wp_schedule_single_event(time() + (int) $wp_cache_preload_interval * 60, 'wp_cache_full_preload_hook');
        }
        global $file_prefix, $cache_max_time;
        if ($wp_cache_preload_interval > 0) {
            $cache_max_time = (int) $wp_cache_preload_interval * 60;
            // fool the GC into expiring really old files
        } else {
            $cache_max_time = 86400;
            // fool the GC into expiring really old files
        }
        if ($wp_cache_preload_email_me) {
            wp_mail(get_option('admin_email'), sprintf(__('[%s] Cache Preload Completed', 'wp-super-cache'), home_url()), __("Cleaning up old supercache files.", 'wp-super-cache') . "\n" . $msg);
        }
        wp_cache_debug("wp_cron_preload_cache: clean expired cache files older than {$cache_max_time} seconds.", 5);
        wp_cache_phase2_clean_expired($file_prefix, true);
        // force cleanup of old files.
    }
    @unlink($mutex);
}
 /**
  *
  *  Flush rewrites/cached css
  *
  *  @package PageLines Framework
  *  @since 2.2
  */
 function flush_version($rules = true)
 {
     $types = array('sections', 'core', 'custom');
     $folder = trailingslashit(self::get_css_dir('path'));
     $file = sprintf('compiled-css-%s.css', get_theme_mod('pl_save_version'));
     if (is_file($folder . $file)) {
         @unlink($folder . $file);
     }
     // Attempt to flush super-cache and w3 cache.
     if (function_exists('prune_super_cache')) {
         global $cache_path;
         $GLOBALS["super_cache_enabled"] = 1;
         prune_super_cache($cache_path . 'supercache/', true);
         prune_super_cache($cache_path, true);
     }
     if (class_exists('W3_Plugin_TotalCacheAdmin')) {
         $plugin_totalcacheadmin =& w3_instance('W3_Plugin_TotalCacheAdmin');
         $plugin_totalcacheadmin->flush_all();
     }
     if ($rules) {
         flush_rewrite_rules(true);
     }
     set_theme_mod('pl_save_version', time());
     $types = array('sections', 'core', 'custom');
     foreach ($types as $t) {
         $compiled = get_transient("pagelines_{$t}_css");
         $backup = get_transient("pagelines_{$t}_css_backup");
         if (!is_array($backup) && is_array($compiled) && strpos($compiled[$t], 'PARSE ERROR') === false) {
             set_transient("pagelines_{$t}_css_backup", $compiled, 604800);
         }
         delete_transient("pagelines_{$t}_css");
     }
 }