10
10
namespace Plausible \Analytics \WP ;
11
11
12
12
class Setup {
13
- /**
14
- * Cron job handle
15
- *
16
- * @var string
17
- */
18
- private $ cron = 'plausible_analytics_update_js ' ;
19
-
20
13
/**
21
14
* Filters and Hooks.
22
15
*
@@ -28,7 +21,7 @@ public function __construct() {
28
21
register_deactivation_hook ( PLAUSIBLE_ANALYTICS_PLUGIN_FILE , [ $ this , 'deactivate_cron ' ] );
29
22
30
23
// 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 ' ] );
32
25
33
26
// This assures that the local file is downloaded/updated when settings are saved.
34
27
add_action ( 'plausible_analytics_settings_saved ' , [ $ this , 'load_cron_script ' ] );
@@ -51,8 +44,8 @@ public function create_cache_dir() {
51
44
* @codeCoverageIgnore
52
45
*/
53
46
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 );
56
49
}
57
50
}
58
51
@@ -62,8 +55,8 @@ public function activate_cron() {
62
55
* @codeCoverageIgnore
63
56
*/
64
57
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 );
67
60
}
68
61
}
69
62
0 commit comments