wp_save_post_revision [ WordPress Function ]
wp_save_post_revision ( $post_id )
| Parameters: |
|
| Uses: | |
| Returns: |
|
| Defined at: |
|
Soorgelijke functies: wp_is_post_revision, wp_get_post_revision, wp_get_post_revisions, wp_list_post_revisions, wp_restore_post_revision
Saves an already existing post as a post revision.
Typically used immediately prior to post updates.
Source
<?php
function wp_save_post_revision( $post_id ) {
// We do autosaves manually with wp_create_post_autosave()
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
return;
// WP_POST_REVISIONS = 0, false
if ( ! WP_POST_REVISIONS )
return;
if ( !$post = get_post( $post_id, ARRAY_A ) )
return;
if ( !post_type_supports($post['post_type'], 'revisions') )
return;
$return = _wp_put_post_revision( $post );
// 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 );
}
return $return;
}
?>
Examples [ wp-snippets.com ]
Top Google zoekresultaten
- WordPress › Support » Tags — wp_save_post_revision
Forums. Username or Email Address Password (forgot?) Register · WordPress › Support » wp_save_post_revision. Tag: wp_save_post_revision Add New » ...
wordpress.org - WordPress › Support » Auto Upgrade Problem
... by edit_post, wp_update_post, wp_insert_post, do_action, call_user_func_array, wp_save_post_revision, _wp_put_post_revision, wp_insert_post, do_action, ...
wordpress.org - wp_save_post_revision
Function and Method Cross Reference. wp_save_post_revision(). Defined at: /wp -includes/post.php -> line 4703. No references found.
phpxref.ftwr.co.uk - php - Enable/disable post revisions programmatically - WordPress
Oct 28, 2010 ... remove_action('pre_post_update', 'wp_save_post_revision');// stop ... add_action( 'pre_post_update', 'wp_save_post_revision');// enable ...
wordpress.stackexchange.com