Skip to content

Commit 868616c

Browse files
committed
Add site health check for DISABLE_WP_CRON configuration
Add a new health check to warn site administrators when the DISABLE_WP_CRON constant is enabled. While it's acceptable to use a system cron to call wp-cron.php, having WP-Cron completely disabled can cause delays in: - Publishing posts to the fediverse - Processing reactions (likes, boosts, replies) - Other scheduled ActivityPub tasks The health check: - Shows as "good" when WP-Cron is enabled (default) - Shows as "recommended" warning when DISABLE_WP_CRON is true - Provides clear explanation of potential impacts - Includes link to WordPress documentation on setting up system cron - Suggests running system cron every 1-5 minutes for optimal performance
1 parent f0d6834 commit 868616c

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

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\'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)