diff --git a/projects/packages/waf/src/class-waf-initializer.php b/projects/packages/waf/src/class-waf-initializer.php index 57a64306d1812..1433dcfe14090 100644 --- a/projects/packages/waf/src/class-waf-initializer.php +++ b/projects/packages/waf/src/class-waf-initializer.php @@ -42,6 +42,9 @@ public static function init() { // Update the WAF after installing or upgrading a relevant Jetpack plugin add_action( 'upgrader_process_complete', __CLASS__ . '::update_waf_after_plugin_upgrade', 10, 2 ); + // Update the WAF after updating the rules settings + Waf_Rules_Manager::add_hooks(); + // Check for compatibility updates add_action( 'admin_init', __CLASS__ . '::check_for_updates' ); @@ -49,6 +52,9 @@ public static function init() { add_action( 'jetpack_activate_module_waf', __CLASS__ . '::on_waf_activation' ); add_action( 'jetpack_deactivate_module_waf', __CLASS__ . '::on_waf_deactivation' ); + // Update the WAF rule files on a schedule + Waf_Rules_Manager::schedule_rules_cron(); + // Brute force protection activation/deactivation hooks add_action( 'jetpack_activate_module_protect', __CLASS__ . '::on_brute_force_protection_activation' ); add_action( 'jetpack_deactivate_module_protect', __CLASS__ . '::on_brute_force_protection_deactivation' ); diff --git a/projects/packages/waf/src/class-waf-runner.php b/projects/packages/waf/src/class-waf-runner.php index c5eb2c987cf48..6dc06cce9027a 100644 --- a/projects/packages/waf/src/class-waf-runner.php +++ b/projects/packages/waf/src/class-waf-runner.php @@ -36,12 +36,7 @@ public static function initialize() { if ( ! self::is_allowed_mode( JETPACK_WAF_MODE ) ) { return; } - // Don't run if in standalone mode - if ( function_exists( 'add_action' ) ) { - self::add_hooks(); - Waf_Rules_Manager::add_hooks(); - Waf_Rules_Manager::schedule_rules_cron(); - } + if ( ! self::did_run() ) { self::run(); } @@ -51,11 +46,10 @@ public static function initialize() { * Set action hooks * * @return void + * + * @deprecated $$next-version$$ Hooks have been moved to Waf_Initializer class. */ - public static function add_hooks() { - // Register REST routes. - add_action( 'rest_api_init', array( new REST_Controller(), 'register_rest_routes' ) ); - } + public static function add_hooks() {} /** * Did the WAF run yet or not?