Ticket #22289: 22289.patch
File 22289.patch, 6.1 KB (added by , 10 years ago) |
---|
-
wp-admin/revision.php
28 28 if ( !$post = get_post( $revision->post_parent ) ) 29 29 break; 30 30 31 // Revision context to aid wp_post_revisions filter 32 $context = 'admin-' . $action; 33 31 34 // 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 ) ) {35 if ( ( ! apply_filters( 'wp_post_revisions', WP_POST_REVISIONS, compact( 'context', 'post', 'revision' ) ) || !post_type_supports($post->post_type, 'revisions') ) && !wp_is_post_autosave( $revision ) ) { 33 36 $redirect = 'edit.php?post_type=' . $post->post_type; 34 37 break; 35 38 } … … 70 73 else 71 74 break; // Don't diff two unrelated revisions 72 75 73 if ( ! WP_POST_REVISIONS || !post_type_supports($post->post_type, 'revisions') ) { // Revisions disabled 76 // Revision context to aid wp_post_revisions filter 77 $context = 'admin-' . $action; 78 79 if ( ! apply_filters( 'wp_post_revisions', WP_POST_REVISIONS, compact( 'context', 'post', 'left_revision', 'right_revision' ) ) || !post_type_supports($post->post_type, 'revisions') ) { // Revisions disabled 74 80 if ( 75 81 // we're not looking at an autosave 76 82 ( !wp_is_post_autosave( $left_revision ) && !wp_is_post_autosave( $right_revision ) ) … … 111 117 if ( !current_user_can( 'read_post', $revision->ID ) || !current_user_can( 'read_post', $post->ID ) ) 112 118 break; 113 119 120 // Revision context to aid wp_post_revisions filter 121 $context = 'admin-' . $action; 122 114 123 // 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 ) ) {124 if ( ( ! apply_filters( 'wp_post_revisions', WP_POST_REVISIONS, compact( 'context', 'post', 'revision' ) ) || !post_type_supports($post->post_type, 'revisions') ) && !wp_is_post_autosave( $revision ) ) { 116 125 $redirect = 'edit.php?post_type=' . $post->post_type; 117 126 break; 118 127 } … … 209 218 210 219 <?php 211 220 221 // Revision context to aid wp_post_revisions filter 222 $context = 'admin'; 223 212 224 $args = array( 'format' => 'form-table', 'parent' => true, 'right' => $right, 'left' => $left ); 213 if ( ! WP_POST_REVISIONS|| !post_type_supports($post->post_type, 'revisions') )225 if ( ! apply_filters( 'wp_post_revisions', WP_POST_REVISIONS, compact( 'context', 'post', 'left', 'right' ) ) || !post_type_supports($post->post_type, 'revisions') ) 214 226 $args['type'] = 'autosave'; 215 227 216 228 wp_list_post_revisions( $post, $args ); -
wp-includes/class-wp-xmlrpc-server.php
3535 3535 return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); 3536 3536 3537 3537 // Check if revisions are enabled. 3538 if ( ! WP_POST_REVISIONS || ! post_type_supports( $post->post_type, 'revisions' ) ) 3538 $context = 'xmlrpc-get'; 3539 if ( ! apply_filters( 'wp_post_revisions', WP_POST_REVISIONS, compact( 'context', 'post', 'blog_id', 'username' ) ) || ! post_type_supports( $post->post_type, 'revisions' ) ) 3539 3540 return new IXR_Error( 401, __( 'Sorry, revisions are disabled.' ) ); 3540 3541 3541 3542 $revisions = wp_get_post_revisions( $post_id ); … … 3564 3565 * 3565 3566 * @since 3.5.0 3566 3567 * 3568 * @uses apply_filters 3567 3569 * @uses wp_restore_post_revision() 3568 3570 * 3569 3571 * @param array $args Method parameters. Contains: … … 3602 3604 return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) ); 3603 3605 3604 3606 // Check if revisions are disabled. 3605 if ( ! WP_POST_REVISIONS || ! post_type_supports( $post->post_type, 'revisions' ) ) 3607 $context = 'xmlrpc-restore'; 3608 if ( ! apply_filters( 'wp_post_revisions', WP_POST_REVISIONS, compact( 'context', 'post', 'revision', 'blog_id', 'username' ) ) || ! post_type_supports( $post->post_type, 'revisions' ) ) 3606 3609 return new IXR_Error( 401, __( 'Sorry, revisions are disabled.' ) ); 3607 3610 3608 3611 $post = wp_restore_post_revision( $revision_id ); -
wp-includes/post.php
4932 4932 * @subpackage Post_Revisions 4933 4933 * @since 2.6.0 4934 4934 * 4935 * @uses apply_filters() 4935 4936 * @uses _wp_put_post_revision() 4936 4937 * 4937 4938 * @param int $post_id The ID of the post to save as a revision. … … 4942 4943 if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) 4943 4944 return; 4944 4945 4945 // WP_POST_REVISIONS = 0, false 4946 if ( ! WP_POST_REVISIONS ) 4946 // Revision quantity 4947 $context = 'save'; 4948 $revision_qty = apply_filters( 'wp_post_revisions', WP_POST_REVISIONS, compact( 'context', 'post_id' ) ); 4949 4950 // $revision_qty = 0, false 4951 if ( ! $revision_qty ) 4947 4952 return; 4948 4953 4949 4954 if ( !$post = get_post( $post_id, ARRAY_A ) ) … … 4957 4962 4958 4963 $return = _wp_put_post_revision( $post ); 4959 4964 4960 // WP_POST_REVISIONS= true (default), -14961 if ( !is_numeric( WP_POST_REVISIONS ) || WP_POST_REVISIONS< 0 )4965 // $revision_qty = true (default), -1 4966 if ( !is_numeric( $revision_qty ) || $revision_qty < 0 ) 4962 4967 return $return; 4963 4968 4964 4969 // all revisions and (possibly) one autosave 4965 4970 $revisions = wp_get_post_revisions( $post_id, array( 'order' => 'ASC' ) ); 4966 4971 4967 // WP_POST_REVISIONS= (int) (# of autosaves to save)4968 $delete = count($revisions) - WP_POST_REVISIONS;4972 // $revision_qty = (int) (# of autosaves to save) 4973 $delete = count($revisions) - $revision_qty; 4969 4974 4970 4975 if ( $delete < 1 ) 4971 4976 return $return; … … 5218 5223 * @subpackage Post_Revisions 5219 5224 * @since 2.6.0 5220 5225 * 5226 * @uses apply_filters() 5221 5227 * @uses get_children() 5222 5228 * 5223 5229 * @param int|object $post_id Post ID or post object 5224 5230 * @return array empty if no revisions 5225 5231 */ 5226 5232 function wp_get_post_revisions( $post_id = 0, $args = null ) { 5227 if ( ! WP_POST_REVISIONS ) 5233 $context = 'get'; 5234 $revision_qty = apply_filters( 'wp_post_revisions', WP_POST_REVISIONS, compact( 'context', 'post_id', 'args' ) ); 5235 5236 if ( ! $revision_qty ) 5228 5237 return array(); 5238 5229 5239 if ( ( !$post = get_post( $post_id ) ) || empty( $post->ID ) ) 5230 5240 return array(); 5231 5241