feat: implement new license validation and updater system with SitiWebUpdater2
This commit is contained in:
85
LICENSE_INTEGRATION.md
Normal file
85
LICENSE_INTEGRATION.md
Normal file
@@ -0,0 +1,85 @@
|
||||
# Nieuwe License Validator en Updater
|
||||
|
||||
Deze plugin gebruikt nu een eigen licentie- en updatesysteem via plugins.robert.ooo in plaats van GitHub.
|
||||
|
||||
## Gebruik
|
||||
|
||||
### License Validator
|
||||
|
||||
```php
|
||||
require_once __DIR__ . '/includes/SitiLicenseValidator.php';
|
||||
|
||||
// Initialiseer validator
|
||||
$validator = new SitiLicenseValidator();
|
||||
|
||||
// Stel licentie in (van settings)
|
||||
$validator->set_license_key( get_option( 'siti_license_key' ) );
|
||||
|
||||
// Verificeer
|
||||
$result = $validator->verify();
|
||||
if ( is_wp_error( $result ) ) {
|
||||
// Toon fout
|
||||
echo $result->get_error_message();
|
||||
} else {
|
||||
// Licentie geldig
|
||||
$version = $result['license']['pluginVersion'];
|
||||
}
|
||||
```
|
||||
|
||||
### SitiWebUpdater2
|
||||
|
||||
```php
|
||||
require_once __DIR__ . '/includes/SitiWebUpdater2.php';
|
||||
|
||||
// Initialiseer updater
|
||||
$updater = new SitiWebUpdater2( __FILE__ );
|
||||
|
||||
// Stel owner/repo in (bijv. van manifest.json)
|
||||
$updater->set_owner( 'siti-ai-product-content-generator' );
|
||||
$updater->set_repository( 'siti-ai-product-content-generator' );
|
||||
|
||||
// Stel licentie in voor downloads
|
||||
$updater->set_license_key( get_option( 'siti_license_key' ) );
|
||||
|
||||
// API URL (optioneel, default is plugins.robert.ooo)
|
||||
$updater->set_api_base_url( 'https://plugins.robert.ooo' );
|
||||
```
|
||||
|
||||
## Instellingen
|
||||
|
||||
Voeg in je admin settings pagina velden toe voor:
|
||||
|
||||
- Licentiecode
|
||||
- API URL (optioneel)
|
||||
|
||||
Sla op in wp_options:
|
||||
|
||||
```php
|
||||
update_option( 'siti_license_key', sanitize_text_field( $_POST['license_key'] ) );
|
||||
update_option( 'siti_api_url', esc_url_raw( $_POST['api_url'] ) ?: 'https://plugins.robert.ooo' );
|
||||
```
|
||||
|
||||
## Cron Job voor Licentie Checks
|
||||
|
||||
```php
|
||||
add_action( 'siti_daily_license_check', function() {
|
||||
$validator = new SitiLicenseValidator();
|
||||
$result = $validator->verify();
|
||||
// Log of handel af
|
||||
} );
|
||||
|
||||
if ( ! wp_next_scheduled( 'siti_daily_license_check' ) ) {
|
||||
wp_schedule_event( time(), 'daily', 'siti_daily_license_check' );
|
||||
}
|
||||
```
|
||||
|
||||
## Admin Notices
|
||||
|
||||
```php
|
||||
add_action( 'admin_notices', function() {
|
||||
$validator = new SitiLicenseValidator();
|
||||
if ( ! $validator->is_valid() ) {
|
||||
echo '<div class="notice notice-error"><p>Licentie ongeldig. Controleer je instellingen.</p></div>';
|
||||
}
|
||||
} );
|
||||
```
|
||||
Reference in New Issue
Block a user