User:Lysander/Noreferrer hack: Difference between revisions
From BoyWiki
No edit summary |
No edit summary |
||
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> | <pre> | ||
public static function getExternalLinkRel( $url = false, $title = null ) { | public static function getExternalLinkRel( $url = false, $title = null ) { |
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'; }