From 4f0fae9e90381ff1c107fd746a9b28275f5dd4fc Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Tue, 27 Oct 2015 17:13:11 +0000 Subject: [PATCH] Show better source for linback items --- plugins/Linkback/LinkbackPlugin.php | 30 +++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/plugins/Linkback/LinkbackPlugin.php b/plugins/Linkback/LinkbackPlugin.php index 642909112d..4e6214c714 100644 --- a/plugins/Linkback/LinkbackPlugin.php +++ b/plugins/Linkback/LinkbackPlugin.php @@ -358,4 +358,34 @@ class LinkbackPlugin extends Plugin $action_name === 'linkbacksettings'); return true; } + + function onStartNoticeSourceLink($notice, &$name, &$url, &$title) + { + // If we don't handle this, keep the event handler going + if (!in_array($notice->source, array('linkback'))) { + return true; + } + + try { + $url = $notice->getUrl(); + // If getUrl() throws exception, $url is never set + + $bits = parse_url($url); + $domain = $bits['host']; + if (substr($domain, 0, 4) == 'www.') { + $name = substr($domain, 4); + } else { + $name = $domain; + } + + // TRANS: Title. %s is a domain name. + $title = sprintf(_m('Sent from %s via Linkback'), $domain); + + // Abort event handler, we have a name and URL! + return false; + } catch (InvalidUrlException $e) { + // This just means we don't have the notice source data + return true; + } + } } -- 2.39.5