Ticket #22289: 22289.3.patch
File 22289.3.patch, 5.2 KB (added by , 10 years ago) |
---|
-
wp-admin/revision.php
29 29 break; 30 30 31 31 // Revisions disabled and we're not looking at an autosave 32 if ( ( ! WP_POST_REVISIONS || !post_type_supports($post->post_type, 'revisions')) && !wp_is_post_autosave( $revision ) ) {32 if ( ! wp_revisions_enabled( $post ) && !wp_is_post_autosave( $revision ) ) { 33 33 $redirect = 'edit.php?post_type=' . $post->post_type; 34 34 break; 35 35 } … … 70 70 else 71 71 break; // Don't diff two unrelated revisions 72 72 73 if ( ! WP_POST_REVISIONS || !post_type_supports($post->post_type, 'revisions') ) { // Revisions disabled73 if ( ! wp_revisions_enabled( $post ) ) { // Revisions disabled 74 74 if ( 75 75 // we're not looking at an autosave 76 76 ( !wp_is_post_autosave( $left_revision ) && !wp_is_post_autosave( $right_revision ) ) … … 112 112 break; 113 113 114 114 // Revisions disabled and we're not looking at an autosave 115 if ( ( ! WP_POST_REVISIONS || !post_type_supports($post->post_type, 'revisions')) && !wp_is_post_autosave( $revision ) ) {115 if ( ! wp_revisions_enabled( $post ) && !wp_is_post_autosave( $revision ) ) { 116 116 $redirect = 'edit.php?post_type=' . $post->post_type; 117 117 break; 118 118 } … … 210 210 <?php 211 211 212 212 $args = array( 'format' => 'form-table', 'parent' => true, 'right' => $right, 'left' => $left ); 213 if ( ! WP_POST_REVISIONS || !post_type_supports($post->post_type, 'revisions') )213 if ( ! wp_revisions_enabled( $post ) ) 214 214 $args['type'] = 'autosave'; 215 215 216 216 wp_list_post_revisions( $post, $args ); -
wp-includes/class-wp-xmlrpc-server.php
3441 3441 return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); 3442 3442 3443 3443 // Check if revisions are enabled. 3444 if ( ! WP_POST_REVISIONS || ! post_type_supports( $post->post_type, 'revisions') )3444 if ( ! wp_revisions_enabled( $post ) ) 3445 3445 return new IXR_Error( 401, __( 'Sorry, revisions are disabled.' ) ); 3446 3446 3447 3447 $revisions = wp_get_post_revisions( $post_id ); … … 3506 3506 return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) ); 3507 3507 3508 3508 // Check if revisions are disabled. 3509 if ( ! WP_POST_REVISIONS || ! post_type_supports( $post->post_type, 'revisions') )3509 if ( ! wp_revisions_enabled( $post ) ) 3510 3510 return new IXR_Error( 401, __( 'Sorry, revisions are disabled.' ) ); 3511 3511 3512 3512 $post = wp_restore_post_revision( $revision_id ); -
wp-includes/post.php
5021 5021 if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) 5022 5022 return; 5023 5023 5024 // WP_POST_REVISIONS = 0, false 5025 if ( ! WP_POST_REVISIONS ) 5024 if ( !$post = get_post( $post_id, ARRAY_A ) ) 5026 5025 return; 5027 5026 5028 if ( ! $post = get_post( $post_id, ARRAY_A) )5027 if ( ! wp_revisions_enabled( (object) $post ) ) 5029 5028 return; 5030 5029 5031 5030 if ( 'auto-draft' == $post['post_status'] ) … … 5050 5049 5051 5050 $return = _wp_put_post_revision( $post ); 5052 5051 5053 // WP_POST_REVISIONS = true (default), -1 5054 if ( !is_numeric( WP_POST_REVISIONS ) || WP_POST_REVISIONS < 0 ) 5052 $revisions_to_keep = wp_revisions_to_keep( (object) $post ); 5053 5054 if ( $revisions_to_keep < 0 ) 5055 5055 return $return; 5056 5056 5057 5057 // all revisions and (possibly) one autosave 5058 5058 $revisions = wp_get_post_revisions( $post_id, array( 'order' => 'ASC' ) ); 5059 5059 5060 // WP_POST_REVISIONS = (int) (# of autosaves to save) 5061 $delete = count($revisions) - WP_POST_REVISIONS; 5060 $delete = count($revisions) - $revisions_to_keep; 5062 5061 5063 5062 if ( $delete < 1 ) 5064 5063 return $return; … … 5314 5313 * @return array empty if no revisions 5315 5314 */ 5316 5315 function wp_get_post_revisions( $post_id = 0, $args = null ) { 5317 if ( ! WP_POST_REVISIONS )5318 return array();5319 5316 if ( ( !$post = get_post( $post_id ) ) || empty( $post->ID ) ) 5320 5317 return array(); 5321 5318 5319 if ( ! wp_revisions_enabled( $post ) ) 5320 return array(); 5321 5322 5322 $defaults = array( 'order' => 'DESC', 'orderby' => 'date' ); 5323 5323 $args = wp_parse_args( $args, $defaults ); 5324 5324 $args = array_merge( $args, array( 'post_parent' => $post->ID, 'post_type' => 'revision', 'post_status' => 'inherit' ) ); … … 5328 5328 return $revisions; 5329 5329 } 5330 5330 5331 /** 5332 * Determine if revisions are enabled for a given post. 5333 * 5334 * @since 3.6 5335 * 5336 * @uses wp_revisions_to_keep 5337 * 5338 * @param object $post 5339 * @return bool 5340 */ 5341 function wp_revisions_enabled( $post ) { 5342 return wp_revisions_to_keep( $post ) != 0; 5343 } 5344 5345 /** 5346 * Determine how many revisions to retain for a given post. 5347 * By default, an infinite number of revisions are stored if a post type supports revisions. 5348 * 5349 * @since 3.6 5350 * 5351 * @uses post_type_supports 5352 * @uses apply_filters 5353 * 5354 * @param object $post 5355 * @return int 5356 */ 5357 function wp_revisions_to_keep( $post ) { 5358 $num = WP_POST_REVISIONS; 5359 5360 if ( true === $num ) 5361 $num = -1; 5362 else 5363 $num = intval( $num ); 5364 5365 if ( ! post_type_supports( $post->post_type, 'revisions' ) ) 5366 $num = 0; 5367 5368 return (int) apply_filters( 'wp_revisions_to_keep', $num, $post ); 5369 } 5370 5331 5371 function _set_preview($post) { 5332 5372 5333 5373 if ( ! is_object($post) )