27 lines
925 B
PHP
27 lines
925 B
PHP
<?php
|
|
/**
|
|
* ClickAt
|
|
*
|
|
* This plugin makes microblogging social networks (Twitter/X, Threads, Bluesky and Fediverse) addresses clickable.
|
|
*/
|
|
|
|
use Shaarli\Config\ConfigManager;
|
|
use Shaarli\Plugin\PluginManager;
|
|
use Shaarli\Render\TemplatePage;
|
|
|
|
function hook_clickat_render_linklist($data)
|
|
{
|
|
$patterns = array(
|
|
'/([^\S]+)@([\w]+).bsky.social/' => '\1<a href="https://bsky.app/profile/\2.bsky.social">@\2.bsky.social</a>',
|
|
'/([^\S]+)@([\w]+)@([\w_\-\.]+)/' => '\1<a href="https://\3/@\2">@\2</a>',
|
|
'/([^\S]+)@([\w]+)/' => '\1<a href="https://x.com/\2">@\2</a>'
|
|
);
|
|
foreach ($data['links'] as &$value) {
|
|
if (strpos($value['description'], '@') !== false) {
|
|
foreach ($patterns as $nic => $link) {
|
|
$value['description'] = preg_replace($nic, $link, $value['description']);
|
|
}
|
|
}
|
|
}
|
|
return $data;
|
|
}
|