Ticket #34560: 34560.12.diff
File 34560.12.diff, 4.2 KB (added by , 7 years ago) |
---|
-
src/wp-admin/edit-form-advanced.php
217 217 218 218 $publish_callback_args = null; 219 219 if ( post_type_supports($post_type, 'revisions') && 'auto-draft' != $post->post_status ) { 220 $revisions = wp_get_post_revisions( $post_ID );221 220 221 require_once( ABSPATH . 'wp-admin/includes/class-wp-revisions.php' ); 222 global $wp_revisions; 223 222 224 // We should aim to show the revisions metabox only when there are revisions. 223 if ( count( $revisions ) > 1 ) { 224 reset( $revisions ); // Reset pointer for key() 225 $publish_callback_args = array( 'revisions_count' => count( $revisions ), 'revision_id' => key( $revisions ) ); 225 if ( $wp_revisions->revisions_count > 1 ) { 226 $publish_callback_args = array( 227 'revisions_count' => $wp_revisions->revisions_count, 228 'revision_id' => $wp_revisions->last_revision_id, 229 ); 226 230 add_meta_box('revisionsdiv', __('Revisions'), 'post_revisions_meta_box', null, 'normal', 'core'); 227 231 } 228 232 } -
src/wp-includes/post-template.php
1660 1660 * @return string|false gravatar, user, i18n formatted datetimestamp or localized 'Current Revision'. 1661 1661 */ 1662 1662 function wp_post_revision_title_expanded( $revision, $link = true ) { 1663 if ( !$revision = get_post( $revision ) )1664 return $revision;1665 1663 1666 1664 if ( !in_array( $revision->post_type, array( 'post', 'page', 'revision' ) ) ) 1667 1665 return false; … … 1673 1671 $gravatar = get_avatar( $revision->post_author, 24 ); 1674 1672 1675 1673 $date = date_i18n( $datef, strtotime( $revision->post_modified ) ); 1676 if ( $link && current_user_can( 'edit_post', $revision->ID ) && $link = get_edit_post_link( $revision->ID) )1674 if ( $link && $link = admin_url( sprintf( 'revision.php?revision=%d&action=edit', $revision->ID ) ) ) 1677 1675 $date = "<a href='$link'>$date</a>"; 1678 1676 1679 1677 $revision_date_author = sprintf( … … 1721 1719 if ( ! $post = get_post( $post_id ) ) 1722 1720 return; 1723 1721 1722 if ( ! current_user_can( 'read_post', $post->ID ) ) 1723 return; 1724 1724 1725 // $args array with (parent, format, right, left, type) deprecated since 3.6 1725 1726 if ( is_array( $type ) ) { 1726 1727 $type = ! empty( $type['type'] ) ? $type['type'] : $type; … … 1727 1728 _deprecated_argument( __FUNCTION__, '3.6' ); 1728 1729 } 1729 1730 1730 if ( ! $revisions = wp_get_post_revisions( $post->ID ) ) 1731 require_once( ABSPATH . 'wp-admin/includes/class-wp-revisions.php' ); 1732 global $wp_revisions; 1733 1734 if ( ! $revisions = $wp_revisions->revisions_details ) { 1731 1735 return; 1736 } 1732 1737 1733 1738 $rows = ''; 1734 1739 foreach ( $revisions as $revision ) { 1735 if ( ! current_user_can( 'read_post', $revision->ID ) )1736 continue;1737 1738 1740 $is_autosave = wp_is_post_autosave( $revision ); 1739 1741 if ( ( 'revision' === $type && $is_autosave ) || ( 'autosave' === $type && ! $is_autosave ) ) 1740 1742 continue; -
src/wp-includes/revision.php
225 225 * @return WP_Post|false The autosaved data or false on failure or when no autosave exists. 226 226 */ 227 227 function wp_get_post_autosave( $post_id, $user_id = 0 ) { 228 $revisions = wp_get_post_revisions( $post_id, array( 'check_enabled' => false ) );228 global $wpdb; 229 229 230 foreach ( $revisions as $revision ) { 231 if ( false !== strpos( $revision->post_name, "{$post_id}-autosave" ) ) { 232 if ( $user_id && $user_id != $revision->post_author ) 233 continue; 230 // Contruct the autosave query. 231 $autosave_query = " 232 SELECT * 233 FROM $wpdb->posts 234 WHERE post_parent = %d 235 AND post_type = 'revision' 236 AND post_status = 'inherit' 237 AND post_name = %s 238 AND post_author = %s 239 LIMIT 1"; 234 240 235 return $revision; 236 } 241 $autosave_details = $wpdb->get_results( 242 $wpdb->prepare( 243 $autosave_query, 244 $post_id, 245 $post_id . '-autosave-v1', 246 ( 0 !== $user_id ) ? $user_id : get_current_user_id() 247 ) 248 ); 249 250 if ( empty( $autosave_details ) ) { 251 return false; 237 252 } 238 253 239 return false;254 return $autosave_details[0]; 240 255 } 241 256 242 257 /**