Skip to content

Commit

Permalink
Short content end characters fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ihorvansach committed Aug 29, 2022
1 parent 342680b commit 7c426d7
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Model/ShortContentExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,21 @@ public function execute($content, $len = null, $endCharacters = null)
}

if ($endCharacters === null) {
$endCharacters = '';
$endCharacters = $this->scopeConfig->getValue(
'mfblog/post_list/end_characters',
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
);
}

if ($len && $endCharacters) {
$trimMask = " \t\n\r\0\x0B,.!?";
if ($p = strrpos($content, '</')) {
$p2 = $p;
do {
$p = $p2;
$p2 = strrpos($content, '</', $p - strlen($content) - 1);
} while ($p2 && $p - $p2 <= 6);

$content = trim(substr($content, 0, $p), $trimMask)
. $endCharacters
. substr($content, $p);
Expand Down

0 comments on commit 7c426d7

Please sign in to comment.