url_helper = $url_helper; $this->wp = $wp; $this->captcha_session = $captcha_session; } public function getCaptchaPageTitle() { return $this->wp->__("Confirm you’re not a robot", 'mailpoet'); } public function getCaptchaPageContent() { $fields = [ [ 'id' => 'captcha', 'type' => 'text', 'params' => [ 'label' => $this->wp->__('Type in the characters you see in the picture above:', 'mailpoet'), 'value' => '', 'obfuscate' => false, ], ], ]; $form = array_merge( $fields, [ [ 'id' => 'submit', 'type' => 'submit', 'params' => [ 'label' => $this->wp->__('Subscribe', 'mailpoet'), ], ], ] ); $captcha_session_form = $this->captcha_session->getFormData(); $form_id = 0; $show_success_message = !empty($_GET['mailpoet_success']); $show_error_message = !empty($_GET['mailpoet_error']); if (isset($captcha_session_form['form_id'])) { $form_id = (int)$captcha_session_form['form_id']; } elseif ($show_success_message) { $form_id = (int)$_GET['mailpoet_success']; } elseif ($show_error_message) { $form_id = (int)$_GET['mailpoet_error']; } $form_model = FormModel::findOne($form_id); if (!$form_model instanceof FormModel) { return false; } $form_model = $form_model->asArray(); if ($show_success_message) { // Display a success message in a no-JS flow return $this->renderFormMessages($form_model, $show_success_message); } $form_html = '
'; return $form_html; } private function renderFormMessages( array $form_model, $show_success_message = false, $show_error_message = false ) { $form_html = ' '; return $form_html; } }