Allow hiding read more button [MAILPOET-2979]

This commit is contained in:
wxa
2020-09-30 12:59:21 +03:00
committed by Veljko V
parent 4122c53dae
commit e4c435f81b

View File

@ -39,7 +39,9 @@ class PostTransformerContentsExtractor {
$readMoreBtn = $this->getReadMoreButton($post);
$blocksCount = count($content);
if ($readMoreBtn['type'] === 'text' && $blocksCount > 0 && $content[$blocksCount - 1]['type'] === 'text') {
if (!$readMoreBtn) {
// Don't attach a button
} else if ($readMoreBtn['type'] === 'text' && $blocksCount > 0 && $content[$blocksCount - 1]['type'] === 'text') {
$content[$blocksCount - 1]['text'] .= $readMoreBtn['text'];
} else {
$content[] = $readMoreBtn;
@ -106,6 +108,10 @@ class PostTransformerContentsExtractor {
}
private function getReadMoreButton($post) {
if ($this->args['readMoreType'] === 'none') {
return false;
}
if ($this->args['readMoreType'] === 'button') {
$button = $this->args['readMoreButton'];
$button['url'] = $this->wp->getPermalink($post->ID);