Newsletter Fix: - Move all hooks (useQuery, useMutation) before conditional returns - Add 'enabled' option to useQuery to control when it fetches - Fixes React error #310: useEffect called conditionally - Newsletter page now loads without errors at /marketing/newsletter Wishlist Module Refactoring: - Create WishlistSettings.php with 8 configurable settings: * Enable guest wishlists * Wishlist page selector * Show in header toggle * Enable sharing * Back in stock notifications * Max items per wishlist * Multiple wishlists support * Show add to cart button - Add has_settings flag to wishlist module in ModuleRegistry - Initialize WishlistSettings in woonoow.php - Update customer-spa BaseLayout to use isEnabled('wishlist') check - Wishlist page already has module check (no changes needed) Files Added (1): - includes/Modules/WishlistSettings.php Files Modified (5): - admin-spa/src/routes/Marketing/Newsletter.tsx - includes/Core/ModuleRegistry.php - woonoow.php - customer-spa/src/layouts/BaseLayout.tsx - admin-spa/dist/app.js (rebuilt) Both newsletter and wishlist now follow the same module pattern: - Settings via schema (no code required) - Module enable/disable controls feature visibility - Settings page at /settings/modules/{module_id} - Consistent user experience
51 lines
1.7 KiB
PHP
51 lines
1.7 KiB
PHP
<?php
|
|
/**
|
|
* Plugin Name: WooNooW
|
|
* Description: The modern experience layer for WooCommerce (no migration, no risk).
|
|
* Version: 0.1.0
|
|
* Author: WooNooW
|
|
* Requires Plugins: woocommerce
|
|
*/
|
|
|
|
if (!defined('ABSPATH')) exit;
|
|
|
|
// Define plugin constants
|
|
define('WOONOOW_PATH', plugin_dir_path(__FILE__));
|
|
define('WOONOOW_URL', plugin_dir_url(__FILE__));
|
|
define('WOONOOW_VERSION', '0.1.0');
|
|
|
|
spl_autoload_register(function ($class) {
|
|
$prefix = 'WooNooW\\';
|
|
$base_dir = __DIR__ . '/includes/';
|
|
if (strncmp($prefix, $class, strlen($prefix)) !== 0) return;
|
|
$relative = substr($class, strlen($prefix));
|
|
$file = $base_dir . str_replace('\\', '/', $relative) . '.php';
|
|
if (file_exists($file)) require $file;
|
|
});
|
|
|
|
// Load translations on init hook (WordPress 6.7+ requirement)
|
|
add_action('init', function() {
|
|
load_plugin_textdomain('woonoow', false, dirname(plugin_basename(__FILE__)) . '/languages');
|
|
});
|
|
|
|
add_action('plugins_loaded', function () {
|
|
if (!class_exists('WooCommerce')) {
|
|
add_action('admin_notices', function () {
|
|
echo '<div class="notice notice-error"><p>WooNooW membutuhkan WooCommerce aktif.</p></div>';
|
|
});
|
|
return;
|
|
}
|
|
WooNooW\Core\Bootstrap::init();
|
|
|
|
// Initialize module settings
|
|
WooNooW\Modules\NewsletterSettings::init();
|
|
WooNooW\Modules\WishlistSettings::init();
|
|
});
|
|
|
|
// Activation/Deactivation hooks
|
|
register_activation_hook(__FILE__, ['WooNooW\Core\Installer', 'activate']);
|
|
register_deactivation_hook(__FILE__, ['WooNooW\Core\Installer', 'deactivate']);
|
|
|
|
// Dev mode filters removed - use wp-config.php if needed:
|
|
// add_filter('woonoow/admin_is_dev', '__return_true');
|
|
// add_filter('woonoow/admin_dev_server', fn() => 'https://woonoow.local:5173');
|