コード例 #1
0
function podlove_validate_image_cache()
{
    set_time_limit(5 * MINUTE_IN_SECONDS);
    PHP_Timer::start();
    $cache_files = glob(trailingslashit(Image::cache_dir()) . "*" . DIRECTORY_SEPARATOR . "*" . DIRECTORY_SEPARATOR . "cache.yml");
    foreach ($cache_files as $cache_file) {
        $cache = Yaml::parse(file_get_contents($cache_file));
        $validator = new HttpHeaderValidator($cache['source'], $cache['etag'], $cache['last-modified']);
        $validator->validate();
        if ($validator->hasChanged()) {
            wp_schedule_single_event(time(), 'podlove_refetch_cached_image', [$cache['source'], $cache['filename']]);
        }
    }
    $time = PHP_Timer::stop();
    \Podlove\Log::get()->addInfo(sprintf('Finished validating %d images in %s', count($cache_files), PHP_Timer::secondsToTimeString($time)));
}
コード例 #2
0
 private static function clear_podlove_image_cache()
 {
     \Podlove\Model\Image::flush_cache();
     self::add_to_repair_log(__('Podlove image cache cleared', 'podlove'));
 }