Skip to content

Commit

Permalink
Update functions.php
Browse files Browse the repository at this point in the history
To enable manual and automatic teaser-break
  • Loading branch information
sb0001 authored Jan 4, 2024
1 parent 9924efd commit 8ec27bf
Showing 1 changed file with 27 additions and 8 deletions.
35 changes: 27 additions & 8 deletions system/includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1988,27 +1988,46 @@ function get_teaser($string, $url = null, $char = null)
}
}

if ($teaserType === 'full') {
// To enable manual and automatic teaser-break

if ($teaserType === 'trimmed') {
$readMore = explode('<!--more-->', $string);
if (isset($readMore['1'])) {
$patterns = array('<a id="more"></a><br>', '<p><a id="more"></a><br></p>');
$string = str_replace($patterns, '', $readMore['0']);
$string = replace_href($string, 'a', 'footnote-ref', $url);
return $string . '<p class="jump-link"><a class="read-more btn btn-cta-secondary" href="'. $url .'#more">' . $more . '</a></p>';
} else {
return $string;
}
} elseif (strlen(strip_tags($string)) < $char) {

$string = preg_replace('/\s\s+/', ' ', strip_tags($string));
$string = ltrim(rtrim($string));

//$string = replace_href($string, 'a', 'footnote-ref', $url);

return $string;
//return $string . '<p class="jump-link"><a class="read-more btn btn-cta-secondary" href="'. $url .'#more">[sb]' . $more . '</a></p>';


} elseif (strlen(strip_tags($string)) < $char) {
$string = preg_replace('/\s\s+/', ' ', strip_tags($string));
$string = ltrim(rtrim($string));
return $string;
} else {
} else {
$string = preg_replace('/\s\s+/', ' ', strip_tags($string));
$string = ltrim(rtrim($string));
$string = substr($string, 0, $char);
$string = substr($string, 0, strrpos($string, ' '));
return $string;
}
} else {
$readMore = explode('<!--more-->', $string);
if (isset($readMore['1'])) {
$patterns = array('<a id="more"></a><br>', '<p><a id="more"></a><br></p>');
$string = str_replace($patterns, '', $readMore['0']);
$string = replace_href($string, 'a', 'footnote-ref', $url);
return $string . '<p class="jump-link"><a class="read-more btn btn-cta-secondary" href="'. $url .'#more">' . $more . '</a></p>';
} else {
return $string;
}
}

}

// Get thumbnail from image and Youtube.
Expand Down

0 comments on commit 8ec27bf

Please sign in to comment.