/** * Timber Clear cache function */ function clear_cache_for_timber_clear_cache() { if (class_exists('Timber\\Integrations\\Command')) { return \Timber\Integrations\Command::clear_cache(); } else { return TimberCommand::clear_cache(); } }
/** * Clears Timber's Cache * * ## EXAMPLES * * wp timber clear_cache_timber * */ function clear_cache_timber() { $clear = TimberCommand::clear_cache_timber(); $message = 'Failed to clear timber cache'; if ($clear) { $message = "Cleared contents of Timber's Cache"; WP_CLI::success($messsage); } else { WP_CLI::warning($message); } return $message; }
function testWPCLIClearCacheAllArray() { $cache_dir = __DIR__ . '/../cache/twig'; if (is_dir($cache_dir)) { TimberLoader::rrmdir($cache_dir); } $this->assertFileNotExists($cache_dir); Timber::$cache = true; $pid = $this->factory->post->create(); $post = new TimberPost($pid); Timber::compile('assets/single-post.twig', array('post' => $post)); sleep(1); $this->assertFileExists($cache_dir); Timber::compile('assets/single.twig', array('data' => 'foobar'), 600); $success = TimberCommand::clear_cache(array('all')); $this->assertTrue($success); Timber::$cache = false; $success = TimberCommand::clear_cache('bunk'); $this->assertNull($success); }