#25272 closed task (blessed) (fixed)
Refactor/clean up autosave and use heartbeat for transport
Reported by: | azaozz | Owned by: | azaozz |
---|---|---|---|
Milestone: | 3.9 | Priority: | normal |
Severity: | normal | Version: | 3.8 |
Component: | Autosave | Keywords: | early |
Focuses: | Cc: |
Description
Autosave has lots of "moving parts" and over the years many additional functions were "pinned" to it. In 3.6 most of the additional functionality was moved to heartbeat, like logged out warning, nonces update, etc. It's time to move the saving of post data over to heartbeat as originally planned, and avoid the extra XHR.
Attachments (7)
Change History (41)
#4
@
11 years ago
In 25272.3.patch:
- Move form submit handling, #title.blur(), etc. from autosave.js to post.js as they are only for that screen.
- Rename 'wp.autosave.remote' to 'wp.autosave.server'.
This patch requires the heartbeat http://core.trac.wordpress.org/attachment/ticket/25073/25073.2.patch and includes the updated tests from 25272-tests.patch.
#5
@
11 years ago
- Keywords early added
- Milestone changed from 3.7 to 3.8
This is huge. Per IRC, early 3.8. See also #23362 for 3.8.
#7
follow-up:
↓ 8
@
11 years ago
@azaozz:
In your latest patch, could you make the following tweak:
- $('form#post').attr('target', 'wp-preview').submit().attr('target', ''); + $('form#post').attr('target', $(this).attr('target')).submit().attr('target', '');
Two reasons for this. First, it eliminates redundancy as the wp-preview
target is already defined in post_submit_meta_box()
as:
<a class="preview button" href="<?php echo $preview_link; ?>" target="wp-preview" id="post-preview"><?php echo $preview_button; ?></a>
Secondly, I'm working on a plugin <https://github.com/x-team/wp-customizer-everywhere> that manipulates the window target for the preview, and the only way to do so at the moment is to override the global doPreview
function with one that uses the above change. But if the #post-preview
click handler supplies the $('form#post').attr('target')
from its own target
attribute, then a plugin just has to manipulate the preview link/button target
upon jQuery.ready
.
#8
in reply to:
↑ 7
@
11 years ago
Replying to westonruter:
This makes sense. Combined with the suggestion from #20233 about adding the post_id
to the form submit target it should remove some confusion.
#11
@
11 years ago
In 25272.4.patch: refresh, pass autosave.js through jshint, make few names more specific.
#12
@
11 years ago
- Milestone changed from 3.8 to Future Release
Moving to 3.9-early as discussed in the dev chat on 2013-11-20
The patch is quite large and could potentially introduce hard to spot bugs. 3.8 is even more condensed than 3.7, better to keep everybody's attention on the main features: MP6, Dashboard, Themes screen, Widgets...
#13
@
11 years ago
- Milestone changed from Future Release to 3.9
In 25272.5.patch:
- Improvements for wp.autosave.server.
- Catch changes in both editors on
beforeunload
. - Refresh post.js.
#18
@
11 years ago
There's a typo in autosave.js on line 352: 'click.autosae-local'.
https://core.trac.wordpress.org/browser/trunk/src/wp-includes/js/autosave.js?rev=27038#L352
#19
@
11 years ago
We should probably set window.autosave = wp.autosave. Not sure if any plugins were using it to force an autosave, but there's little harm in doing so.
#21
@
11 years ago
We should probably set window.autosave = wp.autosave...
Was looking at how many plugins do autosave = function(){}
to disable it, may need to add back-compat for that.
#22
@
11 years ago
In 25272.6.patch: back-compat, before saving check whether the old window.autosave()
was overridden by a plugin.
#23
@
11 years ago
Looks like there are eight plugins that disable autosave by overriding window.autosave()
. Four are derivatives of AtD that will have to be updated anyway.
At this point I'm 50/50 on whether we need 25272.6.patch.
#24
@
11 years ago
What was the canonical way in 3.8 to say "whoa there, don't run autosave"? Setting window.autosave to nothing? Maybe it was setting blockSave to true? I'm not sure what kind of back compat is needed here, but it seems like people surely came up with *some* way to block autosaves when necessary.
#26
@
11 years ago
What was the canonical way in 3.8 to say "whoa there, don't run autosave"?
Core used autosave = function(){};
mostly because jquery.schedule.js can't cancel existing schedule properly, it runs one more time. Some plugins picked that up too. Don't see any blockSave = true
when searching the github mirror.
Speaking of jquery.schedule.js, it's not used anywhere in core any more. We need a way to deprecate scripts.
.button-disabled
and.button-primary-disabled
classes were removed from JS...
Thinking they are needed for back-compat.
In 25272.patch:
autosave( $post_data )
(in PHP).edit-post . $post_id
nonce instead._wp_translate_postdata()
(before the "What to do based on which button they pressed" part).wp_create_post_autosave()
to accept either the post data or post_id.post_preview()
.wp.autosave.remote.disable()
andwp.autosave.remote.triggerSave()
.'before-autosave'
and'after-autosave'
custom events. Use the after-autosave event to load the edit slug part under the title field.