duplicate-post icon indicating copy to clipboard operation
duplicate-post copied to clipboard

Add Rewrite & Republish hooks

Open mphillips opened this issue 1 year ago • 1 comments

Context

This PR adds the same dp_duplicate_post and dp_duplicate_page actions when a post is duplicated for Rewrite & Republish that are fired when when a post is cloned. Without these hooks, we can't hook into the Rewrite & Republish process the way we can with the other copy processes.

Summary

This PR can be summarized in the following changelog entry:

  • Added hooks when a post is duplicated for Rewrite & Republish to align with the hooks already present when a post is just copied.

Test instructions

Test instructions for the acceptance test before the PR gets merged

This PR can be acceptance tested by following these steps:

  • Create a duplicate of a post for Rewrite & Republish
  • If the post type is hierarchical or in the Pages post type, verify the dp_duplicate_page hook is fired and includes the duplicate post's ID, the WP_Post object representing the original post, and the status of the new post.
  • If the post type is not hierarchical or in the Pages post type, verify the dp_duplicate_post hook is fired and includes the duplicate post's ID, the WP_Post object representing the original post, and the status of the new post.
  • Verify the duplicate_rewrite_and_republish_post_copy hook is fired and includes the duplicate post's ID, the WP_Post object representing the original post, and the status of the new post.

Relevant test scenarios

  • [ ] Changes should be tested with the browser console open
  • [x] Changes should be tested on different posts/pages/post types
  • [x] Changes should be tested on different editors (Block/Classic/Elementor/other)
  • [ ] Changes should be tested on different browsers
  • [ ] Changes should be tested on multisite

Test instructions for QA when the code is in the RC

  • [x] QA should use the same steps as above.

Impact check

This PR affects the following parts of the plugin, which may require extra testing:

  • Since this PR adds the dp_duplicate_post and dp_duplicate_page actions to the Rewrite & Republish process, verify the setting to copy children works since it relies on those actions.
  • Also need to verify the dp_duplicate_page and dp_duplicate_post hooks aren't fired multiple times when duplicating a post for Rewrite & Republish

UI changes

  • [ ] This PR changes the UI in the plugin. I have added the 'UI change' label to this PR.

Documentation

  • [x] I have written documentation for this change.

Quality assurance

  • [x] I have tested this code to the best of my abilities
  • [ ] I have added unittests to verify the code works as intended

Innovation

  • [x] No innovation project is applicable for this PR.
  • [ ] This PR falls under an innovation project. I have attached the innovation label and noted the work hours.

Fixes #

mphillips avatar Apr 06 '23 19:04 mphillips

This PR would be a very welcome addition. When using repost and rewrite and republish I need to update the post ID to the new post in the database.

This would be extremely helpful for that :-) Thanks @mphillips

YourMark avatar May 23 '24 15:05 YourMark