Update DisplayFormInWPContent::display method type and add more tests

MAILPOET-4885
MAILPOET-4820
This commit is contained in:
Oluwaseun Olorunsola
2023-01-16 07:59:23 +01:00
committed by Aschepikov
parent 62325dc096
commit 0019ad110e
2 changed files with 64 additions and 27 deletions

View File

@@ -87,7 +87,7 @@ class DisplayFormInWPContent {
* @param mixed $content
* @return string|mixed
*/
public function display($content = null) {
private function display($content = null) {
if (!is_string($content) || !$this->shouldDisplay()) return $content;
$forms = $this->getForms();
@@ -125,6 +125,7 @@ class DisplayFormInWPContent {
// this code ensures that we display the form only on a page which is related to single post
if (!$this->wp->isSingle() && !$this->wp->isPage()) $result = $this->wp->applyFilters('mailpoet_display_form_is_single', false);
// Ensure form does not show up multiple times when called from the woocommerce_product_loop_end filter
if ($this->inWooProductLoop) $result = $this->displayFormInProductListPage();
$noFormsCache = $this->wp->getTransient(DisplayFormInWPContent::NO_FORM_TRANSIENT_KEY);