prefix = $prefix;
$this->mainfile = $mainfile;
$this->domain = $domain;
$this->item = $item;
$this->version = $version;
if ( $this->is_registered() ) {
add_filter( $this->prefix . '_meowapps_is_registered', array( $this, 'is_registered' ), 10 );
}
if ( MeowCommon_Helpers::is_rest() ) {
new MeowCommon_Classes_Rest_License( $this );
}
else if ( is_admin() ) {
$license_key = $this->license && isset( $this->license['key'] ) ? $this->license['key'] : "";
new MeowCommon_Classes_Updater(
( get_option( 'force_sslverify', false ) ? 'https' : 'http' ) . '://store.meowapps.com', $this->mainfile,
array(
'version' => $this->version,
'license' => $license_key,
'item_name' => $this->item,
'wp_override' => true,
'author' => 'Jordy Meow',
'url' => strtolower( home_url() ),
'beta' => false
)
);
}
}
function retry_validation() {
if ( isset( $_POST[$this->prefix . '_pro_serial'] ) ) {
$serial = sanitize_text_field( $_POST[$this->prefix . '_pro_serial'] );
$this->validate_pro( $serial );
}
}
function is_registered( $force = false ) {
if ( !$force && !empty( $this->license ) )
return empty( $this->license['issue'] );
$this->license = get_option( $this->prefix . '_license', "" );
if ( empty( $this->license ) || !empty( $this->license['issue'] ) )
return false;
if ( $this->license['expires'] == "lifetime" )
return true;
$datediff = strtotime( $this->license['expires'] ) - time();
$days = floor( $datediff / ( 60 * 60 * 24 ) );
if ( $days < 0 )
$this->validate_pro( $this->license['key'] );
return true;
}
function validate_pro( $subscr_id ) {
$prefix = $this->prefix;
delete_option( $prefix . '_license', "" );
if ( empty( $subscr_id ) )
return false;
$url = ( get_option( 'force_sslverify', false ) ? 'https' : 'http' ) .
'://store.meowapps.com/?edd_action=activate_license' .
'&item_name=' . urlencode( $this->item ) .
'&license=' . $subscr_id . '&url=' . strtolower( home_url() ) . '&cache=' . bin2hex( openssl_random_pseudo_bytes( 4 ) );
$response = wp_remote_get( $url, array(
'user-agent' => "MeowApps",
'sslverify' => get_option( 'force_sslverify', false ),
'timeout' => 45,
'method' => 'GET'
)
);
$body = is_array( $response ) ? $response['body'] : null;
$post = @json_decode( $body );
$status = null;
$license = null;
$expires = null;
$logs = null;
if ( !$post || ( property_exists( $post, 'code' ) ) ) {
$status = 'error';
// $status = __( "There was an error while validating the serial.
Please contact Meow Apps and mention the following log: