Conditions | 4 |
Paths | 6 |
Total Lines | 24 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
15 | public function clear( $args, $args_assoc ) { |
||
16 | $clear = ''; |
||
17 | if ( ! empty( $args_assoc ) ) { |
||
18 | $clear = $args_assoc['type']; |
||
19 | if ( ! in_array( $clear, array( 'css', 'js' ), true ) ) { |
||
20 | WP_CLI::error( esc_html__( 'Please choose `css` or `js`.', 'autoptimize' ) ); |
||
21 | } |
||
22 | } |
||
23 | |||
24 | if ( empty( $clear ) ) { |
||
25 | WP_CLI::line( esc_html__( 'Flushing the cache...', 'autoptimize' ) ); |
||
26 | autoptimizeCache::clearall(); |
||
27 | WP_CLI::success( esc_html__( 'Cache flushed.', 'autoptimize' ) ); |
||
28 | return; |
||
29 | } |
||
30 | |||
31 | WP_CLI::line( esc_html__( 'Clearing the cache...', 'autoptimize' ) ); |
||
32 | |||
33 | WP_Filesystem(); |
||
34 | global $wp_filesystem; |
||
35 | $wp_filesystem->rmdir( AUTOPTIMIZE_CACHE_DIR . $clear, true ); |
||
36 | |||
37 | WP_CLI::success( esc_html__( sprintf( '%s cache cleared.', strtoupper( $clear ) ),'autoptimize' ) ); |
||
38 | } |
||
39 | |||
43 |