[wp-trac] [WordPress Trac] #46588: comment-reply JavaScript not working with comments loaded via Ajax
WordPress Trac
noreply at wordpress.org
Thu Apr 4 17:21:37 UTC 2019
#46588: comment-reply JavaScript not working with comments loaded via Ajax
--------------------------+------------------------------
Reporter: dcooney | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Comments | Version: 5.1
Severity: normal | Resolution:
Keywords: | Focuses: javascript
--------------------------+------------------------------
Comment (by dcooney):
Hi @peterwilsoncc,
Thanks and apologize for the delay as I was away.
I am using the [Ajax Load More](https://wordpress.org/plugins/ajax-load-
more/) plugin.
The plugin retrieves comments via Ajax using get_comments() and
wp_list_comments() functions.
It returns them via JSON and then appended to the DOM.
I am seeing this issue in all browsers. This issue was not present in WP
5.0.
The get_comment_reply_link() function has been modified and creates issues
with the href on the 'Reply' button and the mutation event is working
causing a browser link action to trigger.
Replacing:
{{{
$link = sprintf(
"<a rel='nofollow' class='comment-reply-link' href='%s' %s aria-
label='%s'>%s</a>",
esc_url(
add_query_arg(
array(
'replytocom' => $comment->comment_ID,
'unapproved' => false,
'moderation-hash' => false,
)
)
) . '#' . $args['respond_id'],
$data_attribute_string,
esc_attr( sprintf( $args['reply_to_text'],
$comment->comment_author ) ),
$args['reply_text']
);
}}}
with:
{{{
$onclick = sprintf( 'return addComment.moveForm( "%1$s-%2$s", "%2$s",
"%3$s", "%4$s" )',
$args['add_below'], $comment->comment_ID, $args['respond_id'],
$post->ID
);
$link = sprintf( "<a rel='nofollow' class='comment-reply-link' href='%s'
onclick='%s' aria-label='%s'>%s</a>",
esc_url( add_query_arg( 'replytocom', $comment->comment_ID,
get_permalink( $post->ID ) ) ) . "#" . $args['respond_id'],
$onclick,
esc_attr( sprintf( $args['reply_to_text'],
$comment->comment_author ) ),
$args['reply_text']
);
}}}
from 5.0 fixes the issue.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/46588#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list