Skip to content

Commit

Permalink
Move hooks out of Waf_Runner class
Browse files Browse the repository at this point in the history
  • Loading branch information
nateweller committed Nov 6, 2024
1 parent 2286a32 commit 9f2f0b1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
6 changes: 6 additions & 0 deletions projects/packages/waf/src/class-waf-initializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,19 @@ 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' );

// WAF activation/deactivation hooks
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' );
Expand Down
14 changes: 4 additions & 10 deletions projects/packages/waf/src/class-waf-runner.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,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();
}
Expand All @@ -52,11 +47,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?
Expand Down

0 comments on commit 9f2f0b1

Please sign in to comment.