From 4fdd43dc4e4d241d9f4de748be4319795b04b11b Mon Sep 17 00:00:00 2001 From: kplaczek Date: Mon, 16 Jul 2018 18:11:46 +0200 Subject: [PATCH] Bug where everytime before printing paper would gram word from vocabulary, not just when there is a shortcode in a content. --- app/Paper/HtmlToPos.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/Paper/HtmlToPos.php b/app/Paper/HtmlToPos.php index 942f1fe..6b91fef 100644 --- a/app/Paper/HtmlToPos.php +++ b/app/Paper/HtmlToPos.php @@ -62,13 +62,17 @@ class HtmlToPos public function vocabularyWord($posText) { - $voc = new Vocabulary(); - $randomWord = $voc->getRandomWord(); - $word = $voc->getWord($randomWord); + if (strstr($posText, '[vocabulary_word]') + || strpos($posText, '[vocabulary_short]') + || strpos($posText, '[vocabulary_long]')) { + $voc = new Vocabulary(); + $randomWord = $voc->getRandomWord(); + $word = $voc->getWord($randomWord); - $posText = str_replace('[vocabulary_word]', $word->word, $posText); - $posText = str_replace('[vocabulary_short]', $word->short, $posText); - $posText = str_replace('[vocabulary_long]', $word->long, $posText); + $posText = str_replace('[vocabulary_word]', $word->word, $posText); + $posText = str_replace('[vocabulary_short]', $word->short, $posText); + $posText = str_replace('[vocabulary_long]', $word->long, $posText); + } return $posText; }