From 197fbf180dc5f2942dbf99d1566807777cdbc4b0 Mon Sep 17 00:00:00 2001 From: RajkiranBagal Date: Wed, 14 Oct 2026 20:05:12 +0530 Subject: [PATCH] Skip license notices when add_settings_error() isn't loaded get_activation() adds a notice on any API error, and add_settings_error() only exists in wp-admin. Calling it on init, the front end, REST, cron or WP-CLI fataled whenever the license API failed. Also bump to 1.2.3 and note in the README that bundled copies share one namespace. --- README.md | 2 ++ src/Client.php | 2 +- src/Settings.php | 5 +++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 04579a7..e4c4450 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,8 @@ if ( ! class_exists( 'SureCart\Licensing\Client' ) ) { } ``` +**Note:** Every plugin or theme that bundles the SDK shares the `SureCart\Licensing` namespace, so whichever copy loads first is used by all of them. An older copy bundled elsewhere can override fixes in yours. We recommend prefixing the namespace with a scoper such as [Strauss](https://github.com/BrianHenryIE/strauss) or [PHP-Scoper](https://github.com/humbug/php-scoper) when bundling. + ## Include a release.json Add a `release.json` file to the root of your plugin or theme project. diff --git a/src/Client.php b/src/Client.php index 935508a..92871dd 100644 --- a/src/Client.php +++ b/src/Client.php @@ -12,7 +12,7 @@ class Client { * * @var string */ - public $version = '1.2.2'; + public $version = '1.2.3'; /** * Name of the plugin diff --git a/src/Settings.php b/src/Settings.php index 5924986..9d0c35f 100644 --- a/src/Settings.php +++ b/src/Settings.php @@ -413,6 +413,11 @@ public function redirect( $url ) { * @return void */ public function add_notice( $code, $message, $type = 'info' ) { + // Only loaded in wp-admin; the settings page re-runs get_activation() on render. + if ( ! function_exists( 'add_settings_error' ) ) { + return; + } + add_settings_error( $this->name . '_license_options', // matches what we registered in `register_setting. $code, // the error code.