Changeset 23735 for trunk/wp-admin/includes/ajax-actions.php
- Timestamp:
- 03/16/2013 09:15:43 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/ajax-actions.php
r23729 r23735 1044 1044 1045 1045 $do_autosave = (bool) $_POST['autosave']; 1046 $do_lock = true;1047 1046 $data = ''; 1048 1047 $supplemental = array(); 1049 1048 $id = $revision_id = 0; 1050 1049 1051 /* translators: draft saved date format, see http://php.net/date */ 1052 $draft_saved_date_format = __('g:i:s a'); 1053 /* translators: %s: date and time */ 1054 $message = sprintf( __('Draft saved at %s.'), date_i18n( $draft_saved_date_format ) ); 1050 if ( ! $user_id = get_current_user_id() ) 1051 wp_die('-1'); 1055 1052 1056 1053 $post_id = (int) $_POST['post_id']; … … 1059 1056 if ( 'auto-draft' == $post->post_status ) 1060 1057 $_POST['post_status'] = 'draft'; 1061 1062 if ( $last = wp_check_post_lock( $post->ID ) ) {1063 // This will change after we have per-user autosaves1064 $do_autosave = $do_lock = false;1065 1066 $last_user = get_userdata( $last );1067 $last_user_name = $last_user ? $last_user->display_name : __( 'Someone' );1068 $data = __( 'Autosave disabled.' );1069 1070 $supplemental['disable_autosave'] = 'disable';1071 }1072 1058 1073 1059 if ( 'page' == $post->post_type ) { … … 1080 1066 1081 1067 if ( $do_autosave ) { 1082 // Drafts and auto-drafts are just overwritten by autosave 1083 if ( 'auto-draft' == $post->post_status || 'draft' == $post->post_status) {1068 // Drafts and auto-drafts are just overwritten by autosave for the same user 1069 if ( $user_id == $post->post_author && ( 'auto-draft' == $post->post_status || 'draft' == $post->post_status ) ) { 1084 1070 $id = edit_post(); 1085 } else { // Non drafts are not overwritten. The autosave is stored in a special post revision .1071 } else { // Non drafts are not overwritten. The autosave is stored in a special post revision for each user. 1086 1072 $revision_id = wp_create_post_autosave( $post->ID ); 1087 1073 if ( is_wp_error($revision_id) ) … … 1090 1076 $id = $post->ID; 1091 1077 } 1092 $data = $message; 1078 1079 if ( is_wp_error($id) ) { 1080 // is_wp_error($id) overwrites $data in WP_Ajax_Response but no point in doing wp_create_nonce('update-post_' . $id) below 1081 // todo: Needs review. The errors generated in WP_Ajax_Response and parsed with wpAjax.parseAjaxResponse() haven't been used for many years. 1082 $data = $id; 1083 $id = 0; 1084 } else { 1085 /* translators: draft saved date format, see http://php.net/date */ 1086 $draft_saved_date_format = __('g:i:s a'); 1087 /* translators: %s: date and time */ 1088 $data = sprintf( __('Draft saved at %s.'), date_i18n( $draft_saved_date_format ) ); 1089 } 1093 1090 } else { 1094 1091 if ( ! empty( $_POST['auto_draft'] ) ) … … 1104 1101 $supplemental['replace-closedpostboxesnonce'] = wp_create_nonce('closedpostboxes'); 1105 1102 $supplemental['replace-_ajax_linking_nonce'] = wp_create_nonce( 'internal-linking' ); 1106 if ( $id ) { 1107 if ( $_POST['post_type'] == 'post' ) 1108 $supplemental['replace-_wpnonce'] = wp_create_nonce('update-post_' . $id); 1109 elseif ( $_POST['post_type'] == 'page' ) 1110 $supplemental['replace-_wpnonce'] = wp_create_nonce('update-page_' . $id); 1111 } 1103 if ( $id ) 1104 $supplemental['replace-_wpnonce'] = wp_create_nonce('update-post_' . $id); 1112 1105 } 1113 1106
Note: See TracChangeset
for help on using the changeset viewer.