From d51cfaa06d4d3dc83de98887ef7844c9efd30766 Mon Sep 17 00:00:00 2001 From: ai-bot Date: Wed, 14 Oct 2026 09:32:56 +0000 Subject: [PATCH] Dequeue bbPress default stylesheet --- functions.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/functions.php b/functions.php index e0edb79..bb78b7f 100644 --- a/functions.php +++ b/functions.php @@ -14,6 +14,34 @@ function register_my_menu() { add_action("init", "register_my_menu"); +/** + * Remove bbPress' own front-end stylesheet. + * + * bbPress ships css/bbpress.css and enqueues it on every forum page. It clashes + * with the theme's forum styling, so we drop it and let the theme control the + * forum look (as it did before wp_head() was added to the theme). + * + * Matched by file name rather than by handle, so this keeps working even if + * bbPress changes the style handle. + */ +function super_simple_remove_bbpress_styles() { + global $wp_styles; + + if (empty($wp_styles->queue)) { + return; + } + + foreach ($wp_styles->queue as $handle) { + $src = isset($wp_styles->registered[$handle]) ? (string) $wp_styles->registered[$handle]->src : ""; + + if (false !== strpos($src, "bbpress") && ".css" === substr($src, -4)) { + wp_dequeue_style($handle); + } + } +} +add_action("wp_enqueue_scripts", "super_simple_remove_bbpress_styles", 100); + + // Redirect guests to the login page when they visit the forum. function redirect_to_login_if_not_logged_in() { if (function_exists("is_bbpress") && is_bbpress() && !is_user_logged_in()) {