| @@ -48,18 +48,21 @@ | ||
| 48 | 48 | |
| 49 | 49 | foreach ($data as $moduleKey => $moduleData) { |
| 50 | 50 | $prevStatus = Arr::get($prevSettings, $moduleKey . '.active', 'no'); |
| 51 | 51 | $newStatus = Arr::get($moduleData, 'active', 'no'); |
| 52 | - if ($newStatus === $prevStatus) { | |
| 53 | - continue; | |
| 54 | - } | |
| 55 | 52 | |
| 56 | 53 | if ($prevStatus === 'yes' && $newStatus === 'no') { |
| 57 | 54 | // Module deactivated |
| 58 | - do_action('fluent_cart/module/deactivated/' . $moduleKey, $moduleData, $prevSettings[$moduleKey]); | |
| 55 | + do_action('fluent_cart/module/deactivated/' . $moduleKey, $moduleData, $prevSettings[$moduleKey] ?? []); | |
| 59 | 56 | } elseif ($prevStatus === 'no' && $newStatus === 'yes') { |
| 60 | 57 | // Module activated |
| 61 | - do_action('fluent_cart/module/activated/' . $moduleKey, $moduleData, $prevSettings[$moduleKey]); | |
| 58 | + do_action('fluent_cart/module/activated/' . $moduleKey, $moduleData, $prevSettings[$moduleKey] ?? []); | |
| 59 | + } elseif ($newStatus === 'yes') { | |
| 60 | + // Module is active — fire activation hook if any child settings changed | |
| 61 | + $hasChanged = $this->hasModuleSettingsChanged($moduleData, $prevSettings[$moduleKey] ?? []); | |
| 62 | + if ($hasChanged) { | |
| 63 | + do_action('fluent_cart/module/activated/' . $moduleKey, $moduleData, $prevSettings[$moduleKey] ?? []); | |
| 64 | + } | |
| 62 | 65 | } |
| 63 | 66 | } |
| 64 | 67 | |
| 65 | 68 | return $this->sendSuccess([ |
| @@ -66,8 +69,28 @@ | ||
| 66 | 69 | 'message' => __('Settings saved successfully', 'fluent-cart') |
| 67 | 70 | ]); |
| 68 | 71 | } |
| 69 | 72 | |
| 73 | + private function hasModuleSettingsChanged($newData, $oldData) | |
| 74 | + { | |
| 75 | + if (!is_array($newData) || !is_array($oldData)) { | |
| 76 | + return true; | |
| 77 | + } | |
| 78 | + | |
| 79 | + foreach ($newData as $key => $value) { | |
| 80 | + if ($key === 'active') { | |
| 81 | + continue; | |
| 82 | + } | |
| 83 | + | |
| 84 | + $oldValue = Arr::get($oldData, $key); | |
| 85 | + if ($oldValue !== $value) { | |
| 86 | + return true; | |
| 87 | + } | |
| 88 | + } | |
| 89 | + | |
| 90 | + return false; | |
| 91 | + } | |
| 92 | + | |
| 70 | 93 | public function getPluginAddons(): \WP_REST_Response |
| 71 | 94 | { |
| 72 | 95 | $addons = $this->getRegisteredPluginAddons(); |
| 73 | 96 | |
| @@ -77,9 +100,8 @@ | ||
| 77 | 100 | if($isUpcoming){ |
| 78 | 101 | $addon['is_installed'] = false; |
| 79 | 102 | $addon['is_active'] = false; |
| 80 | 103 | $addon['plugin_file'] = ''; |
| 81 | - $addon['plugin_file'] = ''; | |
| 82 | 104 | $addon['source_link'] = ''; |
| 83 | 105 | $addon['source_type'] = ''; |
| 84 | 106 | continue; |
| 85 | 107 | } |
| @@ -244,10 +266,32 @@ | ||
| 244 | 266 | 'plugin_file' => 'fluent-cart-elementor-blocks/fluent-cart-elementor-blocks.php', |
| 245 | 267 | 'source_type' => 'cdn', |
| 246 | 268 | 'source_link' => 'https://addons-cdn.fluentcart.com/fluent-cart-elementor-blocks.zip', |
| 247 | 269 | 'upcoming' => false, |
| 248 | - 'repo_link' => 'https://github.com/WPManageNinja/fluent-cart-elementor-blocks' | |
| 270 | + 'repo_link' => 'https://fluentcart.com/fluentcart-addons/' | |
| 249 | 271 | ], |
| 272 | + 'fluent-cart-bricks-blocks' => [ | |
| 273 | + 'title' => __('FluentCart Bricks Blocks', 'fluent-cart'), | |
| 274 | + 'description' => __('Enable to get Bricks Builder elements for FluentCart. Requires the Bricks theme.', 'fluent-cart'), | |
| 275 | + 'logo' => Vite::getAssetUrl('images/bricks/logo.png'), | |
| 276 | + 'plugin_slug' => 'fluent-cart-bricks-blocks', | |
| 277 | + 'plugin_file' => 'fluent-cart-bricks-blocks/fluent-cart-bricks-blocks.php', | |
| 278 | + 'source_type' => 'cdn', | |
| 279 | + 'upcoming' => false, | |
| 280 | + 'repo_link' => 'https://fluentcart.com/fluentcart-addons/' | |
| 281 | + ], | |
| 282 | + 'fluent-cart-divi-modules' => [ | |
| 283 | + 'title' => __('FluentCart Divi Modules', 'fluent-cart'), | |
| 284 | + 'description' => __('Native Divi 5 modules for FluentCart products, cart, and checkout. Requires Divi 5.0+ and FluentCart 1.3.4+.', 'fluent-cart'), | |
| 285 | + 'logo' => Vite::getAssetUrl('images/divi/black.svg'), | |
| 286 | + 'dark_logo' => Vite::getAssetUrl('images/divi/white.svg'), | |
| 287 | + 'plugin_slug' => 'fluent-cart-divi-modules', | |
| 288 | + 'plugin_file' => 'fluent-cart-divi-modules/fluent-cart-divi-modules.php', | |
| 289 | + 'source_type' => 'cdn', | |
| 290 | + 'source_link' => 'https://addons-cdn.fluentcart.com/fluent-cart-divi-modules.zip', | |
| 291 | + 'upcoming' => false, | |
| 292 | + 'repo_link' => 'https://fluentcart.com/fluentcart-addons/' | |
| 293 | + ], | |
| 250 | 294 | 'fluent-pdf' => [ |
| 251 | 295 | 'title' => __('Fluent PDF', 'fluent-cart'), |
| 252 | 296 | 'description' => __('Generate PDF receipts and attach them to email notifications.', 'fluent-cart'), |
| 253 | 297 | 'logo' => Vite::getAssetUrl('images/fluent-pdf/black.svg'), |
| @@ -266,8 +310,18 @@ | ||
| 266 | 310 | 'source_type' => 'cdn', |
| 267 | 311 | 'source_link' => 'https://addons-cdn.fluentcart.com/fluent-cart-migrator.zip', |
| 268 | 312 | 'upcoming' => false, |
| 269 | 313 | 'repo_link' => 'https://fluentcart.com/fluentcart-addons/?3181_search=Migrator' |
| 314 | + ], | |
| 315 | + 'fluent-cart-customer-rights' => [ | |
| 316 | + 'title' => __('FluentCart Customer Rights', 'fluent-cart'), | |
| 317 | + 'description' => __('Manage customer withdrawal, refund, return, and cancellation requests with dedicated forms, workflows, notifications, and admin tools. Includes support for the German Withdrawal Button requirement under § 356a BGB.', 'fluent-cart'), | |
| 318 | + 'logo' => Vite::getAssetUrl('images/fluent-cart-resolution/logo.svg'), | |
| 319 | + 'plugin_slug' => 'fluent-cart-customer-rights', | |
| 320 | + 'plugin_file' => 'fluent-cart-customer-rights/fluent-cart-customer-rights.php', | |
| 321 | + 'source_type' => 'cdn', | |
| 322 | + 'upcoming' => false, | |
| 323 | + 'repo_link' => 'https://fluentcart.com/fluentcart-addons/' | |
| 270 | 324 | ], |
| 271 | 325 | ]; |
| 272 | 326 | |
| 273 | 327 | // Allow other modules/plugins to register their addons |