Ticket #22289: 22289.4.patch
File 22289.4.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/revision.php
78 78 if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) 79 79 return; 80 80 81 // WP_POST_REVISIONS = 0, false 82 if ( ! WP_POST_REVISIONS ) 81 if ( !$post = get_post( $post_id, ARRAY_A ) ) 83 82 return; 84 83 85 if ( ! $post = get_post( $post_id, ARRAY_A) )84 if ( ! wp_revisions_enabled( (object) $post ) ) 86 85 return; 87 86 88 87 if ( 'auto-draft' == $post['post_status'] ) … … 107 106 108 107 $return = _wp_put_post_revision( $post ); 109 108 110 // WP_POST_REVISIONS = true (default), -1 111 if ( !is_numeric( WP_POST_REVISIONS ) || WP_POST_REVISIONS < 0 ) 109 $revisions_to_keep = wp_revisions_to_keep( (object) $post ); 110 111 if ( $revisions_to_keep < 0 ) 112 112 return $return; 113 113 114 114 // all revisions and (possibly) one autosave 115 115 $revisions = wp_get_post_revisions( $post_id, array( 'order' => 'ASC' ) ); 116 116 117 // WP_POST_REVISIONS = (int) (# of autosaves to save) 118 $delete = count($revisions) - WP_POST_REVISIONS; 117 $delete = count($revisions) - $revisions_to_keep; 119 118 120 119 if ( $delete < 1 ) 121 120 return $return; … … 371 370 * @return array empty if no revisions 372 371 */ 373 372 function wp_get_post_revisions( $post_id = 0, $args = null ) { 374 if ( ! WP_POST_REVISIONS )375 return array();376 373 if ( ( !$post = get_post( $post_id ) ) || empty( $post->ID ) ) 377 374 return array(); 378 375 376 if ( ! wp_revisions_enabled( $post ) ) 377 return array(); 378 379 379 $defaults = array( 'order' => 'DESC', 'orderby' => 'date' ); 380 380 $args = wp_parse_args( $args, $defaults ); 381 381 $args = array_merge( $args, array( 'post_parent' => $post->ID, 'post_type' => 'revision', 'post_status' => 'inherit' ) ); … … 385 385 return $revisions; 386 386 } 387 387 388 /** 389 * Determine if revisions are enabled for a given post. 390 * 391 * @since 3.6 392 * 393 * @uses wp_revisions_to_keep 394 * 395 * @param object $post 396 * @return bool 397 */ 398 function wp_revisions_enabled( $post ) { 399 return wp_revisions_to_keep( $post ) != 0; 400 } 401 402 /** 403 * Determine how many revisions to retain for a given post. 404 * By default, an infinite number of revisions are stored if a post type supports revisions. 405 * 406 * @since 3.6 407 * 408 * @uses post_type_supports 409 * @uses apply_filters 410 * 411 * @param object $post 412 * @return int 413 */ 414 function wp_revisions_to_keep( $post ) { 415 $num = WP_POST_REVISIONS; 416 417 if ( true === $num ) 418 $num = -1; 419 else 420 $num = intval( $num ); 421 422 if ( ! post_type_supports( $post->post_type, 'revisions' ) ) 423 $num = 0; 424 425 return (int) apply_filters( 'wp_revisions_to_keep', $num, $post ); 426 } 427 388 428 function _set_preview($post) { 389 429 390 430 if ( ! is_object($post) )