X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/76aea3697c6043c1613370f172395b4f65ee71f0..c55863f11e8589bf8d4a5698bf15752406654f1c:/wp-admin/edit-form-advanced.php diff --git a/wp-admin/edit-form-advanced.php b/wp-admin/edit-form-advanced.php index 983bc27d..dab3f84e 100644 --- a/wp-admin/edit-form-advanced.php +++ b/wp-admin/edit-form-advanced.php @@ -1,388 +1,607 @@ go back.' ), attribute_escape( stripslashes( $_GET['_wp_original_http_referer'] ) ) ); -$messages[2] = __('Custom field updated.'); -$messages[3] = __('Custom field deleted.'); -$messages[4] = __('Post updated.'); -if ( isset($_GET['revision']) ) - $messages[5] = sprintf( __('Post restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) ); +if ( post_type_supports($post_type, 'editor') || post_type_supports($post_type, 'thumbnail') ) { + add_thickbox(); + wp_enqueue_media( array( 'post' => $post_ID ) ); +} -$notice = false; -$notices[1] = __( 'There is an autosave of this post that is more recent than the version below. View the autosave.' ); +// Add the local autosave notice HTML +add_action( 'admin_footer', '_local_storage_notice' ); + +/* + * @todo Document the $messages array(s). + */ +$messages = array(); +$messages['post'] = array( + 0 => '', // Unused. Messages start at index 1. + 1 => sprintf( __('Post updated. View post'), esc_url( get_permalink($post_ID) ) ), + 2 => __('Custom field updated.'), + 3 => __('Custom field deleted.'), + 4 => __('Post updated.'), + /* translators: %s: date and time of the revision */ + 5 => isset($_GET['revision']) ? sprintf( __('Post restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, + 6 => sprintf( __('Post published. View post'), esc_url( get_permalink($post_ID) ) ), + 7 => __('Post saved.'), + 8 => sprintf( __('Post submitted. Preview post'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ), + 9 => sprintf( __('Post scheduled for: %1$s. Preview post'), + // translators: Publish box date format, see http://php.net/date + date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post_ID) ) ), + 10 => sprintf( __('Post draft updated. Preview post'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ), +); +$messages['page'] = array( + 0 => '', // Unused. Messages start at index 1. + 1 => sprintf( __('Page updated. View page'), esc_url( get_permalink($post_ID) ) ), + 2 => __('Custom field updated.'), + 3 => __('Custom field deleted.'), + 4 => __('Page updated.'), + 5 => isset($_GET['revision']) ? sprintf( __('Page restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, + 6 => sprintf( __('Page published. View page'), esc_url( get_permalink($post_ID) ) ), + 7 => __('Page saved.'), + 8 => sprintf( __('Page submitted. Preview page'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ), + 9 => sprintf( __('Page scheduled for: %1$s. Preview page'), date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post_ID) ) ), + 10 => sprintf( __('Page draft updated. Preview page'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ), +); +$messages['attachment'] = array_fill( 1, 10, __( 'Media attachment updated.' ) ); // Hack, for now. + +/** + * Filter the post updated messages. + * + * @since 3.0.0 + * + * @param array $messages Post updated messages. For defaults @see $messages declarations above. + */ +$messages = apply_filters( 'post_updated_messages', $messages ); + +$message = false; +if ( isset($_GET['message']) ) { + $_GET['message'] = absint( $_GET['message'] ); + if ( isset($messages[$post_type][$_GET['message']]) ) + $message = $messages[$post_type][$_GET['message']]; + elseif ( !isset($messages[$post_type]) && isset($messages['post'][$_GET['message']]) ) + $message = $messages['post'][$_GET['message']]; +} -if ( !isset($post_ID) || 0 == $post_ID ) { - $form_action = 'post'; - $temp_ID = -1 * time(); // don't change this formula without looking at wp_write_post() - $form_extra = ""; +$notice = false; +$form_extra = ''; +if ( 'auto-draft' == $post->post_status ) { + if ( 'edit' == $action ) + $post->post_title = ''; $autosave = false; + $form_extra .= ""; } else { - $post_ID = (int) $post_ID; - $form_action = 'editpost'; - $form_extra = ""; - $autosave = wp_get_post_autosave( $post_id ); - - // Detect if there exists an autosave newer than the post and if that autosave is different than the post - if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt ) > mysql2date( 'U', $post->post_modified_gmt ) ) { - foreach ( _wp_post_revision_fields() as $autosave_field => $_autosave_field ) { - if ( wp_text_diff( $autosave->$autosave_field, $post->$autosave_field ) ) { - $notice = sprintf( $notices[1], get_edit_post_link( $autosave->ID ) ); - break; - } + $autosave = wp_get_post_autosave( $post_ID ); +} + +$form_action = 'editpost'; +$nonce_action = 'update-post_' . $post_ID; +$form_extra .= ""; + +// Detect if there exists an autosave newer than the post and if that autosave is different than the post +if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt, false ) > mysql2date( 'U', $post->post_modified_gmt, false ) ) { + foreach ( _wp_post_revision_fields() as $autosave_field => $_autosave_field ) { + if ( normalize_whitespace( $autosave->$autosave_field ) != normalize_whitespace( $post->$autosave_field ) ) { + $notice = sprintf( __( 'There is an autosave of this post that is more recent than the version below. View the autosave' ), get_edit_post_link( $autosave->ID ) ); + break; } - unset($autosave_field, $_autosave_field); } + // If this autosave isn't different from the current post, begone. + if ( ! $notice ) + wp_delete_post_revision( $autosave->ID ); + unset($autosave_field, $_autosave_field); } -?> - -