Under the Hood
Clone this wiki locally
** Warning: geek content! **
Forking a post creates a copy of the most recent version of the post as a "fork" custom post type. Certain fields (e.g.,
post_title) are copied over to the new fork. The plugin also stores the revision ID for the revision prior to when the fork was created (see
includes/revisions.php for more information as to why we store the previous revision).
The fork post type has its own capabilities, allowing a user without the ability to edit or publish on the parent post to edit a fork. Once changes have been made, assuming the user does not have the
publish_fork capability, the user would submit the fork for review (similar to submitting a Pull Request in GitHub parlance) using the normal WordPress moderation system.
Publishing a fork (either by the fork author, if they have the capability, or my an editor) triggers the merge itself. The post content of the fork undergoes a three way merge with the base revision and current version of the parent post.
A fork can have three post statuses:
- Draft - The fork is being edited
- Pending - The fork has been submitted for publication
- Published - The fork has been merged
Note: No user should have the
edit_published_fork capability. Once published, the fork post_type simply exists to provide a record of the change and allow the author page, to theoretically list contributions by author.