Changeset 48422 for trunk/src/wp-includes/revision.php
- Timestamp:
- 07/10/2020 03:12:00 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/revision.php
r48109 r48422 222 222 * Retrieve the autosaved data of the specified post. 223 223 * 224 * Returns a postobject containing the information that was autosaved for the224 * Returns an object containing the information that was autosaved for the 225 225 * specified post. If the optional $user_id is passed, returns the autosave for that user 226 226 * otherwise returns the latest autosave. … … 233 233 */ 234 234 function wp_get_post_autosave( $post_id, $user_id = 0 ) { 235 $revisions = wp_get_post_revisions( $post_id, array( 'check_enabled' => false ) ); 236 237 foreach ( $revisions as $revision ) { 238 if ( false !== strpos( $revision->post_name, "{$post_id}-autosave" ) ) { 239 if ( $user_id && $user_id != $revision->post_author ) { 240 continue; 241 } 242 243 return $revision; 244 } 245 } 246 247 return false; 235 global $wpdb; 236 237 $autosave_name = $post_id . '-autosave-v1'; 238 $user_id_query = ( 0 !== $user_id ) ? "AND post_author = $user_id" : null; 239 240 // Construct the autosave query 241 $autosave_query = " 242 SELECT * 243 FROM $wpdb->posts 244 WHERE post_parent = %d 245 AND post_type = 'revision' 246 AND post_status = 'inherit' 247 AND post_name = %s " . $user_id_query . ' 248 ORDER BY post_date DESC 249 LIMIT 1'; 250 251 $autosave = $wpdb->get_results( 252 $wpdb->prepare( 253 $autosave_query, 254 $post_id, 255 $autosave_name 256 ) 257 ); 258 259 if ( ! $autosave ) { 260 return false; 261 } 262 263 return $autosave[0]; 248 264 } 249 265
Note: See TracChangeset
for help on using the changeset viewer.