', '', '', '', '', '', '', '', '', '', '', '', ]; if ($displayType === 'full') { $tagsNotBeingStripped = array_merge($tagsNotBeingStripped, ['', '', '', '', '', '']); } if (is_array($content)) { $content = implode(' ', $content); } $content = strip_tags($content, implode('', $tagsNotBeingStripped)); if ($withPostClass) { $dOMParser = new pQuery(); $DOM = $dOMParser->parseStr(WPFunctions::get()->wpautop($content)); $paragraphs = $DOM->query('p'); foreach ($paragraphs as $paragraph) { // We replace the class attribute to avoid conflicts in the newsletter editor $paragraph->removeAttr('class'); $paragraph->addClass(self::WP_POST_CLASS); } $content = $DOM->__toString(); } else { $content = WPFunctions::get()->wpautop($content); } $content = trim($content); return $content; } private function getContentForProduct($product, $displayType) { if ($displayType === 'excerpt') { return $product->get_short_description(); } return $product->get_description(); } private function generateExcerpt($content) { // remove image captions in gutenberg $content = preg_replace( "/.*?<\/figcaption>/", '', $content ); // remove image captions in classic posts $content = preg_replace( "/\[caption.*?\](.*?)\[\/caption\]/", '', $content ); $content = self::stripShortCodes($content); // if excerpt is empty then try to find the "more" tag $excerpts = explode('', $content); if (count($excerpts) > 1) { // separator was present return $excerpts[0]; } else { // Separator not present, try to shorten long posts return WPFunctions::get()->wpTrimWords($content, $this->maxExcerptLength, ' …'); } } private function stripShortCodes($content) { // remove captions $content = preg_replace( "/\[caption.*?\](.*<\/a>)(.*?)\[\/caption\]/", '$1', $content ); // remove other shortcodes $content = preg_replace('/\[[^\[\]]*\]/', '', $content); return $content; } private function convertEmbeddedContent($content = '') { // remove embedded video and replace with links $content = preg_replace( '#<\/iframe>#', '' . __('Click here to view media.', 'mailpoet') . '', $content ); // replace youtube links $content = preg_replace( '#http://www.youtube.com/embed/([a-zA-Z0-9_-]*)#Ui', 'http://www.youtube.com/watch?v=$1', $content ); return $content; } private function isWcProduct($post) { return class_exists('\WC_Product') && $post instanceof \WC_Product; } }
', ]; if ($displayType === 'full') { $tagsNotBeingStripped = array_merge($tagsNotBeingStripped, ['', '', '', '', '', '']); } if (is_array($content)) { $content = implode(' ', $content); } $content = strip_tags($content, implode('', $tagsNotBeingStripped)); if ($withPostClass) { $dOMParser = new pQuery(); $DOM = $dOMParser->parseStr(WPFunctions::get()->wpautop($content)); $paragraphs = $DOM->query('p'); foreach ($paragraphs as $paragraph) { // We replace the class attribute to avoid conflicts in the newsletter editor $paragraph->removeAttr('class'); $paragraph->addClass(self::WP_POST_CLASS); } $content = $DOM->__toString(); } else { $content = WPFunctions::get()->wpautop($content); } $content = trim($content); return $content; } private function getContentForProduct($product, $displayType) { if ($displayType === 'excerpt') { return $product->get_short_description(); } return $product->get_description(); } private function generateExcerpt($content) { // remove image captions in gutenberg $content = preg_replace( "/.*?<\/figcaption>/", '', $content ); // remove image captions in classic posts $content = preg_replace( "/\[caption.*?\](.*?)\[\/caption\]/", '', $content ); $content = self::stripShortCodes($content); // if excerpt is empty then try to find the "more" tag $excerpts = explode('', $content); if (count($excerpts) > 1) { // separator was present return $excerpts[0]; } else { // Separator not present, try to shorten long posts return WPFunctions::get()->wpTrimWords($content, $this->maxExcerptLength, ' …'); } } private function stripShortCodes($content) { // remove captions $content = preg_replace( "/\[caption.*?\](.*<\/a>)(.*?)\[\/caption\]/", '$1', $content ); // remove other shortcodes $content = preg_replace('/\[[^\[\]]*\]/', '', $content); return $content; } private function convertEmbeddedContent($content = '') { // remove embedded video and replace with links $content = preg_replace( '#<\/iframe>#', '' . __('Click here to view media.', 'mailpoet') . '', $content ); // replace youtube links $content = preg_replace( '#http://www.youtube.com/embed/([a-zA-Z0-9_-]*)#Ui', 'http://www.youtube.com/watch?v=$1', $content ); return $content; } private function isWcProduct($post) { return class_exists('\WC_Product') && $post instanceof \WC_Product; } }