-
Notifications
You must be signed in to change notification settings - Fork 34
Use a sidebar panel instead of the metabox in the block editor #446
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
base: trunk
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR replaces the classic editor metabox with a sidebar panel in the Block editor (Gutenberg) for managing the removal of references to original posts in Duplicate Post copies. The feature uses React hooks to manage toggle state and synchronize with the _dp_remove_original meta field, improving UX by making this functionality more accessible in the block editor while maintaining backward compatibility with the classic editor.
Changes:
- Added a new sidebar panel in the Block editor's document settings with a toggle control for removing references to original items
- Registered the
_dp_remove_originalmeta field for REST API access to enable block editor integration - Updated the metabox to not render in the block editor, delegating to the new sidebar panel instead
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
js/src/duplicate-post-edit-script.js |
Implements the new sidebar panel with React hooks for state management and save event handling |
src/ui/block-editor.php |
Adds original item data and meta box visibility flag to JavaScript object for block editor |
src/handlers/save-post-handler.php |
Registers _dp_remove_original meta field and updates save logic to handle both classic and block editor inputs |
src/ui/metabox.php |
Prevents metabox rendering in block editor |
tests/Unit/UI/Metabox_Test.php |
Adds test coverage for block editor metabox suppression |
tests/Unit/UI/Block_Editor_Test.php |
Updates existing tests to handle new JavaScript object properties |
css/duplicate-post.css |
Adds styling for the new sidebar panel |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| 'single' => true, | ||
| 'type' => 'boolean', | ||
| 'default' => false, | ||
| 'auth_callback' => static function ( $allowed, $meta_key, $post_id ) { |
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The auth_callback function signature is incorrect. The first parameter should be named $allowed but it's not used. According to WordPress documentation, the auth_callback should return true/false based on whether the current user has permission, and it receives $allowed, $meta_key, $object_id, $meta_value as parameters. Since $allowed is unused, the parameter list is misleading. Consider removing the unused $allowed parameter or using the correct signature.
| 'auth_callback' => static function ( $allowed, $meta_key, $post_id ) { | |
| 'auth_callback' => static function ( $allowed, $meta_key, $post_id, $meta_value ) { |
| const [ willBeDeletedReference, setWillBeDeletedReference ] = useState( false ); | ||
| const [ referenceRemoved, setReferenceRemoved ] = useState( false ); |
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The state variable name willBeDeletedReference is ambiguous. Consider renaming to shouldRemoveReference or removeReferenceOnSave to better reflect that it represents the user's intent to remove the reference upon saving, not a future passive state.
| > | ||
| { ! isRewriting && | ||
| <ToggleControl | ||
| label={ __( "Delete reference to original item.", "duplicate-post" ) } |
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The label text 'Delete reference to original item.' uses 'Delete' which might be confusing since the toggle help text uses 'will be deleted'. Consider using 'Remove reference to original item' for consistency with the help text and the actual functionality described.
| label={ __( "Delete reference to original item.", "duplicate-post" ) } | |
| label={ __( "Remove reference to original item.", "duplicate-post" ) } |
Context
This PR introduces a new sidebar panel in the document settings of the block editor (Gutenberg) to manage the removal of the reference to the original post for regular copies created with Duplicate Post. The goal is to improve the user experience and make this functionality clearer and more accessible. This panel replaces the classic editor metabox for this feature in the block editor.
Summary
This PR can be summarized in the following changelog entry:
Relevant technical choices:
useState,useEffect) to manage the toggle state and synchronize with the_dp_remove_originalmeta field.dispatch('core/editor').editPost.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 the instructions above.
Impact check
This PR affects the following parts of the plugin, which may require extra testing:
UI changes
Documentation
Quality assurance
Innovation
Fixes #