WordPress 中的自动保存和自定义字段
我遇到了 WordPress 自动保存不发送自定义字段数据的问题,并在 SO 上找到了此条目:
批准的答案有效,但这不仅仅是通过提前返回来阻止任何自动保存的发生?完全禁用自动保存不是一样吗?如果是这样,以正确的方式执行此操作而不是让它尝试自动保存只是为了阻止它不是更好吗?
我看到的唯一例外是,如果在检查自动保存之前检查帖子类型,以便您只禁用某些帖子类型的自动保存。
我将完全禁用自动保存,但想知道你们的想法。
编辑:我不再遇到自动保存问题了。这个问题是要讨论我上面提到的解决方案的优点。
此外,我不明白这将如何成为 WordPress 的一个功能,并假设应该更改自动保存以包含所有发布数据。不?
I was having the problem with WordPress autosave not sending custom field data, and found this entry on SO:
Wordpress add_meta_box() weirdness
The approved answer works, but is it not just preventing any autosave from happening by returning early? Isn't the same as disabling autosave completely? If so, wouldn't it be better to do so in the proper way instead of letting it try to autosave just to prevent it?
The only exception I could see is if one checked for a post-type before checking for autosave so that you only disabled autosave for certain post types.
I'm going to be disabling autosave completely, but was wondering what you guys thought.
EDIT: I'm not having problems with the autosave anymore. This question is to discuss the merits of the solutions that I mentioned above.
Additionally, I can't see how this would be a feature of WordPress, and would assume that autosave should be changed to include all post data. No?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
链接答案中的代码不会禁用自动保存,它只会在自动保存时停止执行自定义保存函数。这是必要的,因为 WordPress 自动保存系统不支持帖子元数据(自定义字段),无论是在整理帖子数据的 Javascript 中还是在创建和恢复修订的 PHP 中。
The code in the linked answer does not disable autosave, it only stops a custom save function executing when autosaving. This is necessary because the Wordpress autosave system does not support post meta data (custom fields), either in the Javascript which collates the post data or in the PHP which creates and restores revisions.
我已将以下内容用于我创建的自定义字段,并且效果很好。
I've used the following for Custom Fields I've created and it's worked fine.
仅供参考,此处发布的解决方案 http://wordpress.org/support/topic /custom-post-type-information-disappearing 对我有用,我认为更优雅。
FYI, the solution posted here http://wordpress.org/support/topic/custom-post-type-information-disappearing worked for me and I think is much more elegant.