Make the Webmention form easier to understand and reusable as block - #667
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The editor preview generates duplicate element IDs, and the filter argument fix lacks regression coverage.
Review effort: Balanced
Findings: 1
Open (2)
What changed in this PR
Improves Webmention form clarity and introduces a reusable server-rendered block.
Changes:
- Redesigns form markup, text, styling, and unique IDs.
- Adds automatic Block Hooks integration and duplicate suppression.
- Updates tests, linting configuration, dependencies, and build artifacts.
| File | Description |
|---|---|
tests/phpunit/tests/class-test-form.php |
Tests form rendering and block integration. |
templates/endpoint-form.php |
Clarifies URL placeholders. |
templates/comment-form.php |
Adds reusable, accessible form markup. |
src/rsvp/index.js |
Refines callback JSDoc type. |
src/reaction-links/reactions.js |
Refines function JSDoc types. |
src/form/render.php |
Renders the dynamic form block. |
src/form/index.js |
Implements the editor preview. |
src/form/block.json |
Defines block metadata and hooks. |
package.json |
Adds direct WordPress dependencies. |
package-lock.json |
Locks added dependencies. |
includes/functions.php |
Adds reusable rendering and hook selection. |
includes/class-block.php |
Registers and controls the form block. |
eslint.config.cjs |
Configures Jest globals. |
build/form/render.php |
Provides built server rendering. |
build/form/index.js |
Provides compiled editor code. |
build/form/index.asset.php |
Declares editor script dependencies. |
build/form/block.json |
Provides built block metadata. |
assets/css/webmention.css |
Styles the redesigned form. |
Files not reviewed (1)
- build/form/index.js: Generated file
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| ) } | ||
| </label> | ||
| <input | ||
| id="webmention-source-preview" |
| $text = get_default_webmention_form_text(); | ||
| } | ||
| return wp_kses_post( apply_filters( 'webmention_form_text', $text ), $post_id ); | ||
| return wp_kses_post( apply_filters( 'webmention_form_text', $text, $post_id ) ); |
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.


The Webmention form under the comments was a long block of text and a field labeled "URL/Permalink of your article". It was not really clear what to enter there. The German translation even said your own URL should be "the permalink", which is not what the original text meant.
This PR makes the form a bit more self-explanatory:
The form is now reusable.
get_webmention_form( $args )renders the template and is used by the classic comment form and by a newwebmention/formblock. The block is server side rendered, so both always look the same. A second form on the same page gets unique IDs. The old IDs and thewebmention_comment_formtemplate filter still work.Which form is used depends on the theme:
webmention_use_block_hooksfilter to change the default.It also fixes
$post_idbeing passed towp_kses_post()instead of thewebmention_form_textfilter.The second commit fixes the JS linting: the missing
@wordpress/*dev dependencies, Jest globals for the tests (the@wordpress/scripts36 default config only knows Vitest), and the JSDocFunctiontypes.Two things to keep in mind:
::details-content, older browsers show the text only next to the buttonTesting
composer test:wp-env, 6 new tests intests/phpunit/tests/class-test-form.phpnpm run test:unitandnpm run lint:js