Changeset 32809 for trunk/src/wp-includes/functions.php
- Timestamp:
- 06/16/2015 11:12:21 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/functions.php
r32800 r32809 4914 4914 } 4915 4915 } 4916 4917 /** 4918 * Outputs a small JS snippet on preview tabs/windows to remove `window.name` on unload. 4919 * This prevents reusing the same tab for a preview when the user has navigated away. 4920 * 4921 * @since 4.3.0 4922 */ 4923 function wp_post_preview_js() { 4924 global $post; 4925 4926 if ( ! is_preview() || empty( $post ) ) { 4927 return; 4928 } 4929 4930 // Has to match the window name used in post_submit_meta_box() 4931 $name = 'wp-preview-' . (int) $post->ID; 4932 4933 ?> 4934 <script> 4935 ( function() { 4936 var query = document.location.search; 4937 4938 if ( query && query.indexOf( 'preview=true' ) !== -1 ) { 4939 window.name = '<?php echo $name; ?>'; 4940 } 4941 4942 if ( window.addEventListener ) { 4943 window.addEventListener( 'unload', function() { window.name = ''; }, false ); 4944 } 4945 }()); 4946 </script> 4947 <?php 4948 }
Note: See TracChangeset
for help on using the changeset viewer.