Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/storegrowth-sales-booster/assets/build/modules.asset.php
+++ b/storegrowth-sales-booster/assets/build/modules.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => '64f5f4cdd07521fd8f88');
+<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => '06c3215a373f0a28a2c9');
--- a/storegrowth-sales-booster/assets/build/notices.asset.php
+++ b/storegrowth-sales-booster/assets/build/notices.asset.php
@@ -0,0 +1 @@
+<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-api-fetch', 'wp-components', 'wp-date', 'wp-element', 'wp-hooks', 'wp-i18n'), 'version' => '3fe45395ef3d1e260240');
--- a/storegrowth-sales-booster/assets/build/settings.asset.php
+++ b/storegrowth-sales-booster/assets/build/settings.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-data', 'wp-element', 'wp-hooks', 'wp-i18n'), 'version' => '497c2b9cf297357b79b9');
+<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-data', 'wp-element', 'wp-hooks', 'wp-i18n'), 'version' => 'fafae39e65ab5dcc8693');
--- a/storegrowth-sales-booster/includes/Admin/AdminMenu.php
+++ b/storegrowth-sales-booster/includes/Admin/AdminMenu.php
@@ -127,14 +127,14 @@
* Display module page content.
*/
public function modules_callback() {
- echo '<div class="wrap"><div id="sbooster-modules-page"></div></div>';
+ echo '<div class="wrap"><div id="spsg-admin-notices"></div><div id="sbooster-modules-page"></div></div>';
}
/**
* Display settings page content.
*/
public function settings_callback() {
- echo '<div class="wrap"><div id="sbooster-settings-page"></div></div>';
+ echo '<div class="wrap"><div id="spsg-admin-notices"></div><div id="sbooster-settings-page"></div></div>';
}
/**
@@ -162,7 +162,9 @@
*/
private function redirect_to_url( $url ) {
if ( ! empty( $url ) ) {
- wp_redirect( $url );
+ // Deliberate off-site redirect to storegrowth.io; wp_safe_redirect() would
+ // reject the external host and bounce back to wp-admin.
+ wp_redirect( $url ); // phpcs:ignore WordPress.Security.SafeRedirect.wp_redirect_wp_redirect
exit;
}
}
@@ -176,9 +178,12 @@
'go-spsg-docs' => 'https://storegrowth.io/docs/',
);
- if ( ! empty( $_GET['page'] ) && isset( $redirect_pages[ $_GET['page'] ] ) ) {
- $redirect_url = $redirect_pages[ $_GET['page'] ];
- $this->redirect_to_url( $redirect_url );
+ // Reads the admin menu slug only; no form data is processed, so there is
+ // no nonce to verify. The value is matched against a fixed whitelist below.
+ $page = isset( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
+
+ if ( isset( $redirect_pages[ $page ] ) ) {
+ $this->redirect_to_url( $redirect_pages[ $page ] );
}
}
}
--- a/storegrowth-sales-booster/includes/Ajax.php
+++ b/storegrowth-sales-booster/includes/Ajax.php
@@ -7,8 +7,6 @@
namespace StorePulseStoreGrowth;
-use WP_Error;
-
use StorePulseStoreGrowthTraitsSingleton;
// If this file is called directly, abort.
@@ -24,39 +22,13 @@
use Singleton;
/**
- * Insights Version
- */
- const INVZ_VERSION = '1.0.0';
-
- /**
- * API URL
- */
- const API_URL = '#';
-
- /**
- * Installed Plugin File
- *
- * @var string
- */
- private $plugin_file = null;
-
- /**
- * Installed Plugin Name
- *
- * @var string
- */
- private $plugin_name = null;
- /**
* Constructor of _Ajax class.
*/
public function __construct() {
- $this->plugin_file = plugin_dir_path( __FILE__ ) . '../storegrowth-sales-booster.php';
- $this->plugin_name = basename( $this->plugin_file, '.php' );
add_action( 'wp_ajax_spsg_admin_ajax', array( $this, 'admin_ajax' ) );
/**
* Register ajax callback
*/
- add_action( 'wp_ajax_spsg_process_user_concent_data', array( $this, 'spsg_process_user_concent_data' ) );
add_action( 'wp_ajax_spsg_inisetup_flag_update', array( $this, 'spsg_inisetup_flag_update' ) );
}
@@ -69,16 +41,26 @@
public function admin_ajax() {
check_ajax_referer( 'spsg_ajax_nonce' );
+ if ( ! current_user_can( 'manage_options' ) ) {
+ wp_send_json_error( __( 'You are not allowed to perform this action.', 'storegrowth-sales-booster' ), 403 );
+ }
+
if ( ! isset( $_POST['method'] ) ) {
wp_die();
}
$method = sanitize_text_field( wp_unslash( $_POST['method'] ) );
- if ( method_exists( $this, $method ) ) {
- call_user_func( array( $this, $method ) );
+ // Only these methods may be dispatched from this endpoint. Never call an
+ // arbitrary method name taken from the request.
+ $allowed_methods = array( 'get_all_modules', 'update_module_status' );
+
+ if ( ! in_array( $method, $allowed_methods, true ) || ! method_exists( $this, $method ) ) {
+ wp_send_json_error( __( 'Method not allowed.', 'storegrowth-sales-booster' ), 400 );
}
+ call_user_func( array( $this, $method ) );
+
wp_die();
}
@@ -127,156 +109,15 @@
wp_send_json_success();
}
/**
- * Collect plugin data,
- * Retrieve current plugin information
- *
- * @since 3.0.0
+ * Flag the initial setup wizard as completed.
*/
- public function plugin_data() {
- if ( ! function_exists( 'get_plugin_data' ) ) {
- include ABSPATH . '/wp-admin/includes/plugin.php';
- }
- $plugin = get_plugin_data( $this->plugin_file );
- return $plugin;
- }
- public function spsg_collect_non_sensitive_data() {
- $body = array(
- 'plugin_slug' => sanitize_text_field( $this->plugin_name ),
- 'url' => get_bloginfo( 'url' ),
- 'site_name' => get_bloginfo( 'name' ),
- 'site_version' => get_bloginfo( 'version' ),
- 'site_language' => get_bloginfo( 'language' ),
- 'charset' => get_bloginfo( 'charset' ),
- 'wpins_version' => self::INVZ_VERSION,
- 'php_version' => phpversion(),
- 'multisite' => is_multisite(),
- 'file_location' => __FILE__,
- );
-
- // Collect the email if the correct option has been set
-
- if ( ! function_exists( 'wp_get_current_user' ) ) {
- include ABSPATH . 'wp-includes/pluggable.php';
- }
- $current_user = wp_get_current_user();
- $email = $current_user->user_email;
- if ( is_email( $email ) ) {
- $body['email'] = $email;
- }
- $body['server'] = isset( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : '';
-
- /**
- * Collect all active and inactive plugins
- */
- if ( ! function_exists( 'get_plugins' ) ) {
- include ABSPATH . '/wp-admin/includes/plugin.php';
- }
- $plugins = array_keys( get_plugins() );
- $active_plugins = is_network_admin() ? array_keys( get_site_option( 'active_sitewide_plugins', array() ) ) : get_option( 'active_plugins', array() );
- foreach ( $plugins as $key => $plugin ) {
- if ( in_array( $plugin, $active_plugins ) ) {
- unset( $plugins[ $key ] );
- }
- }
- $body['active_plugins'] = $active_plugins;
- $body['inactive_plugins'] = $plugins;
-
- /**
- * Text Direction.
- */
- $body['text_direction'] = ( function_exists( 'is_rtl' ) ? ( is_rtl() ? 'RTL' : 'LTR' ) : 'NOT SET' );
- /**
- * Get Our Plugin Data.
- *
- * @since 3.0.0
- */
- $plugin = $this->plugin_data();
- if ( empty( $plugin ) ) {
- $body['message'] = ( $body['message'] ?? '' ) . __( 'We can't detect any plugin information. This is most probably because you have not included the code in the plugin main file.', 'storegrowth-sales-booster' );
- $body['status'] = 'NOT FOUND';
- } else {
- if ( isset( $plugin['Name'] ) ) {
- $body['plugin'] = sanitize_text_field( $plugin['Name'] );
- }
- if ( isset( $plugin['Version'] ) ) {
- $body['version'] = sanitize_text_field( $plugin['Version'] );
- }
- $body['status'] = 'Active';
- }
-
- /**
- * Get active theme name and version
- *
- * @since 3.0.0
- */
- $theme = wp_get_theme();
- if ( $theme->Name ) {
- $body['theme'] = sanitize_text_field( $theme->Name );
- }
- if ( $theme->Version ) {
- $body['theme_version'] = sanitize_text_field( $theme->Version );
- }
- return $body;
- }
- /**
- * Process Consent Data
- */
- public function spsg_process_user_concent_data() {
+ public function spsg_inisetup_flag_update() {
check_ajax_referer( 'spsg_ajax_nonce', '_ajax_nonce' );
- $post_data = json_decode( wp_unslash( stripslashes( $_POST['data'] ) ) );
-
- $update_news = $post_data->update_news;
- $user_details = $post_data->user_details;
- if ( ! $update_news && ! $user_details ) {
- return;
+ if ( ! current_user_can( 'manage_options' ) ) {
+ wp_send_json_error( __( 'You are not allowed to perform this action.', 'storegrowth-sales-booster' ), 403 );
}
- $data_to_send = $this->spsg_collect_non_sensitive_data();
-
- $request_args = [
- 'data_to_send' => $data_to_send,
- 'body' => wp_json_encode( $data_to_send ),
- 'headers' => [
- 'Content-Type' => 'application/json',
- ],
- 'timeout' => 30,
- 'redirection' => 5,
- 'blocking' => true,
- 'httpversion' => '1.0',
- 'sslverify' => true,
- 'data_format' => 'body',
- ];
-
- $old_data = StorePulseStoreGrowthHelper::get_settings( 'spsg_user_consent_data', [] );
- array_push( $old_data, $request_args );
- update_option( 'spsg_user_consent_data', $old_data );
-
-// TODO: we can use this code to send data to different server in future.
-
-// $response = wp_remote_post( self::API_URL, $request_args );
-//
-// if ( is_wp_error( $response ) ) {
-// $error_message = $response->get_error_message();
-// return new WP_Error( 'api_error', $error_message );
-// } else {
-// $response_code = wp_remote_retrieve_response_code( $response );
-// if ( $response_code === 200 ) {
-// $response_body = wp_remote_retrieve_body( $response );
-// return $response_body;
-// } else {
-// return new WP_Error( 'api_error', 'API returned unexpected response code: ' . $response_code );
-// }
-// }
-
- wp_send_json_success( array( 'message' => 'Success message' ) );
- wp_die();
- }
- /**
- * Process Consent Data
- */
- public function spsg_inisetup_flag_update() {
- check_ajax_referer( 'spsg_ajax_nonce', '_ajax_nonce' );
$flag_data = isset( $_POST['spsg_ini_completion'] );
update_option( 'spsg_ini_completion', $flag_data );
wp_send_json_success( array( 'message' => 'Success message' ) );
--- a/storegrowth-sales-booster/includes/Assets.php
+++ b/storegrowth-sales-booster/includes/Assets.php
@@ -39,42 +39,51 @@
* Constructor of Enqueue class.
*/
private function __construct() {
- add_action( 'init', array( $this, 'register_all_scripts' ) );
+ add_action( 'init', array( $this, 'register_all_scripts' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ), 11 );
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_styles' ) );
}
- /**
- * Register scripts here.
- *
- * @return void
- */
- public function register_all_scripts() {
- wp_register_script(
- 'spsg-accounting',
- WC()->plugin_url() . '/assets/js/accounting/accounting.min.js',
- [ 'jquery' ]
- );
-
- // localize dokan frontend script
- wp_localize_script(
- 'spsg-accounting',
- 'spsg',
- apply_filters(
- 'spsg_global_common_localized_args',
- array(
- 'currency' => array(
- 'precision' => wc_get_price_decimals(),
- 'symbol' => html_entity_decode( get_woocommerce_currency_symbol() ),
- 'decimal' => esc_attr( wc_get_price_decimal_separator() ),
- 'thousand' => esc_attr( wc_get_price_thousand_separator() ),
- 'position' => esc_attr( get_option( 'woocommerce_currency_pos' ) ),
- 'format' => esc_attr( str_replace( [ '%1$s', '%2$s' ], [ '%s', '%v' ], get_woocommerce_price_format() ) ), // For accounting JS
- ),
- )
- ),
- );
- }
+ /**
+ * Register scripts here.
+ *
+ * @return void
+ */
+ public function register_all_scripts() {
+ wp_register_script(
+ 'spsg-accounting',
+ WC()->plugin_url() . '/assets/js/accounting/accounting.min.js',
+ [ 'jquery' ],
+ WC()->version,
+ false
+ );
+
+ // Localize the accounting script shared by every admin screen.
+ wp_localize_script(
+ 'spsg-accounting',
+ 'spsg',
+ /**
+ * Filters the arguments localized for the shared `spsg` script object.
+ *
+ * @since 2.0.1
+ *
+ * @param array $args Localized arguments, keyed by name.
+ */
+ apply_filters(
+ 'spsg_global_common_localized_args',
+ array(
+ 'currency' => array(
+ 'precision' => wc_get_price_decimals(),
+ 'symbol' => html_entity_decode( get_woocommerce_currency_symbol() ),
+ 'decimal' => esc_attr( wc_get_price_decimal_separator() ),
+ 'thousand' => esc_attr( wc_get_price_thousand_separator() ),
+ 'position' => esc_attr( get_option( 'woocommerce_currency_pos' ) ),
+ 'format' => esc_attr( str_replace( [ '%1$s', '%2$s' ], [ '%s', '%v' ], get_woocommerce_price_format() ) ), // For accounting JS.
+ ),
+ )
+ ),
+ );
+ }
/**
* Add JS scripts to admin.
@@ -82,14 +91,38 @@
* @param string $hook page slug.
*/
public function admin_enqueue_scripts( $hook ) {
+ if (
+ $this->modules_page_hook === $hook
+ || $this->settings_page_hook === $hook
+ ) {
+ $notices_file = require Helper::get_plugin_path( 'assets/build/notices.asset.php' );
+
+ wp_enqueue_script(
+ 'spsg-notices-script',
+ Helper::get_plugin_assets_url( 'build/notices.js' ),
+ $notices_file['dependencies'],
+ $notices_file['version'],
+ true
+ );
+
+ wp_localize_script(
+ 'spsg-notices-script',
+ 'spsgNotices',
+ [
+ 'noticesUrl' => rest_url( Upgrader::REST_NAMESPACE . '/notices/admin' ),
+ 'actionUrl' => rest_url( Upgrader::REST_NAMESPACE . '/migration/upgrade' ),
+ ]
+ );
+ }
+
if ( $this->modules_page_hook === $hook ) {
$settings_file = require Helper::get_plugin_path( 'assets/build/modules.asset.php' );
- $dependencies = array_merge( $settings_file['dependencies'], [ 'spsg-accounting' ] );
+ $dependencies = array_merge( $settings_file['dependencies'], [ 'spsg-accounting' ] );
wp_enqueue_script(
'spsg-modules-script',
Helper::get_plugin_assets_url( 'build/modules.js' ),
- $dependencies,
+ $dependencies,
$settings_file['version'],
true
);
@@ -108,11 +141,11 @@
if ( $this->settings_page_hook === $hook ) {
$settings_file = require Helper::get_plugin_path( 'assets/build/settings.asset.php' );
- $dependencies = array_merge( $settings_file['dependencies'], [ 'spsg-accounting' ] );
+ $dependencies = array_merge( $settings_file['dependencies'], [ 'spsg-accounting' ] );
wp_enqueue_script(
'spsg-settings-script',
Helper::get_plugin_assets_url( 'build/settings.js' ),
- $dependencies,
+ $dependencies,
$settings_file['version'],
true
);
@@ -146,6 +179,14 @@
array(),
filemtime( Helper::get_plugin_path( 'assets/build/modules.css' ) )
);
+
+ // Styles of the standalone admin notice app.
+ wp_enqueue_style(
+ 'spsg-notices-style',
+ Helper::get_plugin_assets_url( 'build/notices.css' ),
+ [ 'spsg-admin-style' ],
+ filemtime( Helper::get_plugin_path( 'assets/build/notices.css' ) )
+ );
}
}
}
--- a/storegrowth-sales-booster/includes/Bootstrap.php
+++ b/storegrowth-sales-booster/includes/Bootstrap.php
@@ -29,12 +29,22 @@
public ?Tracker $tracker = null;
/**
+ * Minimum WooCommerce version the plugin supports.
+ *
+ * @since 2.1.2
+ *
+ * @var string
+ */
+ const MIN_WC_VERSION = '8.0';
+
+ /**
* Constructor of Bootstrap class.
*/
private function __construct() {
$this->tracker = new Tracker();
add_action( 'woocommerce_loaded', [ $this, 'on_wc_loaded' ] );
add_action( 'admin_notices', [ $this, 'show_notice_if_wc_is_not_active' ] );
+ add_action( 'admin_notices', [ $this, 'show_notice_if_wc_below_minimum' ] );
}
public function show_notice_if_wc_is_not_active(): void {
@@ -51,6 +61,29 @@
printf( '<div class="%1$s"><p><strong>%2$s</strong></p></div>', esc_attr( 'notice notice-error' ), wp_kses_post( $message ) );
}
+ /**
+ * Warn, without disabling anything, when WooCommerce is older than the
+ * supported floor.
+ *
+ * @since 2.1.2
+ *
+ * @return void
+ */
+ public function show_notice_if_wc_below_minimum(): void {
+ if ( ! defined( 'WC_VERSION' ) || version_compare( WC_VERSION, self::MIN_WC_VERSION, '>=' ) ) {
+ return;
+ }
+
+ $message = sprintf(
+ // translators: 1: required WooCommerce version, 2: active WooCommerce version.
+ __( 'StoreGrowth is built for WooCommerce %1$s or newer. You are running %2$s; please update WooCommerce for full compatibility.', 'storegrowth-sales-booster' ),
+ esc_html( self::MIN_WC_VERSION ),
+ esc_html( WC_VERSION )
+ );
+
+ printf( '<div class="%1$s"><p><strong>%2$s</strong></p></div>', esc_attr( 'notice notice-warning' ), wp_kses_post( $message ) );
+ }
+
public function on_wc_loaded(): void {
do_action( 'storegrowth_before_load' );
--- a/storegrowth-sales-booster/includes/DependencyManagement/BaseServiceProvider.php
+++ b/storegrowth-sales-booster/includes/DependencyManagement/BaseServiceProvider.php
@@ -32,7 +32,7 @@
* @return bool True if the service provider can provide the service, false otherwise.
*/
public function provides( string $alias ): bool {
- static $implements = array();
+ $implements = array();
foreach ( $this->services as $class ) {
if ( ! class_exists( $class ) ) {
--- a/storegrowth-sales-booster/includes/DependencyManagement/Providers/CommonServiceProvider.php
+++ b/storegrowth-sales-booster/includes/DependencyManagement/Providers/CommonServiceProvider.php
@@ -1,35 +1,81 @@
<?php
+/**
+ * Common service provider.
+ *
+ * @package StorePulseStoreGrowth
+ */
namespace StorePulseStoreGrowthDependencyManagementProviders;
use StorePulseStoreGrowthDependencyManagementBootableServiceProvider;
+use StorePulseStoreGrowthUpgrader;
use StorePulseStoreGrowthRESTProductController;
+/**
+ * CommonServiceProvider Class
+ *
+ * Registers the services that are shared across the plugin, regardless of
+ * which modules are active.
+ */
class CommonServiceProvider extends BootableServiceProvider {
/**
- * Tag for services added to the container.
- */
+ * Services added to the container.
+ *
+ * @var string[]
+ */
+ protected $services = [
+ ProductController::class,
+ Upgrader::class,
+ ];
+
+ /**
+ * Whether the services have already been registered.
+ *
+ * @since 2.1.2
+ *
+ * @var bool
+ */
+ protected $is_registered = false;
+
+ /**
+ * Boot the provider.
+ *
+ * Registration cannot be left to the container's lazy resolution: it only falls
+ * through to a service provider when no definition already carries the requested
+ * tag, and the module providers register their own `WP_REST_Controller` /
+ * `HookRegistry` definitions first, so this provider would never be asked.
+ *
+ * It also cannot run right now: `ProductController` extends a WooCommerce class,
+ * and the tags are derived from the parent chain, so WooCommerce must have
+ * declared its classes first.
+ *
+ * @inheritDoc
+ *
+ * @return void
+ */
+ public function boot(): void {
+ if ( did_action( 'woocommerce_loaded' ) ) {
+ $this->register();
+
+ return;
+ }
+
+ add_action( 'woocommerce_loaded', [ $this, 'register' ], 0 );
+ }
+
+ /**
+ * Register the classes.
+ */
+ public function register(): void {
+ if ( $this->is_registered ) {
+ return;
+ }
+
+ $this->is_registered = true;
- protected $services = [
- ProductController::class
- ];
-
- /**
- * @inheritDoc
- *
- * @return void
- */
- public function boot(): void {
-
- }
-
- /**
- * Register the classes.
- */
- public function register(): void {
foreach ( $this->services as $service ) {
- $this->share_with_implements_tags( $service );
- }
- }
+ $this->share_with_implements_tags( $service );
+ }
+ }
}
--- a/storegrowth-sales-booster/includes/Helper.php
+++ b/storegrowth-sales-booster/includes/Helper.php
@@ -204,10 +204,12 @@
* @return boolean True if the module is active, false otherwise.
*/
public static function is_module_active( string $module_id ): bool {
- $modules = new ModuleManager();
- $active_modules = $modules->get_active_modules();
+ // `get_active_modules()` returns ModuleSkeleton objects, so a string ID
+ // is never strictly equal to any element. Resolve by ID and read the
+ // module's own state instead, which also returns false for unknown IDs.
+ $modules = new ModuleManager();
- return in_array( $module_id, $active_modules, true );
+ return $modules->is_active_module( $module_id );
}
/**
--- a/storegrowth-sales-booster/includes/Migrations/BaseMigration.php
+++ b/storegrowth-sales-booster/includes/Migrations/BaseMigration.php
@@ -0,0 +1,37 @@
+<?php
+/**
+ * File for BaseMigration class.
+ *
+ * @package SBFW
+ */
+
+namespace StorePulseStoreGrowthMigrations;
+
+use StorePulseStoreGrowthUpgrader;
+use StorePulseStoreGrowthThirdPartyPackagesWeDevsWPKitMigrationBaseMigration as WPKitMigration;
+
+// If this file is called directly, abort.
+if ( ! defined( 'ABSPATH' ) ) {
+ exit;
+}
+
+/**
+ * Base class of every StoreGrowth migration.
+ *
+ * Binds the WPKit migration runner to the plugin database version option. Child
+ * classes are named after the version they ship in (`V_2_1_2` => `2.1.2`) and
+ * every public static method they declare is executed by the runner.
+ *
+ * @since 2.1.2
+ */
+abstract class BaseMigration extends WPKitMigration {
+
+ /**
+ * Option key holding the migrated database version.
+ *
+ * @since 2.1.2
+ *
+ * @var string
+ */
+ protected static string $db_version_key = Upgrader::DB_VERSION_KEY;
+}
--- a/storegrowth-sales-booster/includes/Migrations/V_2_1_2.php
+++ b/storegrowth-sales-booster/includes/Migrations/V_2_1_2.php
@@ -0,0 +1,38 @@
+<?php
+/**
+ * File for V_2_1_2 migration class.
+ *
+ * @package SBFW
+ */
+
+namespace StorePulseStoreGrowthMigrations;
+
+// If this file is called directly, abort.
+if ( ! defined( 'ABSPATH' ) ) {
+ exit;
+}
+
+/**
+ * Migration shipped with 2.1.2.
+ *
+ * @since 2.1.2
+ */
+class V_2_1_2 extends BaseMigration {
+
+ /**
+ * Drop the consent records left behind by the removed setup wizard handler.
+ *
+ * Every consent appended a full request payload — the administrator email
+ * address, the site plugin list and a duplicate JSON copy of the same data —
+ * to the autoloaded `spsg_user_consent_data` option. Nothing read it, it was
+ * never sent anywhere, and the telemetry it duplicated is collected by the
+ * Appsero client instead.
+ *
+ * @since 2.1.2
+ *
+ * @return void
+ */
+ public static function remove_legacy_consent_data(): void {
+ delete_option( 'spsg_user_consent_data' );
+ }
+}
--- a/storegrowth-sales-booster/includes/ModuleManager.php
+++ b/storegrowth-sales-booster/includes/ModuleManager.php
@@ -120,10 +120,15 @@
* @return ModuleSkeleton|null
*/
public function get( string $module_id ): ?ModuleSkeleton {
- $module = array_find( $this->get_all(), function ( ModuleSkeleton $module ) use ( $module_id ) {
- return $module->get_id() === $module_id;
- } );
+ // A plain loop instead of array_find(): the latter is a PHP 8.4 function
+ // only polyfilled by WordPress core from 6.8 onward, so it fataled when
+ // toggling a module on WordPress < 6.8 with PHP < 8.4.
+ foreach ( $this->get_all() as $module ) {
+ if ( $module->get_id() === $module_id ) {
+ return $module;
+ }
+ }
- return $module;
+ return null;
}
}
--- a/storegrowth-sales-booster/includes/Notices/UpgradeNoticeProvider.php
+++ b/storegrowth-sales-booster/includes/Notices/UpgradeNoticeProvider.php
@@ -0,0 +1,100 @@
+<?php
+/**
+ * File for UpgradeNoticeProvider class.
+ *
+ * @package SBFW
+ */
+
+namespace StorePulseStoreGrowthNotices;
+
+use StorePulseStoreGrowthThirdPartyPackagesWeDevsWPKitAdminNotificationContractsNoticeProviderInterface;
+use StorePulseStoreGrowthThirdPartyPackagesWeDevsWPKitAdminNotificationNotice;
+use StorePulseStoreGrowthThirdPartyPackagesWeDevsWPKitAdminNotificationNotificationHelper;
+use StorePulseStoreGrowthThirdPartyPackagesWeDevsWPKitMigrationMigrationManager;
+
+// If this file is called directly, abort.
+if ( ! defined( 'ABSPATH' ) ) {
+ exit;
+}
+
+/**
+ * Notice asking the merchant to run the pending database migrations.
+ *
+ * @since 2.1.2
+ */
+class UpgradeNoticeProvider implements NoticeProviderInterface {
+
+ /**
+ * Key identifying the notice.
+ *
+ * @since 2.1.2
+ */
+ const NOTICE_KEY = 'spsg_database_upgrade_required';
+
+ /**
+ * Migration manager.
+ *
+ * @since 2.1.2
+ *
+ * @var MigrationManager
+ */
+ protected MigrationManager $manager;
+
+ /**
+ * Constructor.
+ *
+ * @since 2.1.2
+ *
+ * @param MigrationManager $manager Migration manager.
+ */
+ public function __construct( MigrationManager $manager ) {
+ $this->manager = $manager;
+ }
+
+ /**
+ * Return the upgrade notice while migrations are pending.
+ *
+ * @since 2.1.2
+ *
+ * @return array
+ */
+ public function get_notices(): array {
+ if ( ! $this->manager->is_upgrade_required() ) {
+ return [];
+ }
+
+ return [
+ new Notice(
+ NotificationHelper::warning(
+ __( 'StoreGrowth database update required', 'storegrowth-sales-booster' ),
+ __( 'This update removes data StoreGrowth no longer uses, including stored administrator email addresses. It runs once and takes a moment.', 'storegrowth-sales-booster' ),
+ [
+ 'key' => self::NOTICE_KEY,
+ 'scope' => 'global',
+ 'priority' => 1,
+ 'is_dismissible' => false,
+ 'actions' => [
+
+ /*
+ * The plugin-ui AdminNotice component posts form encoded
+ * `ajax_data` to the endpoint the app is mounted with, which
+ * is the WPKit migration upgrade route. The route takes no
+ * parameters, so the payload only marks the action as one to
+ * post rather than a link to follow.
+ */
+ [
+ 'type' => 'primary',
+ 'text' => __( 'Run the update', 'storegrowth-sales-booster' ),
+ 'loading_text' => __( 'Updating…', 'storegrowth-sales-booster' ),
+ 'ajax_data' => [
+ 'action' => 'storegrowth_run_migrations',
+ ],
+ 'reload' => true,
+ ],
+ ],
+ ]
+ )
+ ),
+ ];
+ }
+}
--- a/storegrowth-sales-booster/includes/Upgrader.php
+++ b/storegrowth-sales-booster/includes/Upgrader.php
@@ -0,0 +1,175 @@
+<?php
+/**
+ * File for Upgrader class.
+ *
+ * @package SBFW
+ */
+
+namespace StorePulseStoreGrowth;
+
+use StorePulseStoreGrowthInterfacesHookRegistry;
+use StorePulseStoreGrowthMigrationsV_2_1_2;
+use StorePulseStoreGrowthNoticesUpgradeNoticeProvider;
+use StorePulseStoreGrowthThirdPartyPackagesWeDevsWPKitAdminNotificationNoticeManager;
+use StorePulseStoreGrowthThirdPartyPackagesWeDevsWPKitAdminNotificationNoticeRESTController;
+use StorePulseStoreGrowthThirdPartyPackagesWeDevsWPKitMigrationMigrationHooks;
+use StorePulseStoreGrowthThirdPartyPackagesWeDevsWPKitMigrationMigrationManager;
+use StorePulseStoreGrowthThirdPartyPackagesWeDevsWPKitMigrationMigrationRegistry;
+use StorePulseStoreGrowthThirdPartyPackagesWeDevsWPKitMigrationMigrationRESTController;
+
+// If this file is called directly, abort.
+if ( ! defined( 'ABSPATH' ) ) {
+ exit;
+}
+
+/**
+ * Database upgrades and the admin notice that triggers them.
+ *
+ * Migrations are versioned and run on demand: the merchant is told an update is
+ * pending through the REST backed notice feed, and the upgrade runs when they
+ * confirm it, instead of on an arbitrary page load.
+ *
+ * @since 2.1.2
+ */
+class Upgrader implements HookRegistry {
+
+ /**
+ * Option key holding the migrated database version.
+ *
+ * @since 2.1.2
+ */
+ const DB_VERSION_KEY = 'spsg_db_version';
+
+ /**
+ * Prefix of the hooks and options owned by the migration runner.
+ *
+ * @since 2.1.2
+ */
+ const PREFIX = 'storegrowth';
+
+ /**
+ * REST namespace serving the migration and notice routes.
+ *
+ * @since 2.1.2
+ */
+ const REST_NAMESPACE = 'sales-booster/v1';
+
+ /**
+ * Options proving the plugin ran before the database version was tracked.
+ *
+ * @since 2.1.2
+ */
+ const LEGACY_INSTALL_OPTIONS = [
+ 'spsg_active_module_ids',
+ 'spsg_ini_completion',
+ 'spsg_user_consent_data',
+ ];
+
+ /**
+ * Migration registry.
+ *
+ * @since 2.1.2
+ *
+ * @var MigrationRegistry
+ */
+ protected MigrationRegistry $registry;
+
+ /**
+ * Migration manager.
+ *
+ * @since 2.1.2
+ *
+ * @var MigrationManager
+ */
+ protected MigrationManager $manager;
+
+ /**
+ * Admin notice manager.
+ *
+ * @since 2.1.2
+ *
+ * @var NoticeManager
+ */
+ protected NoticeManager $notices;
+
+ /**
+ * Build the migration registry, manager and notice manager.
+ *
+ * @since 2.1.2
+ */
+ public function __construct() {
+ $this->registry = new MigrationRegistry( self::DB_VERSION_KEY, STOREGROWTH_VERSION );
+ $this->registry->register_many(
+ [
+ '2.1.2' => V_2_1_2::class,
+ ]
+ );
+
+ $this->manager = new MigrationManager( $this->registry, self::PREFIX );
+ $this->notices = new NoticeManager( self::PREFIX );
+
+ $this->notices->register_provider( new UpgradeNoticeProvider( $this->manager ) );
+ }
+
+ /**
+ * Register hooks.
+ *
+ * @since 2.1.2
+ *
+ * @return void
+ */
+ public function register_hooks(): void {
+ ( new MigrationHooks( $this->manager, self::PREFIX ) )->register();
+
+ add_action( 'rest_api_init', [ $this, 'register_rest_routes' ] );
+ }
+
+ /**
+ * Register the migration and notice REST routes.
+ *
+ * @since 2.1.2
+ *
+ * @return void
+ */
+ public function register_rest_routes(): void {
+ ( new MigrationRESTController( $this->manager, self::REST_NAMESPACE ) )->register_routes();
+ ( new NoticeRESTController( $this->notices, self::REST_NAMESPACE ) )->register_routes();
+ }
+
+ /**
+ * Retrieve the migration manager.
+ *
+ * @since 2.1.2
+ *
+ * @return MigrationManager
+ */
+ public function get_manager(): MigrationManager {
+ return $this->manager;
+ }
+
+ /**
+ * Stamp the current version on a fresh install.
+ *
+ * A site installing StoreGrowth for the first time has nothing to migrate,
+ * so it starts at the current version and never sees the upgrade notice. A
+ * site that ran an older release keeps its missing version, which leaves the
+ * pending migrations to run.
+ *
+ * @since 2.1.2
+ *
+ * @return void
+ */
+ public static function maybe_stamp_fresh_install(): void {
+ if ( false !== get_option( self::DB_VERSION_KEY, false ) ) {
+ return;
+ }
+
+ foreach ( self::LEGACY_INSTALL_OPTIONS as $option ) {
+ if ( null !== get_option( $option, null ) ) {
+ return;
+ }
+ }
+
+ update_option( self::DB_VERSION_KEY, STOREGROWTH_VERSION, false );
+ }
+}
--- a/storegrowth-sales-booster/integrations/assets/build/bogo-dokan-admin.asset.php
+++ b/storegrowth-sales-booster/integrations/assets/build/bogo-dokan-admin.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-data', 'wp-element', 'wp-hooks', 'wp-i18n'), 'version' => 'd7cf723c5a365afbbd68');
+<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-data', 'wp-element', 'wp-hooks', 'wp-i18n'), 'version' => '5201217fc42d47de5ccb');
--- a/storegrowth-sales-booster/integrations/assets/build/bogo-dokan-dashboard.asset.php
+++ b/storegrowth-sales-booster/integrations/assets/build/bogo-dokan-dashboard.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-url'), 'version' => '1aaf787e360d73cfdb04');
+<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-url'), 'version' => '37d05416e6de04f1b680');
--- a/storegrowth-sales-booster/integrations/includes/Dokan/Admin/EnqueueScript.php
+++ b/storegrowth-sales-booster/integrations/includes/Dokan/Admin/EnqueueScript.php
@@ -4,6 +4,7 @@
use StorePulseStoreGrowthTraitsSingleton;
use StorePulseStoreGrowthHelper;
+use StorePulseStoreGrowthModuleManager;
/**
* Admin EnqueueScript Class.
@@ -37,38 +38,63 @@
*
* @since 1.12.0
*
+ * @param string $hook Current admin screen hook suffix.
+ *
+ * @return void
*/
- public function admin_enqueue_scripts() {
- $admin_file = require Helper::get_plugin_path( 'integrations/assets/build/bogo-dokan-admin.asset.php' );
- $admin_file = require Helper::get_plugin_path( 'integrations/assets/build/bogo-dokan-admin.asset.php' );
- $flycart_file = require Helper::get_plugin_path( 'integrations/assets/build/dokan-fly-cart.asset.php' );
- $countdown_file = require Helper::get_plugin_path( 'integrations/assets/build/dokan-countdown-timer.asset.php' );
+ public function admin_enqueue_scripts( $hook = '' ) {
+ // These bundles only extend the StoreGrowth settings SPA, so bail on
+ // every other admin screen instead of shipping React plugin-wide.
+ if ( 'storegrowth_page_spsg-settings' !== $hook ) {
+ return;
+ }
+
+ $modules = new ModuleManager();
+
+ // `spsg-bogo-dokan-admin` registers a `spsg_bogo_tab_panels` filter that
+ // only the BOGO module's settings bundle consumes. Enqueuing it while the
+ // module is inactive leaves its dependency unregistered and WP drops the
+ // script with a "Missing Dependencies" notice.
+ if (
+ $modules->is_active_module( 'bogo' )
+ && file_exists( Helper::get_plugin_path( 'integrations/assets/build/bogo-dokan-admin.js' ) )
+ ) {
+ $admin_file = require Helper::get_plugin_path( 'integrations/assets/build/bogo-dokan-admin.asset.php' );
- if ( file_exists( Helper::get_plugin_path( 'integrations/assets/build/bogo-dokan-admin.js' ) ) ) {
wp_enqueue_script(
'spsg-bogo-dokan-admin',
Helper::get_integrations_path( 'assets/build/bogo-dokan-admin.js' ),
- array_merge( $admin_file['dependencies'], [ 'spsg-bogo-admin-script' ] ),
+ array_merge( $admin_file['dependencies'], [ 'spsg-bogo-settings' ] ),
$admin_file['version'],
true
);
}
- if ( file_exists( Helper::get_plugin_path( 'integrations/assets/build/dokan-fly-cart.js' ) ) ) {
+ if (
+ $modules->is_active_module( 'fly-cart' )
+ && file_exists( Helper::get_plugin_path( 'integrations/assets/build/dokan-fly-cart.js' ) )
+ ) {
+ $flycart_file = require Helper::get_plugin_path( 'integrations/assets/build/dokan-fly-cart.asset.php' );
+
wp_enqueue_script(
'spsg-dokan-fly-cart',
Helper::get_integrations_path( 'assets/build/dokan-fly-cart.js' ),
- $flycart_file['dependencies'] ,
+ $flycart_file['dependencies'],
$flycart_file['version'],
true
);
}
- if ( file_exists( Helper::get_plugin_path( 'integrations/assets/build/dokan-countdown-timer.js' ) ) ) {
+ if (
+ $modules->is_active_module( 'countdown-timer' )
+ && file_exists( Helper::get_plugin_path( 'integrations/assets/build/dokan-countdown-timer.js' ) )
+ ) {
+ $countdown_file = require Helper::get_plugin_path( 'integrations/assets/build/dokan-countdown-timer.asset.php' );
+
wp_enqueue_script(
'spsg-dokan-countdown-timer',
Helper::get_integrations_path( 'assets/build/dokan-countdown-timer.js' ),
- $countdown_file['dependencies'] ,
+ $countdown_file['dependencies'],
$countdown_file['version'],
true
);
--- a/storegrowth-sales-booster/integrations/includes/Dokan/Ajax.php
+++ b/storegrowth-sales-booster/integrations/includes/Dokan/Ajax.php
@@ -35,6 +35,10 @@
public function save_settings() {
check_ajax_referer( 'spsg_ajax_nonce' );
+ if ( ! current_user_can( 'manage_options' ) ) {
+ wp_send_json_error( __( 'You are not allowed to perform this action.', 'storegrowth-sales-booster' ), 403 );
+ }
+
if ( ! isset( $_POST['data'] ) ) {
wp_send_json_error();
}
@@ -60,6 +64,10 @@
public function get_settings() {
check_ajax_referer( 'spsg_ajax_nonce' );
+ if ( ! current_user_can( 'manage_options' ) ) {
+ wp_send_json_error( __( 'You are not allowed to perform this action.', 'storegrowth-sales-booster' ), 403 );
+ }
+
$form_data = StorePulseStoreGrowthHelper::get_settings( 'spsg_bogo_dokan_vendors_settings', [] );
wp_send_json_success( $form_data );
--- a/storegrowth-sales-booster/integrations/includes/Dokan/Dashboard/Bogo.php
+++ b/storegrowth-sales-booster/integrations/includes/Dokan/Dashboard/Bogo.php
@@ -146,8 +146,12 @@
'spsg-bogo-dokan-vendor-dashboard',
'spsgAdmin',
[
+ // The admin write nonce (`spsg_ajax_nonce`) is intentionally NOT
+ // localized on this frontend vendor screen. Emitting it would
+ // hand any dashboard viewer a token the privileged settings
+ // handlers accept. Vendor operations use the REST / frontend
+ // nonces in `bogo_save_url` below.
'ajax_url' => admin_url( 'admin-ajax.php' ),
- 'nonce' => wp_create_nonce( 'spsg_ajax_nonce' ),
'isPro' => sp_store_growth()->has_pro(),
'buyXGetXEnableForVendor' => $is_enable,
]
--- a/storegrowth-sales-booster/lib/packages/WeDevs/WPKit/AdminNotification/Contracts/NoticeProviderInterface.php
+++ b/storegrowth-sales-booster/lib/packages/WeDevs/WPKit/AdminNotification/Contracts/NoticeProviderInterface.php
@@ -0,0 +1,26 @@
+<?php
+/**
+ * Interface for notice providers.
+ *
+ * @package StorePulseStoreGrowthThirdPartyPackagesWeDevsWPKitAdminNotification
+ */
+
+namespace StorePulseStoreGrowthThirdPartyPackagesWeDevsWPKitAdminNotificationContracts;
+
+/**
+ * Interface for notice providers.
+ *
+ * Plugins implement this to supply notices to the NoticeManager.
+ */
+interface NoticeProviderInterface {
+
+ /**
+ * Return an array of notices.
+ *
+ * Each notice should be either a Notice object or an associative array with keys:
+ * type, title, description, priority, scope, actions, is_dismissible, key.
+ *
+ * @return array
+ */
+ public function get_notices(): array;
+}
--- a/storegrowth-sales-booster/lib/packages/WeDevs/WPKit/AdminNotification/Notice.php
+++ b/storegrowth-sales-booster/lib/packages/WeDevs/WPKit/AdminNotification/Notice.php
@@ -0,0 +1,104 @@
+<?php
+/**
+ * Value object representing an admin notice.
+ *
+ * @package StorePulseStoreGrowthThirdPartyPackagesWeDevsWPKitAdminNotification
+ */
+
+namespace StorePulseStoreGrowthThirdPartyPackagesWeDevsWPKitAdminNotification;
+
+/**
+ * Value object representing an admin notice.
+ */
+class Notice {
+
+ /**
+ * Notice type: 'info', 'success', 'warning', 'error'.
+ *
+ * @var string
+ */
+ public string $type;
+
+ /**
+ * Notice title.
+ *
+ * @var string
+ */
+ public string $title;
+
+ /**
+ * Notice description/content.
+ *
+ * @var string
+ */
+ public string $description;
+
+ /**
+ * Priority (lower = higher priority).
+ *
+ * @var int
+ */
+ public int $priority;
+
+ /**
+ * Scope: 'local' (plugin pages only) or 'global' (all admin pages).
+ *
+ * @var string
+ */
+ public string $scope;
+
+ /**
+ * Action button configurations.
+ *
+ * @var array
+ */
+ public array $actions;
+
+ /**
+ * Whether the notice can be dismissed.
+ *
+ * @var bool
+ */
+ public bool $is_dismissible;
+
+ /**
+ * Unique notice identifier for dismissal tracking.
+ *
+ * @var string
+ */
+ public string $key;
+
+ /**
+ * Constructor.
+ *
+ * @param array $args Notice arguments.
+ */
+ public function __construct( array $args = [] ) {
+ $this->type = $args['type'] ?? 'info';
+ $this->title = $args['title'] ?? '';
+ $this->description = $args['description'] ?? '';
+ $this->priority = $args['priority'] ?? 10;
+ $this->scope = $args['scope'] ?? 'local';
+ $this->actions = $args['actions'] ?? [];
+ $this->is_dismissible = $args['is_dismissible'] ?? false;
+ $this->key = $args['key'] ?? '';
+ }
+
+ /**
+ * Convert to array.
+ *
+ * @return array
+ */
+ public function to_array(): array {
+ return [
+ 'type' => $this->type,
+ 'title' => $this->title,
+ 'description' => $this->description,
+ 'priority' => $this->priority,
+ 'scope' => $this->scope,
+ 'actions' => $this->actions,
+ 'is_dismissible' => $this->is_dismissible,
+ 'key' => $this->key,
+ ];
+ }
+}
--- a/storegrowth-sales-booster/lib/packages/WeDevs/WPKit/AdminNotification/NoticeManager.php
+++ b/storegrowth-sales-booster/lib/packages/WeDevs/WPKit/AdminNotification/NoticeManager.php
@@ -0,0 +1,151 @@
+<?php
+/**
+ * Central notice collector and manager.
+ *
+ * @package StorePulseStoreGrowthThirdPartyPackagesWeDevsWPKitAdminNotification
+ */
+
+namespace StorePulseStoreGrowthThirdPartyPackagesWeDevsWPKitAdminNotification;
+
+use StorePulseStoreGrowthThirdPartyPackagesWeDevsWPKitAdminNotificationContractsNoticeProviderInterface;
+
+/**
+ * Central notice collector and manager.
+ *
+ * Collects notices from registered providers and WordPress filters,
+ * filters dismissed notices, and sorts by priority.
+ */
+class NoticeManager {
+
+ /**
+ * Registered notice providers.
+ *
+ * @var NoticeProviderInterface[]
+ */
+ protected array $providers = [];
+
+ /**
+ * WordPress filter name for collecting notices.
+ *
+ * @var string
+ */
+ protected string $filter_name;
+
+ /**
+ * Prefix for option keys.
+ *
+ * @var string
+ */
+ protected string $prefix;
+
+ /**
+ * Constructor.
+ *
+ * @param string $prefix Plugin-specific prefix (e.g., 'dokan').
+ */
+ public function __construct( string $prefix ) {
+ $this->prefix = $prefix;
+ $this->filter_name = $prefix . '_admin_notices';
+ }
+
+ /**
+ * Register a notice provider.
+ *
+ * @param NoticeProviderInterface $provider Notice provider.
+ *
+ * @return self
+ */
+ public function register_provider( NoticeProviderInterface $provider ): self {
+ $this->providers[] = $provider;
+
+ return $this;
+ }
+
+ /**
+ * Get all notices, optionally filtered by scope.
+ *
+ * @param string $scope Filter by scope: 'local', 'global', or '' for all.
+ *
+ * @return array
+ */
+ public function get_notices( string $scope = '' ): array {
+ $notices = [];
+
+ // Collect from registered providers.
+ foreach ( $this->providers as $provider ) {
+ $provider_notices = $provider->get_notices();
+
+ foreach ( $provider_notices as $notice ) {
+ if ( $notice instanceof Notice ) {
+ $notices[] = $notice->to_array();
+ } else {
+ $notices[] = $notice;
+ }
+ }
+ }
+
+ // Collect from WordPress filter (backward compatibility).
+ $notices = apply_filters( $this->filter_name, $notices );
+
+ // Filter out dismissed notices.
+ $notices = $this->filter_dismissed( $notices );
+
+ // Filter by scope.
+ if ( $scope ) {
+ $notices = array_filter(
+ $notices,
+ function ( $notice ) use ( $scope ) {
+ return ( $notice['scope'] ?? 'local' ) === $scope;
+ }
+ );
+ }
+
+ // Sort by priority.
+ usort(
+ $notices,
+ function ( $a, $b ) {
+ return ( $a['priority'] ?? 10 ) - ( $b['priority'] ?? 10 );
+ }
+ );
+
+ return array_values( $notices );
+ }
+
+ /**
+ * Filter out dismissed notices.
+ *
+ * @param array $notices Notices to filter.
+ *
+ * @return array
+ */
+ protected function filter_dismissed( array $notices ): array {
+ $dismissed = get_option( $this->prefix . '_dismissed_notices', [] );
+
+ return array_filter(
+ $notices,
+ function ( $notice ) use ( $dismissed ) {
+ $key = $notice['key'] ?? '';
+
+ return ! $key || ! in_array( $key, $dismissed, true );
+ }
+ );
+ }
+
+ /**
+ * Get the filter name used for collecting notices.
+ *
+ * @return string
+ */
+ public function get_filter_name(): string {
+ return $this->filter_name;
+ }
+
+ /**
+ * Get the prefix.
+ *
+ * @return string
+ */
+ public function get_prefix(): string {
+ return $this->prefix;
+ }
+}
--- a/storegrowth-sales-booster/lib/packages/WeDevs/WPKit/AdminNotification/NoticeRESTController.php
+++ b/storegrowth-sales-booster/lib/packages/WeDevs/WPKit/AdminNotification/NoticeRESTController.php
@@ -0,0 +1,138 @@
+<?php
+/**
+ * REST API controller for admin notices.
+ *
+ * @package StorePulseStoreGrowthThirdPartyPackagesWeDevsWPKitAdminNotification
+ */
+
+namespace StorePulseStoreGrowthThirdPartyPackagesWeDevsWPKitAdminNotification;
+
+use WP_REST_Server;
+use WP_REST_Request;
+use WP_REST_Response;
+
+/**
+ * REST API controller for admin notices.
+ */
+class NoticeRESTController {
+
+ /**
+ * Notice manager instance.
+ *
+ * @var NoticeManager
+ */
+ protected NoticeManager $manager;
+
+ /**
+ * REST API namespace.
+ *
+ * @var string
+ */
+ protected string $namespace;
+
+ /**
+ * REST route base.
+ *
+ * @var string
+ */
+ protected string $base = 'notices';
+
+ /**
+ * Constructor.
+ *
+ * @param NoticeManager $manager Notice manager.
+ * @param string $namespace REST API namespace (e.g., 'dokan/v1').
+ */
+ public function __construct( NoticeManager $manager, string $namespace ) {
+ $this->manager = $manager;
+ $this->namespace = $namespace;
+ }
+
+ /**
+ * Register REST routes.
+ */
+ public function register_routes(): void {
+ register_rest_route(
+ $this->namespace,
+ '/' . $this->base . '/admin',
+ [
+ [
+ 'methods' => WP_REST_Server::READABLE,
+ 'callback' => [ $this, 'get_admin_notices' ],
+ 'permission_callback' => [ $this, 'check_permission' ],
+ 'args' => [
+ 'scope' => [
+ 'type' => 'string',
+ 'enum' => [ 'local', 'global' ],
+ 'default' => '',
+ 'sanitize_callback' => 'sanitize_text_field',
+ ],
+ ],
+ ],
+ ]
+ );
+
+ register_rest_route(
+ $this->namespace,
+ '/' . $this->base . '/dismiss',
+ [
+ [
+ 'methods' => WP_REST_Server::CREATABLE,
+ 'callback' => [ $this, 'dismiss_notice' ],
+ 'permission_callback' => [ $this, 'check_permission' ],
+ 'args' => [
+ 'key' => [
+ 'required' => true,
+ 'type' => 'string',
+ 'sanitize_callback' => 'sanitize_text_field',
+ ],
+ ],
+ ],
+ ]
+ );
+ }
+
+ /**
+ * Get admin notices.
+ *
+ * @param WP_REST_Request $request REST request.
+ *
+ * @return WP_REST_Response
+ */
+ public function get_admin_notices( WP_REST_Request $request ): WP_REST_Response {
+ $scope = $request->get_param( 'scope' ) ? $request->get_param( 'scope' ) : '';
+ $notices = $this->manager->get_notices( $scope );
+
+ return rest_ensure_response( $notices );
+ }
+
+ /**
+ * Dismiss a notice by key.
+ *
+ * @param WP_REST_Request $request REST request.
+ *
+ * @return WP_REST_Response
+ */
+ public function dismiss_notice( WP_REST_Request $request ): WP_REST_Response {
+ $key = $request->get_param( 'key' );
+ $prefix = $this->manager->get_prefix();
+
+ $dismissed = get_option( $prefix . '_dismissed_notices', [] );
+
+ if ( ! in_array( $key, $dismissed, true ) ) {
+ $dismissed[] = $key;
+ update_option( $prefix . '_dismissed_notices', $dismissed );
+ }
+
+ return new WP_REST_Response( [ 'success' => true ], 200 );
+ }
+
+ /**
+ * Check if the current user has permission.
+ *
+ * @return bool
+ */
+ public function check_permission(): bool {
+ return current_user_can( 'manage_options' );
+ }
+}
--- a/storegrowth-sales-booster/lib/packages/WeDevs/WPKit/AdminNotification/NotificationHelper.php
+++ b/storegrowth-sales-booster/lib/packages/WeDevs/WPKit/AdminNotification/NotificationHelper.php
@@ -0,0 +1,145 @@
+<?php
+/**
+ * Static helper methods for creating notice data structures.
+ *
+ * @package StorePulseStoreGrowthThirdPartyPackagesWeDevsWPKitAdminNotification
+ */
+
+namespace StorePulseStoreGrowthThirdPartyPackagesWeDevsWPKitAdminNotification;
+
+/**
+ * Static helper methods for creating notice data structures.
+ */
+class NotificationHelper {
+
+ /**
+ * Create an info notice array.
+ *
+ * @param string $title Notice title.
+ * @param string $description Notice description.
+ * @param array $extra Additional notice properties.
+ *
+ * @return array
+ */
+ public static function info( string $title, string $description, array $extra = [] ): array {
+ return array_merge(
+ [
+ 'type' => 'info',
+ 'title' => $title,
+ 'description' => $description,
+ 'priority' => 10,
+ 'scope' => 'local',
+ ],
+ $extra
+ );
+ }
+
+ /**
+ * Create a warning notice array.
+ *
+ * @param string $title Notice title.
+ * @param string $description Notice description.
+ * @param array $extra Additional notice properties.
+ *
+ * @return array
+ */
+ public static function warning( string $title, string $description, array $extra = [] ): array {
+ return array_merge(
+ [
+ 'type' => 'warning',
+ 'title' => $title,
+ 'description' => $description,
+ 'priority' => 5,
+ 'scope' => 'local',
+ ],
+ $extra
+ );
+ }
+
+ /**
+ * Create an error notice array.
+ *
+ * @param string $title Notice title.
+ * @param string $description Notice description.
+ * @param array $extra Additional notice properties.
+ *
+ * @return array
+ */
+ public static function error( string $title, string $description, array $extra = [] ): array {
+ return array_merge(
+ [
+ 'type' => 'error',
+ 'title' => $title,
+ 'description' => $description,
+ 'priority' => 1,
+ 'scope' => 'global',
+ ],
+ $extra
+ );
+ }
+
+ /**
+ * Create a success notice array.
+ *
+ * @param string $title Notice title.
+ * @param string $description Notice description.
+ * @param array $extra Additional notice properties.
+ *
+ * @return array
+ */
+ public static function success( string $title, string $description, array $extra = [] ): array {
+ return array_merge(
+ [
+ 'type' => 'success',
+ 'title' => $title,
+ 'description' => $description,
+ 'priority' => 10,
+ 'scope' => 'local',
+ ],
+ $extra
+ );
+ }
+
+ /**
+ * Build a REST API action button config.
+ *
+ * @param string $text Button text.
+ * @param string $endpoint REST API endpoint URL.
+ * @param string $method HTTP method (default: POST).
+ * @param array $extra Additional action properties.
+ *
+ * @return array
+ */
+ public static function rest_action( string $text, string $endpoint, string $method = 'POST', array $extra = [] ): array {
+ return array_merge(
+ [
+ 'type' => 'primary',
+ 'text' => $text,
+ 'rest_data' => [
+ 'endpoint' => $endpoint,
+ 'method' => $method,
+ 'nonce' => wp_create_nonce( 'wp_rest' ),
+ ],
+ ],
+ $extra
+ );
+ }
+
+ /**
+ * Build a URL link action button config.
+ *
+ * @param string $text Button text.
+ * @param string $url Target URL.
+ * @param string $target Link target (_self, _blank).
+ *
+ * @return array
+ */
+ public static function link_action( string $text, string $url, string $target = '_self' ): array {
+ return [
+ 'type' => 'primary',
+ 'text' => $text,
+ 'action' => $url,
+ 'target' => $target,
+ ];
+ }
+}
--- a/storegrowth-sales-booster/lib/packages/WeDevs/WPKit/Cache/CacheNameSpaceTrait.php
+++ b/storegrowth-sales-booster/lib/packages/WeDevs/WPKit/Cache/CacheNameSpaceTrait.php
@@ -0,0 +1,69 @@
+<?php
+/**
+ * Cache namespace trait for group-level invalidation.
+ *
+ * @package StorePulseStoreGrowthThirdPartyPackagesWeDevsWPKitCache
+ */
+
+namespace StorePulseStoreGrowthThirdPartyPackagesWeDevsWPKitCache;
+
+/**
+ * Implements namespacing algorithm for wp_cache group invalidation.
+ *
+ * Uses a microtime-based prefix stored in cache itself. To invalidate a group,
+ * the prefix is regenerated, making all old keys inaccessible.
+ *
+ * Works correctly with distributed caches (Redis, Memcached) where
+ * wp_cache_flush_group() may not exist.
+ *
+ * Classes using this trait MUST define a `get_cache_key_prefix()` method
+ * that returns the consumer-provided prefix (e.g., 'dokan', 'myplugin').
+ *
+ * @see https://github.com/memcached/memcached/wiki/ProgrammingTricks#namespacing
+ */
+trait CacheNameSpaceTrait {
+
+ /**
+ * Get the cache prefix for a group.
+ *
+ * @param string $group Cache group.
+ *
+ * @return string The prefix string.
+ */
+ public function get_cache_prefix( string $group ): string {
+ $key_prefix = $this->get_cache_key_prefix();
+ $prefix = wp_cache_get( $key_prefix . '_' . $group . '_prefix', $group );
+
+ if ( false === $prefix ) {
+ $prefix = microtime();
+ wp_cache_set( $key_prefix . '_' . $group . '_prefix', $prefix, $group );
+ }
+
+ return $key_prefix . '_cache_' . $prefix . '_';
+ }
+
+ /**
+ * Invalidate all cached values in a group by regenerating the prefix.
+ *
+ * @param string $group Cache group to invalidate.
+ *
+ * @return bool True on success.
+ */
+ public function invalidate_cache_group( string $group ): bool {
+ $key_prefix = $this->get_cache_key_prefix();
+
+ return false !== wp_cache_set( $key_prefix . '_' . $group . '_prefix', microtime(), $group );
+ }
+
+ /**
+ * Get a prefixed cache key.
+ *
+ * @param string $key The original key.
+ * @param string $group The cache group.
+ *
+ * @return string The prefixed key.
+ */
+ public function get_prefixed_key( string $key, string $group ): string {
+ return $this->get_cache_prefix( $group ) . $key;
+ }
+}
--- a/storegrowth-sales-booster/lib/packages/WeDevs/WPKit/Cache/Contracts/CacheEngineInterface.php
+++ b/storegrowth-sales-booster/lib/packages/WeDevs/WPKit/Cache/Contracts/CacheEngineInterface.php
@@ -0,0 +1,88 @@
+<?php
+/**
+ * Cache engine interface for ObjectCache.
+ *
+ * @package StorePulseStoreGrowthThirdPartyPackagesWeDevsWPKitCache
+ */
+
+namespace StorePulseStoreGrowthThirdPartyPackagesWeDevsWPKitCacheContracts;
+
+/**
+ * Interface for cache engines used by ObjectCache.
+ *
+ * Inspired by WooCommerce's CacheEngine interface.
+ */
+interface CacheEngineInterface {
+
+ /**
+ * Retrieve a cached value.
+ *
+ * @param string $key The cache key.
+ * @param string $group The cache group.
+ *
+ * @return mixed|null The cached value, or null if not found.
+ */
+ public function get( string $key, string $group = '' );
+
+ /**
+ * Retrieve multiple cached values.
+ *
+ * @param string[] $keys The cache keys.
+ * @param string $group The cache group.
+ *
+ * @return array Associative array of key => value, null for cache misses.
+ */
+ public function get_many( array $keys, string $group = '' ): array;
+
+ /**
+ * Store a value in cache.
+ *
+ * @param string $key The cache key.
+ * @param mixed $value The value to cache.
+ * @param string $group The cache group.
+ * @param int $expiration Expiration in seconds.
+ *
+ * @return bool True on success.
+ */
+ public function set( string $key, $value, string $group = '', int $expiration = 0 ): bool;
+
+ /**
+ * Store multiple values in cache.
+ *
+ * @param array $items Associative array of key => value.
+ * @param string $group The cache group.
+ * @param int $expiration Expiration in seconds.
+ *
+ * @return array Associative array of key => bool success.
+ */
+ public function set_many( array $items, string $group = '', int $expiration = 0 ): array;
+
+ /**
+ * Delete a cached value.
+ *
+ * @param string $key The cache key.
+ * @param string $group The cache group.
+ *
+ * @return bool True on success.
+ */
+ public function delete( string $key, string $group = '' ): bool;
+
+ /**
+ * Check if a key exists in cache.
+ *
+ * @param string $key The cache key.
+ * @param string $group The cache group.
+ *
+ * @return bool True if cached.
+ */
+ public function exists( string $key, string $group = '' ): bool;
+
+ /**
+ * Invalidate all cached values in a group.
+ *
+ * @param string $group The cache group to flush.
+ *
+ * @return bool True on success.
+ */
+ public function flush_group( string $group = '' ): bool;
+}
--- a/storegrowth-sales-booster/lib/packages/WeDevs/WPKit/Cache/ObjectCache.php
+++ b/storegrowth-sales-booster/lib/packages/WeDevs/WPKit/Cache/ObjectCache.php
@@ -0,0 +1,199 @@
+<?php
+/**
+ * Typed object cache with TTL support.
+ *
+ * @package StorePulseStoreGrowthThirdPartyPackagesWeDevsWPKitCache
+ */
+
+namespace StorePulseStoreGrowthThirdPartyPackagesWeDevsWPKitCache;
+
+use StorePulseStoreGrowthThirdPartyPackagesWeDevsWPKitCacheContractsCacheEngineInterface;
+
+/**
+ * Typed object cache with TTL support.
+ *
+ * Provides a high-level caching API for specific object types (models, data stores).
+ * Objects are identified by integer or string IDs. Cache keys are automatically
+ * namespaced by object type and prefixed for group invalidation.
+ */
+class ObjectCache {
+
+ /**
+ * Use default expiration value.
+ */
+ const DEFAULT_EXPIRATION = -1;
+
+ /**
+ * Maximum expiration time in seconds.
+ */
+ const MAX_EXPIRATION = MONTH_IN_SECONDS;
+
+ /**
+ * Default expiration in seconds.
+ *
+ * @var int
+ */
+ protected int $default_expiration = HOUR_IN_SECONDS;
+
+ /**
+ * The cache engine instance.
+ *
+ * @var CacheEngineInterface
+ */
+ protected CacheEngineInterface $engine;
+
+ /**
+ * The object type identifier used as cache group.
+ *
+ * @var string
+ */
+ protected string $object_type;
+
+ /**
+ * Constructor.
+ *
+ * @param CacheEngineInterface $engine The cache engine to use.
+ * @param string $object_type Object type identifier (used as cache group).
+ * @param int $expiration Default expiration in seconds.
+ */
+ public function __construct( CacheEngineInterface $engine, string $object_type, int $expiration = HOUR_IN_SECONDS ) {
+ $this->engine =