From e4c435f81b98a85461fb20f483b57365846010d5 Mon Sep 17 00:00:00 2001 From: wxa Date: Wed, 30 Sep 2020 12:59:21 +0300 Subject: [PATCH] Allow hiding read more button [MAILPOET-2979] --- .../Editor/PostTransformerContentsExtractor.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/Newsletter/Editor/PostTransformerContentsExtractor.php b/lib/Newsletter/Editor/PostTransformerContentsExtractor.php index 21d776bc8e..f1046b1e8d 100644 --- a/lib/Newsletter/Editor/PostTransformerContentsExtractor.php +++ b/lib/Newsletter/Editor/PostTransformerContentsExtractor.php @@ -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);