Opened 9 years ago
Closed 9 years ago
#34731 closed defect (bug) (fixed)
Need method to revert "comment" field position
Reported by: | greenshady | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | 4.4 | Priority: | normal |
Severity: | normal | Version: | 4.4 |
Component: | Comments | Keywords: | has-patch commit |
Focuses: | Cc: |
Description
In #29974, we fixed a bug where the focus handle jumped to the incorrect field when replying to a comment. This was eventually correctly fixed by fixing the JavaScript.
During the course of that ticket's lifespan, a call was made to move the "comment" field above the other form fields (see [34525]). This particular change did not directly correct the issue. It was a Band-Aid for a larger issue that was fixed later in the ticket.
This changed the HTML structure entirely from something we've had for something like 10 years to something new. It's a welcoming change in many respects.
However, such changes should give theme or plugin developers the ability to revert the output to the original. This can be done either via a hook or an argument for comment_form()
. If neither solution is acceptable, we should revert that particular change until a better solution comes along.
Attachments (6)
Change History (24)
This ticket was mentioned in Slack in #core by afercia. View the logs.
9 years ago
#2
@
9 years ago
- Milestone changed from Awaiting Review to 4.4
- Owner set to afercia
- Status changed from new to assigned
This ticket was mentioned in Slack in #core by afercia. View the logs.
9 years ago
#5
in reply to:
↑ 4
@
9 years ago
Replying to johnbillion:
Are you seeing particular problems as a result of the change in HTML? For example, broken comment form layouts, etc.
Actually, yes, I have a theme where the HTML change breaks the comment form design. That's easily fixable on my part though.
---
FWIW, I managed to piece together a plugin that would actually move the comment field. It's just a bit weird doing it this way:
<?php final class JT_Revert_Comment_Field_Position { public $comment_field = ''; public static function get_instance() { static $instance = null; if ( is_null( $instance ) ) { $instance = new self; $instance->setup_actions(); } return $instance; } private function setup_actions() { // Capture the comment field HTML. add_filter( 'comment_form_field_comment', array( $this, 'capture_comment_field' ), 999 ); // Dirty hack to move the comment field. add_filter( 'comment_form_submit_field', array( $this, 'hack_in_comment_field' ), 999 ); } public function capture_comment_field( $field ) { $this->comment_field = $field; return ''; } public function hack_in_comment_field( $submit_field ) { if ( $this->comment_field ) $submit_field = $this->comment_field . $submit_field; return $submit_field; } } JT_Revert_Comment_Field_Position::get_instance();
#6
@
9 years ago
- Keywords has-patch added; reporter-feedback 2nd-opinion removed
34731.patch introduces a comment_form_fields
filter for all the fields including the comment field, which allows for placing the comment field before, after, or even between other fields.
Moving the comment field to the bottom becomes trivial:
function wp34731_move_comment_field_to_bottom( $fields ) { $comment_field = $fields['comment']; unset( $fields['comment'] ); $fields['comment'] = $comment_field; return $fields; } add_filter( 'comment_form_fields', 'wp34731_move_comment_field_to_bottom' );
#7
@
9 years ago
34731.2.patch also moves $args['comment_notes_after']
to where it was before [34525]. Per the docs, it should be after all the fields (and before the submit button), not after the comment field.
#8
@
9 years ago
- Keywords commit added
Tested @SergeyBiryukov's patch and removed some extra whitespace between brackets in 34731.3.patch
This ticket was mentioned in Slack in #core by rachelbaker. View the logs.
9 years ago
This ticket was mentioned in Slack in #core by afercia. View the logs.
9 years ago
#11
follow-up:
↓ 12
@
9 years ago
- Keywords 2nd-opinion added; commit removed
Not 100% sure comment_notes_after
should be moved back at the bottom of the form. This was originally used for the default "You may use these HTML tags..." text displayed right after the comment textarea and recently removed. Looks like there are some plugins that are using it to display stuff after the textarea, so I'm guessing they would want their stuff output in the same, old, position. Any thoughts?
Some examples:
https://wordpress.org/plugins/open-social/ https://github.com/wp-plugins/open-social/blob/1268c7936c69f1cb8b981202a8cc6db396f78594/open-social.php#L1119 https://wordpress.org/plugins/rot13-encoderdecoder/ https://github.com/wp-plugins/rot13-encoderdecoder/blob/f7eccfad20a6fd5d78bb58fb5b3a7e7d6ce939a8/rot13-encoderdecoder.php#L124 https://wordpress.org/plugins/rating-widget/ https://github.com/wp-plugins/rating-widget/blob/6b959c80ac0213005c80a98b896c1fab1a5f65e9/rating-widget.php#L971 https://wordpress.org/plugins/yikes-inc-easy-mailchimp-extender/ https://github.com/wp-plugins/yikes-inc-easy-mailchimp-extender/blob/d479bc94f768134b842492af03b8e5e2d4be0493/classes/class.yksemeBase.php#L3451
#12
in reply to:
↑ 11
@
9 years ago
Replying to afercia:
This was originally used for the default "You may use these HTML tags..." text displayed right after the comment textarea and recently removed. Looks like there are some plugins that are using it to display stuff after the textarea, so I'm guessing they would want their stuff output in the same, old, position. Any thoughts?
Makes sense, 34731.patch is the way to go then.
We'll also need to update the Codex page and the inline docs, since they're incorrect now.
This ticket was mentioned in Slack in #core by afercia. View the logs.
9 years ago
#15
@
9 years ago
34731.4.patch adjusts the docs to better describe the current behaviour. It's not very consistent, but it's what we have:
$comment_notes_before
argument is displayed before the comment fields (including 'Comment'), *if the user is not logged in*.$comment_notes_after
argument is displayed after the 'Comment' field.comment_form_before_fields
action fires before the comment fields (excluding 'Comment').comment_form_after_fields
action fires after the comment fields (excluding 'Comment').
@DrewAPicture: Do you think some of this needs additional clarification?
@greenshady: Would the approach from comment:6 work for you?
Are you seeing particular problems as a result of the change in HTML? For example, broken comment form layouts, etc.