feat: Implement centralized module management system
- Add ModuleRegistry for managing built-in modules (newsletter, wishlist, affiliate, subscription, licensing) - Add ModulesController REST API for module enable/disable - Create Modules settings page with category grouping and toggle controls - Integrate module checks across admin-spa and customer-spa - Add useModules hook for both SPAs to check module status - Hide newsletter from footer builder when module disabled - Hide wishlist features when module disabled (product cards, account menu, wishlist page) - Protect wishlist API endpoints with module checks - Auto-update navigation tree when modules toggled - Clean up obsolete documentation files - Add comprehensive documentation: - MODULE_SYSTEM_IMPLEMENTATION.md - MODULE_INTEGRATION_SUMMARY.md - ADDON_MODULE_INTEGRATION.md (proposal) - ADDON_MODULE_DESIGN_DECISIONS.md (design doc) - FEATURE_ROADMAP.md - SHIPPING_INTEGRATION.md Module system provides: - Centralized enable/disable for all features - Automatic navigation updates - Frontend/backend integration - Foundation for addon-module unification
This commit is contained in:
@@ -13,7 +13,7 @@ if ( ! defined('ABSPATH') ) exit;
|
||||
*/
|
||||
class NavigationRegistry {
|
||||
const NAV_OPTION = 'wnw_nav_tree';
|
||||
const NAV_VERSION = '1.0.7'; // Removed 'New Coupon' from submenu
|
||||
const NAV_VERSION = '1.0.8'; // Added Modules to Settings menu
|
||||
|
||||
/**
|
||||
* Initialize hooks
|
||||
@@ -105,7 +105,7 @@ class NavigationRegistry {
|
||||
* @return array Base navigation tree
|
||||
*/
|
||||
private static function get_base_tree(): array {
|
||||
return [
|
||||
$tree = [
|
||||
[
|
||||
'key' => 'dashboard',
|
||||
'label' => __('Dashboard', 'woonoow'),
|
||||
@@ -160,10 +160,7 @@ class NavigationRegistry {
|
||||
'label' => __('Marketing', 'woonoow'),
|
||||
'path' => '/marketing',
|
||||
'icon' => 'mail',
|
||||
'children' => [
|
||||
['label' => __('Newsletter', 'woonoow'), 'mode' => 'spa', 'path' => '/marketing/newsletter'],
|
||||
['label' => __('Coupons', 'woonoow'), 'mode' => 'spa', 'path' => '/coupons'],
|
||||
],
|
||||
'children' => self::get_marketing_children(),
|
||||
],
|
||||
[
|
||||
'key' => 'appearance',
|
||||
@@ -190,6 +187,27 @@ class NavigationRegistry {
|
||||
'children' => self::get_settings_children(),
|
||||
],
|
||||
];
|
||||
|
||||
return $tree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get marketing submenu children
|
||||
*
|
||||
* @return array Marketing submenu items
|
||||
*/
|
||||
private static function get_marketing_children(): array {
|
||||
$children = [];
|
||||
|
||||
// Newsletter - only if module enabled
|
||||
if (\WooNooW\Core\ModuleRegistry::is_enabled('newsletter')) {
|
||||
$children[] = ['label' => __('Newsletter', 'woonoow'), 'mode' => 'spa', 'path' => '/marketing/newsletter'];
|
||||
}
|
||||
|
||||
// Coupons - always available
|
||||
$children[] = ['label' => __('Coupons', 'woonoow'), 'mode' => 'spa', 'path' => '/coupons'];
|
||||
|
||||
return $children;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -208,6 +226,7 @@ class NavigationRegistry {
|
||||
['label' => __('Tax', 'woonoow'), 'mode' => 'spa', 'path' => '/settings/tax'],
|
||||
['label' => __('Customers', 'woonoow'), 'mode' => 'spa', 'path' => '/settings/customers'],
|
||||
['label' => __('Notifications', 'woonoow'), 'mode' => 'spa', 'path' => '/settings/notifications'],
|
||||
['label' => __('Modules', 'woonoow'), 'mode' => 'spa', 'path' => '/settings/modules'],
|
||||
['label' => __('Developer', 'woonoow'), 'mode' => 'spa', 'path' => '/settings/developer'],
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user