mirror of
https://github.com/friendica/friendica
synced 2025-04-24 13:10:11 +00:00
Some more improvements for posts with shares
This commit is contained in:
parent
db82bdfc44
commit
c65fff6f93
10 changed files with 100 additions and 99 deletions
|
@ -1070,6 +1070,30 @@ class BBCode
|
|||
return $attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks, if the provided body contains a native reshare
|
||||
*
|
||||
* @param string $body
|
||||
* @return boolean
|
||||
*/
|
||||
public static function isNativeReshare(string $body): bool
|
||||
{
|
||||
$shared = BBCode::fetchShareAttributes($body);
|
||||
return !empty($shared['guid'] ?? '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the provided body contains a "share" element
|
||||
*
|
||||
* @param string $body
|
||||
* @return boolean
|
||||
*/
|
||||
public static function existsShare(string $body): bool
|
||||
{
|
||||
$shared = BBCode::fetchShareAttributes($body);
|
||||
return !empty($shared['link'] ?? '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace the share block with a link
|
||||
*
|
||||
|
@ -1094,7 +1118,7 @@ class BBCode
|
|||
*/
|
||||
public static function removeSharedData(string $body): string
|
||||
{
|
||||
return preg_replace("/\s*\[share .*?\].*?\[\/share\]\s*/ism", '', $body);
|
||||
return trim(preg_replace("/\s*\[share .*?\].*?\[\/share\]\s*/ism", '', $body));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue