@@ -1733,19 +1733,23 @@ function comments_popup_link( $zero = false, $one = false, $more = false, $css_c
1733
1733
* @param array $args {
1734
1734
* Optional. Override default arguments.
1735
1735
*
1736
- * @type string $add_below The first part of the selector used to identify the comment to respond below.
1737
- * The resulting value is passed as the first parameter to addComment.moveForm(),
1738
- * concatenated as $add_below-$comment->comment_ID. Default 'comment'.
1739
- * @type string $respond_id The selector identifying the responding comment. Passed as the third parameter
1740
- * to addComment.moveForm(), and appended to the link URL as a hash value.
1741
- * Default 'respond'.
1742
- * @type string $reply_text The text of the Reply link. Default 'Reply'.
1743
- * @type string $login_text The text of the link to reply if logged out. Default 'Log in to Reply'.
1744
- * @type int $max_depth The max depth of the comment tree. Default 0.
1745
- * @type int $depth The depth of the new comment. Must be greater than 0 and less than the value
1746
- * of the 'thread_comments_depth' option set in Settings > Discussion. Default 0.
1747
- * @type string $before The text or HTML to add before the reply link. Default empty.
1748
- * @type string $after The text or HTML to add after the reply link. Default empty.
1736
+ * @type string $add_below The first part of the selector used to identify the comment to respond below.
1737
+ * The resulting value is passed as the first parameter to addComment.moveForm(),
1738
+ * concatenated as $add_below-$comment->comment_ID. Default 'comment'.
1739
+ * @type string $respond_id The selector identifying the responding comment. Passed as the third parameter
1740
+ * to addComment.moveForm(), and appended to the link URL as a hash value.
1741
+ * Default 'respond'.
1742
+ * @type string $reply_text The visible text of the Reply link. Default 'Reply'.
1743
+ * @type string $reply_to_text The accessible name of the Reply link, using `%s` as a placeholder
1744
+ * for the comment author's name. Default 'Reply to %s'.
1745
+ * Should start with the visible `reply_text` value.
1746
+ * @type bool $show_reply_to_text Whether to use `reply_to_text` as visible link text. Default false.
1747
+ * @type string $login_text The text of the link to reply if logged out. Default 'Log in to Reply'.
1748
+ * @type int $max_depth The max depth of the comment tree. Default 0.
1749
+ * @type int $depth The depth of the new comment. Must be greater than 0 and less than the value
1750
+ * of the 'thread_comments_depth' option set in Settings > Discussion. Default 0.
1751
+ * @type string $before The text or HTML to add before the reply link. Default empty.
1752
+ * @type string $after The text or HTML to add after the reply link. Default empty.
1749
1753
* }
1750
1754
* @param int|WP_Comment $comment Optional. Comment being replied to. Default current comment.
1751
1755
* @param int|WP_Post $post Optional. Post ID or WP_Post object the comment is going to be displayed on.
@@ -1754,16 +1758,17 @@ function comments_popup_link( $zero = false, $one = false, $more = false, $css_c
1754
1758
*/
1755
1759
function get_comment_reply_link ( $ args = array (), $ comment = null , $ post = null ) {
1756
1760
$ defaults = array (
1757
- 'add_below ' => 'comment ' ,
1758
- 'respond_id ' => 'respond ' ,
1759
- 'reply_text ' => __ ( 'Reply ' ),
1761
+ 'add_below ' => 'comment ' ,
1762
+ 'respond_id ' => 'respond ' ,
1763
+ 'reply_text ' => __ ( 'Reply ' ),
1760
1764
/* translators: Comment reply button text. %s: Comment author name. */
1761
- 'reply_to_text ' => __ ( 'Reply to %s ' ),
1762
- 'login_text ' => __ ( 'Log in to Reply ' ),
1763
- 'max_depth ' => 0 ,
1764
- 'depth ' => 0 ,
1765
- 'before ' => '' ,
1766
- 'after ' => '' ,
1765
+ 'reply_to_text ' => __ ( 'Reply to %s ' ),
1766
+ 'login_text ' => __ ( 'Log in to Reply ' ),
1767
+ 'max_depth ' => 0 ,
1768
+ 'depth ' => 0 ,
1769
+ 'before ' => '' ,
1770
+ 'after ' => '' ,
1771
+ 'show_reply_to_text ' => false ,
1767
1772
);
1768
1773
1769
1774
$ args = wp_parse_args ( $ args , $ defaults );
@@ -1829,8 +1834,14 @@ function get_comment_reply_link( $args = array(), $comment = null, $post = null
1829
1834
1830
1835
$ data_attribute_string = trim ( $ data_attribute_string );
1831
1836
1837
+ $ reply_text = $ args ['show_reply_to_text ' ]
1838
+ ? sprintf ( $ args ['reply_to_text ' ], get_comment_author ( $ comment ) )
1839
+ : $ args ['reply_text ' ];
1840
+
1841
+ $ aria_label = $ args ['show_reply_to_text ' ] ? '' : sprintf ( $ args ['reply_to_text ' ], get_comment_author ( $ comment ) );
1842
+
1832
1843
$ link = sprintf (
1833
- " <a rel=' nofollow' class=' comment-reply-link' href='%s' %s aria-label='%s' >%s</a> " ,
1844
+ ' <a rel=" nofollow" class=" comment-reply-link" href="%s" %s%s >%s</a> ' ,
1834
1845
esc_url (
1835
1846
add_query_arg (
1836
1847
array (
@@ -1842,8 +1853,8 @@ function get_comment_reply_link( $args = array(), $comment = null, $post = null
1842
1853
)
1843
1854
) . '# ' . $ args ['respond_id ' ],
1844
1855
$ data_attribute_string ,
1845
- esc_attr ( sprintf ( $ args [ ' reply_to_text ' ], get_comment_author ( $ comment ) ) ) ,
1846
- $ args [ ' reply_text ' ]
1856
+ $ aria_label ? ' aria-label=" ' . esc_attr ( $ aria_label ) . ' " ' : '' ,
1857
+ $ reply_text
1847
1858
);
1848
1859
}
1849
1860
@@ -2089,15 +2100,15 @@ function comment_id_fields( $post = null ) {
2089
2100
*
2090
2101
* @global WP_Comment $comment Global comment object.
2091
2102
*
2092
- * @param string|false $no_reply_text Optional. Text to display when not replying to a comment.
2093
- * Default false.
2094
- * @param string|false $reply_text Optional. Text to display when replying to a comment.
2095
- * Default false. Accepts "%s" for the author of the comment
2096
- * being replied to.
2097
- * @param bool $link_to_parent Optional. Boolean to control making the author's name a link
2098
- * to their comment. Default true.
2099
- * @param int|WP_Post|null $post Optional. The post that the comment form is being displayed for.
2100
- * Defaults to the current global post.
2103
+ * @param string|false $no_reply_text Optional. Text to display when not replying to a comment.
2104
+ * Default false.
2105
+ * @param string|false $reply_text Optional. Text to display when replying to a comment.
2106
+ * Default false. Accepts "%s" for the author of the comment
2107
+ * being replied to.
2108
+ * @param bool $link_to_parent Optional. Boolean to control making the author's name a link
2109
+ * to their comment. Default true.
2110
+ * @param int|WP_Post|null $post Optional. The post that the comment form is being displayed for.
2111
+ * Defaults to the current global post.
2101
2112
*/
2102
2113
function comment_form_title ( $ no_reply_text = false , $ reply_text = false , $ link_to_parent = true , $ post = null ) {
2103
2114
global $ comment ;
0 commit comments