Centralize share tag attribute extraction code in Content\Text\BBCode

This commit is contained in:
Hypolite Petovan 2022-06-25 06:15:26 -04:00
parent 8446de2aa6
commit a7d49877a8
2 changed files with 36 additions and 30 deletions

View file

@ -3438,18 +3438,7 @@ class Item
*/
public static function getShareArray(array $item): array
{
if (!preg_match("/(.*?)\[share(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism", $item['body'], $matches)) {
return [];
}
$attribute_string = $matches[2];
$attributes = ['comment' => trim($matches[1]), 'shared' => trim($matches[3])];
foreach (['author', 'profile', 'avatar', 'guid', 'posted', 'link'] as $field) {
if (preg_match("/$field=(['\"])(.+?)\\1/ism", $attribute_string, $matches)) {
$attributes[$field] = trim(html_entity_decode($matches[2] ?? '', ENT_QUOTES, 'UTF-8'));
}
}
return $attributes;
return BBCode::fetchShareAttributes($item['body']);
}
/**