Skip to content

Instantly share code, notes, and snippets.

@alexkingorg
Last active October 6, 2015 22:27
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save alexkingorg/3062569 to your computer and use it in GitHub Desktop.
Save alexkingorg/3062569 to your computer and use it in GitHub Desktop.
Add a preview button to the WordPress fullscreen editor toolbar.
<?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');
@alexkingorg
Copy link
Author

Updated for WP 3.5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment