BuddyDev

Search

[Resolved] tags are removed from tab content

  • Participant
    Level: Initiated
    Posts: 10
    Jeremy Holden on #36007

    In the Content area for any of my Group Tabs, I have to add <p></p> in the text view so that the text is styled correctly.

    The issue is after I save the post, it defaults back to the Visual tab and when I go back to the Text tab all my <p> (and any <br>) tags are gone.

    Example – this is what I enter in the text tab:

    
    <strong>Tracking your wins is so important!</strong>
    
    Stay tuned for more information following Session 3 of the class. Your group leader will instruct you on how to use this form to help you watch your progress.
    
    

    This is what I see on the page in the inspector:

    
    <strong>Tracking your wins is so important!</strong>
    
    Stay tuned for more information following Session 3 of the class.<br> Your group leader will instruct you on how to use this form to help you watch your progress.
    
    

    After I save, when I come back to the text tab, this is what I have:

    
    <strong>Tracking your wins is so important!</strong>
    
    Stay tuned for more information following Session 3 of the class.
    Your group leader will instruct you on how to use this form to help you watch your progress.
    

    And this is what I see in the inspector:

    
    <strong>Tracking your wins is so important!</strong>
    
    Stay tuned for more information following Session 3 of the class.
    Your group leader will instruct you on how to use this form to help you watch your progress.'
    

    So on the front end I have no line breaks and the text is not applying the css that should be applied because the text is not inside the tags.

    I have auto p disabled in my theme but it's only on pages so I don't think that is the issue.

    
    function disable_wp_auto_p( $content ) {
      if ( is_singular( 'page' ) ) {
        remove_filter( 'the_content', 'wpautop' );
        remove_filter( 'the_excerpt', 'wpautop' );
      }
      return $content;
    }
    add_filter( 'the_content', 'disable_wp_auto_p', 0 );
    

    Is there something I can do to allow auto p or keep the html I save in the text tab in the content editor?

  • Keymaster
    (BuddyDev Team)
    Posts: 24149
    Brajesh Singh on #36012

    Hi Jeremy,
    Thank you for reporting the issue. We are looking into it and will be replying with more details in next 24 hours.

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 24149
    Brajesh Singh on #36039

    Hi Jeremy,
    Thank you for the patience.

    Can you please update your code and use this instead

    
    
    function disable_wp_auto_p( $content ) {
    	$is_user_page = function_exists( 'bp_is_user' ) && bp_is_user();
    
    	if ( ! $is_user_page && is_singular( 'page' ) ) {
    		remove_filter( 'the_content', 'wpautop' );
    		remove_filter( 'the_excerpt', 'wpautop' );
    	}
    
    	return $content;
    }
    
    add_filter( 'the_content', 'disable_wp_auto_p', 0 );
    

    Does it work?

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 10
    Jeremy Holden on #36053

    I updated using your code and it is still doing the same thing.

  • Keymaster
    (BuddyDev Team)
    Posts: 24149
    Brajesh Singh on #36070

    Hi Jeremy,
    Thank you for the reply.

    Can you please confirm that it does not have any effect on the front end generated markup? The above code will have no effect on the back end.

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 10
    Jeremy Holden on #36146

    That is correct, the front end markup is still doing the same thing.

  • Participant
    Level: Initiated
    Posts: 10
    Jeremy Holden on #38314

    There is something that is stripping the tags out of the displayed text in the editor window, on both the wysiwyg and text editing screens. If I look in the inspector when I open the tabs, I can see the tags in the text but it is not shown in the browser.

    https://www.loom.com/i/418245902a9644cfaeb39caa3dfa6464

  • Keymaster
    (BuddyDev Team)
    Posts: 24149
    Brajesh Singh on #38343

    Hi Jeremy,
    Thank you for the reply.

    Do you have a staging site where I can check it by disabling some of the plugin? If yes, Please let me know with the details.

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 10
    Jeremy Holden on #38365
    This reply has been marked as private.
  • Keymaster
    (BuddyDev Team)
    Posts: 24149
    Brajesh Singh on #38376

    Hi Jeremy,
    Thank you.

    Please check now.

    Your problem was this line in your functions.php

    
    function disable_wp_auto_p( $content ) {
      if ( is_singular( 'page' ) ) {
        remove_filter( 'the_content', 'wpautop' );
        remove_filter( 'the_excerpt', 'wpautop' );
      }
      return $content;
    }
    add_filter( 'the_content', 'disable_wp_auto_p', 0 );
    
    

    BuddyBoss/BuddyPress treats Group/User page as single page too. My previous code was aimed at user profile tabs. I updated it in your child theme’s functions.php with the following code.

    
    
    function disable_wp_auto_p( $content ) {
    	$is_group_page = function_exists( 'bp_is_group' ) && bp_is_group();
    
    	if ( ! $is_group_page && is_singular( 'page' ) ) {
    		remove_filter( 'the_content', 'wpautop' );
    		remove_filter( 'the_excerpt', 'wpautop' );
    	}
    
    	return $content;
    }
    
    add_filter( 'the_content', 'disable_wp_auto_p', 0 );
    
    

    That fixed it.

    Regards
    Brajesh

The topic ‘ [Resolved] tags are removed from tab content’ is closed to new replies.

This topic is: resolved