User:Lysander/Noreferrer hack: Difference between revisions
From BoyWiki
Created page with "This is a proposed hack to make it so that external links will have [http://www.w3schools.com/tags/att_a_rel.asp rel=noreferrer] applied to them. This function is found in <co..." |
No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
This is a proposed hack to make it so that external links will have [http://www.w3schools.com/tags/att_a_rel.asp rel=noreferrer] applied to them. This function is found in <code>Parser.php</code>: | This is a proposed hack to make it so that external links will have [http://www.w3schools.com/tags/att_a_rel.asp rel=noreferrer] applied to them. This function is found in <code>[[mediawikiwiki:Parser.php|Parser.php]]</code>: | ||
<pre> | |||
public static function getExternalLinkRel( $url = false, $title = null ) { | public static function getExternalLinkRel( $url = false, $title = null ) { | ||
global $wgNoFollowLinks, $wgNoFollowNsExceptions, $wgNoFollowDomainExceptions; | global $wgNoFollowLinks, $wgNoFollowNsExceptions, $wgNoFollowDomainExceptions; | ||
Line 11: | Line 11: | ||
return null; | return null; | ||
} | } | ||
</pre> | |||
It should be changed to: | It should be changed to: | ||
<pre> | |||
public static function getExternalLinkRel( $url = false, $title = null ) { | public static function getExternalLinkRel( $url = false, $title = null ) { | ||
global $wgNoFollowLinks, $wgNoFollowNsExceptions, $wgNoFollowDomainExceptions; | global $wgNoFollowLinks, $wgNoFollowNsExceptions, $wgNoFollowDomainExceptions; | ||
Line 24: | Line 24: | ||
return 'noreferrer'; | return 'noreferrer'; | ||
} | } | ||
</pre> |
Latest revision as of 19:58, 13 April 2015
This is a proposed hack to make it so that external links will have rel=noreferrer applied to them. This function is found in Parser.php
:
public static function getExternalLinkRel( $url = false, $title = null ) { global $wgNoFollowLinks, $wgNoFollowNsExceptions, $wgNoFollowDomainExceptions; $ns = $title ? $title->getNamespace() : false; if ( $wgNoFollowLinks && !in_array( $ns, $wgNoFollowNsExceptions ) && !wfMatchesDomainList( $url, $wgNoFollowDomainExceptions ) ) { return 'nofollow'; } return null; }
It should be changed to:
public static function getExternalLinkRel( $url = false, $title = null ) { global $wgNoFollowLinks, $wgNoFollowNsExceptions, $wgNoFollowDomainExceptions; $ns = $title ? $title->getNamespace() : false; if ( $wgNoFollowLinks && !in_array( $ns, $wgNoFollowNsExceptions ) && !wfMatchesDomainList( $url, $wgNoFollowDomainExceptions ) ) { return 'nofollow noreferrer'; } return 'noreferrer'; }