feat(block): add block version of the republish button#320
Draft
rbcorrales wants to merge 15 commits intotrunkfrom
Draft
feat(block): add block version of the republish button#320rbcorrales wants to merge 15 commits intotrunkfrom
rbcorrales wants to merge 15 commits intotrunkfrom
Conversation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…and layout support Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds a dynamic Gutenberg “Republish Button” block intended for block themes, reusing the existing republication modal/content infrastructure while avoiding duplicate modal rendering across multiple buttons/widgets.
Changes:
- Introduces a new dynamic block (
republication-tracker-tool/republish-button) with editor UI, styles, and a frontend script for modal behavior. - Refactors modal rendering deduplication so both widget and block share a single “modal rendered” flag.
- Updates build tooling to generate
dist/assets (webpack config + package scripts) and adjusts packaging ignores accordingly.
Reviewed changes
Copilot reviewed 14 out of 15 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
webpack.config.js |
Adds webpack entries for the block editor bundle and frontend “view” bundle. |
src/blocks/republish-button/index.js |
Registers the block client-side (editor). |
src/blocks/republish-button/edit.js |
Implements inline-editable message/button text and inspector control for display mode. |
src/blocks/republish-button/block.json |
Declares block metadata, supports, attributes, and built asset references in dist/. |
src/blocks/republish-button/style.scss |
Adds minimal frontend/editor styling for the block wrapper elements. |
src/blocks/republish-button/view.js |
Adds vanilla JS modal handling for block triggers + copy/tab behaviors. |
includes/class-republish-button-block.php |
Registers (conditionally) and server-renders the dynamic block; enqueues modal assets when needed. |
republication-tracker-tool.php |
Requires the new block class and introduces a shared static flag for modal deduplication. |
includes/class-widget.php |
Switches modal deduplication to the shared static flag and updates modal include behavior. |
includes/shareable-content.php |
Replaces inline onclick copy handler with a data-copy-active hook. |
assets/widget.js |
Binds the copy handler via data-copy-active (matching the shareable-content change). |
package.json |
Adds build/watch/clean + JS/SCSS lint scripts and ensures release archives include built dist/. |
.gitignore |
Ignores dist/ in git. |
.distignore |
Excludes src/** JS/SCSS and webpack config from release artifacts (expects built dist/). |
readme.txt |
Updates “Requires at least” and “Tested up to” metadata. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
All Submissions:
Changes proposed in this Pull Request:
Block themes don't have widget areas, so the existing classic widget can't be used on them. This adds a Gutenberg block (
republication-tracker-tool/republish-button) that provides the same republication functionality for block themes.The block is only registered when a block theme is active, so it doesn't interfere with the existing widget on classic themes.
It supports two display modes: modal (opens an overlay with copyable HTML and plain text content) and page (links to the
/republish/endpoint). The button label and description message are editable inline, and the block supports color, typography, spacing, border, shadow, and anchor.All existing plugin settings are respected: policy text, license, GA4 tracking, attribution, media distribution, plain text toggle, post meta to hide the widget, and post type filters.
Also includes a small backwards compatible refactor to share the modal rendering flag between the widget and the block, so only one modal is ever rendered per page regardless of how many buttons exist.
Closes NPPD-1347.
How to test the changes in this Pull Request:
Prerequisites:
newspack-block-themeorTwenty Twenty-Five)npm ci && npm run buildBlock editor:
Frontend (modal mode):
#show-republishappended. The modal should auto-open on page loadFrontend (page mode):
/republish/<post-permalink-path>/Post meta and filters:
Widget backwards compatibility (classic theme):
newspack-theme). The block should NOT appear in the inserterdata-copy-active(no inlineonclick) and clipboard copy worksCoexistence:
Other information: