shaarli-plugin-clickat/clickat.php
2024-01-27 15:29:27 +01:00

34 lines
973 B
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* ClickAt
*
* This plugin makes microblogging social networks (Twitter/𝕏, Threads, Bluesky and Fediverse) addresses clickable.
*/
use Shaarli\Config\ConfigManager;
use Shaarli\Plugin\PluginManager;
use Shaarli\Render\TemplatePage;
function hook_clickat_render_linklist($data)
{
foreach ($data['links'] as &$value) {
$value['description'] = preg_replace(
'/\ @([\w\d]+).bsky.social/',
' <a href="https://bsky.app/profile/\1.bsky.social">&commat;\1.bsky.social</a>',
$value['description']
);
$value['description'] = preg_replace(
'/\ @([\w\d]+)@([\w\d_\-\.]+)/',
' <a href="https://\2/@\1">&commat;\1</a>',
$value['description']
);
$value['description'] = preg_replace(
'/\ @([\w\d]+)/',
' <a href="https://twitter.com/\1">&commat;\1</a>',
$value['description']
);
}
return $data;
}