Skip to content

Instantly share code, notes, and snippets.

@seedprod
Created November 27, 2017 17:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seedprod/e1f5fda3dcb141682c9e8e25a5be2a74 to your computer and use it in GitHub Desktop.
Save seedprod/e1f5fda3dcb141682c9e8e25a5be2a74 to your computer and use it in GitHub Desktop.
// Multisite Initial Install License Check
function seed_cspv5_check_license_updater(){
if(get_option('seed_cspv5_a') === false){
add_option('seed_cspv5_license_key',SEED_CSP_API_KEY);
add_option('seed_cspv5_token',strtolower(wp_generate_password(32,false, false)));
$params = array(
'action' => 'info',
'license_key'=> SEED_CSP_API_KEY,
'slug' => SEED_CSPV5_SLUG,
'domain' => home_url(),
'installed_version' => SEED_CSPV5_VERSION,
'token' => get_option('seed_cspv5_token'),
);
$request = wp_remote_post( SEED_CSPV5_API_URL, array( 'timeout' => 15, 'sslverify' => false, 'body' => $params ) );
if ( ! is_wp_error( $request ) ) {
$request = wp_remote_retrieve_body( $request );
$arequest = json_decode($request);
$nag = $arequest->message;
update_option('seed_cspv5_license_key',$api_key);
update_option('seed_cspv5_api_message',$nag);
if($arequest->status == '200'){
update_option('seed_cspv5_api_nag','');
update_option('seed_cspv5_a',true);
update_option('seed_cspv5_per',$arequest->per);
}elseif($arequest->status == '401'){
update_option('seed_cspv5_api_nag',$nag);
update_option('seed_cspv5_a',false);
update_option('seed_cspv5_per','');
}elseif($arequest->status == '402'){
update_option('seed_cspv5_api_nag',$nag);
update_option('seed_cspv5_a',false);
update_option('seed_cspv5_per',$arequest->per);
}
}
}
}
if(defined('SEED_CSP_API_KEY')){
if(isset($_GET['page']) && $_GET['page'] == 'seed_cspv5'){
add_action( 'admin_init', 'seed_cspv5_check_license_updater');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment