-
-
Notifications
You must be signed in to change notification settings - Fork 513
Page previews always open a new tab #1400
Description
Wordpress has a nifty feature where you can press Preview Changes when editing a post and it'll open a new tab with the preview, and if you press Preview Changes again, it will just refresh your preview tab instead of creating a new tab each time.
In the Timber starter theme (and my Goshen College theme that's based on it), post previews work as expected for posts but not pages. When you press Preview Changes in a page editor, it will always create a new tab.
Expected behavior
Open page editor and press Preview Changes button once. A new tab will be created. Go back to page editor and press Preview Changes again. The new tab will refresh.
Actual behavior
Open page editor and press Preview Changes button once. A new tab will be created. Go back to page editor and press Preview Changes again. A third tab will be created (and so on...).
What version of WordPress, PHP and Timber are you using?
WordPress 4.4.1, PHP 7.0, Timber 1.3 (but this bug existed in prior versions as well)
How did you install Timber? (for example, from GitHub, Composer/Packagist, WP.org?)
Composer
The Timber Starter Theme has a very simple page.php:
$context = Timber::get_context();
$post = new TimberPost();
$context['post'] = $post;
Timber::render( array( 'page-' . $post->post_name . '.twig', 'page.twig' ), $context );The Goshen College theme has a much more complex page.php, including the_preview filter:
if ($context['post'] && isset($_GET['preview_id'], $_GET['preview_nonce'])) {
$context['post'] = apply_filters('the_preview', $context['post']);
}This bug exists in both themes. It doesn't exist in my Genesis child theme or in TwentySeventeen, so I'm confident it's related to Timber.
I wish I could provide more code, but I'm really at a loss as to how to debug this, since I'm not very familiar with Wordpress' implementation of page previews and how it refreshes other tabs.