Only use host name and remove trailing spaces
-
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>"; }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Only use host name and remove trailing spaces’ is closed to new replies.