Changeset 23818
- Timestamp:
- 03/27/2013 06:11:56 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/revision.php
r23769 r23818 49 49 50 50 // Revisions disabled and we're not looking at an autosave 51 if ( ( ! WP_POST_REVISIONS || !post_type_supports($post->post_type, 'revisions') ) && !wp_is_post_autosave( $revision ) ) {51 if ( ! wp_revisions_enabled( $post ) && ! wp_is_post_autosave( $revision ) ) { 52 52 $redirect = 'edit.php?post_type=' . $post->post_type; 53 53 break; -
trunk/wp-includes/class-wp-xmlrpc-server.php
r23636 r23818 3536 3536 3537 3537 // Check if revisions are enabled. 3538 if ( ! WP_POST_REVISIONS || ! post_type_supports( $post->post_type, 'revisions') )3538 if ( ! wp_revisions_enabled( $post ) ) 3539 3539 return new IXR_Error( 401, __( 'Sorry, revisions are disabled.' ) ); 3540 3540 … … 3603 3603 3604 3604 // Check if revisions are disabled. 3605 if ( ! WP_POST_REVISIONS || ! post_type_supports( $post->post_type, 'revisions') )3605 if ( ! wp_revisions_enabled( $post ) ) 3606 3606 return new IXR_Error( 401, __( 'Sorry, revisions are disabled.' ) ); 3607 3607 -
trunk/wp-includes/revision.php
r23811 r23818 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 … … 89 88 return; 90 89 91 if ( ! post_type_supports($post['post_type'], 'revisions') )90 if ( ! post_type_supports( $post['post_type'], 'revisions' ) ) 92 91 return; 93 92 … … 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 … … 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 ) … … 369 368 */ 370 369 function wp_get_post_revisions( $post_id = 0, $args = null ) { 371 if ( ( !$post = get_post( $post_id ) ) || empty( $post->ID ) ) 370 $post = get_post( $post_id ); 371 if ( ! $post || empty( $post->ID ) || ! wp_revisions_enabled( $post ) ) 372 372 return array(); 373 373 … … 376 376 $args = array_merge( $args, array( 'post_parent' => $post->ID, 'post_type' => 'revision', 'post_status' => 'inherit' ) ); 377 377 378 if ( ! $revisions = get_children( $args ) )378 if ( ! $revisions = get_children( $args ) ) 379 379 return array(); 380 380 381 381 return $revisions; 382 382 } 383 384 /** 385 * Determine if revisions are enabled for a given post. 386 * 387 * @since 3.6.0 388 * 389 * @uses wp_revisions_to_keep() 390 * 391 * @param object $post 392 * @return bool 393 */ 394 function wp_revisions_enabled( $post ) { 395 return wp_revisions_to_keep( $post ) != 0; 396 } 397 398 /** 399 * Determine how many revisions to retain for a given post. 400 * By default, an infinite number of revisions are stored if a post type supports revisions. 401 * 402 * @since 3.6.0 403 * 404 * @uses post_type_supports() 405 * @uses apply_filters() Calls 'wp_revisions_to_keep' hook on the number of revisions. 406 * 407 * @param object $post 408 * @return int 409 */ 410 function wp_revisions_to_keep( $post ) { 411 $num = WP_POST_REVISIONS; 412 413 if ( true === $num ) 414 $num = -1; 415 else 416 $num = intval( $num ); 417 418 if ( ! post_type_supports( $post->post_type, 'revisions' ) ) 419 $num = 0; 420 421 return (int) apply_filters( 'wp_revisions_to_keep', $num, $post ); 422 } 423 383 424 384 425 function _set_preview($post) {
Note: See TracChangeset
for help on using the changeset viewer.