feat: add Notes as an element to copy when cloning a post - #548
Open
faisalahammad wants to merge 1 commit into
Open
faisalahammad wants to merge 1 commit into
faisalahammad wants to merge 1 commit into
Conversation
Adds a Notes checkbox to the settings page and a Notes_Copier class that copies block-level notes and their replies when cloning a post. The note IDs stored in the block markup are remapped to the copied notes, so the copy references its own notes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
WordPress 6.9 stores Notes as comments with
comment_typenote, and the block markup keeps a reference to the note in the blockmetadata.noteIdattribute. Until now the plugin had no way to copy Notes, so a cloned post lost all its notes and the block references were left pointing at the notes of the original post.Fixes #421
Summary
This PR can be summarized in the following changelog entry:
Relevant technical choices:
Notes_Copierclass insrc/notes-copier.phpqueries the notes of the original post withget_comments( [ 'type' => 'note' ] ), which only returns open and resolved notes, and copies them with their comment fields and comment meta.comment_parentto the copied parent note, so the copied thread keeps the same structure even when the database order is not chronological.parse_blocks()and updating themetadata.noteIdattribute of each block, then saving it back withserialize_blocks(). Parsing the blocks instead of a text search keeps the remap limited to block metadata, including nested blocks, and leaves the rest of the content untouched.duplicate_post_after_duplicatedhook (priority 45), and off by default.Test instructions
Test instructions for the acceptance test before the PR gets merged
This PR can be acceptance tested by following these steps:
Relevant test scenarios
Test instructions for QA when the code is in the RC
QA can test this PR by following these steps:
Use the same steps as above.
Impact check
This PR affects the following parts of the plugin, which may require extra testing:
UI changes
Documentation
Quality assurance
Innovation
innovationlabel and noted the work hours.Fixes #421