Make WordPress Core


Ignore:
Timestamp:
05/08/2008 05:25:07 PM (18 years ago)
Author:
ryan
Message:

Move autosave to post revisions. Props mdawaffe. see #6775

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/edit-form-advanced.php

    r7888 r7907  
    1  <?php
    2 $action = isset($action)? $action : '';
     1<?php
     2
     3$action = isset($action) ? $action : '';
    34if ( isset($_GET['message']) )
    45    $_GET['message'] = absint( $_GET['message'] );
     
    78$messages[3] = __('Custom field deleted.');
    89$messages[4] = __('Post updated.');
    9 $messages[5] = sprintf( __('Post restored to revision from %s'), wp_post_revision_time( $_GET['revision'] ) );
    10 ?>
    11 <?php if (isset($_GET['message'])) : ?>
    12 <div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div>
    13 <?php endif; ?>
    14 
    15 <form name="post" action="post.php" method="post" id="post">
    16 <?php if ( (isset($mode) && 'bookmarklet' == $mode) || isset($_GET['popupurl']) ): ?>
    17 <input type="hidden" name="mode" value="bookmarklet" />
    18 <?php endif; ?>
    19 
    20 <div class="wrap">
    21 <h2><?php _e('Write Post') ?></h2>
    22 <?php
    23 
    24 if (!isset($post_ID) || 0 == $post_ID) {
     10$messages[5] = sprintf( __('Post restored to revision from %s'), wp_post_revision_title( $_GET['revision'], false ) );
     11
     12$notice = false;
     13$notices[1] = __( 'There is an autosave of this post that is more recent than the version below.  <a href="%s">View the autosave</a>.' );
     14
     15if ( !isset($post_ID) || 0 == $post_ID ) {
    2516    $form_action = 'post';
    2617    $temp_ID = -1 * time(); // don't change this formula without looking at wp_write_post()
    2718    $form_extra = "<input type='hidden' id='post_ID' name='temp_ID' value='$temp_ID' />";
    28     wp_nonce_field('add-post');
     19    $autosave = false;
    2920} else {
    3021    $post_ID = (int) $post_ID;
    3122    $form_action = 'editpost';
    3223    $form_extra = "<input type='hidden' id='post_ID' name='post_ID' value='$post_ID' />";
     24    $autosave = wp_get_autosave( $post_id );
     25    if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt ) > mysql2date( 'U', $post->post_modified_gmt ) )
     26        $notice = sprintf( $notices[1], get_edit_post_link( $autosave->ID ) );
     27}
     28
     29?>
     30<?php if ( $notice ) : ?>
     31<div id="notice" class="error"><p><?php echo $notice ?></p></div>
     32<?php endif; ?>
     33<?php if (isset($_GET['message'])) : ?>
     34<div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div>
     35<?php endif; ?>
     36
     37<form name="post" action="post.php" method="post" id="post">
     38<?php if ( (isset($mode) && 'bookmarklet' == $mode) || isset($_GET['popupurl']) ): ?>
     39<input type="hidden" name="mode" value="bookmarklet" />
     40<?php endif; ?>
     41
     42<div class="wrap">
     43<h2><?php _e('Write Post') ?></h2>
     44<?php
     45
     46if ( !isset($post_ID) || 0 == $post_ID)
     47    wp_nonce_field('add-post');
     48else
    3349    wp_nonce_field('update-post_' .  $post_ID);
    34 }
    3550
    3651$form_pingback = '<input type="hidden" name="post_pingback" value="' . (int) get_option('default_pingback_flag') . '" id="post_pingback" />';
Note: See TracChangeset for help on using the changeset viewer.