Changeset 7987
- Timestamp:
- 05/23/2008 03:27:56 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/post.php
r7985 r7987 3019 3019 return; 3020 3020 3021 // WP_POST_REVISIONS = 0, false 3021 3022 if ( !constant('WP_POST_REVISIONS') ) 3022 3023 return; … … 3028 3029 return; 3029 3030 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; 3031 3055 } 3032 3056 … … 3226 3250 * @return array empty if no revisions 3227 3251 */ 3228 function wp_get_post_revisions( $post_id = 0 ) {3252 function wp_get_post_revisions( $post_id = 0, $args = null ) { 3229 3253 if ( !constant('WP_POST_REVISIONS') ) 3230 3254 return array(); 3231 3255 if ( ( !$post = get_post( $post_id ) ) || empty( $post->ID ) ) 3232 3256 return array(); 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 ) ) 3234 3263 return array(); 3235 3264 return $revisions;
Note: See TracChangeset
for help on using the changeset viewer.