Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Site Health: Check if the cron job is enabled #391

Merged
merged 2 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/install-wp-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ install_test_suite() {
svn export --quiet --ignore-externals https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/data/ $WP_TESTS_DIR/data
fi

if [ ! -f wp-tests-config.php ]; then
if [ ! -f "$WP_TESTS_DIR"/wp-tests-config.php ]; then
download https://develop.svn.wordpress.org/${WP_TESTS_TAG}/wp-tests-config-sample.php "$WP_TESTS_DIR"/wp-tests-config.php
# remove all forward slashes in the end
WP_CORE_DIR=$(echo $WP_CORE_DIR | sed "s:/\+$::")
Expand Down
37 changes: 37 additions & 0 deletions includes/class-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -3447,6 +3447,10 @@ public function site_status_tests( $tests ) {
'label' => __( 'Friend roles were created', 'friends' ),
'test' => array( $this, 'friend_roles_test' ),
);
$tests['direct']['friends-cron'] = array(
'label' => __( 'Friend cron job is enabled', 'friends' ),
'test' => array( $this, 'friends_cron_test' ),
);
return $tests;
}

Expand Down Expand Up @@ -3513,6 +3517,39 @@ public function friend_roles_test() {
return $result;
}

public function friends_cron_test() {
$result = array(
'label' => __( 'The friend cron job is enabled', 'friends' ),
'status' => 'good',
'badge' => array(
'label' => __( 'Friends', 'friends' ),
'color' => 'green',
),
'description' =>
'<p>' .
__( 'The Friends Plugin uses a cron job to fetch your friends\' feeds.', 'friends' ) .
'</p>',
'test' => 'friends-cron',
);

if ( ! wp_next_scheduled( 'cron_friends_refresh_feeds' ) ) {
$result['label'] = __( 'The friends cron job is not enabled', 'friends' );
$result['badge']['color'] = 'red';
$result['status'] = 'critical';
$result['description'] .= '<p>';
$result['description'] .= wp_kses_post(
sprintf(
// translators: %s is a URL.
__( '<strong>To fix this:</strong> <a href="%s">Enable the Friends cron job</a>.', 'friends' ),
esc_url( wp_nonce_url( add_query_arg( '_wp_http_referer', remove_query_arg( '_wp_http_referer' ), self_admin_url( 'admin.php?page=friends-settings&rerun-activate' ) ), 'friends-settings' ) )
)
);
$result['description'] .= '</p>';
}

return $result;
}

public function site_status_test_php_modules( $modules ) {
$modules['mbstring']['required'] = true;
return $modules;
Expand Down
Loading