distributor icon indicating copy to clipboard operation
distributor copied to clipboard

Original date not used on pull (after use of snippet)

Open Zodiac1978 opened this issue 10 months ago • 1 comments

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

  1. Network activated Distributor plugin
  2. Add https://10up.github.io/distributor/tutorial-snippets.html#push-original-publication-date somewhere
  3. Go to /wp-admin/admin.php?page=pull on Subdomain A in multisite
  4. Pull post from blog on main site
  5. 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

Zodiac1978 avatar Apr 17 '24 17:04 Zodiac1978

@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 );

kirtangajjar avatar Jun 15 '24 14:06 kirtangajjar