Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 task done
Zodiac1978 opened this issue Apr 17, 2024 · 1 comment
Open
1 task done

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

Zodiac1978 opened this issue Apr 17, 2024 · 1 comment
Labels
type:bug Something isn't working.
Milestone

Comments

@Zodiac1978
Copy link

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

  • I agree to follow this project's Code of Conduct
@Zodiac1978 Zodiac1978 added the type:bug Something isn't working. label Apr 17, 2024
@jeffpaul jeffpaul added this to the 2.1.0 milestone Apr 17, 2024
@kirtangajjar
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Something isn't working.
Projects
Status: To Do
Development

No branches or pull requests

3 participants