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:
Dwindi Ramadhana
2025-12-26 19:19:49 +07:00
parent 0b2c8a56d6
commit 07020bc0dd
59 changed files with 3891 additions and 12132 deletions

View File

@@ -4,6 +4,7 @@ namespace WooNooW\Frontend;
use WP_REST_Request;
use WP_REST_Response;
use WP_Error;
use WooNooW\Core\ModuleRegistry;
class WishlistController {
@@ -60,6 +61,10 @@ class WishlistController {
* Get wishlist items with product details
*/
public static function get_wishlist(WP_REST_Request $request) {
if (!ModuleRegistry::is_enabled('wishlist')) {
return new WP_Error('module_disabled', __('Wishlist module is disabled', 'woonoow'), ['status' => 403]);
}
$user_id = get_current_user_id();
$wishlist = get_user_meta($user_id, 'woonoow_wishlist', true);
@@ -98,6 +103,10 @@ class WishlistController {
* Add product to wishlist
*/
public static function add_to_wishlist(WP_REST_Request $request) {
if (!ModuleRegistry::is_enabled('wishlist')) {
return new WP_Error('module_disabled', __('Wishlist module is disabled', 'woonoow'), ['status' => 403]);
}
$user_id = get_current_user_id();
$product_id = $request->get_param('product_id');
@@ -137,6 +146,10 @@ class WishlistController {
* Remove product from wishlist
*/
public static function remove_from_wishlist(WP_REST_Request $request) {
if (!ModuleRegistry::is_enabled('wishlist')) {
return new WP_Error('module_disabled', __('Wishlist module is disabled', 'woonoow'), ['status' => 403]);
}
$user_id = get_current_user_id();
$product_id = (int) $request->get_param('product_id');
@@ -165,6 +178,10 @@ class WishlistController {
* Clear entire wishlist
*/
public static function clear_wishlist(WP_REST_Request $request) {
if (!ModuleRegistry::is_enabled('wishlist')) {
return new WP_Error('module_disabled', __('Wishlist module is disabled', 'woonoow'), ['status' => 403]);
}
$user_id = get_current_user_id();
delete_user_meta($user_id, 'woonoow_wishlist');