Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

We are running a news site based on WP 3.5.1. Some editors complain that the WYSIWYG editor on the post editing page is not working properly for some posts. The editing buttons are not shown.

In some cases we need to update a post many times (like more than 500 times).
May it be the cause?
What will happen to these posts if I set WP_POST_REVISIONS to 10?
Will old versions be deleted automatically, or will they remain?

share|improve this question
    
IIRC when you have a large number of revisions, then set a threshold lower only once the post is updated will the oldest be purged. –  Cristian Jun 13 '13 at 11:06

2 Answers 2

To address:

What will happen to these posts if I set WP_POST_REVISIONS to 10? Will old versions be deleted automatically, or will they remain?

You have this action:

add_action( 'pre_post_update', 'wp_save_post_revision' );

set by default in /wp-includes/default-filters.php.

If you check the source of wp_save_post_revision() you can see that it will delete the remaining revisions of the current post:

$delete = count($revisions) - WP_POST_REVISIONS;

with wp_delete_post_revision() when the hook pre_post_update is activated for a given $post_id, except when it is performing an auto-saving.

Here is the relevant part from the source of wp_save_post_revision():

// WP_POST_REVISIONS = true (default), -1
if ( !is_numeric( WP_POST_REVISIONS ) || WP_POST_REVISIONS < 0 )
        return $return;

// all revisions and (possibly) one autosave
$revisions = wp_get_post_revisions( $post_id, array( 'order' => 'ASC' ) );

// WP_POST_REVISIONS = (int) (# of autosaves to save)
$delete = count($revisions) - WP_POST_REVISIONS;

if ( $delete < 1 )
        return $return;

$revisions = array_slice( $revisions, 0, $delete );

for ( $i = 0; isset($revisions[$i]); $i++ ) {
        if ( false !== strpos( $revisions[$i]->post_name, 'autosave' ) )
                continue;
        wp_delete_post_revision( $revisions[$i]->ID );
}
share|improve this answer

You should set WP_POST_REVISIONS to a fixed number. If you don’t, WordPress will keep an unlimited number of revisions. See function wp_revisions_to_keep():

function wp_revisions_to_keep( $post ) {
    $num = WP_POST_REVISIONS;

    if ( true === $num )
        $num = -1;
    else
        $num = intval( $num );

    if ( ! post_type_supports( $post->post_type, 'revisions' ) )
        $num = 0;

    return (int) apply_filters( 'wp_revisions_to_keep', $num, $post );
}

On the other hand … if you need such a high number of changes you should revisit the edit work flow. There are surely ways to get this number down.

share|improve this answer
    
hi, what's "edit work flow"? –  mustafa Jun 13 '13 at 11:30
    
@mustafa The process for editing your posts. There seem to be too many steps in your setup. –  toscho Jun 13 '13 at 11:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.