WordPress.org

Make WordPress Core


Ignore:
Timestamp:
06/02/2016 01:29:25 AM (5 years ago)
Author:
azaozz
Message:

Editor: ensure the page is refreshed when the users navigate to it with the Back or Forward buttons. In these cases the browsers usually load the page from (memory) cache and it contains the old editor content.

Fixes #35852.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/misc.php

    r37537 r37619  
    893893
    894894/**
    895  * Disables autocomplete on the 'post' form (Add/Edit Post screens) for WebKit browsers,
    896  * as they disregard the autocomplete setting on the editor textarea. That can break the editor
    897  * when the user navigates to it with the browser's Back button. See #28037
    898  *
    899  * @since 4.0.0
    900  *
    901  * @global bool $is_safari
    902  * @global bool $is_chrome
    903  */
    904 function post_form_autocomplete_off() {
    905     global $is_safari, $is_chrome;
    906 
    907     if ( $is_safari || $is_chrome ) {
    908         echo ' autocomplete="off"';
    909     }
    910 }
    911 
    912 /**
    913895 * Remove single-use URL parameters and create canonical link based on new URL.
    914896 *
     
    937919<?php
    938920}
     921
     922/**
     923 * Output JS that reloads the page if the user navigated to it with the Back or Forward button.
     924 *
     925 * Used on the Edit Post and Add New Post screens. Needed to ensure the page is not loaded from browser cache,
     926 * so the post title and editor content are the last saved versions. Ideally this script should run first in the head.
     927 *
     928 * @since 4.6.0
     929 */
     930function wp_page_reload_on_back_button_js() {
     931    ?>
     932    <script>
     933        if ( typeof performance !== 'undefined' && performance.navigation && performance.navigation.type === 2 ) {
     934            document.location.reload( true );
     935        }
     936    </script>
     937    <?php
     938}
Note: See TracChangeset for help on using the changeset viewer.