Updated URL Replace addon #1483

Merged
MrPetovan merged 18 commits from toddy/friendica-addons:2024.03-rc into 2024.03-rc 2024-03-19 18:00:46 +01:00
Showing only changes of commit 32f698ce10 - Show all commits

View file

@ -134,6 +134,7 @@ function url_replace_addon_admin(string &$o)
*/ */
function url_replace_render(array &$b) function url_replace_render(array &$b)
{ {
$replaced = false;
$replacements = []; $replacements = [];
$nitter_server = DI::config()->get('url_replace', 'nitter_server') ?? URL_REPLACE_NITTER_DEFAULT; $nitter_server = DI::config()->get('url_replace', 'nitter_server') ?? URL_REPLACE_NITTER_DEFAULT;
@ -171,6 +172,7 @@ function url_replace_render(array &$b)
foreach ($replacements as $server => $replacement) { foreach ($replacements as $server => $replacement) {
if (strpos($b['html'], $server) !== false) { if (strpos($b['html'], $server) !== false) {
$b['html'] = str_replace($server, $replacement, $b['html']); $b['html'] = str_replace($server, $replacement, $b['html']);
$replaced = true;
} }
} }
@ -178,10 +180,11 @@ function url_replace_render(array &$b)
foreach ($twelvefeet_sites as $twelvefeet_site) { foreach ($twelvefeet_sites as $twelvefeet_site) {
if (strpos($b['html'], $twelvefeet_site) !== false) { if (strpos($b['html'], $twelvefeet_site) !== false) {
$b['html'] = str_replace($twelvefeet_site, 'https://12ft.io/' . $twelvefeet_site, $b['html']); $b['html'] = str_replace($twelvefeet_site, 'https://12ft.io/' . $twelvefeet_site, $b['html']);
$replaced = true;
} }
} }
if (count($replacements) > 0) { if ($replaced) {
$b['html'] .= '<hr><p><small>' . DI::l10n()->t('(URL replace addon enabled for X, YouTube, Instagram and some news sites.)') . '</small></p>'; $b['html'] .= '<hr><p><small>' . DI::l10n()->t('(URL replace addon enabled for X, YouTube, Instagram and some news sites.)') . '</small></p>';
} }
} }