You've already forked wc-licensed-product
Release v0.6.1 - UI improvements and bug fixes
- Fix admin license test popup showing empty product field - Display product name in bold in test license modal - Split auto-update settings into notification and auto-install options - Add filter functionality to customer account licenses page - Update translations (402 strings) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Jeremias\WcLicensedProduct\Update;
|
||||
|
||||
use Jeremias\WcLicensedProduct\Admin\SettingsController;
|
||||
use Jeremias\WcLicensedProduct\License\PluginLicenseChecker;
|
||||
use Symfony\Component\HttpClient\HttpClient;
|
||||
|
||||
@@ -74,8 +75,8 @@ final class PluginUpdateChecker
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
// Skip if auto-updates are disabled
|
||||
if ($this->isAutoUpdateDisabled()) {
|
||||
// Skip if update notifications are disabled
|
||||
if ($this->isUpdateNotificationDisabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -88,15 +89,19 @@ final class PluginUpdateChecker
|
||||
// Add authentication headers to download requests
|
||||
add_filter('http_request_args', [$this, 'addAuthHeaders'], 10, 2);
|
||||
|
||||
// Handle auto-install setting
|
||||
add_filter('auto_update_plugin', [$this, 'handleAutoInstall'], 10, 2);
|
||||
|
||||
// Clear cache on settings save
|
||||
add_action('update_option_wc_licensed_product_plugin_license_key', [$this, 'clearCache']);
|
||||
add_action('update_option_wc_licensed_product_plugin_license_server_url', [$this, 'clearCache']);
|
||||
add_action('update_option_wc_licensed_product_update_notification_enabled', [$this, 'clearCache']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if auto-updates are disabled
|
||||
* Check if update notifications are disabled
|
||||
*/
|
||||
private function isAutoUpdateDisabled(): bool
|
||||
private function isUpdateNotificationDisabled(): bool
|
||||
{
|
||||
// Check constant
|
||||
if (defined('WC_LICENSE_DISABLE_AUTO_UPDATE') && WC_LICENSE_DISABLE_AUTO_UPDATE) {
|
||||
@@ -104,8 +109,25 @@ final class PluginUpdateChecker
|
||||
}
|
||||
|
||||
// Check setting
|
||||
$enabled = get_option('wc_licensed_product_plugin_auto_update_enabled', 'yes');
|
||||
return $enabled !== 'yes';
|
||||
return !SettingsController::isUpdateNotificationEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle auto-install setting for WordPress automatic updates
|
||||
*
|
||||
* @param bool|null $update The update decision
|
||||
* @param object $item The plugin update object
|
||||
* @return bool|null Whether to auto-update this plugin
|
||||
*/
|
||||
public function handleAutoInstall($update, $item): ?bool
|
||||
{
|
||||
// Only handle our plugin
|
||||
if (!isset($item->plugin) || $item->plugin !== $this->pluginBasename) {
|
||||
return $update;
|
||||
}
|
||||
|
||||
// Return true to enable auto-install, false to disable, or null to use default
|
||||
return SettingsController::isAutoInstallEnabled() ? true : $update;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user