Use WP functions to get content and excerpt
[MAILPOET-3671]
This commit is contained in:
@@ -14,11 +14,14 @@ class PostContentManager {
|
||||
/** @var WooCommerceHelper */
|
||||
private $woocommerceHelper;
|
||||
|
||||
/** @var WPFunctions */
|
||||
private $wp;
|
||||
|
||||
public function __construct(
|
||||
WooCommerceHelper $woocommerceHelper = null
|
||||
) {
|
||||
$wp = new WPFunctions;
|
||||
$this->maxExcerptLength = $wp->applyFilters('mailpoet_newsletter_post_excerpt_length', $this->maxExcerptLength);
|
||||
$this->wp = new WPFunctions;
|
||||
$this->maxExcerptLength = $this->wp->applyFilters('mailpoet_newsletter_post_excerpt_length', $this->maxExcerptLength);
|
||||
$this->woocommerceHelper = $woocommerceHelper ?: new WooCommerceHelper();
|
||||
}
|
||||
|
||||
@@ -26,19 +29,19 @@ class PostContentManager {
|
||||
if ($displayType === 'titleOnly') {
|
||||
return '';
|
||||
}
|
||||
if ($this->woocommerceHelper->isWooCommerceActive() && $post->post_type === 'product') { // phpcs:ignore Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
|
||||
if ($this->woocommerceHelper->isWooCommerceActive() && $this->wp->getPostType($post) === 'product') {
|
||||
$product = $this->woocommerceHelper->wcGetProduct($post->ID);
|
||||
if ($product) {
|
||||
return $this->getContentForProduct($product, $displayType);
|
||||
}
|
||||
}
|
||||
if ($displayType === 'excerpt') {
|
||||
if (!empty($post->post_excerpt)) { // phpcs:ignore Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
|
||||
return self::stripShortCodes($post->post_excerpt); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
|
||||
if ($this->wp->hasExcerpt($post)) {
|
||||
return self::stripShortCodes($this->wp->getTheExcerpt($post));
|
||||
}
|
||||
return $this->generateExcerpt($post->post_content); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
|
||||
return $this->generateExcerpt($this->wp->getTheContent(null, false, $post));
|
||||
}
|
||||
return self::stripShortCodes($post->post_content); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
|
||||
return self::stripShortCodes($this->wp->getTheContent(null, false, $post));
|
||||
}
|
||||
|
||||
public function filterContent($content, $displayType, $withPostClass = true) {
|
||||
|
Reference in New Issue
Block a user