feat: enhance SitiWebUpdater2 with global license management and automatic updates
All checks were successful
Build & Release Plugin / release (push) Successful in 12s

This commit is contained in:
2026-02-01 03:46:14 +00:00
parent c279ea7247
commit 4a789363c5
3 changed files with 227 additions and 107 deletions

View File

@@ -1,85 +1,49 @@
# Nieuwe License Validator en Updater
# SitiWebUpdater2 - Globale Plugin Updater
Deze plugin gebruikt nu een eigen licentie- en updatesysteem via plugins.robert.ooo in plaats van GitHub.
Deze class gebruikt een globale registry zodat alle plugins die deze updater gebruiken hun licenties op één centrale pagina beheren.
## Gebruik
### License Validator
### Basis setup (per plugin)
```php
require_once __DIR__ . '/includes/SitiLicenseValidator.php';
require_once 'path/to/SitiWebUpdater2.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' );
$updater->set_owner( 'jouw-github-username' );
$updater->set_repository( 'jouw-plugin-repo' );
$updater->initialize();
```
## Instellingen
### Automatische features
Voeg in je admin settings pagina velden toe voor:
De updater doet alles automatisch:
- Licentiecode
- API URL (optioneel)
1. **Globale license pagina**: Voegt één instellingen pagina toe onder Instellingen > Plugin Licenties
2. **Admin notices**: Toont rood bericht per plugin als licentie ongeldig is
3. **Dagelijkse checks**: Controleert dagelijks alle licenties
4. **Auto-updates**: Controleert op updates voor alle plugins
Sla op in wp_options:
### Centrale licentie pagina
```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' );
```
Alle plugins die SitiWebUpdater2 gebruiken verschijnen automatisch op de centrale pagina `Instellingen > Plugin Licenties`, waar je alle licentiecodes in één keer kunt beheren.
## Cron Job voor Licentie Checks
## Configuratie
```php
add_action( 'siti_daily_license_check', function() {
$validator = new SitiLicenseValidator();
$result = $validator->verify();
// Log of handel af
} );
- **Owner/Repo**: Stel in via `set_owner()` en `set_repository()`
- **API URL**: Standaard `https://plugins.robert.ooo`, aanpasbaar met `set_api_base_url()`
- **License key**: Wordt opgeslagen in eigen option key per plugin
if ( ! wp_next_scheduled( 'siti_daily_license_check' ) ) {
wp_schedule_event( time(), 'daily', 'siti_daily_license_check' );
}
```
## Option Keys (per plugin)
## Admin Notices
- `siti_updater_{plugin_slug}_license_key`: De licentiecode
- `siti_updater_{plugin_slug}_license_data`: Gecachte licentie data
- `siti_updater_{plugin_slug}_last_check`: Timestamp laatste check
```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>';
}
} );
```
## Cron Jobs (per plugin)
- `siti_updater_daily_check_siti_updater_{plugin_slug}_`: Dagelijkse licentie verificatie
## Herbruikbaarheid
Deze class is volledig herbruikbaar in meerdere plugins. Elke plugin registreert zichzelf automatisch in de globale registry en verschijnt op de centrale licentie pagina.