bbPress

Simple, Fast, Elegant

bbPress support forums » Troubleshooting

Add nofollow to links

(18 posts)
  • Started 1 year ago by kineda
  • Latest reply from cordoval
  • This topic is not resolved
  1. Is there anyway to add the nofollow tag to links?

    Posted 1 year ago #
  2. I would imagine that you could do this without affecting any core files through a plugin as the links portion for posts is pluggable. Now, saying that, we need someone with some experience working with the code to make this a plugin.

    Trent

    Posted 1 year ago #
  3. bbPress has a function called bb_rel_nofollow() which can be added via filter to functions which output a link (... not functions that output a URL).

    For example:

    add_filter('post_author_link', 'bb_rel_nofollow');
    Posted 1 year ago #
  4. Please--can you tell me specifically where to add this? What file and which lines? (Sorry, perpetual noob, trying to learn.) :-)

    Posted 8 months ago #
  5. You can simply add that line into bb-includes/default-filters.php
    or
    create your own plugin file with that line.

    Posted 8 months ago #
  6. livibetter, for us noobs, can you show what a plugin would look like with just that functionality, so we could avoid modifying a core file in bb-includes?

    Thanks.

    Posted 8 months ago #
  7. Here it is:

    <?php
    /*
    Plugin Name: My own tweak for my forums
    Plugin URI: http://bbpress.org/
    Description: Fine tuning codes for my forum
    Author: Your name
    Author URI: http://www.myforum.com/
    Version: 0.1
    */
    
    add_filter('post_author_link', 'bb_rel_nofollow');
    ?>

    Basically, you can put many fine tuning codes within one PHP files, and this file is for your forum only. Remember to activate this plugin.

    Posted 8 months ago #
  8. If it were a _plugin, would it load automatically, and not require activation? Like, you could call it _myforumtweaks.php and it would be loaded automatically with no activation once you dropped it into my-plugins?

    That's all there is to a simple add_filter plugin, eh? (no video required...)

    Posted 8 months ago #
  9. livibetter,

    Thanks so much! It works beautifully.

    I know it works on new posts, on URLs in the post.

    Does it also work on URLS in old posts, when they're viewed? I am not able to test that.

    Also, it obviously doesn't work on author's website links (the ones saves in their user profile, I mean). How do we make those nofollow if we want to?

    Many, many thanks. I am learning, but slowly.

    Posted 8 months ago #
  10. Okay, upon further testing, it does seem to be working with older posts--in certain circumstances.

    Let me explain

    If you simply type (or in the past typed) in a URL, this plugin adds "nofollow." But if you write a sentence and add a link to the text, it doesn't. You can see this in effect here:
    http://bedbugger.com/forum/topic/test-5?replies=3#post-14812

    Compare the two tests of a link to google. The first, where the URL is typed in, adds nofollow, the second, where the HTML is used to link out to google, doesn't.

    Please help me fix this? Thanks again, this is a huge help!

    Posted 8 months ago #
  11. winpoka
    Member

    It works great.. but a savvy spammer can bypass this simply by editing their post and adding rel='follow' to their a tag.. anyone know of a more complete/thorough solution?

    Posted 5 months ago #
  12. It worked fine with me, I'll just manually delete the entry of the spammers! :)

    Posted 5 months ago #
  13. winpoka
    Member

    Try manually deleting a few hundred posts per day once you get popular..?

    Anyone know of more thorough solution? One that permanently adds "nofollow" to all posted links??

    Posted 4 months ago #
  14. I thought this plugin did that?
    http://bbpress.org/forums/topic/add-nofollow-to-links#post-12523

    Posted 4 months ago #
  15. cordoval
    Member

    Hi there,

    I have tried so hard to tweak this plug in but I am unable. All I want is to add besides the nofollow is a target="_top" so that the forum user is able to go out to another window for external links.

    Can anyone help me please,

    Many thanks,

    Posted 1 month ago #
  16. cordoval
    Member

    by default the nofollow is there, but how can we add some more things to the tag?

    Posted 1 month ago #
  17. cordoval, make this into a plugin:

    //add target=_blank to post links
    function bb_target_blank( $text ) {
    	$text = preg_replace('|<a (.+?)>|i', '<a $1 target="_blank">', $text);
    	return $text;
    }
    add_filter('pre_post', 'bb_target_blank');
    Posted 1 month ago #
  18. cordoval
    Member

    the problem was that it was not 'post_author_link but 'post_text

    Posted 1 month ago #

RSS feed for this topic

Reply

You must log in to post.

Code is Poetry.