1010namespace Plausible \Analytics \WP ;
1111
1212class Setup {
13- /**
14- * Cron job handle
15- *
16- * @var string
17- */
18- private $ cron = 'plausible_analytics_update_js ' ;
19-
2013 /**
2114 * Filters and Hooks.
2215 *
@@ -28,7 +21,7 @@ public function __construct() {
2821 register_deactivation_hook ( PLAUSIBLE_ANALYTICS_PLUGIN_FILE , [ $ this , 'deactivate_cron ' ] );
2922
3023 // Attach the cron script to the cron action.
31- add_action ( $ this -> cron , [ $ this , 'load_cron_script ' ] );
24+ add_action ( Cron:: TASK_NAME , [ $ this , 'load_cron_script ' ] );
3225
3326 // This assures that the local file is downloaded/updated when settings are saved.
3427 add_action ( 'plausible_analytics_settings_saved ' , [ $ this , 'load_cron_script ' ] );
@@ -51,8 +44,8 @@ public function create_cache_dir() {
5144 * @codeCoverageIgnore
5245 */
5346 public function activate_cron () {
54- if ( ! wp_next_scheduled ( $ this -> cron ) ) {
55- wp_schedule_event ( time (), 'daily ' , $ this -> cron );
47+ if ( ! wp_next_scheduled ( Cron:: TASK_NAME ) ) {
48+ wp_schedule_event ( time (), 'daily ' , Cron:: TASK_NAME );
5649 }
5750 }
5851
@@ -62,8 +55,8 @@ public function activate_cron() {
6255 * @codeCoverageIgnore
6356 */
6457 public function deactivate_cron () {
65- if ( wp_next_scheduled ( $ this -> cron ) ) {
66- wp_clear_scheduled_hook ( $ this -> cron );
58+ if ( wp_next_scheduled ( Cron:: TASK_NAME ) ) {
59+ wp_clear_scheduled_hook ( Cron:: TASK_NAME );
6760 }
6861 }
6962
0 commit comments