Replaces links to twitter.com an "x.com" to a nitter server #1461

Closed
loma-one wants to merge 3 commits from (deleted):develop into develop
Showing only changes of commit ebd54b2398 - Show all commits

View file

@ -1,8 +1,8 @@
<?php
/*
* Name: nitter
* Description: Replaces links to twitter.com to a nitter server in all displays of postings on a node.
* Version: 2.0
* Description: Replaces links to twitter.com an "x.com" to a nitter server in all displays of postings on a node.
* Version: 2.1
* Author: Tobias Diekershoff <tobias@social.diekershoff.de>
*
* Copyright (c) 2020 Tobias Diekershoff
@ -55,7 +55,7 @@ function nitter_addon_admin(string &$o)
}
/*
* replace "twitter.com" with "nitter.net"
* replace "twitter.com" an "x.com" with "nitter.net"
*/
function nitter_render(array &$b)
{
@ -69,6 +69,10 @@ function nitter_render(array &$b)
if (strstr($b['html'], 'https://twitter.com')) {
$b['html'] = str_replace('https://twitter.com', $nitter, $b['html']);
$replaced = true;
}
if (strstr($b['html'], 'https://x.com')) {
$b['html'] = str_replace('https://x.com', $nitter, $b['html']);
$replaced = true;
}
if ($replaced) {
$b['html'] .= '<hr><p><small>' . DI::l10n()->t('(Nitter addon enabled: Twitter links via %s)', $nitter) . '</small></p>';