<?php
}
function run_wpc_theme($old_value, $new_value){
$old_license_key = $old_value['wpc_license_key'];
$new_license_key = $new_value['wpc_license_key'];
if($old_license_key != $new_license_key){
wpc_run_api($new_license_key);
}
else{
$r = array(
'status' => 'fail',
'message' => 'Invalid license key.',
);
die(json_encode($r));
}
}
}
function wpc_run_api($license_key = false){
if(!$license_key){
return false;
}
$postdata = http_build_query(
array(
'license_key' => $license_key,
'domain' => site_url(),
)
);
$opts = array('http' =>
array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => $postdata
)
);
$context = stream_context_create($opts);
$r = file_get_contents('http://www.yuppythemes.com/wp-content/plugins/wp-licensing-for-theme-and-plugin/ltp-api-activate.php', false, $context);
$r = json_decode($r, true);
if($r['status'] == 'ok'){
wpc_activate_wpc_options();
add_action( 'admin_notices', 'wpc_api_admin_notice__success' );
}
else{
add_action( 'admin_notices', 'wpc_api_admin_notice__error' );
}
die(json_encode($r));
}
function wpc_api_admin_notice__error() {
$class = 'notice notice-error';
$message = 'WPCanvo: Invalid license key.';
echo '<div class="'.$class.'"><p>'.$message.'</p></div>';
}
function wpc_api_admin_notice__success() {
$class = 'notice notice-success';
$message = 'WPCanvo: Success!! You theme was activated successfully.';
echo '<div class="'.$class.'"><p>'.$message.'</p></div>';
}