feat: update version to 1.9.4 and enhance license validation handling
All checks were successful
Build & Release Plugin / release (push) Successful in 20s
All checks were successful
Build & Release Plugin / release (push) Successful in 20s
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
* Plugin Name: SitiAI Product Teksten
|
||||
* Description: Genereer productteksten met diverse AI-aanbieders rechtstreeks vanuit WooCommerce.
|
||||
* Version: 1.9.3
|
||||
* Version: 1.9.4
|
||||
* Author: Roberto Guagliardo | SitiWeb
|
||||
* Author URI: https://sitiweb.nl/
|
||||
* Text Domain: siti-ai-product-content-generator
|
||||
|
||||
@@ -79,22 +79,30 @@ class SitiLicenseValidator {
|
||||
$code = wp_remote_retrieve_response_code( $response );
|
||||
$body = json_decode( wp_remote_retrieve_body( $response ), true );
|
||||
|
||||
if ( ! is_array( $body ) ) {
|
||||
return new WP_Error( 'verification_failed', 'Onverwacht antwoord van licentieserver.' );
|
||||
}
|
||||
|
||||
$has_payload = isset( $body['license'] ) || isset( $body['pluginVersion'] ) || isset( $body['version'] );
|
||||
|
||||
if ( 200 !== $code ) {
|
||||
if ( $has_payload ) {
|
||||
$this->store_license_payload( $body );
|
||||
}
|
||||
|
||||
$error_message = isset( $body['error'] ) ? $body['error'] : 'Licentie verificatie mislukt.';
|
||||
return new WP_Error( 'verification_failed', $error_message );
|
||||
}
|
||||
|
||||
if ( empty( $body['valid'] ) ) {
|
||||
if ( $has_payload ) {
|
||||
$this->store_license_payload( $body );
|
||||
}
|
||||
|
||||
return new WP_Error( 'invalid_license', 'Licentie is ongeldig.' );
|
||||
}
|
||||
|
||||
// Update last check time
|
||||
update_option( 'siti_license_last_check', current_time( 'mysql' ) );
|
||||
|
||||
// Store license data
|
||||
if ( isset( $body['license'] ) ) {
|
||||
update_option( 'siti_license_data', $body['license'] );
|
||||
}
|
||||
$this->store_license_payload( $body );
|
||||
|
||||
return $body;
|
||||
}
|
||||
@@ -137,4 +145,37 @@ class SitiLicenseValidator {
|
||||
// In practice, you might want to proxy this through WordPress
|
||||
return $this->api_base_url . '/api/licenses/download?key=' . urlencode( $this->license_key ) . '&hostname=' . urlencode( $this->hostname ) . '&version=' . urlencode( $version );
|
||||
}
|
||||
|
||||
/**
|
||||
* Persist payload data locally for UI purposes
|
||||
*/
|
||||
private function store_license_payload( $body ) {
|
||||
$license_data = array();
|
||||
|
||||
if ( isset( $body['license'] ) && is_array( $body['license'] ) ) {
|
||||
$license_data = $body['license'];
|
||||
}
|
||||
|
||||
if ( empty( $license_data['key'] ) ) {
|
||||
$license_data['key'] = $this->license_key;
|
||||
}
|
||||
|
||||
$version = null;
|
||||
if ( ! empty( $body['pluginVersion'] ) ) {
|
||||
$version = $body['pluginVersion'];
|
||||
} elseif ( ! empty( $body['version'] ) ) {
|
||||
$version = $body['version'];
|
||||
}
|
||||
|
||||
if ( $version ) {
|
||||
$license_data['pluginVersion'] = $version;
|
||||
}
|
||||
|
||||
if ( empty( $license_data ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
update_option( 'siti_license_data', $license_data );
|
||||
update_option( 'siti_license_last_check', current_time( 'mysql' ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -273,14 +273,26 @@ class SitiWebUpdater2 {
|
||||
return new WP_Error( 'verification_failed', 'Onverwacht antwoord van licentieserver.' );
|
||||
}
|
||||
|
||||
$has_license_payload = isset( $body['license'] ) || isset( $body['pluginVersion'] ) || isset( $body['version'] );
|
||||
|
||||
if ( 200 !== $code ) {
|
||||
$error_message = isset( $body['error'] ) ? $body['error'] : 'Licentie verificatie mislukt.';
|
||||
if ( $has_license_payload ) {
|
||||
$this->store_license_data( $body );
|
||||
} else {
|
||||
$this->clear_cached_license_data();
|
||||
}
|
||||
|
||||
$error_message = isset( $body['error'] ) ? $body['error'] : 'Licentie verificatie mislukt.';
|
||||
return new WP_Error( 'verification_failed', $error_message );
|
||||
}
|
||||
|
||||
if ( empty( $body['valid'] ) ) {
|
||||
if ( $has_license_payload ) {
|
||||
$this->store_license_data( $body );
|
||||
} else {
|
||||
$this->clear_cached_license_data();
|
||||
}
|
||||
|
||||
return new WP_Error( 'invalid_license', 'Licentie is ongeldig.' );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user