Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Add cURL test to WP 5.2 Site Health tests
<?php
/**
* Adds a cURL version test to Site Health
*
* Info here: https://make.wordpress.org/core/2019/04/25/site-health-check-in-5-2/
* NOTE: Requires version 5.2+ of WordPress
*
**/
function register_give_curl_tester( $tests ) {
$tests['direct']['curl_tester'] = array(
'label' => __( 'Test cURL' ),
'test' => 'give_test_curl_version',
);
return $tests;
}
add_filter( 'site_status_tests', 'register_give_curl_tester' );
function give_test_curl_version() {
$results = array(
'label' => __( 'cURL Version' ),
'status' => 'good',
'badge' => array(
'label' => __( 'Security' ),
'color' => 'blue',
),
'description' => sprintf(
'<p>' . __( 'Your cURL version is: ', 'give' ) . '%g -- this meets or exceeds the minimum requirement for secure online donations.</p>', curl_version()['version']),
'actions' => '',
'test' => 'curl_tester',
);
$curl_version = curl_version()['version'];
if ( $curl_version < '7.40' ) {
$results['status'] = 'critical';
$results['label'] = __( 'cURL version is outdated' );
$results['description'] = sprintf(
'<p>' . __( 'Your cURL version is: ', 'give' ) . '%g</p>', curl_version()['version']);
$results['actions'] = sprintf(
'<p>%s</p>',
__( 'Your cURL version is outdated. This can negatively impact your online donations with GiveWP. Please contact your host about getting cURL updated to at least version 7.40.', 'give' )
);
$results['badge']['color'] = 'red';
}
return $results;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment