Dequeue bbPress default stylesheet
This commit is contained in:
1 parent
acf3d6efca
commit
d51cfaa06d
1 file changed
+28
@@ -14,6 +14,34 @@ function register_my_menu() {
|
|||||||
add_action("init", "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.
|
// Redirect guests to the login page when they visit the forum.
|
||||||
function redirect_to_login_if_not_logged_in() {
|
function redirect_to_login_if_not_logged_in() {
|
||||||
if (function_exists("is_bbpress") && is_bbpress() && !is_user_logged_in()) {
|
if (function_exists("is_bbpress") && is_bbpress() && !is_user_logged_in()) {
|
||||||
|
|||||||
Reference in new issue
Block a user