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

Improve/verify handling of post status changes #112

Open
adamsilverstein opened this issue Apr 30, 2018 · 9 comments · May be fixed by #446
Open

Improve/verify handling of post status changes #112

adamsilverstein opened this issue Apr 30, 2018 · 9 comments · May be fixed by #446
Labels
type:enhancement New feature or request.
Milestone

Comments

@adamsilverstein
Copy link

adamsilverstein commented Apr 30, 2018

Updating post status

What happens when a post that has been distributed is published, or changed from published to draft (or moved to the trash)

Opening this issue to discuss the expected behavior when a post that has been distributed has it's post status changed.

Related: #107 & #110 & #159

Expected behavior

After some internal discussion, we have decided that the expected behavior for post status changes is as follows:

Distributing:

  • Pushing draft posts is disabled by default.
  • Pushing drafts can be enabled by returning true from the dt_drafts_can_be_distributed filter. [Update] This was replaced by the distributable_post_statuses filter.
  • When a draft post is distributed, copies will always have a status of draft. The 'As Draft' option is not available when distributing drafts (showing it would be confusing).
  • When a published post is distributed, copies will have a status of draft if the 'As Draft' checkbox is left checked, or 'publish' if it is unchecked.

Updating:

  • When an origin published post is updated (or a draft published), no change is made to the status of distributed copies.This behavior can be overwritten by returning true from the (not yet implemented) dt_published_posts_distribute_status filter. [Update 2023-11-29] The default behavior is that this is disabled/false.
  • If the dt_published_posts_distribute_status is set to true and an origin post status is changed from publish to any other status (a "takedown"), or any non published post is updated ("embargo lifted"), the statuses of distributed copies are updated to match. Status could be trash, private, draft, autodraft, future, pending, etc.

Deleting

  • When an origin post is deleted, remote posts are unlinked and the editor shows a warning message: This post was distributed from [SITENAME]. However, the original has been deleted. [Update 2023-11-29] This could be altered using the same dt_published_posts_distribute_status set to true to similarly delete the remote posts, but this should be disabled/false by default.

Connections

  • Post status updates should work the same for network and external connections

Remaining Todo after testing

Add a dt_published_posts_distribute_status filter to determine if a posts's status should be distributed along with other post data.

@adamsilverstein
Copy link
Author

cc: @tlovett1

@tlovett1
Copy link
Member

@adamsilverstein did #159 solve this?

@adamsilverstein
Copy link
Author

Yes, I think this is resolved although I haven't gone back to test. I'll try to to that soon and close.

@jeffpaul
Copy link
Member

jeffpaul commented Apr 1, 2019

@adamsilverstein mind re-testing this to see if it can be closed?

@jeffpaul
Copy link
Member

jeffpaul commented Jun 6, 2019

@adamsilverstein mind re-testing this to see if it can be closed?

@jeffpaul jeffpaul added type:enhancement New feature or request. needs:feedback This requires reporter feedback to better understand the request. labels Jun 6, 2019
@adamsilverstein
Copy link
Author

Testing results

Pushing draft posts is disabled by default.

verified

Pushing drafts can be enabled by returning true from the dt_drafts_can_be_distributed filter. [Update] This was replaced by the distributable_post_statuses filter .

verified filter works as expected, added:

add_filter( 'dt_distributable_post_statuses', function() { return array( 'publish', 'draft' ); } ); and draft was distributable.

When a draft post is distributed, copies will always have a status of draft. The 'As Draft' option is not available when distributing drafts (showing it would be confusing).

verified this

When a published post is distributed, copies will have a status of draft if the 'As Draft' checkbox is left checked, or 'publish' if it is unchecked.

Verified.

Updating:

When an origin published post is updated (or a draft published), no change is made to the status of distributed copies.This behavior can be overwritten by returning true from the (not yet implemented) dt_published_posts_distribute_status filter.

verified no change in remote status. don't see dt_published_posts_distribute_status

it might be possible to achieve this with the dt_push_post_args filter.

If the dt_published_posts_distribute_status is set to true and an origin post status is changed from publish to any other status (a "takedown"), or any non published post is updated, the statuses of distributed copies are updated to match. Status could be trash, private, draft, autodraft, future, pending, etc.

not in place as far as I can tell.

Deleting

When an origin post is deleted, remote posts are unlinked and the editor shows a warning message: This post was distributed from [SITENAME]. However, the original has been deleted.

verified. post also becomes unlinked (editable)

Results

The one thing missing is a dt_published_posts_distribute_status filter to determine if a posts's status should be distributed.

@adamsilverstein
Copy link
Author

I started work on addressing the final issue here in #446

@jeffpaul jeffpaul added this to the 2.0.0 milestone Sep 24, 2019
@jeffpaul jeffpaul removed the needs:feedback This requires reporter feedback to better understand the request. label Nov 21, 2019
@dinhtungdu dinhtungdu self-assigned this Feb 10, 2020
@jeffpaul jeffpaul modified the milestones: 1.6.0, 2.0.0 Jun 8, 2020
@jeffpaul jeffpaul modified the milestones: 2.0.0, 1.7.0 Sep 16, 2020
@TangramWerbeagentur
Copy link

TangramWerbeagentur commented Oct 6, 2020

I found a simple workaround to automatically trash posts on the receiving site that were trashed on the pushing site. It's possible since the permalink does update to "__trashed" correctly, just the post status doesn't. With this added to the receiving site's functions.php it does:

$args = array(
  'post_type' => array('post'), // post types you want to check
  'posts_per_page' => -1
);
$posts = get_posts($args);

foreach($posts as $p){

  $expiredlink = get_permalink( $p->ID );

  if(strpos($expiredlink, "__trashed") !== false) {
    $postdata = array(
      'ID' => $p->ID,
      'post_status' => 'trash'
    );
    wp_update_post($postdata);
  }
}

@jeffpaul
Copy link
Member

jeffpaul commented Oct 6, 2020

Thanks for this @TangramWerbeagentur! We're working to document and think through the various implications this has, especially as this inter-relates to distributing "as draft", to ensure we're considering all use cases and not negatively impacting a current use case with a PR on this topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:enhancement New feature or request.
Projects
Status: Code Review
5 participants