if ($is_locked) { echo 'Lock active, stopped processing. Wait 60 seconds'; //die(); } function mp_warm_cache_limit_filter($limit) { if (defined('MP_WARM_CACHE_FILTER_LIMIT')) { $newlimit = intval(MP_WARM_CACHE_FILTER_LIMIT); if ($newlimit > 0) { return $newlimit; } } return $limit; } add_filter('mp_warm_cache_limit_filters', 'mp_warm_cache_limit_filter', 10, 1); $warm_cache = new warm_cache(); $warm_cache->google_sitemap_generator_options = get_option("sm_options"); $useflush = get_option("plugin_warm_cache_lb_flush"); $limit = apply_filters('mp_warm_cache_limit_filters', get_option('plugin_warm_cache_limit', 20)); $start = get_option('plugin_warm_cache_start', 0); echo "Start at item {$start} {$limit}"; $mtime = microtime(); $mtime = explode(' ', $mtime); $mtime = $mtime[1] + $mtime[0]; $starttime = $mtime; @set_time_limit(0); ob_start(); if (file_exists('./wp-load.php')) { require_once './wp-load.php'; } // Get url
public function admin_menu() { load_plugin_textdomain('plugin_warm_cache', '/wp-content/plugins/warm-cache/language/'); $warm_cache_admin = new warm_cache(); $warm_cache_admin->plugin_title = 'Warm cache'; if (!$warm_cache_admin->configuration_check()) { } else { $warm_cache_admin->content_start(); $stats = $warm_cache_admin->get_stats(); if (!$stats['crawl']) { $msg = 'Ok, we have detected your sitemap url but it has not been visited by the plugin\'s crawler.<br/>'; $warm_cache_api_url = trailingslashit(get_bloginfo('url')) . '?warm_cache=' . get_option('plugin_warm_cache_api'); $msg .= 'The url you should call from a cronjob is: ' . $warm_cache_api_url . '<br/>'; $msg .= 'To re-set the key, visit this url: ' . admin_url('plugins.php?page=warm-cache/warm-cache.php&resetkey=true') . '<br/>'; $msg .= 'If you are in need of an external cronjob service, you might like to use Easycron.com (affiliate link) <a href="http://www.easycron.com/?ref=12201">http://www.easycron.com/?ref=12201</a> or <a href="https://webshop.mijnpress.nl/shop/cronjob-for-warm-cache">buy our cronjob service</a>'; $msg .= '<br/><a href="https://www.managedwphosting.nl/contact/offerte-op-maat/">I offer paid WordPress speed-optimisation consultancy and Varnish & memcached WordPress webhosting & servers.</a>'; $warm_cache_admin->show_message($msg); echo '<br/><br/>'; } else { $msg = 'Crawled in total ' . $stats['stats_pages'] . ' pages in a total of ' . $stats['stats_times'] . ' seconds (based on the last 75 crawls)<br/>'; if ($stats['stats_pages']) { $msg .= 'Average page to load a page in seconds: ' . $stats['stats_times'] / $stats['stats_pages']; } $msg .= '<br/><a href="https://www.managedwphosting.nl/contact/offerte-op-maat/">I offer paid WordPress speed-optimisation consultancy and Varnish & memcached WordPress webhosting & servers.</a>'; $warm_cache_admin->show_message($msg); } echo '<table class="widefat">'; echo '<tr><th class="manage-column" style="width: 150px;">Crawled at</th><th class="manage-column">Time needed</th><th class="manage-column" style="width: 120px;">Number of pages</th><th class="manage-column">Average load time per page</th><th class="manage-column">Pages</th></tr>'; echo $stats['table_string']; echo '</table>'; $warm_cache_admin->content_end(); } }