Skip to content

@ocean90 /gist:5586293
Last active

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Revisions generator
<?php
// How many revisions should be created?
$num_of_revisions = 40;
// Demo content
$content = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.";
// Create a post
$post = array(
'post_content' => $content,
'post_title' => sprintf( '%d Revisions: %d', $num_of_revisions, time() )
);
$pid = wp_insert_post( $post );
// Create revisions
for( $i = 0; $i <= $num_of_revisions - 2; $i++ ) {
$post = get_post( $pid );
$old_content = $post->post_content;
$old_content = str_split( $old_content, rand( 1, ceil( mb_strlen( $old_content ) / 2 ) ) );
$new_content = $old_content[ 0 ] . "\n\n" . $content . "\n\n" . $old_content[ 1 ];
$args = array(
'ID' => $pid,
'post_content' => $new_content
);
wp_update_post( $args );
// We need to slow down it a bit
sleep( 1 );
};
echo 'Done - ' . time();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.