Skip to:
Content
Pages
Categories
Search
Top
Bottom

Problems displaying shortcode contents in non-standard BP 1.7 themes

  • Profile photo of sensibleplugins
    sensibleplugins
    Participant

    @sensibleplugins

    Hi,

    We’re having problems displaying the contents of shortcodes inside the tabs of our BuddyPress Custom Profile Menu plugin. This only happens in non-standard BP 1.7 themes, but works as expected in themes like “BuddyPress Default” that ships with BP.

    Researching the issue some more, we found the following line in bp-core-theme-compatibility.php (line 525)

    bp_remove_all_filters( 'the_content' );

    This is clearly the cause of the issue, as it removes, amongst others, the ‘do_shortcode’ filter function from ‘the_content’ filter (function added to filter in WordPress’ shortcodes.php, line 335). Why does BuddyPress remove all ‘the_content’ filters when in theme compatibility mode? Does this mean that shotcodes cannot be displayed in this mode?

    Thanks in advance!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Profile photo of Hugo
    Hugo
    Moderator

    @hnla

    I recently ran into the same issue – yes bp feels the need to strip out filters in theme compatibility mode as it feeds via the page content loop – I was pushing loop content through a do_action on a new group front page, my resolution was to re-instate the filter I needed ‘wpautop’ on ‘the_content’ just before my while loop then immediately after closing the loop I removed the filter again ( which could also have been via bp_remove_all_filters or add . Didn’t look further into this though.

    Profile photo of sensibleplugins
    sensibleplugins
    Participant

    @sensibleplugins

    Thank you so much @Hugo. Your suggestion didn’t work for us though. This is what we currently have:

    $content = $page->post_content;
    $content = apply_filters('the_content', $content);

    Following your suggestion, we changed it to:

    add_filter( 'the_content', 'wpautop');
    $content = $page->post_content;
    $content = apply_filters('the_content', $content);

    But that didn’t help at all. Are we on the right path here?

    If you’ve found a case where theme compatibility breaks stuff, please submit a bug report onto https://buddypress.trac.wordpress.org

    Profile photo of sensibleplugins
    sensibleplugins
    Participant

    @sensibleplugins

    Will do, thanks a lot @djpaul.

    Profile photo of Hugo
    Hugo
    Moderator

    @hnla

    @sensibleplugins don’t think this is a bug necessarily, Not sure I can get the order of processing clear with your snippet but it suggests that you are applying your filters too early and BP is still getting to cut in with it’s own.

    In my circumstance I’m forcing a cpt content loop through to a do_action on a groups page so think my filters run and are processed before bp grabs that page content to push out to or replace the wp content loop.

    I have just changed my filters to bp_restore_all_filters(‘the_content’) and then add back via bp_remove_all_filters(‘the_content’) as I needed the do_shortcodes running as well, this, in my situation, works fine.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Problems displaying shortcode contents in non-standard BP 1.7 themes’ is closed to new replies.
Skip to toolbar