• 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:

    rcq[whatever]

    eg.

    rcqTestMsg

    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 = '<span class="interview initials">RC</span>$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 topic ‘content_save_pre creates “The backup version”… Warning’ is closed to new replies.