@@ -1,41 +1,41 @@ |
||
1 | 1 | <?php |
2 | 2 | // Exit if accessed directly |
3 | 3 | if ( ! defined( 'ABSPATH' ) ) { |
4 | - exit; |
|
4 | + exit; |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | class autoptimizeCLI extends WP_CLI_Command { |
8 | 8 | |
9 | - /** |
|
10 | - * Clears the cache. |
|
11 | - * |
|
12 | - * @subcommand clear |
|
13 | - * @synopsis [--type=<css|js>] |
|
14 | - */ |
|
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 | - } |
|
9 | + /** |
|
10 | + * Clears the cache. |
|
11 | + * |
|
12 | + * @subcommand clear |
|
13 | + * @synopsis [--type=<css|js>] |
|
14 | + */ |
|
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 | 39 | |
40 | 40 | } |
41 | 41 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // Exit if accessed directly |
3 | -if ( ! defined( 'ABSPATH' ) ) { |
|
3 | +if (!defined('ABSPATH')) { |
|
4 | 4 | exit; |
5 | 5 | } |
6 | 6 | |
@@ -12,31 +12,31 @@ discard block |
||
12 | 12 | * @subcommand clear |
13 | 13 | * @synopsis [--type=<css|js>] |
14 | 14 | */ |
15 | - public function clear( $args, $args_assoc ) { |
|
15 | + public function clear($args, $args_assoc) { |
|
16 | 16 | $clear = ''; |
17 | - if ( ! empty( $args_assoc ) ) { |
|
17 | + if (!empty($args_assoc)) { |
|
18 | 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' ) ); |
|
19 | + if (!in_array($clear, array('css', 'js'), true)) { |
|
20 | + WP_CLI::error(esc_html__('Please choose `css` or `js`.', 'autoptimize')); |
|
21 | 21 | } |
22 | 22 | } |
23 | 23 | |
24 | - if ( empty( $clear ) ) { |
|
25 | - WP_CLI::line( esc_html__( 'Flushing the cache...', 'autoptimize' ) ); |
|
24 | + if (empty($clear)) { |
|
25 | + WP_CLI::line(esc_html__('Flushing the cache...', 'autoptimize')); |
|
26 | 26 | autoptimizeCache::clearall(); |
27 | - WP_CLI::success( esc_html__( 'Cache flushed.', 'autoptimize' ) ); |
|
27 | + WP_CLI::success(esc_html__('Cache flushed.', 'autoptimize')); |
|
28 | 28 | return; |
29 | 29 | } |
30 | 30 | |
31 | - WP_CLI::line( esc_html__( 'Clearing the cache...', 'autoptimize' ) ); |
|
31 | + WP_CLI::line(esc_html__('Clearing the cache...', 'autoptimize')); |
|
32 | 32 | |
33 | 33 | WP_Filesystem(); |
34 | 34 | global $wp_filesystem; |
35 | - $wp_filesystem->rmdir( AUTOPTIMIZE_CACHE_DIR . $clear, true ); |
|
35 | + $wp_filesystem->rmdir(AUTOPTIMIZE_CACHE_DIR.$clear, true); |
|
36 | 36 | |
37 | - WP_CLI::success( esc_html__( sprintf( '%s cache cleared.', strtoupper( $clear ) ), 'autoptimize' ) ); |
|
37 | + WP_CLI::success(esc_html__(sprintf('%s cache cleared.', strtoupper($clear)), 'autoptimize')); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | } |
41 | 41 | |
42 | -WP_CLI::add_command( 'autoptimize', 'autoptimizeCLI' ); |
|
42 | +WP_CLI::add_command('autoptimize', 'autoptimizeCLI'); |