fix: WP-Admin CSS conflicts and add-to-cart redirect
- Fix CSS conflicts between WP-Admin and SPA (radio buttons, chart text) - Add Tailwind important selector scoped to #woonoow-admin-app - Remove overly aggressive inline SVG styles from Assets.php - Add targeted WordPress admin CSS overrides in index.css - Fix add-to-cart redirect to use woocommerce_add_to_cart_redirect filter - Let WooCommerce handle cart operations natively for proper session management - Remove duplicate tailwind.config.cjs
This commit is contained in:
@@ -35,15 +35,11 @@ class Assets {
|
||||
public static function enqueue_assets() {
|
||||
// Only load on pages with WooNooW shortcodes or in full SPA mode
|
||||
if (!self::should_load_assets()) {
|
||||
error_log('[WooNooW Customer] should_load_assets returned false - not loading');
|
||||
return;
|
||||
}
|
||||
|
||||
error_log('[WooNooW Customer] should_load_assets returned true - loading assets');
|
||||
|
||||
// Check if dev mode is enabled
|
||||
$is_dev = defined('WOONOOW_CUSTOMER_DEV') && WOONOOW_CUSTOMER_DEV;
|
||||
error_log('[WooNooW Customer] Dev mode: ' . ($is_dev ? 'true' : 'false'));
|
||||
|
||||
if ($is_dev) {
|
||||
// Dev mode: Load from Vite dev server
|
||||
@@ -66,9 +62,6 @@ class Assets {
|
||||
null,
|
||||
false // Load in header
|
||||
);
|
||||
|
||||
error_log('WooNooW Customer: Loading from Vite dev server at ' . $dev_server);
|
||||
error_log('WooNooW Customer: Scripts enqueued - vite client and main.tsx');
|
||||
} else {
|
||||
// Production mode: Load from build
|
||||
$plugin_url = plugin_dir_url(dirname(dirname(__FILE__)));
|
||||
@@ -76,7 +69,6 @@ class Assets {
|
||||
|
||||
// Check if build exists
|
||||
if (!file_exists($dist_path)) {
|
||||
error_log('WooNooW: customer-spa build not found. Run: cd customer-spa && npm run build');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -84,9 +76,6 @@ class Assets {
|
||||
$js_url = $plugin_url . 'customer-spa/dist/app.js';
|
||||
$css_url = $plugin_url . 'customer-spa/dist/app.css';
|
||||
|
||||
error_log('[WooNooW Customer] Enqueuing JS: ' . $js_url);
|
||||
error_log('[WooNooW Customer] Enqueuing CSS: ' . $css_url);
|
||||
|
||||
wp_enqueue_script(
|
||||
'woonoow-customer-spa',
|
||||
$js_url,
|
||||
@@ -109,8 +98,6 @@ class Assets {
|
||||
[],
|
||||
null
|
||||
);
|
||||
|
||||
error_log('[WooNooW Customer] Assets enqueued successfully');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,7 +229,6 @@ class Assets {
|
||||
<script type="module" crossorigin src="<?php echo $dev_server; ?>/@vite/client"></script>
|
||||
<script type="module" crossorigin src="<?php echo $dev_server; ?>/src/main.tsx"></script>
|
||||
<?php
|
||||
error_log('WooNooW Customer: Scripts output directly in head with React Refresh preamble');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,11 +238,8 @@ class Assets {
|
||||
private static function should_load_assets() {
|
||||
global $post;
|
||||
|
||||
error_log('[WooNooW Customer] should_load_assets check - Post ID: ' . ($post ? $post->ID : 'none'));
|
||||
|
||||
// First check: Is this a designated SPA page?
|
||||
if (self::is_spa_page()) {
|
||||
error_log('[WooNooW Customer] Designated SPA page detected - loading assets');
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -264,8 +247,6 @@ class Assets {
|
||||
$spa_settings = get_option('woonoow_customer_spa_settings', []);
|
||||
$mode = isset($spa_settings['mode']) ? $spa_settings['mode'] : 'disabled';
|
||||
|
||||
error_log('[WooNooW Customer] SPA mode: ' . $mode);
|
||||
|
||||
// If disabled, don't load
|
||||
if ($mode === 'disabled') {
|
||||
// Special handling for WooCommerce Shop page (it's an archive, not a regular post)
|
||||
@@ -274,7 +255,6 @@ class Assets {
|
||||
if ($shop_page_id) {
|
||||
$shop_page = get_post($shop_page_id);
|
||||
if ($shop_page && has_shortcode($shop_page->post_content, 'woonoow_shop')) {
|
||||
error_log('[WooNooW Customer] Found woonoow_shop shortcode on Shop page (ID: ' . $shop_page_id . ')');
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -282,27 +262,19 @@ class Assets {
|
||||
|
||||
// Check for shortcodes on regular pages
|
||||
if ($post) {
|
||||
error_log('[WooNooW Customer] Checking post content for shortcodes');
|
||||
error_log('[WooNooW Customer] Post content: ' . substr($post->post_content, 0, 200));
|
||||
|
||||
if (has_shortcode($post->post_content, 'woonoow_shop')) {
|
||||
error_log('[WooNooW Customer] Found woonoow_shop shortcode');
|
||||
return true;
|
||||
}
|
||||
if (has_shortcode($post->post_content, 'woonoow_cart')) {
|
||||
error_log('[WooNooW Customer] Found woonoow_cart shortcode');
|
||||
return true;
|
||||
}
|
||||
if (has_shortcode($post->post_content, 'woonoow_checkout')) {
|
||||
error_log('[WooNooW Customer] Found woonoow_checkout shortcode');
|
||||
return true;
|
||||
}
|
||||
if (has_shortcode($post->post_content, 'woonoow_account')) {
|
||||
error_log('[WooNooW Customer] Found woonoow_account shortcode');
|
||||
return true;
|
||||
}
|
||||
}
|
||||
error_log('[WooNooW Customer] No shortcodes found, not loading');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user