enqueue(); } catch ( \Throwable $e ) { // ID errado ou template removido — ignora sem quebrar o site continue; } } // -------------------------------------------------------------- // 2) Injeta o CSS global de centralização do mega menu // (especificidade reforçada + min-width, pra ganhar de // qualquer empate de !important que vier antes no HTML) // -------------------------------------------------------------- $mega_menu_position_css = ' html body .pix-header-desktop.pix-header-desktop .mega-item.pix-mega-style-lg .dropdown-menu.dropdown-menu { position: fixed !important; top: 132px !important; left: calc(50vw - 10px) !important; transform: translateX(-50%) !important; width: 1379px !important; min-width: 1379px !important; max-width: 95vw !important; } html body .pix-header-desktop.pix-header-desktop .mega-item.pix-mega-style-lg .dropdown-menu.dropdown-menu .submenu-box, html body .pix-header-desktop.pix-header-desktop .mega-item.pix-mega-style-lg .dropdown-menu.dropdown-menu .container, html body .pix-header-desktop.pix-header-desktop .mega-item.pix-mega-style-lg .dropdown-menu.dropdown-menu .container-fluid, html body .pix-header-desktop.pix-header-desktop .mega-item.pix-mega-style-lg .dropdown-menu.dropdown-menu .row { max-width: 100% !important; width: 100% !important; min-width: 0 !important; } '; // "wp-block-library" e outros handles padrão do WP sempre existem, // então é um handle seguro pra pendurar o CSS extra. // Se preferir, troque por outro handle que você saiba que sempre carrega. wp_register_style( 'vb-mega-menu-fix', false ); wp_enqueue_style( 'vb-mega-menu-fix' ); wp_add_inline_style( 'vb-mega-menu-fix', $mega_menu_position_css ); }, PHP_INT_MAX ); // prioridade máxima: garante que carregue por último, vencendo empates de !important // -------------------------------------------------------------- // 3) JS de reforço: se o tema estiver forçando a largura via // style="" inline (JS), o CSS sozinho não consegue vencer de // forma confiável. Esse script observa quando o menu abre // (ganha a classe "show") e reaplica width/position via // setProperty(..., "important") — que É capaz de vencer um // style inline sem !important, e até empata (por ordem) com // um style inline que também tenha !important. // -------------------------------------------------------------- add_action( 'wp_footer', function () { if ( ! did_action( 'elementor/loaded' ) ) { return; } ?>
