[wp-trac] [WordPress Trac] #48580: Update status in save_post hooks always true in WordPress 5.0
WordPress Trac
noreply at wordpress.org
Tue Nov 12 21:47:58 UTC 2019
#48580: Update status in save_post hooks always true in WordPress 5.0
-------------------------------+-----------------------------
Reporter: oxibug | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Posts, Post Types | Version: 5.2.4
Severity: normal | Keywords:
Focuses: |
-------------------------------+-----------------------------
I think this issue shown after integration of Gutenberg editor, The
{save_post} and {save_POST_TYPE} hooks always triggers {$update} as TRUE.
I made some tests, The {$update} is TRUE on saving the post for the first
time and on updating also, it's always true.
{{{#!php
<?php
add_action( 'save_post', array( $this, 'cpt_metas_save' ), 10, 3 );
public function cpt_metas_save( $post_ID, $post, $update ) {
$db_values = array(
'is_new' => 'No'
);
if( $update ) {
/* Saving New Post trigger this -- always {Yes} */
$db_values['is_new'] = 'Yes';
}
else {
$db_values['is_new'] = 'No';
}
/* Connect to IBM Server */
/* Update DB */
update_post_meta( $post_ID, 'postmetas_save_test', wp_unslash(
$db_values ) );
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/48580>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list