Display form on product pages

[MAILPOET-3210]
This commit is contained in:
Pavel Dohnal
2020-09-14 13:52:48 +02:00
committed by Veljko V
parent 72ab5343c0
commit 55a895f2c4
3 changed files with 78 additions and 3 deletions

View File

@@ -187,10 +187,10 @@ class DisplayFormInWPContent {
return false;
}
if ($this->wp->isSingular('post')) {
if ($this->wp->isSingular('post') || $this->wp->isSingular('product')) {
if ($this->shouldDisplayFormOnPost($setup, 'posts')) return true;
if (isset($setup['categories']) && $this->wp->hasCategory($setup['categories'])) return true;
if (isset($setup['tags']) && $this->wp->hasTag($setup['tags'])) return true;
if ($this->shouldDisplayFormOnCategory($setup)) return true;
if ($this->shouldDisplayFormOnTag($setup)) return true;
return false;
}
if ($this->wp->isPage() && $this->shouldDisplayFormOnPost($setup, 'pages')) {
@@ -213,4 +213,18 @@ class DisplayFormInWPContent {
}
return false;
}
private function shouldDisplayFormOnCategory(array $setup): bool {
if (!isset($setup['categories'])) return false;
if ($this->wp->hasCategory($setup['categories'])) return true;
if ($this->wp->hasTerm($setup['categories'], 'product_cat')) return true;
return false;
}
private function shouldDisplayFormOnTag(array $setup): bool {
if (!isset($setup['tags'])) return false;
if ($this->wp->hasTag($setup['tags'])) return true;
if ($this->wp->hasTerm($setup['tags'], 'product_tag')) return true;
return false;
}
}