fix: Remove blur on mobile for all bars + add template_redirect solution (no .htaccess needed)
This commit is contained in:
@@ -258,7 +258,7 @@ function AddonRoute({ config }: { config: any }) {
|
|||||||
function Header({ onFullscreen, fullscreen }: { onFullscreen: () => void; fullscreen: boolean }) {
|
function Header({ onFullscreen, fullscreen }: { onFullscreen: () => void; fullscreen: boolean }) {
|
||||||
const siteTitle = (window as any).wnw?.siteTitle || 'WooNooW';
|
const siteTitle = (window as any).wnw?.siteTitle || 'WooNooW';
|
||||||
return (
|
return (
|
||||||
<header className={`h-16 border-b border-border flex items-center px-4 justify-between sticky ${fullscreen ? `top-0` : `top-[32px]`} z-40 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60`}>
|
<header className={`h-16 border-b border-border flex items-center px-4 justify-between sticky ${fullscreen ? `top-0` : `top-[32px]`} z-40 bg-background md:bg-background/95 md:backdrop-blur md:supports-[backdrop-filter]:bg-background/60`}>
|
||||||
<div className="font-semibold">{siteTitle}</div>
|
<div className="font-semibold">{siteTitle}</div>
|
||||||
<div className="flex items-center gap-3">
|
<div className="flex items-center gap-3">
|
||||||
<div className="text-sm opacity-70 hidden sm:block">{window.WNW_API?.isDev ? 'Dev Server' : 'Production'}</div>
|
<div className="text-sm opacity-70 hidden sm:block">{window.WNW_API?.isDev ? 'Dev Server' : 'Production'}</div>
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ export default function DashboardSubmenuBar({ items = [], fullscreen = false }:
|
|||||||
const topClass = fullscreen ? 'top-0' : 'top-[calc(7rem+32px)]';
|
const topClass = fullscreen ? 'top-0' : 'top-[calc(7rem+32px)]';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div data-submenubar className={`border-b border-border bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60 sticky ${topClass} z-20`}>
|
<div data-submenubar className={`border-b border-border bg-background md:bg-background/95 md:backdrop-blur md:supports-[backdrop-filter]:bg-background/60 sticky ${topClass} z-20`}>
|
||||||
<div className="px-4 py-2">
|
<div className="px-4 py-2">
|
||||||
<div className="flex items-center justify-between gap-4">
|
<div className="flex items-center justify-between gap-4">
|
||||||
{/* Submenu Links */}
|
{/* Submenu Links */}
|
||||||
|
|||||||
120
includes/Admin/StandaloneAdmin.php
Normal file
120
includes/Admin/StandaloneAdmin.php
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
<?php
|
||||||
|
namespace WooNooW\Admin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standalone Admin Handler
|
||||||
|
*
|
||||||
|
* Handles /admin requests without requiring .htaccess modifications.
|
||||||
|
* Uses WordPress template_redirect hook to catch requests early.
|
||||||
|
*
|
||||||
|
* @package WooNooW\Admin
|
||||||
|
*/
|
||||||
|
class StandaloneAdmin {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize standalone admin handler
|
||||||
|
*/
|
||||||
|
public static function init() {
|
||||||
|
// Catch /admin requests early
|
||||||
|
add_action( 'template_redirect', [ __CLASS__, 'handle_admin_request' ], 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle /admin requests
|
||||||
|
*/
|
||||||
|
public static function handle_admin_request() {
|
||||||
|
// Check if this is an /admin request
|
||||||
|
$request_uri = $_SERVER['REQUEST_URI'] ?? '';
|
||||||
|
|
||||||
|
// Remove query string
|
||||||
|
$path = strtok( $request_uri, '?' );
|
||||||
|
|
||||||
|
// Check if path starts with /admin
|
||||||
|
if ( strpos( $path, '/admin' ) !== 0 ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exclude /wp-admin
|
||||||
|
if ( strpos( $path, '/wp-admin' ) === 0 ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This is a standalone admin request
|
||||||
|
self::render_standalone_admin();
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render standalone admin interface
|
||||||
|
*/
|
||||||
|
private static function render_standalone_admin() {
|
||||||
|
// Check if user is logged in and has permissions
|
||||||
|
$is_authenticated = is_user_logged_in() && current_user_can( 'manage_woocommerce' );
|
||||||
|
|
||||||
|
// Get nonce for REST API
|
||||||
|
$nonce = wp_create_nonce( 'wp_rest' );
|
||||||
|
$rest_url = rest_url( 'woonoow/v1' );
|
||||||
|
$wp_admin_url = admin_url( 'admin.php?page=woonoow' );
|
||||||
|
|
||||||
|
// Get current user data if authenticated
|
||||||
|
$current_user = null;
|
||||||
|
if ( $is_authenticated ) {
|
||||||
|
$user = wp_get_current_user();
|
||||||
|
$current_user = [
|
||||||
|
'id' => $user->ID,
|
||||||
|
'name' => $user->display_name,
|
||||||
|
'email' => $user->user_email,
|
||||||
|
'avatar' => get_avatar_url( $user->ID ),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get asset URLs
|
||||||
|
$plugin_url = plugins_url( '', dirname( dirname( __FILE__ ) ) );
|
||||||
|
$asset_url = $plugin_url . '/admin-spa/dist';
|
||||||
|
|
||||||
|
// Cache busting
|
||||||
|
$version = defined( 'WP_DEBUG' ) && WP_DEBUG ? time() : '1.0.0';
|
||||||
|
$css_url = $asset_url . '/app.css?ver=' . $version;
|
||||||
|
$js_url = $asset_url . '/app.js?ver=' . $version;
|
||||||
|
|
||||||
|
// Render HTML
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="<?php echo esc_attr( get_locale() ); ?>">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<meta name="robots" content="noindex, nofollow">
|
||||||
|
<title>WooNooW Admin</title>
|
||||||
|
|
||||||
|
<!-- WooNooW Assets Only - NO wp_head() -->
|
||||||
|
<link rel="stylesheet" href="<?php echo esc_url( $css_url ); ?>">
|
||||||
|
</head>
|
||||||
|
<body class="woonoow-standalone">
|
||||||
|
<div id="woonoow-admin-root"></div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
// Minimal config - no WordPress bloat
|
||||||
|
window.WNW_CONFIG = {
|
||||||
|
restUrl: <?php echo wp_json_encode( $rest_url ); ?>,
|
||||||
|
nonce: <?php echo wp_json_encode( $nonce ); ?>,
|
||||||
|
standaloneMode: true,
|
||||||
|
wpAdminUrl: <?php echo wp_json_encode( $wp_admin_url ); ?>,
|
||||||
|
isAuthenticated: <?php echo $is_authenticated ? 'true' : 'false'; ?>,
|
||||||
|
currentUser: <?php echo wp_json_encode( $current_user ); ?>,
|
||||||
|
locale: <?php echo wp_json_encode( get_locale() ); ?>,
|
||||||
|
siteUrl: <?php echo wp_json_encode( home_url() ); ?>,
|
||||||
|
siteName: <?php echo wp_json_encode( get_bloginfo( 'name' ) ); ?>
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script type="module" src="<?php echo esc_url( $js_url ); ?>"></script>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
// NO wp_footer() - we don't want theme/plugin scripts
|
||||||
|
?>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ namespace WooNooW\Core;
|
|||||||
use WooNooW\Core\Features;
|
use WooNooW\Core\Features;
|
||||||
use WooNooW\Admin\Menu;
|
use WooNooW\Admin\Menu;
|
||||||
use WooNooW\Admin\Assets;
|
use WooNooW\Admin\Assets;
|
||||||
|
use WooNooW\Admin\StandaloneAdmin;
|
||||||
use WooNooW\Compat\HideWooMenus;
|
use WooNooW\Compat\HideWooMenus;
|
||||||
use WooNooW\Compat\MenuProvider;
|
use WooNooW\Compat\MenuProvider;
|
||||||
use WooNooW\Compat\AddonRegistry;
|
use WooNooW\Compat\AddonRegistry;
|
||||||
@@ -24,6 +25,7 @@ class Bootstrap {
|
|||||||
HideWooMenus::init();
|
HideWooMenus::init();
|
||||||
Menu::init();
|
Menu::init();
|
||||||
Assets::init();
|
Assets::init();
|
||||||
|
StandaloneAdmin::init();
|
||||||
|
|
||||||
// Addon system (order matters: Registry → Routes → Navigation)
|
// Addon system (order matters: Registry → Routes → Navigation)
|
||||||
AddonRegistry::init();
|
AddonRegistry::init();
|
||||||
|
|||||||
Reference in New Issue
Block a user