-
Notifications
You must be signed in to change notification settings - Fork 9
feat(block): add block version of the republish button #320
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
Merged
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
c902770
build: add webpack build pipeline with newspack-scripts
rbcorrales d54ddb7
refactor: shared modal flag and remove inline onclick from copy button
rbcorrales 30606cf
feat(block): add block.json metadata and base styles
rbcorrales a7a3530
feat(block): add editor component with block registration
rbcorrales f9feea1
feat(block): add PHP block class with server-side rendering
rbcorrales 395099b
feat(block): add frontend modal JS for block trigger
rbcorrales 162cbb9
chore: raise minimum WP version to 6.0 for block support
rbcorrales 262254e
fix(block): address review findings from 12 parallel code reviewers
rbcorrales 1aace67
fix(block): address remaining review findings
rbcorrales 73620aa
fix(block): apply wrapper attributes to outer div for correct anchor …
rbcorrales 1da6b7f
fix: resolve PHPCS, eslint plugin, and test failures
rbcorrales 529045f
fix(block): address Copilot review feedback
rbcorrales 642d9b8
fix: resolve JS lint errors in edit.js and view.js
rbcorrales f228d76
fix: update widget test assertion and register block in test setup
rbcorrales 1e18f1c
fix: resolve test failures and load composer autoloader in bootstrap
rbcorrales e900d80
fix: remove 'page' as option and leave only modal
laurelfulford 8283ae4
Merge branch 'trunk' into feat/republish-button-block
laurelfulford b0cf32d
feat(block): introduce republish-section pattern + license block
laurelfulford 12852b5
refactor(block): consolidate republish block layout, icons, gating
laurelfulford 8857acd
fix: remove separate license block
laurelfulford d24fadc
chore: update minimum WP version for the switch to API3, and update R…
laurelfulford 618e031
fix: escape translated output
laurelfulford ba68fb6
fix: add 'classic theme only' comment to one of the plugin options
laurelfulford 2609cf5
fix: make sure we're not trapping focus on hidden elements
laurelfulford 5a0d858
Merge branch 'trunk' into feat/republish-button-block
laurelfulford 4a1926a
Merge branch 'trunk' into feat/republish-button-block
laurelfulford 4ac5abf
chore: revert readme.txt and README.md changes to avoid sync clash
laurelfulford 72c3c27
fix: guard composer autoloader in test bootstrap
laurelfulford fc55996
fix(block): guard pre-5.5 fatals, fix i18n double-escape + supports
rbcorrales File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| <?php | ||
| /** | ||
| * Republish block pattern registration. | ||
| * | ||
| * @package Republication_Tracker_Tool | ||
| */ | ||
|
|
||
| defined( 'ABSPATH' ) || exit; | ||
|
|
||
| /** | ||
| * Registers the "Republish Section" pattern and its category. | ||
| */ | ||
| final class Republication_Tracker_Tool_Republish_Pattern { | ||
|
|
||
| /** | ||
| * Pattern name. | ||
| */ | ||
| public const PATTERN_NAME = 'republication-tracker-tool/republish-section'; | ||
|
|
||
| /** | ||
| * Pattern category slug. | ||
| */ | ||
| public const CATEGORY_SLUG = 'republication-tracker-tool'; | ||
|
|
||
| /** | ||
| * Hook up registration. | ||
| */ | ||
| public static function init() { | ||
| add_action( 'init', [ __CLASS__, 'register' ] ); | ||
| } | ||
|
|
||
| /** | ||
| * Register the pattern category and pattern. | ||
| */ | ||
| public static function register() { | ||
| // Block pattern APIs are only available on WP 5.5+. Bail gracefully on | ||
| // older installs instead of fataling on init. | ||
| if ( ! function_exists( 'register_block_pattern' ) || ! function_exists( 'register_block_pattern_category' ) ) { | ||
| return; | ||
| } | ||
|
|
||
| register_block_pattern_category( | ||
| self::CATEGORY_SLUG, | ||
| [ 'label' => esc_html__( 'Republication', 'republication-tracker-tool' ) ] | ||
| ); | ||
|
|
||
| $description = esc_html__( 'Republish our articles for free, online or in print, under a Creative Commons license.', 'republication-tracker-tool' ); | ||
|
|
||
| // Plain __() (not esc_html__): buttonText is JSON-encoded into a block | ||
| // attribute and escaped again by the block's render_callback, so escaping | ||
| // here would double-encode entities in translations (apostrophes, etc.). | ||
| $button_text = __( 'Republish This Story', 'republication-tracker-tool' ); | ||
| $button_text_enc = wp_json_encode( $button_text ); | ||
|
|
||
| $content = <<<HTML | ||
| <!-- wp:group {"className":"republication-tracker-tool-republish-section"} --> | ||
| <div class="wp-block-group republication-tracker-tool-republish-section"> | ||
| <!-- wp:paragraph --> | ||
| <p>{$description}</p> | ||
| <!-- /wp:paragraph --> | ||
|
|
||
| <!-- wp:republication-tracker-tool/republish-button {"buttonText":{$button_text_enc}} /--> | ||
| </div> | ||
| <!-- /wp:group --> | ||
| HTML; | ||
|
|
||
| // Hide the pattern from the inserter on classic themes (matches the | ||
| // republish-button block's gating). Stays registered so existing | ||
| // instances and inter-block references keep working. | ||
| $inserter = ! function_exists( 'wp_is_block_theme' ) || wp_is_block_theme(); | ||
|
|
||
| register_block_pattern( | ||
| self::PATTERN_NAME, | ||
| [ | ||
| 'title' => esc_html__( 'Republish Section', 'republication-tracker-tool' ), | ||
| 'description' => esc_html__( 'A paragraph, republish button, and Creative Commons license badge grouped together.', 'republication-tracker-tool' ), | ||
| 'categories' => [ self::CATEGORY_SLUG ], | ||
| 'content' => $content, | ||
| 'inserter' => $inserter, | ||
| ] | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| Republication_Tracker_Tool_Republish_Pattern::init(); |
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| { | ||
| "$schema": "https://schemas.wp.org/trunk/block.json", | ||
| "apiVersion": 3, | ||
|
laurelfulford marked this conversation as resolved.
|
||
| "name": "republication-tracker-tool/republish-button", | ||
| "title": "Republish Button", | ||
| "category": "widgets", | ||
| "description": "A button that allows readers to republish your content under a Creative Commons license.", | ||
| "keywords": [ "republish", "creative commons", "syndication" ], | ||
| "textdomain": "republication-tracker-tool", | ||
| "attributes": { | ||
| "buttonText": { | ||
| "type": "string", | ||
| "default": "Republish This Story" | ||
| }, | ||
| "showLicense": { | ||
| "type": "boolean", | ||
| "default": true | ||
| } | ||
|
laurelfulford marked this conversation as resolved.
|
||
| }, | ||
| "supports": { | ||
| "anchor": true, | ||
| "align": false, | ||
| "color": { | ||
| "background": true, | ||
| "text": true, | ||
| "__experimentalDefaultControls": { | ||
| "background": true, | ||
| "text": true | ||
| } | ||
| }, | ||
| "typography": { | ||
| "fontSize": true, | ||
| "lineHeight": true, | ||
| "__experimentalFontFamily": true, | ||
| "__experimentalFontWeight": true, | ||
| "__experimentalFontStyle": true, | ||
| "__experimentalTextTransform": true, | ||
| "__experimentalTextDecoration": true, | ||
| "__experimentalLetterSpacing": true, | ||
| "__experimentalDefaultControls": { | ||
| "fontSize": true | ||
| } | ||
| }, | ||
| "spacing": { | ||
| "padding": true, | ||
| "__experimentalDefaultControls": { | ||
| "padding": true | ||
| } | ||
| }, | ||
| "__experimentalBorder": { | ||
| "radius": true, | ||
| "color": true, | ||
| "style": true, | ||
| "width": true, | ||
| "__experimentalDefaultControls": {} | ||
| }, | ||
| "shadow": true | ||
| }, | ||
| "editorScript": "file:../../../dist/republish-button.js", | ||
| "style": "file:../../../dist/republish-button.css", | ||
| "example": { | ||
| "attributes": { | ||
| "buttonText": "Republish This Story" | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.