3030 | | return _wp_put_revision( $post ); |
| 3031 | $return = _wp_put_revision( $post ); |
| 3032 | |
| 3033 | // WP_POST_REVISIONS = true (default), -1 |
| 3034 | if ( !is_numeric( WP_POST_REVISIONS ) || WP_POST_REVISIONS < 0 ) |
| 3035 | return $return; |
| 3036 | |
| 3037 | // all revisions and (possibly) one autosave |
| 3038 | $revisions = wp_get_post_revisions( $post_id, array( 'order' => 'ASC' ) ); |
| 3039 | |
| 3040 | // WP_POST_REVISIONS = (int) (# of autasaves to save) |
| 3041 | $delete = count($revisions) - WP_POST_REVISIONS; |
| 3042 | |
| 3043 | if ( $delete < 1 ) |
| 3044 | return $return; |
| 3045 | |
| 3046 | $revisions = array_slice( $revisions, 0, $delete ); |
| 3047 | |
| 3048 | for ( $i = 0; isset($revisions[$i]); $i++ ) { |
| 3049 | if ( false !== strpos( $revisions[$i]->post_name, 'autosave' ) ) |
| 3050 | continue; |
| 3051 | wp_delete_revision( $revisions[$i]->ID ); |
| 3052 | } |
| 3053 | |
| 3054 | return $return; |
3233 | | if ( !$revisions = get_children( array( 'post_parent' => $post->ID, 'post_type' => 'revision', 'post_status' => 'inherit' ) ) ) |
| 3257 | |
| 3258 | $defaults = array( 'order' => 'DESC', 'orderby' => 'date' ); |
| 3259 | $args = wp_parse_args( $args, $defaults ); |
| 3260 | $args = array_merge( $args, array( 'post_parent' => $post->ID, 'post_type' => 'revision', 'post_status' => 'inherit' ) ); |
| 3261 | |
| 3262 | if ( !$revisions = get_children( $args ) ) |