← All changes
|
jetpack_vendor/automattic/jetpack-waf/src/class-waf-cli.php
+10
-5
12.2.3
→
16.3-beta
View file →
| @@ -6,13 +6,17 @@ | ||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | namespace Automattic\Jetpack\Waf; |
| 9 | 9 | |
| 10 | -use \WP_CLI; | |
| 11 | -use \WP_CLI_Command; | |
| 10 | +use WP_CLI; | |
| 11 | +use WP_CLI_Command; | |
| 12 | 12 | |
| 13 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 14 | + exit( 0 ); | |
| 15 | +} | |
| 16 | + | |
| 13 | 17 | /** |
| 14 | - * Just a few sample commands to learn how WP-CLI works | |
| 18 | + * Set up the WAF, change its mode, or generate its rules. | |
| 15 | 19 | */ |
| 16 | 20 | class CLI extends WP_CLI_Command { |
| 17 | 21 | /** |
| 18 | 22 | * View or set the current mode of the WAF. |
| @@ -114,9 +118,9 @@ | ||
| 114 | 118 | ) |
| 115 | 119 | ); |
| 116 | 120 | } |
| 117 | 121 | |
| 118 | - return WP_CLI::success( __( 'Jetpack WAF has successfully been setup.', 'jetpack-waf' ) ); | |
| 122 | + return WP_CLI::success( __( 'Jetpack WAF has successfully been set up.', 'jetpack-waf' ) ); | |
| 119 | 123 | } |
| 120 | 124 | |
| 121 | 125 | /** |
| 122 | 126 | * Delete the WAF options. |
| @@ -141,8 +145,9 @@ | ||
| 141 | 145 | * @throws WP_CLI\ExitException If there is an error switching the mode. |
| 142 | 146 | */ |
| 143 | 147 | public function generate_rules() { |
| 144 | 148 | try { |
| 149 | + Waf_Constants::define_entrypoint(); | |
| 145 | 150 | Waf_Rules_Manager::generate_automatic_rules(); |
| 146 | 151 | Waf_Rules_Manager::generate_rules(); |
| 147 | 152 | } catch ( \Exception $e ) { |
| 148 | 153 | |
| @@ -158,9 +163,9 @@ | ||
| 158 | 163 | return WP_CLI::success( |
| 159 | 164 | sprintf( |
| 160 | 165 | /* translators: %1$s is the name of the mode that was just switched to. */ |
| 161 | 166 | __( 'Jetpack WAF rules successfully created to: "%1$s".', 'jetpack-waf' ), |
| 162 | - Waf_Runner::get_waf_file_path( Waf_Rules_Manager::RULES_ENTRYPOINT_FILE ) | |
| 167 | + Waf_Runner::get_waf_file_path( JETPACK_WAF_ENTRYPOINT ) | |
| 163 | 168 | ) |
| 164 | 169 | ); |
| 165 | 170 | } |
| 166 | 171 | } |