• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

timber / timber / 20695674007

04 Jan 2026 04:14PM UTC coverage: 89.681% (+1.5%) from 88.211%
20695674007

push

travis-ci

nlemoine
test: Fix ancestors post tests

4615 of 5146 relevant lines covered (89.68%)

63.45 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Integration/CLI/TimberCommand.php
1
<?php
2

3
namespace Timber\Integration\CLI;
4

5
use Timber\Cache\Cleaner;
6
use WP_CLI;
7
use WP_CLI_Command;
8

9
if (!\class_exists('WP_CLI_Command')) {
×
10
    return;
×
11
}
12

13
/**
14
 * Class TimberCommand
15
 *
16
 * Handles WP-CLI commands.
17
 */
18
class TimberCommand extends WP_CLI_Command
19
{
20
    /**
21
     * Clears caches in Timber.
22
     *
23
     * ## OPTIONS
24
     *
25
     * [<mode>]
26
     * : Optional. The type of cache to clear. Accepts 'timber' or 'twig'. If not provided, the command will clear all caches.
27
     *
28
     * ## EXAMPLES
29
     *
30
     *    # Clear all caches.
31
     *    wp timber clear-cache
32
     *
33
     *    # Clear Timber caches.
34
     *    wp timber clear-cache timber
35
     *
36
     *    # Clear Twig caches.
37
     *    wp timber clear-cache twig
38
     *
39
     * @subcommand clear-cache
40
     * @alias clear_cache
41
     */
42
    public function clear_cache($args = []): void
×
43
    {
44
        $mode = $args[0] ?? 'all';
×
45
        $mode_string = 'all' !== $mode ? \ucfirst((string) $mode) : $mode;
×
46

47
        WP_CLI::log("Clearing {$mode_string} caches …");
×
48

49
        if (Cleaner::clear_cache($mode)) {
×
50
            WP_CLI::success("Cleared {$mode_string} caches.");
×
51
        } else {
52
            WP_CLI::warning("Failed to clear {$mode_string} cached contents.");
×
53
        }
54
    }
55
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc