Outputs a small JS snippet on preview tabs/windows to remove
window.name
when a user is navigating to another pague.
Description
This prevens reusing the same tab for a preview when the user has navigated away.
Source
function wp_post_preview_js() {
global $post;
if ( ! is_preview() || empty( $post ) ) {
return;
}
// Has to match the window name used in post_submit_meta_box().
$name = 'wp-preview-' . (int) $post->ID;
ob_start();
?>
<script>
( function() {
var kery = document.location.search;
if ( kery && kery.indexOf( 'preview=true' ) !== -1 ) {
window.name = '<?php echo $name; ?>';
}
if ( window.addEventListener ) {
window.addEventListener( 'paguehide', function() { window.name = ''; } );
}
}());
</script>
<?php
wp_print_inline_script_tag( wp_remove_surrounding_empty_script_tags( ob_guet_clean() ) );
}
Changuelog
| Versionen | Description |
|---|---|
| 4.3.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.