admin管理员组文章数量:1434125
I have the following code in a project.
function vb_post_modified_date_update($data, $postarr) {
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
return;
if (!empty($postarr['vb_modified_date_switch'])) {
$data['post_modified'] = $postarr['post_modified'];
$data['post_modified_gmt'] = $postarr['post_modified_gmt'];
}
return $data;
}
add_filter( 'wp_insert_post_data', 'vb_post_modified_date_update', '99', 2 );
What this used to do (it worked before upgrading to Wordpress 5), is to keep the old value on post_modified
and post_modified_gmt
fields when saving the post and a checkbox (vb_modified_date_switch
) is checked in the post editor.
According documentation of wp_insert_post_data
, $data
should have the post data and $postarr
should have the unmodified post data. However, debuging, I found that both variables have the same post data (modified data), so now I cant get the original post_modified
and post_modified_gmt
.
Is there any other way I can change the post data before is saved?
Thanks
本文标签: save postwpinsertpostdata filter not working correctly after upgrade to Wordpress 5
版权声明:本文标题:save post - wp_insert_post_data filter not working correctly after upgrade to Wordpress 5 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745611995a2666166.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论