Add a Preview Button to the Fullscreen Editor in WordPress

I really like the fullscreen editor in WordPress. I use it nearly all of the time when composing long-form content, often in conjunction with the excellent Markdown on Save plugin by Mark Jaquith. It has always bugged me that there wasn’t a Preview button in the fullscreen mode toolbar.

Problem solved.

fullscreen-preview-button

Here’s the code.


<?php
/*
Plugin Name: Fullscreen Preview Button
Description: Add a preview button to the fullscreen editor toolbar.
Version: 1.2
Author: Alex King
Author URI: http://alexking.org
License: GPL2
*/
function akv3_fullscreen_preview_button() {
?>
<script type="text/javascript">
;(function($) {
var $preview = $('#post-preview');
$preview.clone()
.removeAttr('id').removeClass('preview').addClass('right')
.css('margin-left', '5px')
.click(function(e) {
$preview.click();
e.preventDefault();
})
.insertBefore('#wp-fullscreen-save input.button-primary');
}(jQuery));
</script>
<?php
}
add_action('admin_footer-post-new.php', 'akv3_fullscreen_preview_button');
add_action('admin_footer-post.php', 'akv3_fullscreen_preview_button');

This post is part of the project: Fullscreen Preview Button. View the project timeline for more context on this post.