-
-
Save tommcfarlin/3de0a26bbddc867f88a82def270a483b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// First, update the post using the available WordPress API. | |
wp_update_post( $post ); | |
/** | |
* If the post status attribute of the post that was just updated | |
* maintains the 'publish' post setatus, then manually update the | |
* database column. | |
*/ | |
if ( 'publish' === $post->post_status ) { | |
global $wpdb; | |
$wpdb->query( | |
$wpdb->prepare( | |
" | |
UPDATE $wpdb->posts | |
SET post_status = '%s' | |
WHERE ID = %d | |
", | |
'publish', | |
$post->ID | |
) | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$event_post->post_date_gmt = gmdate( 'Y-m-d H:i:s', $event_post->post_date_gmt ); | |
wp_update_post( $event_post ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( 'attachment' !== $post_type ) { | |
if ( 'publish' == $post_status ) { | |
$now = gmdate('Y-m-d H:i:59'); | |
if ( mysql2date('U', $post_date_gmt, false) > mysql2date('U', $now, false) ) { | |
$post_status = 'future'; | |
} | |
} elseif ( 'future' == $post_status ) { | |
$now = gmdate('Y-m-d H:i:59'); | |
if ( mysql2date('U', $post_date_gmt, false) <= mysql2date('U', $now, false) ) { | |
$post_status = 'publish'; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$post_parent = apply_filters( 'wp_insert_post_parent', $post_parent, $post_ID, compact( array_keys( $postarr ) ), $postarr ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( empty( $postarr['post_date_gmt'] ) || '0000-00-00 00:00:00' == $postarr['post_date_gmt'] ) { | |
if ( ! in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) ) { | |
$post_date_gmt = get_gmt_from_date( $post_date ); | |
} else { | |
$post_date_gmt = '0000-00-00 00:00:00'; | |
} | |
} else { | |
$post_date_gmt = $postarr['post_date_gmt']; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment