How do I disable the warning "The backup of this post in your browser is different from the version below"?

jchwebdev asked
filters wp-admin

I have a small filter below. It does a regular expression replace of a particular string when the user saves the draft.

However, using this filter causes the warning “The backup of this post in your browser is different from the version below.”

Is there a way to ‘tell’ Wordpress not to display the warning when that filter runs?

To re-create:

  1. Create a draft post.

  2. In the body, enter a line of text:




  3. Save the draft.

Here is the code.

UPDATE: WHAT I THINK IS GOING ON: I think that somehow this is triggering the autosave.js CheckPost() function which (apparently) compares the text on screen with the current saved version. Is there a way to disable the autosave or revision just when this filter is triggered? Or is there something in my code that is confusing the revision system?

function jchwebdev_rant_quote_question( $content ) { global $post; $pattern = '/rcq/'; $replacement = 'RC$1'; if ($post->post_status == 'draft') { return preg_replace($pattern, $replacement, $content); } else return $content; } add_filter( 'content_save_pre' , 'jchwebdev_rant_quote_question' , 10, 1);


The way to avoid this error is to make sure the wp-saving-post cookie is being set to a value of [post id]-saved, as seen here. As you can see, if that occurs, then WordPress won’t complain about the difference, because it then knows that the post was saved properly.

Also take a look at this line and note that WordPress handles this for you already. So the error you’re seeing, it likely has to do with some mild cookie corruption in your browser.

I ran several tests with your plugin and I was unable to reproduce the issue that you reported. So my feeling is that you should clear all browser cookies for your domain and eliminate the possibility of corruption causing the problem. Also be sure to do a review of WordPress config settings related to cookie storage. If there’s something wrong with cookie settings on your site, it may have an impact on the behavior that you’re seeing when running tests against this.

Finally, check to be sure you’re not filtering the content, and then immediately redirecting, or exiting the script, or doing something else that would prevent this line from running once your filter is applied. That too, may lead to the problem that you’re seeing.

Share This
Posted in: