feat(block): add block version of the republish button#320
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>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
I made some changes to the block:
I'm going to update the testing steps to reflect this! |
…EADME.md to match readme.txt
a58bdb1 to
5a0d858
Compare
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
jason10lee
left a comment
There was a problem hiding this comment.
Picking up a few old PRs from projects that were absorbed into the monorepo! The ownership/review history on this one's a little odd, so just commenting here--but I've added some notes inline that the agents and I largely agree on. Four suggestions, the rest nits. None really blocking, so if an approval is appropriate here, I'm happy to do so.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Thanks for the review @jason10lee! |
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.
The block version of the block only support the modal version of the republication tracker for now. The block is just a button has the usual button options (editing the label, colour, typography, border, shadow), plus a toggle to show/hide the license graphic that's enabled by default. The original preamble text is included by using the pattern bundled with the block.
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.
Note: some of this code may throw errors about the WordPress version the plugin claims to support (5.3). I actually updated the supported version already in newspack-workspace, and left the files here as-is in case those two PRs clashed when these changes were synced.
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 load.Post meta and filters:
Republication Tracker settings
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: