WordPress.org

Make WordPress Core

Ticket #35852: 35852.patch

File 35852.patch, 3.3 KB (added by azaozz, 3 years ago)
  • src/wp-admin/includes/admin-filters.php

     
    4343add_action( 'admin_head', 'wp_site_icon'             );
    4444add_action( 'admin_head', '_ipad_meta'               );
    4545
    46 add_action( 'post_edit_form_tag', 'post_form_autocomplete_off' );
     46add_action( 'admin_print_scripts-post.php',     'wp_page_reload_on_back_button_js' );
     47add_action( 'admin_print_scripts-post-new.php', 'wp_page_reload_on_back_button_js' );
    4748
    4849add_action( 'update_option_home',          'update_home_siteurl', 10, 2 );
    4950add_action( 'update_option_siteurl',       'update_home_siteurl', 10, 2 );
  • src/wp-admin/includes/deprecated.php

     
    13731373
    13741374        return add_menu_page($page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $_wp_last_utility_menu);
    13751375}
     1376
     1377/**
     1378 * Disables autocomplete on the 'post' form (Add/Edit Post screens) for WebKit browsers,
     1379 * as they disregard the autocomplete setting on the editor textarea. That can break the editor
     1380 * when the user navigates to it with the browser's Back button. See #28037
     1381 *
     1382 * Replaced with wp_page_reload_on_back_button_js() that also fixes this problem.
     1383 *
     1384 * @since 4.0.0
     1385 * $deprecated 4.6.0
     1386 *
     1387 * @global bool $is_safari
     1388 * @global bool $is_chrome
     1389 */
     1390function post_form_autocomplete_off() {
     1391        global $is_safari, $is_chrome;
     1392
     1393        _deprecated_function( __FUNCTION__, '4.6' );
     1394
     1395        if ( $is_safari || $is_chrome ) {
     1396                echo ' autocomplete="off"';
     1397        }
     1398}
  • src/wp-admin/includes/misc.php

     
    892892}
    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 *
    915897 * Remove specific query string parameters from a URL, create the canonical link,
     
    936918        </script>
    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}