Display usnaved form changes in preview

[MAILPOET-2743]
This commit is contained in:
Rostislav Wolny
2020-04-15 18:35:31 +02:00
committed by Veljko V
parent 51f138483c
commit ac359dacf1
4 changed files with 46 additions and 41 deletions

View File

@@ -6,6 +6,9 @@ use MailPoet\Config\Renderer as TemplateRenderer;
use MailPoet\WP\Functions as WPFunctions;
class PreviewPage {
const PREVIEW_DATA_TRANSIENT_PREFIX = 'mailpoet_form_preview_';
const PREVIEW_DATA_EXPIRATION = 84600; // 1 DAY
/** @var WPFunctions */
private $wp;
@@ -52,6 +55,10 @@ class PreviewPage {
* @return array|null
*/
private function fetchFormData(int $id) {
$formData = $this->wp->getTransient(self::PREVIEW_DATA_TRANSIENT_PREFIX . $id);
if (is_array($formData)) {
return $formData;
}
$form = $this->formRepository->findOneById($id);
if ($form) {
return [