Skip to:
Content
Pages
Categories
Search
Top
Bottom

bbp_rel_nofollow


  • Schaum
    Participant

    @schaum

    I use the version 2.4.1 and WP 3.6.1, now I looking for hack to modify the bbp_rel_nofollow function.

    For two possibilities:

    1.) use no nofollow, if the link is set to your own site.
    2.) use for all external links target=”_blank”

    I hope one of here has an indea and this is possible…

Viewing 5 replies - 1 through 5 (of 5 total)

  • koendb
    Participant

    @koendb

    You don’t have to change the bbp_rel_nofollow filter, just add another filter like this in your functions.php:

    <?php
    add_filter( ‘bbp_get_reply_content’,’links_blank_follow’, 90 );
    add_filter( ‘bbp_get_topic_content’,’links_blank_follow’, 90 );

    function links_blank_follow() {
    // add nofollow or target blank to links
    }
    ?>

    As for the function itself, I wouldn’t know how to do that, but you should be able to put it together, could start here.

    Let me know!


    koendb
    Participant

    @koendb

    Using bbp_rel_nofollow as a starting point is obviously better 😉


    Schaum
    Participant

    @schaum

    Thank you, these work for the _blank:

    add_filter( 'bbp_get_reply_content','links_blank_follow', 90 );
    add_filter( 'bbp_get_topic_content','links_blank_follow', 90 );
    
    function links_blank_follow($text) {
     if( strpos( $text, $_SERVER['HTTP_HOST'] ) === false )
          return str_replace('<a', '<a target="_blank"', $text);
      return $text;
    }

    But I don´t know really: how I can use no nofollow, if the link is set to your own site.


    koendb
    Participant

    @koendb

    I only know a little php, and I think this way the function searches through ALL the links in a reply/topic and adds target_blank to all of them when at least one of them is external. That’s not what you want.

    You need to
    1) explode the content
    2) loop through all link tags
    3) Test if it’s external or internal
    4) if external: use the function above to add the target=_blank
    5) if internal: remove nofollow
    6) implode and return the new reply/topic content.

    It would probably take me a few hours to google this together, maybe you could try this yourself or somebody whit a little more php knowledge could help.


    Schaum
    Participant

    @schaum

    Uff, I don´t how I can do it…

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.
Skip to toolbar