From 3afb9f48398625762be3754abac6978b63ae3577 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Thu, 2 Jun 2016 01:29:25 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@37619 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/admin-filters.php | 3 ++- src/wp-admin/includes/deprecated.php | 23 ++++++++++++++++ src/wp-admin/includes/misc.php | 36 ++++++++++++------------- 3 files changed, 43 insertions(+), 19 deletions(-) diff --git a/src/wp-admin/includes/admin-filters.php b/src/wp-admin/includes/admin-filters.php index d9c6f6051f..c8643749fb 100644 --- a/src/wp-admin/includes/admin-filters.php +++ b/src/wp-admin/includes/admin-filters.php @@ -43,7 +43,8 @@ add_action( 'admin_head', 'wp_color_scheme_settings' ); add_action( 'admin_head', 'wp_site_icon' ); add_action( 'admin_head', '_ipad_meta' ); -add_action( 'post_edit_form_tag', 'post_form_autocomplete_off' ); +add_action( 'admin_print_scripts-post.php', 'wp_page_reload_on_back_button_js' ); +add_action( 'admin_print_scripts-post-new.php', 'wp_page_reload_on_back_button_js' ); add_action( 'update_option_home', 'update_home_siteurl', 10, 2 ); add_action( 'update_option_siteurl', 'update_home_siteurl', 10, 2 ); diff --git a/src/wp-admin/includes/deprecated.php b/src/wp-admin/includes/deprecated.php index ebaa7440d5..94f541b181 100644 --- a/src/wp-admin/includes/deprecated.php +++ b/src/wp-admin/includes/deprecated.php @@ -1373,3 +1373,26 @@ function add_utility_page( $page_title, $menu_title, $capability, $menu_slug, $f return add_menu_page($page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $_wp_last_utility_menu); } + +/** + * Disables autocomplete on the 'post' form (Add/Edit Post screens) for WebKit browsers, + * as they disregard the autocomplete setting on the editor textarea. That can break the editor + * when the user navigates to it with the browser's Back button. See #28037 + * + * Replaced with wp_page_reload_on_back_button_js() that also fixes this problem. + * + * @since 4.0.0 + * $deprecated 4.6.0 + * + * @global bool $is_safari + * @global bool $is_chrome + */ +function post_form_autocomplete_off() { + global $is_safari, $is_chrome; + + _deprecated_function( __FUNCTION__, '4.6' ); + + if ( $is_safari || $is_chrome ) { + echo ' autocomplete="off"'; + } +} diff --git a/src/wp-admin/includes/misc.php b/src/wp-admin/includes/misc.php index 8ea759bf42..72b8822e54 100644 --- a/src/wp-admin/includes/misc.php +++ b/src/wp-admin/includes/misc.php @@ -891,24 +891,6 @@ function heartbeat_autosave( $response, $data ) { return $response; } -/** - * Disables autocomplete on the 'post' form (Add/Edit Post screens) for WebKit browsers, - * as they disregard the autocomplete setting on the editor textarea. That can break the editor - * when the user navigates to it with the browser's Back button. See #28037 - * - * @since 4.0.0 - * - * @global bool $is_safari - * @global bool $is_chrome - */ -function post_form_autocomplete_off() { - global $is_safari, $is_chrome; - - if ( $is_safari || $is_chrome ) { - echo ' autocomplete="off"'; - } -} - /** * Remove single-use URL parameters and create canonical link based on new URL. * @@ -936,3 +918,21 @@ function wp_admin_canonical_url() { + +