This website uses cookies to allow us to see how the site is used. If you continue to use this site, we assume that you are okay with this. If you want to use the sites without cookies, please see our privacy policy.

Add cURL version to Site Health Checker

This snippet shows you how you can easily extend the “tests” within the Site Health testing area. The cURL version is really important for secure communications with third-party sites like payment gateways, and it is part of what makes your https connections strong and secure.

/**
  * 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;
}

About

Matt has served nonprofit organizations since early 2000's as a web developer, educator, fundraising consultant, marketing consultant, board member and more. Currently, he is Partner and Head of Support and Outreach at Impress.org who's mission is "Code for Good". Impress.org's flagship product is the number one fundraising tool for WordPress websites: GiveWP. Matt serves on the board of San Diego Refugee Tutoring, a volunteer driven organization dedicated to serving the rising refugee population of children in San Diego. He also serves on the board of Mid-City Church of the Nazarene who hosts bi-weekly food distributions, and houses dozens of other local NGOs in their facility in City Heights, San Diego. Matt is a husband, father to four, and lover of all things musical and/or homebrewed. He also loves to talk about the most taboo of topics: Politics and Religion.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.