Discussion:
Autosave API for custom post types?
TV productions
2014-03-04 22:50:35 UTC
Permalink
Hi wp-hackers,

I have a plugin (http://wordpress.org/plugins/easy-photo-album/) with a
custom post type and as update I've added successfully support for
revisions. But when I restore an autosave, the metadata (that is saved
with the revisions) is empty. After digging into the code, I found out
that autosave only checks the title and the content (which in my plugin
doesn't exists on the edit page) for differences and saves only them.

So I was wondering if there is (or will be in the near future) a
autosave API that allows to save also "custom data". And, if that is not
the case, does anyone know a workaround to save my metadata with
autosave?

Best regards,

Ties
--
TV productions :: Web development and stuff
http://tv-productions.org
Andrew Bartel
2014-03-04 22:57:07 UTC
Permalink
Does autosave not trigger the save_post and/or edit_post actions? You
could probably hook on to those.

-Andrew
Post by TV productions
Hi wp-hackers,
I have a plugin (http://wordpress.org/plugins/easy-photo-album/) with a
custom post type and as update I've added successfully support for
revisions. But when I restore an autosave, the metadata (that is saved with
the revisions) is empty. After digging into the code, I found out that
autosave only checks the title and the content (which in my plugin doesn't
exists on the edit page) for differences and saves only them.
So I was wondering if there is (or will be in the near future) a autosave
API that allows to save also "custom data". And, if that is not the case,
does anyone know a workaround to save my metadata with autosave?
Best regards,
Ties
--
TV productions :: Web development and stuff
http://tv-productions.org
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
TV productions
2014-03-04 23:02:38 UTC
Permalink
Andrew,

I believe it does so, but it doesn't submit the whole post form.

This is the post data that a typical autosave request has (after the
title has changed)
==================================
action autosave
autosave true
autosavenonce ebb79c8859
catslist
comment_status open
content
excerpt
ping_status open
post_author 1
post_id 2996
post_name a
post_title Ab
post_type easy-photo-album
==================================
I hope my problem is a bit more clear now.

Ties

---
TV productions :: Web development and stuff
http://tv-productions.org
Post by Andrew Bartel
Does autosave not trigger the save_post and/or edit_post actions? You
could probably hook on to those.
-Andrew
On Tue, Mar 4, 2014 at 2:50 PM, TV productions
Hi wp-hackers,
I have a plugin (http://wordpress.org/plugins/easy-photo-album/) with a
custom post type and as update I've added successfully support for
revisions. But when I restore an autosave, the metadata (that is saved with
the revisions) is empty. After digging into the code, I found out that
autosave only checks the title and the content (which in my plugin doesn't
exists on the edit page) for differences and saves only them.
So I was wondering if there is (or will be in the near future) a autosave
API that allows to save also "custom data". And, if that is not the case,
does anyone know a workaround to save my metadata with autosave?
Best regards,
Ties
--
TV productions :: Web development and stuff
http://tv-productions.org
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
Pascal Birchler
2014-03-05 15:33:56 UTC
Permalink
Currently WP doesn't store revisions of post meta data, but there are plans
to do this. See this ticket: https://core.trac.wordpress.org/ticket/20564

John Blackbourn has written a small tutorial to make it work with a plugin,
too: https://johnblackbourn.com/post-meta-revisions-wordpress
Post by TV productions
Andrew,
I believe it does so, but it doesn't submit the whole post form.
This is the post data that a typical autosave request has (after the title
has changed)
==================================
action autosave
autosave true
autosavenonce ebb79c8859
catslist
comment_status open
content
excerpt
ping_status open
post_author 1
post_id 2996
post_name a
post_title Ab
post_type easy-photo-album
==================================
I hope my problem is a bit more clear now.
Ties
---
TV productions :: Web development and stuff
http://tv-productions.org
Post by Andrew Bartel
Does autosave not trigger the save_post and/or edit_post actions? You
could probably hook on to those.
-Andrew
Hi wp-hackers,
I have a plugin (http://wordpress.org/plugins/easy-photo-album/) with a
custom post type and as update I've added successfully support for
revisions. But when I restore an autosave, the metadata (that is saved with
the revisions) is empty. After digging into the code, I found out that
autosave only checks the title and the content (which in my plugin doesn't
exists on the edit page) for differences and saves only them.
So I was wondering if there is (or will be in the near future) a autosave
API that allows to save also "custom data". And, if that is not the case,
does anyone know a workaround to save my metadata with autosave?
Best regards,
Ties
--
TV productions :: Web development and stuff
http://tv-productions.org
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
TV productions
2014-03-05 17:40:15 UTC
Permalink
Thanks Pascal! I am going to dig into ticket 20564.
That small tutorial is very nice, I used it to make my revisions work.
The problem is really the autosave. When you restore an autosave now,
all the meta data is lost.

~Ties

---
TV productions :: Web development and stuff
http://tv-productions.org
Post by Pascal Birchler
Currently WP doesn't store revisions of post meta data, but there are plans
https://core.trac.wordpress.org/ticket/20564
John Blackbourn has written a small tutorial to make it work with a plugin,
too: https://johnblackbourn.com/post-meta-revisions-wordpress
Andrew,
I believe it does so, but it doesn't submit the whole post form.
This is the post data that a typical autosave request has (after the title
has changed)
==================================
action autosave
autosave true
autosavenonce ebb79c8859
catslist
comment_status open
content
excerpt
ping_status open
post_author 1
post_id 2996
post_name a
post_title Ab
post_type easy-photo-album
==================================
I hope my problem is a bit more clear now.
Ties
---
TV productions :: Web development and stuff
http://tv-productions.org
Does autosave not trigger the save_post and/or edit_post actions? You
could probably hook on to those.
-Andrew
On Tue, Mar 4, 2014 at 2:50 PM, TV productions
Hi wp-hackers,
I have a plugin (http://wordpress.org/plugins/easy-photo-album/) with a
custom post type and as update I've added successfully support for
revisions. But when I restore an autosave, the metadata (that is saved with
the revisions) is empty. After digging into the code, I found out that
autosave only checks the title and the content (which in my plugin doesn't
exists on the edit page) for differences and saves only them.
So I was wondering if there is (or will be in the near future) a autosave
API that allows to save also "custom data". And, if that is not the case,
does anyone know a workaround to save my metadata with autosave?
Best regards,
Ties
--
TV productions :: Web development and stuff
http://tv-productions.org
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
Sinan
2014-03-05 17:45:52 UTC
Permalink
Nice !
So version control coming for custom fields. Cool !
Post by TV productions
Thanks Pascal! I am going to dig into ticket 20564.
That small tutorial is very nice, I used it to make my revisions work. The
problem is really the autosave. When you restore an autosave now, all the
meta data is lost.
~Ties
---
TV productions :: Web development and stuff
http://tv-productions.org
Post by Pascal Birchler
Currently WP doesn't store revisions of post meta data, but there are plans
to do this. See this ticket: https://core.trac.wordpress.org/ticket/20564
John Blackbourn has written a small tutorial to make it work with a plugin,
too: https://johnblackbourn.com/post-meta-revisions-wordpress
Andrew,
I believe it does so, but it doesn't submit the whole post form.
This is the post data that a typical autosave request has (after the title
has changed)
==================================
action autosave
autosave true
autosavenonce ebb79c8859
catslist
comment_status open
content
excerpt
ping_status open
post_author 1
post_id 2996
post_name a
post_title Ab
post_type easy-photo-album
==================================
I hope my problem is a bit more clear now.
Ties
---
TV productions :: Web development and stuff
http://tv-productions.org
Does autosave not trigger the save_post and/or edit_post actions? You
could probably hook on to those.
-Andrew
Hi wp-hackers,
I have a plugin (http://wordpress.org/plugins/easy-photo-album/) with a
custom post type and as update I've added successfully support for
revisions. But when I restore an autosave, the metadata (that is saved with
the revisions) is empty. After digging into the code, I found out that
autosave only checks the title and the content (which in my plugin doesn't
exists on the edit page) for differences and saves only them.
So I was wondering if there is (or will be in the near future) a autosave
API that allows to save also "custom data". And, if that is not the case,
does anyone know a workaround to save my metadata with autosave?
Best regards,
Ties
--
TV productions :: Web development and stuff
http://tv-productions.org
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
--
Sinan İŞLER
sinanisler.com <http://www.sinanisler.com/>
Loading...