Change all website links to affiliate links automatically

前端 未结 3 1746
情歌与酒
情歌与酒 2021-01-06 13:19

I would like to be able to automatically change links into affiliate links automatically on my MediaWiki installation. This would help to reduce the amount

3条回答
  •  逝去的感伤
    2021-01-06 13:55

    Right way is to use LinkerMakeExternalLink mediawiki hook like that ( you can put it at bottom of your LocalSettings.php:

    $wgHooks['LinkerMakeExternalLink'][] = 'ExampleExtension::exampleLinkerMakeExternalLink';
    
    class ExampleExtension {
        public static function exampleLinkerMakeExternalLink( &$url, &$text, &$link, &$attribs, $linktype ) {
            if( strpos( $url, 'gog.com') !== false ) {
                $url .= '?pp=708a77db476d737e54b8bf4663fc79b346d696d2';
            }
            return false;
        }
    }
    

提交回复
热议问题