Automattic / Automattic/jetpack
Comments: Add support for comment_form_top action after comment title
- Dominant language
- PHP
- Stars
- 1.8k
- Forks
- 898
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 774
Description
#### Is your feature request related to a problem? Please describe.
WordPress Core supports the `comment_form_top` action to allow content to be added at the top of the comment form.
Developer Docs: https://developer.wordpress.org/reference/hooks/comment_form_top/
Source: https://github.com/WordPress/WordPress/blob/5.6/wp-includes/comment-template.php#L2555-L2561
```
function comment_add_policy() {
echo esc_html( '
Howdy, by leaving a comment you agree to our comment policy.
' );}
add_action('comment_form_top', 'comment_add_policy');
```
As Jetpack replaces the comment form and the action is not available, but does appear at the bottom of the comment form but not at the reply location.
https://github.com/Automattic/jetpack/blob/9.2.1/modules/comments/comments.php#L327
#### Describe the solution you'd like
Either adding support for `comment_form_top` within the Jetpack comment form by adding `do_action( 'comment_form_top' )` after the greeting `if` statement but before the iframe:
https://github.com/Automattic/jetpack/blob/9.2.1/modules/comments/comments.php#L338
Alternatively, a new filter could be added `jetpack_comment_form_top` which would allow for customization but be specific to Jetpack itself.
#### Describe alternatives you've considered
Using JavaScript to modify the DOM to add the message before the iframe.
Contributor guide
Research direction
The requested integration is in modules/comments/comments.php around the greeting if statement and iframe, with the issue linking the relevant lines. First inspect that comment-form path and the existing action behavior. Done means the WordPress comment_form_top hook is available at the requested position without relying on JavaScript, or that the selected Jetpack-specific alternative is clearly implemented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php, wordpress
- Domain
- frontend, web-dev
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100