[wp-trac] [WordPress Trac] #20564: Framework for storing revisions of Post Meta

WordPress Trac noreply at wordpress.org
Sat Mar 8 01:13:21 UTC 2014


#20564: Framework for storing revisions of Post Meta
-------------------------------------------------+-------------------------
 Reporter:  alexkingorg                          |       Owner:
     Type:  enhancement                          |      Status:  reopened
 Priority:  normal                               |   Milestone:  Future
Component:  Revisions                            |  Release
 Severity:  normal                               |     Version:  3.4
 Keywords:  needs-testing needs-codex dev-       |  Resolution:
  feedback                                       |     Focuses:
-------------------------------------------------+-------------------------

Comment (by adamsilverstein):

 Replying to [comment:94 TV productions]:
 > Replying to [comment:92 adamsilverstein]:
 > > Replying to [comment:91 TV productions]:
 > > > For the ability for plugin devs to add custom meta to custom post
 type revisions (#13382), you do also need a kind of javascript "filter"
 for the data that is send with the autosave. Something like this
 http://jsfiddle.net/jTjzK/3/ (just a concept to extend the data var).
 > >
 > > I'm not sure this is required. All fields should be 'sent' with the
 auto update post, and the attached patch filters these fields and
 revisions ones that are specified. All fields are sent, and the patch
 allows authors to specify which fields to revision, Does that make sense?
 If not can you please explain a bit more what you would want to revision
 that the current patch would not work for?
 >
 > Just to check, I've pulled the latest code form the repo and applied the
 latest patch (20564.10.diff).
 > As you can see in the attached image [[Image( 20564-autosave-data.png)]]
 the default meta fields are saved.
 >
 > But what I would like to see is a way to "prepaire" the data that will
 be saved into the meta field. The post type in the image is a photo album,
 and instead of "normal" content it saves some image data and the server
 generates the `post_content` from this meta field. So I don't have one
 html input field that matches an meta field, but a lot. There are
 different solutions to this: (1) create a field that does matches the meta
 field and that is updated by javascript on autosave (so you need a hook
 for that) or (2) a "jsfilter" to generate the data and pass it trough.
 >
 > As I write this, I note that it is kinda focussed to my example, but
 what I actually would say is: could we make an autosave API where you can
 add data on client side and extract (and save) it on the server side?

 Thank you for the more detailed description and the screenshot.

 I think what you are looking for is a way to hook in right before the
 autosave, or a filter applied to the transmitted autosave data. This type
 of JavaScript hook or action is currently not standardized in WordPress -
 see ticket #21170 for more details and a proposed solution.

 In the mean time you may be able to hook in using this:

 {{{$( document ).on( 'before-autosave', function() { /* Your Function */ }
 );}}}

 (based on [https://core.trac.wordpress.org/browser/trunk/src/wp-
 includes/js/autosave.js#L517 this code])

--
Ticket URL: <https://core.trac.wordpress.org/ticket/20564#comment:95>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list