• Resolved jasperdy

    (@jasperdy)


    First of all, your work is great. It is the only nofollow plugin that is working right now for me but I had an issue recently with regards to having WordPress installed in a seperate folder on the page, like this https://www.example.com/blog/.

    Plugin works only for the domain with /blog but anything on the root domain receives a rel=nofollow.

    Propose to add an optional feature to only get hostname if required.

    For people interested in overriding the function. I added two lines to make it work for me.

    static function auto_nofollow_callback( $matches ) {
      $inside_a = $matches[1];
      $site_link = get_bloginfo( 'url' );
    		
      /**
      * overrides site url to get hostname only
      * https://stackoverflow.com/questions/17201170/php-how-to-get-the-base-domain-url/17201261
      */
      $site_link =  parse_url($site_link);
      $site_link = $site_link['scheme']."://".$site_link['host'];
    
      if( strpos( $inside_a, $site_link ) ) { //internal link
        return "<a$inside_a>"; //the space is already in $inside_a
      }
    
      if( strpos( $inside_a, 'rel' ) === false ) //already has rel attribute
        return "<a$inside_a rel=\"nofollow\" class=\"".$site_link."\">";
      else
        return "<a$inside_a class>";
    }
    • This topic was modified 6 years, 2 months ago by jasperdy.
Viewing 1 replies (of 1 total)
  • Plugin Author Stefano

    (@ste_95)

    Hi jasperdy,
    thanks for sharing your code! I will integrate it in the next public release for sure! ??

    Have a nice day,
    Stefano

Viewing 1 replies (of 1 total)
  • The topic ‘Only use host name and remove trailing spaces’ is closed to new replies.