summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--wp-admin/admin-ajax.php2
-rw-r--r--wp-admin/admin-functions.php41
-rw-r--r--wp-admin/edit-form-advanced.php2
-rw-r--r--wp-admin/edit-page-form.php2
-rw-r--r--wp-content/themes/classic/sidebar.php4
-rw-r--r--wp-content/themes/default/footer.php6
-rw-r--r--wp-includes/js/autosave-js.php2
-rw-r--r--wp-includes/script-loader.php2
-rw-r--r--wp-settings.php6
9 files changed, 51 insertions, 16 deletions
diff --git a/wp-admin/admin-ajax.php b/wp-admin/admin-ajax.php
index 0d94e6b..ece9539 100644
--- a/wp-admin/admin-ajax.php
+++ b/wp-admin/admin-ajax.php
@@ -220,7 +220,7 @@ case 'add-user' :
) );
$x->send();
break;
-case 'autosave' :
+case 'autosave' : // The name of this action is hardcoded in edit_post()
$_POST['post_content'] = $_POST['content'];
$_POST['post_excerpt'] = $_POST['excerpt'];
$_POST['post_status'] = 'draft';
diff --git a/wp-admin/admin-functions.php b/wp-admin/admin-functions.php
index aa9fa78..e2ef065 100644
--- a/wp-admin/admin-functions.php
+++ b/wp-admin/admin-functions.php
@@ -20,6 +20,25 @@ function wp_write_post() {
return new WP_Error( 'edit_posts', __( 'You are not allowed to create posts or drafts on this blog.' ) );
}
+
+ // Check for autosave collisions
+ if ( isset($_POST['temp_ID']) ) {
+ $temp_id = (int) $_POST['temp_ID'];
+ if ( !$draft_ids = get_user_option( 'autosave_draft_ids' ) )
+ $draft_ids = array();
+ foreach ( $draft_ids as $temp => $real )
+ if ( time() + $temp > 86400 ) // 1 day: $temp is equal to -1 * time( then )
+ unset($draft_ids[$temp]);
+
+ if ( isset($draft_ids[$temp_id]) ) { // Edit, don't write
+ $_POST['post_ID'] = $draft_ids[$temp_id];
+ unset($_POST['temp_ID']);
+ relocate_children( $temp_id, $_POST['post_ID'] );
+ update_user_option( $user_ID, 'autosave_draft_ids', $draft_ids );
+ return edit_post();
+ }
+ }
+
// Rename.
$_POST['post_content'] = $_POST['content'];
$_POST['post_excerpt'] = $_POST['excerpt'];
@@ -88,12 +107,17 @@ function wp_write_post() {
}
// Create the post.
- $post_ID = wp_insert_post( $_POST);
+ $post_ID = wp_insert_post( $_POST );
+
add_meta( $post_ID );
// Reunite any orphaned attachments with their parent
- if ( $_POST['temp_ID'] )
- relocate_children( $_POST['temp_ID'], $post_ID );
+ // Update autosave collision detection
+ if ( $temp_id ) {
+ relocate_children( $temp_id, $post_ID );
+ $draft_ids[$temp_id] = $post_ID;
+ update_user_option( $user_ID, 'autosave_draft_ids', $draft_ids );
+ }
// Now that we have an ID we can fix any attachment anchor hrefs
fix_attachment_links( $post_ID );
@@ -165,6 +189,17 @@ function edit_post() {
wp_die( __('You are not allowed to edit this post.' ));
}
+ // Autosave shouldn't save too soon after a real save
+ if ( 'autosave' == $_POST['action'] ) {
+ $post =& get_post( $post_ID );
+ $now = time();
+ $then = strtotime($post->post_date_gmt . ' +0000');
+ // Keep autosave_interval in sync with autosave-js.php.
+ $delta = apply_filters( 'autosave_interval', 120 ) / 2;
+ if ( ($now - $then) < $delta )
+ return $post_ID;
+ }
+
// Rename.
$_POST['ID'] = (int) $_POST['post_ID'];
$_POST['post_content'] = $_POST['content'];
diff --git a/wp-admin/edit-form-advanced.php b/wp-admin/edit-form-advanced.php
index c519d73..c2e6439 100644
--- a/wp-admin/edit-form-advanced.php
+++ b/wp-admin/edit-form-advanced.php
@@ -17,7 +17,7 @@ $messages[3] = __('Custom field deleted.');
if (0 == $post_ID) {
$form_action = 'post';
- $temp_ID = -1 * time();
+ $temp_ID = -1 * time(); // don't change this formula without looking at wp_write_post()
$form_extra = "<input type='hidden' id='post_ID' name='temp_ID' value='$temp_ID' />";
wp_nonce_field('add-post');
} else {
diff --git a/wp-admin/edit-page-form.php b/wp-admin/edit-page-form.php
index 5247f17..6f2cbd1 100644
--- a/wp-admin/edit-page-form.php
+++ b/wp-admin/edit-page-form.php
@@ -5,7 +5,7 @@
if (0 == $post_ID) {
$form_action = 'post';
$nonce_action = 'add-page';
- $temp_ID = -1 * time();
+ $temp_ID = -1 * time(); // don't change this formula without looking at wp_write_post()
$form_extra = "<input type='hidden' id='post_ID' name='temp_ID' value='$temp_ID' />";
} else {
$form_action = 'editpost';
diff --git a/wp-content/themes/classic/sidebar.php b/wp-content/themes/classic/sidebar.php
index 49d476f..ce72662 100644
--- a/wp-content/themes/classic/sidebar.php
+++ b/wp-content/themes/classic/sidebar.php
@@ -34,8 +34,8 @@
<ul>
<?php wp_register(); ?>
<li><?php wp_loginout(); ?></li>
- <li><a href="feed:<?php bloginfo('rss2_url'); ?>" title="<?php _e('Syndicate this site using RSS'); ?>"><?php _e('<abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li>
- <li><a href="feed:<?php bloginfo('comments_rss2_url'); ?>" title="<?php _e('The latest comments to all posts in RSS'); ?>"><?php _e('Comments <abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li>
+ <li><a href="<?php bloginfo('rss2_url'); ?>" title="<?php _e('Syndicate this site using RSS'); ?>"><?php _e('<abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li>
+ <li><a href="<?php bloginfo('comments_rss2_url'); ?>" title="<?php _e('The latest comments to all posts in RSS'); ?>"><?php _e('Comments <abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li>
<li><a href="http://validator.w3.org/check/referer" title="<?php _e('This page validates as XHTML 1.0 Transitional'); ?>"><?php _e('Valid <abbr title="eXtensible HyperText Markup Language">XHTML</abbr>'); ?></a></li>
<li><a href="http://gmpg.org/xfn/"><abbr title="XHTML Friends Network">XFN</abbr></a></li>
<li><a href="http://wordpress.org/" title="<?php _e('Powered by WordPress, state-of-the-art semantic personal publishing platform.'); ?>"><abbr title="WordPress">WP</abbr></a></li>
diff --git a/wp-content/themes/default/footer.php b/wp-content/themes/default/footer.php
index 6a6c7b8..c2317f2 100644
--- a/wp-content/themes/default/footer.php
+++ b/wp-content/themes/default/footer.php
@@ -4,10 +4,10 @@
<div id="footer">
<!-- If you'd like to support WordPress, having the "powered by" link someone on your blog is the best way, it's our only promotion or advertising. -->
<p>
- <?php bloginfo('name'); ?> is proudly powered by
+ <?php bloginfo('name'); ?> is proudly powered by
<a href="http://mu.wordpress.org/">WordPress MU</a> running on <a href="http://<?php echo $current_site->domain . $current_site->path ?>"><?php echo $current_site->site_name ?></a>. <a href="http://<?php echo $current_site->domain . $current_site->path ?>wp-signup.php" title="Create a new blog">Create a new blog</a> and join in the fun!
- <br /><a href="feed:<?php bloginfo('rss2_url'); ?>">Entries (RSS)</a>
- and <a href="feed:<?php bloginfo('comments_rss2_url'); ?>">Comments (RSS)</a>.
+ <br /><a href="<?php bloginfo('rss2_url'); ?>">Entries (RSS)</a>
+ and <a href="<?php bloginfo('comments_rss2_url'); ?>">Comments (RSS)</a>.
<!-- <?php echo get_num_queries(); ?> queries. <?php timer_stop(1); ?> seconds. -->
</p>
</div>
diff --git a/wp-includes/js/autosave-js.php b/wp-includes/js/autosave-js.php
index 67fcde7..e30134d 100644
--- a/wp-includes/js/autosave-js.php
+++ b/wp-includes/js/autosave-js.php
@@ -7,6 +7,7 @@ var autosavePeriodical;
function autosave_start_timer() {
var form = $('post');
autosaveLast = form.post_title.value+form.content.value;
+ // Keep autosave_interval in sync with edit_post().
autosavePeriodical = new PeriodicalExecuter(autosave, <?php echo apply_filters('autosave_interval', '120'); ?>);
//Disable autosave after the form has been submitted
if(form.addEventListener) {
@@ -85,6 +86,7 @@ function autosave_disable_buttons() {
form.submit ? form.submit.disabled = 'disabled' : null;
form.publish ? form.publish.disabled = 'disabled' : null;
form.deletepost ? form.deletepost.disabled = 'disabled' : null;
+ setTimeout('autosave_enable_buttons();', 1000); // Re-enable 1 sec later. Just gives autosave a head start to avoid collisions.
}
function autosave_enable_buttons() {
diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php
index bcc8bc5..63af673 100644
--- a/wp-includes/script-loader.php
+++ b/wp-includes/script-loader.php
@@ -19,7 +19,7 @@ class WP_Scripts {
$mce_config = apply_filters('tiny_mce_config_url', '/wp-includes/js/tinymce/tiny_mce_config.php');
$this->add( 'wp_tiny_mce', $mce_config, array('tiny_mce'), '20061113' );
$this->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.5.0');
- $this->add( 'autosave', '/wp-includes/js/autosave-js.php', array('prototype', 'sack'), '4508');
+ $this->add( 'autosave', '/wp-includes/js/autosave-js.php', array('prototype', 'sack'), '20070116');
$this->add( 'wp-ajax', '/wp-includes/js/wp-ajax-js.php', array('prototype'), '4459');
$this->add( 'listman', '/wp-includes/js/list-manipulation-js.php', array('wp-ajax', 'fat'), '4583');
$this->add( 'scriptaculous-root', '/wp-includes/js/scriptaculous/wp-scriptaculous.js', array('prototype'), '1.6.1');
diff --git a/wp-settings.php b/wp-settings.php
index f39ec9a..6ca0163 100644
--- a/wp-settings.php
+++ b/wp-settings.php
@@ -158,10 +158,8 @@ if( defined( "SHORTINIT" ) && constant( "SHORTINIT" ) == true ) // stop most of
require (ABSPATH . WPINC . '/functions.php');
require (ABSPATH . WPINC . '/plugin.php');
require (ABSPATH . WPINC . '/default-filters.php');
-
-include_once(ABSPATH . 'wp-includes/streams.php');
-include_once(ABSPATH . 'wp-includes/gettext.php');
-
+include_once(ABSPATH . WPINC . '/streams.php');
+include_once(ABSPATH . WPINC . '/gettext.php');
require_once (ABSPATH . WPINC . '/l10n.php');
$wpdb->hide_errors();