Skip to content

Commit c56e9cd

Browse files
authored
Add site health check for DISABLE_WP_CRON configuration (#2583)
1 parent a93eeb4 commit c56e9cd

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: minor
2+
Type: added
3+
4+
Add site health check to warn when DISABLE_WP_CRON may impact ActivityPub functionality

includes/wp-admin/class-health-check.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ public static function add_tests( $tests ) {
109109
'test' => array( self::class, 'test_check_for_captcha_plugins' ),
110110
);
111111

112+
$tests['direct']['activitypub_test_wp_cron'] = array(
113+
'label' => \__( 'WP-Cron Configuration Test', 'activitypub' ),
114+
'test' => array( self::class, 'test_wp_cron' ),
115+
);
116+
112117
return $tests;
113118
}
114119

@@ -539,4 +544,44 @@ function ( $plugin_file ) use ( $all_plugins ) {
539544

540545
return $result;
541546
}
547+
548+
/**
549+
* WP-Cron configuration test.
550+
*
551+
* @return array The test result.
552+
*/
553+
public static function test_wp_cron() {
554+
$result = array(
555+
'label' => \__( 'WP-Cron is properly configured', 'activitypub' ),
556+
'status' => 'good',
557+
'badge' => array(
558+
'label' => \__( 'ActivityPub', 'activitypub' ),
559+
'color' => 'green',
560+
),
561+
'description' => \sprintf(
562+
'<p>%s</p>',
563+
\__( 'Your WP-Cron configuration allows for timely publishing and processing of ActivityPub activities.', 'activitypub' )
564+
),
565+
'actions' => '',
566+
'test' => 'test_wp_cron',
567+
);
568+
569+
if ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ) {
570+
$result['status'] = 'recommended';
571+
$result['label'] = \__( 'WP-Cron is disabled', 'activitypub' );
572+
$result['badge']['color'] = 'orange';
573+
$result['description'] = \sprintf(
574+
'<p>%s</p><p>%s</p>',
575+
\__( 'The constant <code>DISABLE_WP_CRON</code> is set to <code>true</code> in your configuration. This disables WordPress&#8217;s built-in cron system, which ActivityPub relies on for timely publishing of posts and processing of reactions (likes, boosts, replies).', 'activitypub' ),
576+
\__( 'While it is fine to have a system cron job that calls <code>wp-cron.php</code> at regular intervals, completely disabling WP-Cron may cause delays in ActivityPub functionality. If you notice delays in post publishing or reactions appearing, consider either removing this constant or ensuring you have a system cron job running frequently (every 1-5 minutes).', 'activitypub' )
577+
);
578+
$result['actions'] = \sprintf(
579+
'<p><a href="%s" target="_blank">%s</a></p>',
580+
'https://developer.wordpress.org/plugins/cron/hooking-wp-cron-into-the-system-task-scheduler/',
581+
\__( 'Learn more about setting up system cron for WordPress', 'activitypub' )
582+
);
583+
}
584+
585+
return $result;
586+
}
542587
}

0 commit comments

Comments
 (0)