feat: update version to 1.9.4 and enhance license validation handling
All checks were successful
Build & Release Plugin / release (push) Successful in 20s

This commit is contained in:
2026-02-01 03:55:36 +00:00
parent 4a789363c5
commit ec08c79aab
3 changed files with 63 additions and 10 deletions

View File

@@ -2,7 +2,7 @@
/** /**
* Plugin Name: SitiAI Product Teksten * Plugin Name: SitiAI Product Teksten
* Description: Genereer productteksten met diverse AI-aanbieders rechtstreeks vanuit WooCommerce. * Description: Genereer productteksten met diverse AI-aanbieders rechtstreeks vanuit WooCommerce.
* Version: 1.9.3 * Version: 1.9.4
* Author: Roberto Guagliardo | SitiWeb * Author: Roberto Guagliardo | SitiWeb
* Author URI: https://sitiweb.nl/ * Author URI: https://sitiweb.nl/
* Text Domain: siti-ai-product-content-generator * Text Domain: siti-ai-product-content-generator

View File

@@ -79,22 +79,30 @@ class SitiLicenseValidator {
$code = wp_remote_retrieve_response_code( $response ); $code = wp_remote_retrieve_response_code( $response );
$body = json_decode( wp_remote_retrieve_body( $response ), true ); $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 ( 200 !== $code ) {
if ( $has_payload ) {
$this->store_license_payload( $body );
}
$error_message = isset( $body['error'] ) ? $body['error'] : 'Licentie verificatie mislukt.'; $error_message = isset( $body['error'] ) ? $body['error'] : 'Licentie verificatie mislukt.';
return new WP_Error( 'verification_failed', $error_message ); return new WP_Error( 'verification_failed', $error_message );
} }
if ( empty( $body['valid'] ) ) { if ( empty( $body['valid'] ) ) {
if ( $has_payload ) {
$this->store_license_payload( $body );
}
return new WP_Error( 'invalid_license', 'Licentie is ongeldig.' ); return new WP_Error( 'invalid_license', 'Licentie is ongeldig.' );
} }
// Update last check time $this->store_license_payload( $body );
update_option( 'siti_license_last_check', current_time( 'mysql' ) );
// Store license data
if ( isset( $body['license'] ) ) {
update_option( 'siti_license_data', $body['license'] );
}
return $body; return $body;
} }
@@ -137,4 +145,37 @@ class SitiLicenseValidator {
// In practice, you might want to proxy this through WordPress // 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 ); 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' ) );
}
} }

View File

@@ -273,14 +273,26 @@ class SitiWebUpdater2 {
return new WP_Error( 'verification_failed', 'Onverwacht antwoord van licentieserver.' ); 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 ) { if ( 200 !== $code ) {
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.'; $error_message = isset( $body['error'] ) ? $body['error'] : 'Licentie verificatie mislukt.';
$this->clear_cached_license_data();
return new WP_Error( 'verification_failed', $error_message ); return new WP_Error( 'verification_failed', $error_message );
} }
if ( empty( $body['valid'] ) ) { if ( empty( $body['valid'] ) ) {
$this->clear_cached_license_data(); if ( $has_license_payload ) {
$this->store_license_data( $body );
} else {
$this->clear_cached_license_data();
}
return new WP_Error( 'invalid_license', 'Licentie is ongeldig.' ); return new WP_Error( 'invalid_license', 'Licentie is ongeldig.' );
} }