removing unneeded files from repo and plugin
All checks were successful
Create Release / build (push) Successful in 3s
All checks were successful
Create Release / build (push) Successful in 3s
This commit is contained in:
@@ -8,7 +8,33 @@ This guide shows developers how to integrate their WordPress plugins with the WP
|
||||
|
||||
Download `wpdd-plugin-updater.php` from your product page and include it in your plugin.
|
||||
|
||||
### 2. Basic Integration
|
||||
### 2. Minimal Integration
|
||||
|
||||
For the simplest integration with automatic license management:
|
||||
|
||||
```php
|
||||
<?php
|
||||
/**
|
||||
* Plugin Name: My Plugin
|
||||
* Version: 1.0.0
|
||||
*/
|
||||
|
||||
// Initialize updater with automatic settings page
|
||||
if (!class_exists('WPDD_Plugin_Updater') && is_admin()) {
|
||||
require_once plugin_dir_path(__FILE__) . 'includes/wpdd-plugin-updater.php';
|
||||
|
||||
new WPDD_Plugin_Updater(
|
||||
__FILE__,
|
||||
get_option('my_plugin_license_key', ''),
|
||||
'https://your-store.com',
|
||||
array('add_settings_page' => true)
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
This creates a license settings page under Settings → My Plugin License.
|
||||
|
||||
### 3. Full Integration
|
||||
|
||||
```php
|
||||
<?php
|
||||
@@ -17,8 +43,10 @@ Download `wpdd-plugin-updater.php` from your product page and include it in your
|
||||
* Version: 1.0.0
|
||||
*/
|
||||
|
||||
// Include the WPDD updater library
|
||||
require_once plugin_dir_path(__FILE__) . 'includes/wpdd-plugin-updater.php';
|
||||
// Include the WPDD updater library (check if class exists to avoid conflicts)
|
||||
if (!class_exists('WPDD_Plugin_Updater')) {
|
||||
require_once plugin_dir_path(__FILE__) . 'includes/wpdd-plugin-updater.php';
|
||||
}
|
||||
|
||||
class My_Awesome_Plugin {
|
||||
|
||||
@@ -68,13 +96,18 @@ class My_Plugin_Settings {
|
||||
}
|
||||
|
||||
private function init_updater() {
|
||||
// Check if updater class exists
|
||||
if (!class_exists('WPDD_Plugin_Updater')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$license_key = get_option('my_plugin_license_key', '');
|
||||
|
||||
$this->updater = new WPDD_Plugin_Updater(
|
||||
MY_PLUGIN_FILE,
|
||||
MY_PLUGIN_FILE, // Define this constant to your main plugin file
|
||||
$license_key,
|
||||
'https://your-store.com',
|
||||
array('add_settings_page' => false) // We'll handle settings ourselves
|
||||
array('add_settings_page' => false) // We'll handle settings ourselves
|
||||
);
|
||||
}
|
||||
|
||||
@@ -102,7 +135,7 @@ class My_Plugin_Settings {
|
||||
|
||||
public function render_license_section() {
|
||||
$license_key = get_option('my_plugin_license_key', '');
|
||||
$is_valid = $this->updater->validate_license();
|
||||
$is_valid = $this->updater ? $this->updater->validate_license() : false;
|
||||
|
||||
?>
|
||||
<h3>License Settings</h3>
|
||||
@@ -150,6 +183,11 @@ class My_Premium_Feature {
|
||||
private $updater;
|
||||
|
||||
public function __construct() {
|
||||
// Include updater if not already loaded
|
||||
if (!class_exists('WPDD_Plugin_Updater')) {
|
||||
require_once plugin_dir_path(__FILE__) . 'includes/wpdd-plugin-updater.php';
|
||||
}
|
||||
|
||||
$license_key = get_option('my_plugin_license_key', '');
|
||||
|
||||
$this->updater = new WPDD_Plugin_Updater(
|
||||
@@ -167,7 +205,8 @@ class My_Premium_Feature {
|
||||
}
|
||||
|
||||
private function is_license_valid() {
|
||||
return $this->updater->validate_license();
|
||||
// Check if updater exists and validate license
|
||||
return $this->updater ? $this->updater->validate_license() : false;
|
||||
}
|
||||
|
||||
private function enable_premium_features() {
|
||||
@@ -195,14 +234,20 @@ class My_Premium_Feature {
|
||||
|
||||
### WPDD_Plugin_Updater Class
|
||||
|
||||
#### Requirements
|
||||
|
||||
- **WordPress**: 5.0 or higher
|
||||
- **PHP**: 7.0 or higher
|
||||
- **Plugin Version Header**: Your main plugin file must include a Version header
|
||||
|
||||
#### Constructor Parameters
|
||||
|
||||
```php
|
||||
new WPDD_Plugin_Updater($plugin_file, $license_key, $update_server, $args);
|
||||
```
|
||||
|
||||
- **$plugin_file** (string) - Full path to your main plugin file
|
||||
- **$license_key** (string) - The user's license key
|
||||
- **$plugin_file** (string) - Full path to your main plugin file (typically `__FILE__`)
|
||||
- **$license_key** (string) - The user's license key (can be empty string)
|
||||
- **$update_server** (string) - URL to your store (e.g., 'https://your-store.com')
|
||||
- **$args** (array) - Optional arguments:
|
||||
- `add_settings_page` (bool) - Auto-create license settings page (default: false)
|
||||
@@ -352,10 +397,18 @@ Then visit: `wp-admin/plugins.php?force_update_check=1`
|
||||
Always handle API failures gracefully:
|
||||
|
||||
```php
|
||||
// Check if updater was initialized properly
|
||||
if (!$this->updater) {
|
||||
// Handle initialization failure
|
||||
error_log('WPDD Updater failed to initialize');
|
||||
return;
|
||||
}
|
||||
|
||||
$result = $updater->validate_license();
|
||||
if ($result === false) {
|
||||
// Network error or server down - allow functionality to continue
|
||||
// but maybe show a notice
|
||||
error_log('License validation failed - network or server issue');
|
||||
}
|
||||
```
|
||||
|
||||
@@ -388,13 +441,50 @@ if ($this->is_license_valid()) {
|
||||
}
|
||||
```
|
||||
|
||||
## What's New in Version 1.1.0
|
||||
|
||||
The updated `wpdd-plugin-updater.php` includes several improvements:
|
||||
|
||||
### Enhanced Error Handling
|
||||
- Better HTTP request error handling with status code checking
|
||||
- JSON validation to prevent parsing errors
|
||||
- Improved timeout handling (30 seconds default)
|
||||
- More detailed error logging for debugging
|
||||
|
||||
### Improved Compatibility
|
||||
- Better API response structure handling
|
||||
- Flexible URL checking for package downloads
|
||||
- Support for different server configurations
|
||||
- Fallback values for missing data fields
|
||||
|
||||
### Security Enhancements
|
||||
- SSL verification enabled by default
|
||||
- Proper input validation in constructor
|
||||
- Safe handling of network failures
|
||||
|
||||
### Performance Improvements
|
||||
- 12-hour caching for update checks
|
||||
- Optimized HTTP requests with proper headers
|
||||
- Reduced unnecessary API calls
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Common Issues
|
||||
|
||||
1. **Updates not showing:** Check that the plugin slug matches the product slug in your store
|
||||
2. **License validation fails:** Ensure the update server URL is correct and accessible
|
||||
3. **Download fails:** Verify the license is activated and not expired
|
||||
1. **Updates not showing:**
|
||||
- Check that the plugin slug matches the product slug in your store
|
||||
- Verify the plugin file has a proper Version header
|
||||
- Clear update transients using the force update check method
|
||||
|
||||
2. **License validation fails:**
|
||||
- Ensure the update server URL is correct and accessible
|
||||
- Check that the license key is properly formatted
|
||||
- Verify SSL certificates are valid on your server
|
||||
|
||||
3. **Download fails:**
|
||||
- Verify the license is activated and not expired
|
||||
- Check activation limits haven't been exceeded
|
||||
- Ensure the package file exists on the server
|
||||
|
||||
### Debug Mode
|
||||
|
||||
|
Reference in New Issue
Block a user