Put cleanup hook attachment in an init method.

This commit is contained in:
Jeff Stieler 2021-10-19 09:27:27 -04:00
parent befa2b0a95
commit 5d182ee71a
2 changed files with 9 additions and 7 deletions

View File

@ -36,6 +36,13 @@ class WC_Rate_Limiter {
*/
const CACHE_GROUP = 'wc_rate_limit';
/**
* Hook in methods.
*/
public static function init() {
add_action( 'woocommerce_cleanup_rate_limits', array( __CLASS__, 'cleanup' ) );
}
/**
* Constructs key name from action identifier.
* Left in for backwards compatibility.
@ -162,3 +169,5 @@ class WC_Rate_Limiter {
}
}
}
WC_Rate_Limiter::init();

View File

@ -2548,10 +2548,3 @@ function wc_cache_get_multiple( $keys, $group = '', $force = false ) {
}
return $values;
}
/**
* Cleans up rate limit data - cron callback.
*
* @since 6.0.0
*/
add_action( 'woocommerce_cleanup_rate_limits', array( 'WC_Rate_Limiter', 'cleanup' ) );