Render preview page title correctly

[MAILPOET-2743]
This commit is contained in:
Rostislav Wolny
2020-04-23 16:56:34 +02:00
committed by Veljko V
parent d81c0d490b
commit 2711a00f3e
3 changed files with 12 additions and 2 deletions

View File

@@ -54,7 +54,10 @@ class PreviewPage {
);
}
public function renderTitle() {
public function renderTitle($title = null, $id = null) {
if ($id !== $this->wp->getTheId()) {
return $title;
}
return __('Sample page to preview your form', 'mailpoet');
}

View File

@@ -35,7 +35,7 @@ class FormPreview {
public function view(array $data) {
$this->data = $data;
$this->wp->addFilter('the_content', [$this,'renderContent'], 10);
$this->wp->addFilter('the_title', [$this->formPreviewPage,'renderTitle'], 10);
$this->wp->addFilter('the_title', [$this->formPreviewPage,'renderTitle'], 10, 2);
$this->wp->addFilter('show_admin_bar', function () {
return false;
});

View File

@@ -272,6 +272,13 @@ class Functions {
return get_the_author_meta($field, $userId);
}
/**
* @return false|int
*/
public function getTheId() {
return get_the_ID();
}
/**
* @param int|\WP_User $userId
*/