The problem
there is it's only "WhatLinksHere" in English. Other
languages use localised versions, so it would be a massive regex
very prone to breakage...
Hmm, couldn't you pull the localized name(s) from $specialPageAliases
? Check the wiki's language, find the right alias and chop that off.
That could work, but after looking through the code I found a function
in SpecialPageFactory that does this already! (Except instead of
looking up the page name it cuts everything off up until the first
forward-slash.)
$titleParts = SpecialPageFactory::resolveAlias($wgTitle->getText());
$subpageText = $titleParts[1];
This seems to work well.
Thanks for your help!
Cheers,
Adam.