looks like it might be `is_bbpress()` that i am looking for. will report back if that doesn’t work.
EDIT: yup, that was it.
I’m looking for the correct method to dequeue bbpress css from the plugin directory and also that of the css folder within the theme.
The entire site is much larger than just the forum and I really don’t want to call the css for every page as most people don’t have a need to access the forums. I’ll then enqueue the css with is_bbpress combined with is_page(array for the 2 pages that contain shortcodes.
I need to make sure that it dequeues from both locations as there is a custom css being used.
Thanks in advance for the help!
the function to use for a check is is_bbpress()
Hi,
apparently, there were some major changes in the bbPress version 2.2 update (from 2.1). I’m having massive problems to get bbPress 2.2 to work with my custom theme. It used to work nice with bbPress 2.1 (and it still does if I’m reverting to 2.1), but there’s just no more output from bbPress 2.2.
Custom plugins don’t seem the cause, can’t see any difference in activating or deactivating them.
The strange thing is, that there is no output from bbpress, so it’s not a question of style but a question of how to trigger bbpress output if not through content() ?
I know that it’s a theme issue because it runs fine with the twentyeleven and the WPTouch theme.
I already tried inspecting if it’s an excerpt() issue (it’s not) and checked the page for is_bbPress() to no avail.
Is there a document that describes theming and theme integration for bbPress 2.2 or how to migrate from 2.1 to 2.2?
Or has anyone else had this issue with your custom themes?
I already checked this, but it didn’t help either: http://bbpress.org/forums/topic/non-functional-index-page-when-bbpress-2-1rc4-is-used-with-woothemes-canvas-5-05/
Cheers!
Hi Gang,
well…. this one through me for a loop today as well, when moving our WooThemes Canvas for bbPress & BuddyPress site for a test drive on bbPress 2.2 ( http://labsecrets.com/demo/canvas-commerce )
The individual forums would work fine, but the main forum index was rendering what looked like a post excerpt, with everything jumbled into a single paragraph.
Solution was actually rather simple. If you are using a child-theme in Canvas (you ARE using a child-theme I hope?? 😉 ) simply make a copy of the content-page.php file from parent, and put it into your child-theme folder.
Next, change the entry div as shown, to modify the current conditional check to ALSO see if you are on a bbPress page. Without this extra bit, it assumes that you want the page to show the_excerpt() on every page other than single.php …. not true. We want full content on bbPress pages as well 😉
<div class="entry">
<?php
/* If this is a bbPress page show full content not exerpt */
if ( ! is_singular() && (! is_bbPress()) ) {
the_excerpt();
} else {
the_content(__('Continue Reading →', 'woothemes') );
}
wp_link_pages( $page_link_args );
?>
</div><!-- /.entry -->
With this simple mod, all is well and now the native forums index works, and so does building a custom page with shortcode. Ta da!
See: http://labsecrets.com/demo/canvas-commerce/forums/
Fatal error: Call to undefined function is_bbpress() in /home/jagudyje/public_html/wp-content/plugins/bbpress-members-only/init.php on line 129
Try…
if ( is_bbpress() ) { ... }
Thanks a bunch for sharing this snippet. It works perfectly when not conditioned. It’s not behaving nicely with the is_bbpress() conditional logic, so I’ll have to delve a bit deeper into the set of is_ functions you mentioned above, but I should be able to work something out. Thanks again for the help, and for the great forum software.
Sorry, I guess I’m not being very clear. The is_bbpress() function already seems to deliver the conditional logic I need. That (I don’t think) isn’t my problem. My problem is getting the proper syntax for removing the actions that add styles and scripts to the head area.
remove_action ( 'bbp_enqueue_scripts' , 'enqueue_styles' );
remove_action ( 'bbp_enqueue_scripts' , 'enqueue_scripts' );
This doesn’t work, nor do some variants that I have tried. Could you suggest the proper syntax for removing the relevant actions, regardless of the conditioning logic employed?
I am still having this issue, unfortunately. Although I worked out enough of the technical details of bbPress 2.1 to port the plugin/templates/css over to the live (development) site.
If it would be helpful to see what I’m talking about you can access http://tamrielfoundry.com with username: test, password: test.
The bbpress CSS + some other scripts are being loaded in the head site-wide, and I can’t figure out the correct conditional syntax to remove them unless is_bbpress() is true.
Hey JJJ, thanks for the advice. I am using /css/bbpress.css in my theme, the trouble I’m having is actually getting the proper syntax for unhooking these elements when they aren’t needed.
Essentially, what I’m trying to do is something like this:
add_action( 'get_header', 'remove_bbpress_scripts' );
function remove_bbpress_scripts() {
if ( !is_bbpress() ) {
remove_action ( 'bbp_enqueue_scripts' , 'enqueue_styles' );
remove_action ( 'bbp_enqueue_scripts' , 'enqueue_scripts' );
}
}
Something isn’t working with this syntax though, I suspect I need to prefix ‘enqueue_styles’ with something, but I’m not sure what the proper prefix is.
Hi bbPress community,
Thank you for all your collective hard work on this great plugin. I’m working on an integration of the new 2.1 plugin into my own theme, and I had a question about scripts and styles that bbPress enqueues into the wp_head.
In general, for plugins which are highly localized on the site (ones that only get used in very specific places), I prefer to conditionally enqueue styles and scripts to keep the head section of the main site relatively clean. bbPress currently initializes the following code site-wide:
/** Scripts ***********************************************************/
add_action( 'bbp_enqueue_scripts', array( $this, 'enqueue_styles' ) ); // Enqueue theme CSS
add_action( 'bbp_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); // Enqueue theme JS
add_filter( 'bbp_enqueue_scripts', array( $this, 'localize_topic_script' ) ); // Enqueue theme script localization
add_action( 'bbp_head', array( $this, 'head_scripts' ) ); // Output some extra JS in the
Normally I’m fairly handy with actions and filters in my functions.php file, but I’ve had a load of trouble getting these scripts to conditionally enqueue. Ideally, I would want to condition them on is_bbpress(). Can anyone offer a snippet to filter these unless is_bbpress() is true?
Thanks in advance, and let me know if my question is unclear in any way.
Andrew
I posted this in another topic, this works for me:
function disable_all_widgets( $sidebars_widgets ) {
if ( function_exists('is_bbpress') ) {
if (is_bbpress()) {
$sidebars_widgets = array(false);
remove_all_actions('bp_register_widgets');
unregister_sidebar( 'bp_core_widgets' );
}
}
return $sidebars_widgets;
}
add_filter('sidebars_widgets', 'disable_all_widgets', 1, 1);
But that’s because I haven’t looked into custom themes yet. Did everything with functions and CSS at the moment.
You could try something like this (for an install that also has BuddyPress):
function disable_all_widgets( $sidebars_widgets ) {
if ( function_exists('is_bbpress') ) {
if (is_bbpress()) {
$sidebars_widgets = array(false);
remove_all_actions('bp_register_widgets');
unregister_sidebar( 'bp_core_widgets' );
}
}
return $sidebars_widgets;
}
add_filter('sidebars_widgets', 'disable_all_widgets', 1, 1);
It looks like this is my solo topic.:-) So I continue contributing. Here is my progress in resolving the isue described above.
I have created bbpress-extras directory in MYTHEME directory. All files from /wp-content/plugins/bbpress/bbp-theme-compat/extras were copied into this directory. Than I edited bbpress-functions.php (copied to MYTHEME directory). Following code looks to be promising
function bbpress_custom_template() {
if ( is_bbpress() ) {
require_once ( 'bbpress-extras/page-front-forums.php');
exit;
}
}
add_action('template_redirect', 'bbpress_custom_template');
This is the result: http://poradci-sobe.cz/forums/
This looks like this is the way how my custom template files can be stopped to be ignored by bbpress. At least the first file I am testing – page-front-forums.php. I will try to make the condition more precize and to create special condition for each template file I want to use.
Does anybody know, why this approach creates as many forum lists as the number of forum is?? Each forum lists is the same except forum name is different. I would expect there will be only one forum lists without any name.
I am looking for JJJs answer saying “this is a very poor solution”. I am trying my best. Sorry for that.:-)
-
This reply was modified 12 years, 9 months ago by
viktora.
For anyone else interested, I placed it in the main WP theme header and just wrapped it with is_bbpress()
That allowed me to check if they were on bbpress and not logged in to display the login screen, otherwise continue as it should.
I have two separate headers for my customized skeleton theme, header.php and header-page.php. Is there a way I can call header-page.php on my forums page for bbpress? I tried using:
if ( is_front_page() ) :
get_header();
elseif ( is_bbpress() ) :
get_header(‘page’);
else :
get_header(‘page’);
in my index.php page, but it didn’t work. Is there another way to do this?
Thanks.
I don’t know if this is of any help but to get what I did at SWNK (http://www.swnk.org/forums/) I added the following code to my functions.php:
function disable_all_widgets( $sidebars_widgets ) {
// if ( bbp_is_forum() ) {
if (is_bbpress()) {
$sidebars_widgets = array(false);
remove_all_actions(‘bp_register_widgets’);
unregister_sidebar( ‘bp_core_widgets’ );
}
return $sidebars_widgets;
}
add_filter(‘sidebars_widgets’, ‘disable_all_widgets’, 1, 1);
Then I added some CSS to put the login widget above the forum.
You will need to do some custom development on your end. This isn’t implemented in core (at least not yet) because at the moment each theme/framework handles their layout options differently – so there is no easy way to cover them all.
You can probably use the code in https://wordpress.org/extend/plugins/bbpress-genesis-extend/ as an example.
Basically you will want to check for is_bbpress() and if that comes back true then run your code that forces the full width layout.
There are several different things you can do.
I would recommend inserting this information by using hooks that bbPress put in place. Unfortunately there is no “master list” of the available hooks, so you have to dig in bbPress and find the best one. It’s very do-able but will take some trial and error.
Your other option would be to approach things like you are doing now. I would use bbPress conditionals instead of is_page()
. Here are a few of the conditionals available:
bbp_is_single_forum()
bbp_is_single_topic()
bbp_is_topic_edit()
bbp_is_topic_merge()
bbp_is_topic_split()
bbp_is_single_reply()
bbp_is_reply_edit()
bbp_is_reply_edit()
bbp_is_single_view()
bbp_is_single_user_edit()
bbp_is_single_user()
bbp_is_user_home()
bbp_is_subscriptions()
bbp_is_favorites()
bbp_is_topics_created()
is_bbpress() (this is all of the above wrapped in one)
Try adding a check for bbPress, such as
add_action( 'bbp_ready', 'ja_login_detect' );
function ja_login_detect() {
if ( is_bbpress() ) {
include_once "/dap/dap-config.php";
if ( !Dap_Session::isLoggedIn() )
header( "Location: /dap/login.php" )
}
}
You are going to have to wrap it in something that checks for bbPress.
Similar to:
if ( is_bbpress() ) {
include_once "/dap/dap-config.php";
if( !Dap_Session::isLoggedIn() ) {
header("Location: /dap/login.php");
exit;
}
}
However it’s going to likely take more polish than that.
Hi Raphaelsuzuki – no, making a page (with full width template) and setting it as the base slug doesn’t work I’m afraid.
I’m not using TwentyTen, I’m using a child theme based on Thematic. I ended up just filtering the sidebar away with the following in my main theme’s functions.php:
function remove_sidebar() {
if(function_exists('is_bbpress') && is_bbpress()){
return FALSE;
} else {
return TRUE;
}
}
add_filter('thematic_sidebar', 'remove_sidebar');
Hope that helps someone in future.
Thanks for the share! You might want to use is_bbpress()
function (found in bbp-includes/bbp-common-template.php
instead of $uri = $_SERVER['REQUEST_URI']; if ( strpos($uri,'YOUR-FORUM-BASE') !== false ) {
I have wrapped your code blocks in backticks for easier reading.
I’m looking for something like is_bbpress(), but one that only fires if on the forum homepage. Is there such a conditional?
i.e.
if is_bbpress_forum_home() …. will allow me to add/subtract functionality from the forum homepage no matter where it is located.
Trying to do something like:
<?php if ( $page = bbp_get_page_by_path( $bbp->root_slug ) ) : ?>
<?php _e( 'Forums', 'bbpress' ); ?>
<?php else : ?>
<?php bbp_forum_title(); ?>
<?php endif; ?>