First of all, it looks like this is not the whole file and rather part of it because starting with "
<?PHP }" means that the PHP instance was already opened before that part, maybe in another function preceding the code you included.
That file is part of license checking, but there could be other files too.
That file consists of four functions:
#1. function run_wpc_theme($old_value, $new_value)
It basically tells the script that in case there are 2 license codes and such codes are different after comparing them, then use the newer one.
This one can be left alone.
#2. function wpc_run_api($license_key = false)
This function is the one to modify. It calls the API of the developer's server with your credentials to check if the credentials are valid. The API then sends back the info in its response and the function acts accordingly. The parameter "
$license_key = false" does not matter. It tells the function that if a license key is not provided when calling the function, then use "false" as default. This will have no effect at all on the needed modification.
The positive response is further below in that same function:
Code:
if($r['status'] == 'ok'){
wpc_activate_wpc_options();
add_action( 'admin_notices', 'wpc_api_admin_notice__success' );
}
It means that if the credentials are valid, the "status", which is the server response, will be "ok" and then it will execute the two functions inside that conditional statement, one to activate options that are not available before checking the license and the other to notify that the credentials are valid. This is what you need to put right after the function name (right after "function wpc_run_api($license_key = false)"). Like this:
Code:
function wpc_run_api($license_key = false)
wpc_activate_wpc_options();
add_action( 'admin_notices', 'wpc_api_admin_notice__success' );
return;
I added a "return;" to stop it from running any other instructions in that function. So when it is called, it will just reply "Yes all is good to go on" to the plugin and then will return to everything else. No call to the API and no license verification will be executed.
#3 and #4. The other two functions (
function wpc_api_admin_notice__error() and
function wpc_api_admin_notice__success() ) can be left alone as those are only to notify either if the credentials were valid or not and as you noticed, we will even use the success one of them in our mod above to notify that "the license is valid".
So bellow is the way I would modify the file:
Code:
<?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){
wpc_activate_wpc_options();
add_action( 'admin_notices', 'wpc_api_admin_notice__success' );
return;
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>';
}
If this does not work, then it means that there are other checks in other files in the plugin. If that happens, checking the whole theme or plugin would be required.
Cheers!