distributor
distributor copied to clipboard
Original date not used on pull (after use of snippet)
Describe the bug
I added the snippet from here: https://10up.github.io/distributor/tutorial-snippets.html#push-original-publication-date
Pushing a post does leave the date intact, but pulling it, does not.
Steps to Reproduce
- Network activated Distributor plugin
- Add https://10up.github.io/distributor/tutorial-snippets.html#push-original-publication-date somewhere
- Go to /wp-admin/admin.php?page=pull on Subdomain A in multisite
- Pull post from blog on main site
- Go to posts list table and see the wrong publish date
Screenshots, screen recording, code snippet
The headline says "Push original publication date", but as there is an additional function using dt_pull_post_args
I assumed this is the code for pulling.
If not, a new snippet would be great. Or repair the existing one (and fix the headline ;) )
Environment information
No response
WordPress information
WordPress 6.5.2
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
@dkotter @peterwilsoncc We can update the pull filter code like this, since while pulling, we only clone date if post_status
is future
:
/**
* This filters the the arguments passed into wp_insert_post during a pull
*/
add_filter( 'dt_pull_post_args', function( $post_array, $remote_id, $post ) {
// Date carry forward is only possible on scheduled post
if ( ! isset( $post_array['post_status'] )
|| 'future' !== $post_array['post_status'] ) {
return $post_array
}
$post_array['post_date'] = $post->post_date;
$post_array['post_date_gmt'] = $post->post_date_gmt;
return $post_array;
}, 10, 3 );