Created
June 19, 2018 14:23
-
-
Save hiddenpearls/bf05ec1a17f2270136eadb775f09b1c0 to your computer and use it in GitHub Desktop.
Check EDD License status
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Check and get the license data. | |
* | |
* @param string $license The license key. | |
* | |
* @return false|array | |
*/ | |
public static function check_license( $license ) { | |
$license = trim( $license ); | |
$api_params = array( | |
'edd_action' => 'check_license', | |
'license' => $license, | |
'item_id' => LOGINPRESS_PRODUCT_ID, | |
'url' => home_url() | |
); | |
// Call the custom API. | |
$response = wp_remote_post( self::LOGINPRESS_SITE_URL, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) ); | |
if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) { | |
return false; | |
} | |
return json_decode( wp_remote_retrieve_body( $response ), true ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment