From 4deee321e3c746bbd046da76d3083d5165a42131 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Fri, 8 Aug 2014 20:54:15 +0000 Subject: [PATCH] Editor: use the `post_edit_form_tag` action to add autocomplete="off" to the whole form on the Add/Edit Post screen in WebKit. Prevents editor problems when the browser's Back button is used. Fixes #28037. Built from https://develop.svn.wordpress.org/trunk@29448 git-svn-id: http://core.svn.wordpress.org/trunk@29226 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/misc.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/wp-admin/includes/misc.php b/wp-admin/includes/misc.php index 1d2d26493a..949ea0efe5 100644 --- a/wp-admin/includes/misc.php +++ b/wp-admin/includes/misc.php @@ -826,3 +826,20 @@ function heartbeat_autosave( $response, $data ) { } // Run later as we have to set DOING_AUTOSAVE for back-compat add_filter( 'heartbeat_received', 'heartbeat_autosave', 500, 2 ); + +/** + * 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 + */ +function post_form_autocomplete_off() { + global $is_safari, $is_chrome; + + if ( $is_safari || $is_chrome ) { + echo ' autocomplete="off"'; + } +} + +add_action( 'post_edit_form_tag', 'post_form_autocomplete_off' );