wp/wp-includes/comment-template.php
changeset 7 cf61fcea0001
parent 5 5e2f62d02dcd
child 9 177826044cd9
equal deleted inserted replaced
6:490d5cc509ed 7:cf61fcea0001
    13  *
    13  *
    14  * If the comment has an empty comment_author field, then 'Anonymous' person is
    14  * If the comment has an empty comment_author field, then 'Anonymous' person is
    15  * assumed.
    15  * assumed.
    16  *
    16  *
    17  * @since 1.5.0
    17  * @since 1.5.0
    18  *
    18  * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
    19  * @param int $comment_ID Optional. The ID of the comment for which to retrieve the author. Default current comment.
    19  *
       
    20  * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to retrieve the author.
       
    21  *									 Default current comment.
    20  * @return string The comment author
    22  * @return string The comment author
    21  */
    23  */
    22 function get_comment_author( $comment_ID = 0 ) {
    24 function get_comment_author( $comment_ID = 0 ) {
    23 	$comment = get_comment( $comment_ID );
    25 	$comment = get_comment( $comment_ID );
    24 
    26 
    30 	} else {
    32 	} else {
    31 		$author = $comment->comment_author;
    33 		$author = $comment->comment_author;
    32 	}
    34 	}
    33 
    35 
    34 	/**
    36 	/**
    35 	 * Filter the returned comment author name.
    37 	 * Filters the returned comment author name.
    36 	 *
    38 	 *
    37 	 * @since 1.5.0
    39 	 * @since 1.5.0
    38 	 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added.
    40 	 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added.
    39 	 *
    41 	 *
       
    42 	 * @param string     $author     The comment author's username.
       
    43 	 * @param int        $comment_ID The comment ID.
       
    44 	 * @param WP_Comment $comment    The comment object.
       
    45 	 */
       
    46 	return apply_filters( 'get_comment_author', $author, $comment->comment_ID, $comment );
       
    47 }
       
    48 
       
    49 /**
       
    50  * Displays the author of the current comment.
       
    51  *
       
    52  * @since 0.71
       
    53  * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
       
    54  *
       
    55  * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author.
       
    56  *									 Default current comment.
       
    57  */
       
    58 function comment_author( $comment_ID = 0 ) {
       
    59 	$comment = get_comment( $comment_ID );
       
    60 	$author  = get_comment_author( $comment );
       
    61 
       
    62 	/**
       
    63 	 * Filters the comment author's name for display.
       
    64 	 *
       
    65 	 * @since 1.2.0
       
    66 	 * @since 4.1.0 The `$comment_ID` parameter was added.
       
    67 	 *
    40 	 * @param string $author     The comment author's username.
    68 	 * @param string $author     The comment author's username.
    41 	 * @param int    $comment_ID The comment ID.
    69 	 * @param int    $comment_ID The comment ID.
    42 	 * @param object $comment    The comment object.
    70 	 */
    43 	 */
    71 	echo apply_filters( 'comment_author', $author, $comment->comment_ID );
    44 	return apply_filters( 'get_comment_author', $author, $comment_ID, $comment );
    72 }
    45 }
    73 
    46 
    74 /**
    47 /**
    75  * Retrieve the email of the author of the current comment.
    48  * Displays the author of the current comment.
    76  *
       
    77  * @since 1.5.0
       
    78  * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
       
    79  *
       
    80  * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to get the author's email.
       
    81  *									 Default current comment.
       
    82  * @return string The current comment author's email
       
    83  */
       
    84 function get_comment_author_email( $comment_ID = 0 ) {
       
    85 	$comment = get_comment( $comment_ID );
       
    86 
       
    87 	/**
       
    88 	 * Filters the comment author's returned email address.
       
    89 	 *
       
    90 	 * @since 1.5.0
       
    91 	 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added.
       
    92 	 *
       
    93 	 * @param string     $comment_author_email The comment author's email address.
       
    94 	 * @param int        $comment_ID           The comment ID.
       
    95 	 * @param WP_Comment $comment              The comment object.
       
    96 	 */
       
    97 	return apply_filters( 'get_comment_author_email', $comment->comment_author_email, $comment->comment_ID, $comment );
       
    98 }
       
    99 
       
   100 /**
       
   101  * Display the email of the author of the current global $comment.
       
   102  *
       
   103  * Care should be taken to protect the email address and assure that email
       
   104  * harvesters do not capture your commentors' email address. Most assume that
       
   105  * their email address will not appear in raw form on the site. Doing so will
       
   106  * enable anyone, including those that people don't want to get the email
       
   107  * address and use it for their own means good and bad.
    49  *
   108  *
    50  * @since 0.71
   109  * @since 0.71
    51  *
   110  * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
    52  * @param int $comment_ID Optional. The ID of the comment for which to print the author. Default current comment.
   111  *
    53  */
   112  * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author's email.
    54 function comment_author( $comment_ID = 0 ) {
   113  *									 Default current comment.
    55 	$author = get_comment_author( $comment_ID );
   114  */
    56 
   115 function comment_author_email( $comment_ID = 0 ) {
    57 	/**
   116 	$comment      = get_comment( $comment_ID );
    58 	 * Filter the comment author's name for display.
   117 	$author_email = get_comment_author_email( $comment );
       
   118 
       
   119 	/**
       
   120 	 * Filters the comment author's email for display.
    59 	 *
   121 	 *
    60 	 * @since 1.2.0
   122 	 * @since 1.2.0
    61 	 * @since 4.1.0 The `$comment_ID` parameter was added.
   123 	 * @since 4.1.0 The `$comment_ID` parameter was added.
    62 	 *
   124 	 *
    63 	 * @param string $author     The comment author's username.
   125 	 * @param string $author_email The comment author's email address.
    64 	 * @param int    $comment_ID The comment ID.
   126 	 * @param int    $comment_ID   The comment ID.
    65 	 */
   127 	 */
    66 	$author = apply_filters( 'comment_author', $author, $comment_ID );
   128 	echo apply_filters( 'author_email', $author_email, $comment->comment_ID );
    67 	echo $author;
   129 }
    68 }
   130 
    69 
   131 /**
    70 /**
   132  * Display the html email link to the author of the current comment.
    71  * Retrieve the email of the author of the current comment.
       
    72  *
       
    73  * @since 1.5.0
       
    74  *
       
    75  * @param int $comment_ID Optional. The ID of the comment for which to get the author's email. Default current comment.
       
    76  * @return string The current comment author's email
       
    77  */
       
    78 function get_comment_author_email( $comment_ID = 0 ) {
       
    79 	$comment = get_comment( $comment_ID );
       
    80 
       
    81 	/**
       
    82 	 * Filter the comment author's returned email address.
       
    83 	 *
       
    84 	 * @since 1.5.0
       
    85 	 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added.
       
    86 	 *
       
    87 	 * @param string $comment_author_email The comment author's email address.
       
    88 	 * @param int    $comment_ID           The comment ID.
       
    89 	 * @param object $comment              The comment object.
       
    90 	 */
       
    91 	return apply_filters( 'get_comment_author_email', $comment->comment_author_email, $comment_ID, $comment );
       
    92 }
       
    93 
       
    94 /**
       
    95  * Display the email of the author of the current global $comment.
       
    96  *
   133  *
    97  * Care should be taken to protect the email address and assure that email
   134  * Care should be taken to protect the email address and assure that email
    98  * harvesters do not capture your commentors' email address. Most assume that
   135  * harvesters do not capture your commentors' email address. Most assume that
    99  * their email address will not appear in raw form on the blog. Doing so will
   136  * their email address will not appear in raw form on the site. Doing so will
   100  * enable anyone, including those that people don't want to get the email
   137  * enable anyone, including those that people don't want to get the email
   101  * address and use it for their own means good and bad.
   138  * address and use it for their own means good and bad.
   102  *
   139  *
   103  * @since 0.71
   140  * @since 0.71
   104  *
   141  * @since 4.6.0 Added the `$comment` parameter.
   105  * @param int $comment_ID Optional. The ID of the comment for which to print the author's email. Default current comment.
   142  *
   106  */
   143  * @param string         $linktext Optional. Text to display instead of the comment author's email address.
   107 function comment_author_email( $comment_ID = 0 ) {
   144  *                                 Default empty.
   108 	$author_email = get_comment_author_email( $comment_ID );
   145  * @param string         $before   Optional. Text or HTML to display before the email link. Default empty.
   109 
   146  * @param string         $after    Optional. Text or HTML to display after the email link. Default empty.
   110 	/**
   147  * @param int|WP_Comment $comment  Optional. Comment ID or WP_Comment object. Default is the current comment.
   111 	 * Filter the comment author's email for display.
   148  */
   112 	 *
   149 function comment_author_email_link( $linktext = '', $before = '', $after = '', $comment = null ) {
   113 	 * @since 1.2.0
   150 	if ( $link = get_comment_author_email_link( $linktext, $before, $after, $comment ) ) {
   114 	 * @since 4.1.0 The `$comment_ID` parameter was added.
   151 		echo $link;
   115 	 *
   152 	}
   116 	 * @param string $author_email The comment author's email address.
   153 }
   117 	 * @param int    $comment_ID   The comment ID.
   154 
   118 	 */
   155 /**
   119 	echo apply_filters( 'author_email', $author_email, $comment_ID );
   156  * Return the html email link to the author of the current comment.
   120 }
       
   121 
       
   122 /**
       
   123  * Display the html email link to the author of the current comment.
       
   124  *
   157  *
   125  * Care should be taken to protect the email address and assure that email
   158  * Care should be taken to protect the email address and assure that email
   126  * harvesters do not capture your commentors' email address. Most assume that
   159  * harvesters do not capture your commentors' email address. Most assume that
   127  * their email address will not appear in raw form on the blog. Doing so will
   160  * their email address will not appear in raw form on the site. Doing so will
   128  * enable anyone, including those that people don't want to get the email
   161  * enable anyone, including those that people don't want to get the email
   129  * address and use it for their own means good and bad.
   162  * address and use it for their own means good and bad.
   130  *
   163  *
   131  * @since 0.71
       
   132  *
       
   133  * @param string $linktext Optional. Text to display instead of the comment author's email address.
       
   134  *                         Default empty.
       
   135  * @param string $before   Optional. Text or HTML to display before the email link. Default empty.
       
   136  * @param string $after    Optional. Text or HTML to display after the email link. Default empty.
       
   137  */
       
   138 function comment_author_email_link( $linktext = '', $before = '', $after = '' ) {
       
   139 	if ( $link = get_comment_author_email_link( $linktext, $before, $after ) )
       
   140 		echo $link;
       
   141 }
       
   142 
       
   143 /**
       
   144  * Return the html email link to the author of the current comment.
       
   145  *
       
   146  * Care should be taken to protect the email address and assure that email
       
   147  * harvesters do not capture your commentors' email address. Most assume that
       
   148  * their email address will not appear in raw form on the blog. Doing so will
       
   149  * enable anyone, including those that people don't want to get the email
       
   150  * address and use it for their own means good and bad.
       
   151  *
       
   152  * @global object $comment The current Comment row object.
       
   153  *
       
   154  * @since 2.7.0
   164  * @since 2.7.0
   155  *
   165  * @since 4.6.0 Added the `$comment` parameter.
   156  * @param string $linktext Optional. Text to display instead of the comment author's email address.
   166  *
   157  *                         Default empty.
   167  * @param string         $linktext Optional. Text to display instead of the comment author's email address.
   158  * @param string $before   Optional. Text or HTML to display before the email link. Default empty.
   168  *                                 Default empty.
   159  * @param string $after    Optional. Text or HTML to display after the email link. Default empty.
   169  * @param string         $before   Optional. Text or HTML to display before the email link. Default empty.
   160  */
   170  * @param string         $after    Optional. Text or HTML to display after the email link. Default empty.
   161 function get_comment_author_email_link( $linktext = '', $before = '', $after = '' ) {
   171  * @param int|WP_Comment $comment  Optional. Comment ID or WP_Comment object. Default is the current comment.
   162 	global $comment;
   172  * @return string HTML markup for the comment author email link. By default, the email address is obfuscated
   163 
   173  *                via the {@see 'comment_email'} filter with antispambot().
   164 	/**
   174  */
   165 	 * Filter the comment author's email for display.
   175 function get_comment_author_email_link( $linktext = '', $before = '', $after = '', $comment = null ) {
       
   176 	$comment = get_comment( $comment );
       
   177 
       
   178 	/**
       
   179 	 * Filters the comment author's email for display.
   166 	 *
   180 	 *
   167 	 * Care should be taken to protect the email address and assure that email
   181 	 * Care should be taken to protect the email address and assure that email
   168 	 * harvesters do not capture your commenter's email address.
   182 	 * harvesters do not capture your commenter's email address.
   169 	 *
   183 	 *
   170 	 * @since 1.2.0
   184 	 * @since 1.2.0
   171 	 * @since 4.1.0 The `$comment` parameter was added.
   185 	 * @since 4.1.0 The `$comment` parameter was added.
   172 	 *
   186 	 *
   173 	 * @param string $comment_author_email The comment author's email address.
   187 	 * @param string     $comment_author_email The comment author's email address.
   174 	 * @param object $comment              The comment object.
   188 	 * @param WP_Comment $comment              The comment object.
   175 	 */
   189 	 */
   176 	$email = apply_filters( 'comment_email', $comment->comment_author_email, $comment );
   190 	$email = apply_filters( 'comment_email', $comment->comment_author_email, $comment );
       
   191 
   177 	if ((!empty($email)) && ($email != '@')) {
   192 	if ((!empty($email)) && ($email != '@')) {
   178 	$display = ($linktext != '') ? $linktext : $email;
   193 	$display = ($linktext != '') ? $linktext : $email;
   179 		$return  = $before;
   194 		$return  = $before;
   180 		$return .= "<a href='mailto:$email'>$display</a>";
   195 		$return .= sprintf( '<a href="%1$s">%2$s</a>', esc_url( 'mailto:' . $email ), esc_html( $display ) );
   181 	 	$return .= $after;
   196 	 	$return .= $after;
   182 		return $return;
   197 		return $return;
   183 	} else {
   198 	} else {
   184 		return '';
   199 		return '';
   185 	}
   200 	}
   190  *
   205  *
   191  * Both get_comment_author_url() and get_comment_author() rely on get_comment(),
   206  * Both get_comment_author_url() and get_comment_author() rely on get_comment(),
   192  * which falls back to the global comment variable if the $comment_ID argument is empty.
   207  * which falls back to the global comment variable if the $comment_ID argument is empty.
   193  *
   208  *
   194  * @since 1.5.0
   209  * @since 1.5.0
   195  *
   210  * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
   196  * @param int $comment_ID ID of the comment for which to get the author's link.
   211  *
   197  *                        Default current comment.
   212  * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to get the author's link.
       
   213  *									 Default current comment.
   198  * @return string The comment author name or HTML link for author's URL.
   214  * @return string The comment author name or HTML link for author's URL.
   199  */
   215  */
   200 function get_comment_author_link( $comment_ID = 0 ) {
   216 function get_comment_author_link( $comment_ID = 0 ) {
   201 	$url    = get_comment_author_url( $comment_ID );
   217 	$comment = get_comment( $comment_ID );
   202 	$author = get_comment_author( $comment_ID );
   218 	$url     = get_comment_author_url( $comment );
       
   219 	$author  = get_comment_author( $comment );
   203 
   220 
   204 	if ( empty( $url ) || 'http://' == $url )
   221 	if ( empty( $url ) || 'http://' == $url )
   205 		$return = $author;
   222 		$return = $author;
   206 	else
   223 	else
   207 		$return = "<a href='$url' rel='external nofollow' class='url'>$author</a>";
   224 		$return = "<a href='$url' rel='external nofollow' class='url'>$author</a>";
   208 
   225 
   209 	/**
   226 	/**
   210 	 * Filter the comment author's link for display.
   227 	 * Filters the comment author's link for display.
   211 	 *
   228 	 *
   212 	 * @since 1.5.0
   229 	 * @since 1.5.0
   213 	 * @since 4.1.0 The `$author` and `$comment_ID` parameters were added.
   230 	 * @since 4.1.0 The `$author` and `$comment_ID` parameters were added.
   214 	 *
   231 	 *
   215 	 * @param string $return     The HTML-formatted comment author link.
   232 	 * @param string $return     The HTML-formatted comment author link.
   216 	 *                           Empty for an invalid URL.
   233 	 *                           Empty for an invalid URL.
   217 	 * @param string $author     The comment author's username.
   234 	 * @param string $author     The comment author's username.
   218 	 * @param int    $comment_ID The comment ID.
   235 	 * @param int    $comment_ID The comment ID.
   219 	 */
   236 	 */
   220 	return apply_filters( 'get_comment_author_link', $return, $author, $comment_ID );
   237 	return apply_filters( 'get_comment_author_link', $return, $author, $comment->comment_ID );
   221 }
   238 }
   222 
   239 
   223 /**
   240 /**
   224  * Display the html link to the url of the author of the current comment.
   241  * Display the html link to the url of the author of the current comment.
   225  *
   242  *
   226  * @since 0.71
   243  * @since 0.71
   227  *
   244  * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
   228  * @see get_comment_author_link() Echoes result
   245  *
   229  *
   246  * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author's link.
   230  * @param int $comment_ID ID of the comment for which to print the author's
   247  *									 Default current comment.
   231  *                        link. Default current comment.
       
   232  */
   248  */
   233 function comment_author_link( $comment_ID = 0 ) {
   249 function comment_author_link( $comment_ID = 0 ) {
   234 	echo get_comment_author_link( $comment_ID );
   250 	echo get_comment_author_link( $comment_ID );
   235 }
   251 }
   236 
   252 
   237 /**
   253 /**
   238  * Retrieve the IP address of the author of the current comment.
   254  * Retrieve the IP address of the author of the current comment.
   239  *
   255  *
   240  * @since 1.5.0
   256  * @since 1.5.0
   241  *
   257  * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
   242  * @param int $comment_ID ID of the comment for which to get the author's IP
   258  *
   243  *                        address. Default current comment.
   259  * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to get the author's IP address.
       
   260  *									 Default current comment.
   244  * @return string Comment author's IP address.
   261  * @return string Comment author's IP address.
   245  */
   262  */
   246 function get_comment_author_IP( $comment_ID = 0 ) {
   263 function get_comment_author_IP( $comment_ID = 0 ) {
   247 	$comment = get_comment( $comment_ID );
   264 	$comment = get_comment( $comment_ID );
   248 
   265 
   249 	/**
   266 	/**
   250 	 * Filter the comment author's returned IP address.
   267 	 * Filters the comment author's returned IP address.
   251 	 *
   268 	 *
   252 	 * @since 1.5.0
   269 	 * @since 1.5.0
   253 	 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added.
   270 	 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added.
   254 	 *
   271 	 *
   255 	 * @param string $comment_author_IP The comment author's IP address.
   272 	 * @param string     $comment_author_IP The comment author's IP address.
   256 	 * @param int    $comment_ID        The comment ID.
   273 	 * @param int        $comment_ID        The comment ID.
   257 	 * @param object $comment           The comment object.
   274 	 * @param WP_Comment $comment           The comment object.
   258 	 */
   275 	 */
   259 	return apply_filters( 'get_comment_author_IP', $comment->comment_author_IP, $comment_ID, $comment );
   276 	return apply_filters( 'get_comment_author_IP', $comment->comment_author_IP, $comment->comment_ID, $comment );
   260 }
   277 }
   261 
   278 
   262 /**
   279 /**
   263  * Display the IP address of the author of the current comment.
   280  * Display the IP address of the author of the current comment.
   264  *
   281  *
   265  * @since 0.71
   282  * @since 0.71
   266  *
   283  * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
   267  * @param int $comment_ID ID of the comment for which to print the author's IP
   284  *
   268  *                        address. Default current comment.
   285  * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author's IP address.
       
   286  *									 Default current comment.
   269  */
   287  */
   270 function comment_author_IP( $comment_ID = 0 ) {
   288 function comment_author_IP( $comment_ID = 0 ) {
   271 	echo get_comment_author_IP( $comment_ID );
   289 	echo esc_html( get_comment_author_IP( $comment_ID ) );
   272 }
   290 }
   273 
   291 
   274 /**
   292 /**
   275  * Retrieve the url of the author of the current comment.
   293  * Retrieve the url of the author of the current comment.
   276  *
   294  *
   277  * @since 1.5.0
   295  * @since 1.5.0
   278  *
   296  * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
   279  * @param int $comment_ID ID of the comment for which to get the author's URL.
   297  *
   280  *                        Default current comment.
   298  * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to get the author's URL.
   281  * @return string
   299  *									 Default current comment.
       
   300  * @return string Comment author URL.
   282  */
   301  */
   283 function get_comment_author_url( $comment_ID = 0 ) {
   302 function get_comment_author_url( $comment_ID = 0 ) {
   284 	$comment = get_comment( $comment_ID );
   303 	$comment = get_comment( $comment_ID );
   285 	$url = ('http://' == $comment->comment_author_url) ? '' : $comment->comment_author_url;
   304 	$url = '';
   286 	$url = esc_url( $url, array('http', 'https') );
   305 	$id = 0;
   287 
   306 	if ( ! empty( $comment ) ) {
   288 	/**
   307 		$author_url = ( 'http://' == $comment->comment_author_url ) ? '' : $comment->comment_author_url;
   289 	 * Filter the comment author's URL.
   308 		$url = esc_url( $author_url, array( 'http', 'https' ) );
       
   309 		$id = $comment->comment_ID;
       
   310 	}
       
   311 
       
   312 	/**
       
   313 	 * Filters the comment author's URL.
   290 	 *
   314 	 *
   291 	 * @since 1.5.0
   315 	 * @since 1.5.0
   292 	 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added.
   316 	 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added.
   293 	 *
   317 	 *
   294 	 * @param string $url        The comment author's URL.
   318 	 * @param string     $url        The comment author's URL.
   295 	 * @param int    $comment_ID The comment ID.
   319 	 * @param int        $comment_ID The comment ID.
   296 	 * @param object $comment    The comment object.
   320 	 * @param WP_Comment $comment    The comment object.
   297 	 */
   321 	 */
   298 	return apply_filters( 'get_comment_author_url', $url, $comment_ID, $comment );
   322 	return apply_filters( 'get_comment_author_url', $url, $id, $comment );
   299 }
   323 }
   300 
   324 
   301 /**
   325 /**
   302  * Display the url of the author of the current comment.
   326  * Display the url of the author of the current comment.
   303  *
   327  *
   304  * @since 0.71
   328  * @since 0.71
   305  *
   329  * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
   306  * @param int $comment_ID ID of the comment for which to print the author's URL.
   330  *
   307  *                        Default current comment.
   331  * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author's URL.
       
   332  *									 Default current comment.
   308  */
   333  */
   309 function comment_author_url( $comment_ID = 0 ) {
   334 function comment_author_url( $comment_ID = 0 ) {
   310 	$author_url = get_comment_author_url( $comment_ID );
   335 	$comment    = get_comment( $comment_ID );
   311 
   336 	$author_url = get_comment_author_url( $comment );
   312 	/**
   337 
   313 	 * Filter the comment author's URL for display.
   338 	/**
       
   339 	 * Filters the comment author's URL for display.
   314 	 *
   340 	 *
   315 	 * @since 1.2.0
   341 	 * @since 1.2.0
   316 	 * @since 4.1.0 The `$comment_ID` parameter was added.
   342 	 * @since 4.1.0 The `$comment_ID` parameter was added.
   317 	 *
   343 	 *
   318 	 * @param string $author_url The comment author's URL.
   344 	 * @param string $author_url The comment author's URL.
   319 	 * @param int    $comment_ID The comment ID.
   345 	 * @param int    $comment_ID The comment ID.
   320 	 */
   346 	 */
   321 	echo apply_filters( 'comment_url', $author_url, $comment_ID );
   347 	echo apply_filters( 'comment_url', $author_url, $comment->comment_ID );
   322 }
   348 }
   323 
   349 
   324 /**
   350 /**
   325  * Retrieves the HTML link of the url of the author of the current comment.
   351  * Retrieves the HTML link of the url of the author of the current comment.
   326  *
   352  *
   330  *
   356  *
   331  * Encapsulate the HTML link between the $before and $after. So it will appear
   357  * Encapsulate the HTML link between the $before and $after. So it will appear
   332  * in the order of $before, link, and finally $after.
   358  * in the order of $before, link, and finally $after.
   333  *
   359  *
   334  * @since 1.5.0
   360  * @since 1.5.0
   335  *
   361  * @since 4.6.0 Added the `$comment` parameter.
   336  * @param string $linktext Optional. The text to display instead of the comment
   362  *
   337  *                         author's email address. Default empty.
   363  * @param string         $linktext Optional. The text to display instead of the comment
   338  * @param string $before   Optional. The text or HTML to display before the email link.
   364  *                                 author's email address. Default empty.
   339  *                         Default empty.
   365  * @param string         $before   Optional. The text or HTML to display before the email link.
   340  * @param string $after    Optional. The text or HTML to display after the email link.
   366  *                                 Default empty.
   341  *                         Default empty.
   367  * @param string         $after    Optional. The text or HTML to display after the email link.
       
   368  *                                 Default empty.
       
   369  * @param int|WP_Comment $comment  Optional. Comment ID or WP_Comment object.
       
   370  *                                 Default is the current comment.
   342  * @return string The HTML link between the $before and $after parameters.
   371  * @return string The HTML link between the $before and $after parameters.
   343  */
   372  */
   344 function get_comment_author_url_link( $linktext = '', $before = '', $after = '' ) {
   373 function get_comment_author_url_link( $linktext = '', $before = '', $after = '', $comment = 0 ) {
   345 	$url = get_comment_author_url();
   374 	$url = get_comment_author_url( $comment );
   346 	$display = ($linktext != '') ? $linktext : $url;
   375 	$display = ($linktext != '') ? $linktext : $url;
   347 	$display = str_replace( 'http://www.', '', $display );
   376 	$display = str_replace( 'http://www.', '', $display );
   348 	$display = str_replace( 'http://', '', $display );
   377 	$display = str_replace( 'http://', '', $display );
   349 
   378 
   350 	if ( '/' == substr($display, -1) ) {
   379 	if ( '/' == substr($display, -1) ) {
   352 	}
   381 	}
   353 
   382 
   354 	$return = "$before<a href='$url' rel='external'>$display</a>$after";
   383 	$return = "$before<a href='$url' rel='external'>$display</a>$after";
   355 
   384 
   356 	/**
   385 	/**
   357 	 * Filter the comment author's returned URL link.
   386 	 * Filters the comment author's returned URL link.
   358 	 *
   387 	 *
   359 	 * @since 1.5.0
   388 	 * @since 1.5.0
   360 	 *
   389 	 *
   361 	 * @param string $return The HTML-formatted comment author URL link.
   390 	 * @param string $return The HTML-formatted comment author URL link.
   362 	 */
   391 	 */
   365 
   394 
   366 /**
   395 /**
   367  * Displays the HTML link of the url of the author of the current comment.
   396  * Displays the HTML link of the url of the author of the current comment.
   368  *
   397  *
   369  * @since 0.71
   398  * @since 0.71
   370  *
   399  * @since 4.6.0 Added the `$comment` parameter.
   371  * @param string $linktext Optional. Text to display instead of the comment author's
   400  *
   372  *                         email address. Default empty.
   401  * @param string         $linktext Optional. Text to display instead of the comment author's
   373  * @param string $before   Optional. Text or HTML to display before the email link.
   402  *                                 email address. Default empty.
   374  *                         Default empty.
   403  * @param string         $before   Optional. Text or HTML to display before the email link.
   375  * @param string $after    Optional. Text or HTML to display after the email link.
   404  *                                 Default empty.
   376  *                         Default empty.
   405  * @param string         $after    Optional. Text or HTML to display after the email link.
   377  */
   406  *                                 Default empty.
   378 function comment_author_url_link( $linktext = '', $before = '', $after = '' ) {
   407  * @param int|WP_Comment $comment  Optional. Comment ID or WP_Comment object.
   379 	echo get_comment_author_url_link( $linktext, $before, $after );
   408  *                                 Default is the current comment.
       
   409  */
       
   410 function comment_author_url_link( $linktext = '', $before = '', $after = '', $comment = 0 ) {
       
   411 	echo get_comment_author_url_link( $linktext, $before, $after, $comment );
   380 }
   412 }
   381 
   413 
   382 /**
   414 /**
   383  * Generates semantic classes for each comment element.
   415  * Generates semantic classes for each comment element.
   384  *
   416  *
   385  * @since 2.7.0
   417  * @since 2.7.0
   386  *
   418  * @since 4.4.0 Added the ability for `$comment` to also accept a WP_Comment object.
   387  * @param string|array $class      Optional. One or more classes to add to the class list.
   419  *
       
   420  * @param string|array   $class    Optional. One or more classes to add to the class list.
   388  *                                 Default empty.
   421  *                                 Default empty.
   389  * @param int          $comment_id Comment ID. Default current comment.
   422  * @param int|WP_Comment $comment  Comment ID or WP_Comment object. Default current comment.
   390  * @param int|WP_Post  $post_id    Post ID or WP_Post object. Default current post.
   423  * @param int|WP_Post    $post_id  Post ID or WP_Post object. Default current post.
   391  * @param bool         $echo       Optional. Whether to cho or return the output.
   424  * @param bool           $echo     Optional. Whether to cho or return the output.
   392  *                                 Default true.
   425  *                                 Default true.
   393  */
   426  * @return string If `$echo` is false, the class will be returned. Void otherwise.
   394 function comment_class( $class = '', $comment_id = null, $post_id = null, $echo = true ) {
   427  */
       
   428 function comment_class( $class = '', $comment = null, $post_id = null, $echo = true ) {
   395 	// Separates classes with a single space, collates classes for comment DIV
   429 	// Separates classes with a single space, collates classes for comment DIV
   396 	$class = 'class="' . join( ' ', get_comment_class( $class, $comment_id, $post_id ) ) . '"';
   430 	$class = 'class="' . join( ' ', get_comment_class( $class, $comment, $post_id ) ) . '"';
   397 	if ( $echo)
   431 	if ( $echo)
   398 		echo $class;
   432 		echo $class;
   399 	else
   433 	else
   400 		return $class;
   434 		return $class;
   401 }
   435 }
   402 
   436 
   403 /**
   437 /**
   404  * Returns the classes for the comment div as an array.
   438  * Returns the classes for the comment div as an array.
   405  *
   439  *
   406  * @since 2.7.0
   440  * @since 2.7.0
   407  *
   441  * @since 4.4.0 Added the ability for `$comment_id` to also accept a WP_Comment object.
   408  * @param string|array $class      Optional. One or more classes to add to the class list. Default empty.
   442  *
   409  * @param int          $comment_id Comment ID. Default current comment.
   443  * @global int $comment_alt
   410  * @param int|WP_Post  $post_id    Post ID or WP_Post object. Default current post.
   444  * @global int $comment_depth
       
   445  * @global int $comment_thread_alt
       
   446  *
       
   447  * @param string|array   $class      Optional. One or more classes to add to the class list. Default empty.
       
   448  * @param int|WP_Comment $comment_id Comment ID or WP_Comment object. Default current comment.
       
   449  * @param int|WP_Post    $post_id    Post ID or WP_Post object. Default current post.
   411  * @return array An array of classes.
   450  * @return array An array of classes.
   412  */
   451  */
   413 function get_comment_class( $class = '', $comment_id = null, $post_id = null ) {
   452 function get_comment_class( $class = '', $comment_id = null, $post_id = null ) {
   414 	global $comment_alt, $comment_depth, $comment_thread_alt;
   453 	global $comment_alt, $comment_depth, $comment_thread_alt;
   415 
   454 
   416 	$comment = get_comment($comment_id);
       
   417 
       
   418 	$classes = array();
   455 	$classes = array();
       
   456 
       
   457 	$comment = get_comment( $comment_id );
       
   458 	if ( ! $comment ) {
       
   459 		return $classes;
       
   460 	}
   419 
   461 
   420 	// Get the comment type (comment, trackback),
   462 	// Get the comment type (comment, trackback),
   421 	$classes[] = ( empty( $comment->comment_type ) ) ? 'comment' : $comment->comment_type;
   463 	$classes[] = ( empty( $comment->comment_type ) ) ? 'comment' : $comment->comment_type;
   422 
   464 
   423 	// Add classes for comment authors that are registered users.
   465 	// Add classes for comment authors that are registered users.
   468 	}
   510 	}
   469 
   511 
   470 	$classes = array_map('esc_attr', $classes);
   512 	$classes = array_map('esc_attr', $classes);
   471 
   513 
   472 	/**
   514 	/**
   473 	 * Filter the returned CSS classes for the current comment.
   515 	 * Filters the returned CSS classes for the current comment.
   474 	 *
   516 	 *
   475 	 * @since 2.7.0
   517 	 * @since 2.7.0
   476 	 *
   518 	 *
   477 	 * @param array       $classes    An array of comment classes.
   519 	 * @param array       $classes    An array of comment classes.
   478 	 * @param string      $class      A comma-separated list of additional classes added to the list.
   520 	 * @param string      $class      A comma-separated list of additional classes added to the list.
   479 	 * @param int         $comment_id The comment id.
   521 	 * @param int         $comment_id The comment id.
   480 	 * @param object   	  $comment    The comment
   522 	 * @param WP_Comment  $comment    The comment object.
   481 	 * @param int|WP_Post $post_id    The post ID or WP_Post object.
   523 	 * @param int|WP_Post $post_id    The post ID or WP_Post object.
   482 	 */
   524 	 */
   483 	return apply_filters( 'comment_class', $classes, $class, $comment_id, $comment, $post_id );
   525 	return apply_filters( 'comment_class', $classes, $class, $comment->comment_ID, $comment, $post_id );
   484 }
   526 }
   485 
   527 
   486 /**
   528 /**
   487  * Retrieve the comment date of the current comment.
   529  * Retrieve the comment date of the current comment.
   488  *
   530  *
   489  * @since 1.5.0
   531  * @since 1.5.0
   490  *
   532  * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
   491  * @param string $d          Optional. The format of the date. Default user's setting.
   533  *
   492  * @param int    $comment_ID ID of the comment for which to get the date. Default current comment.
   534  * @param string          $d          Optional. The format of the date. Default user's setting.
       
   535  * @param int|WP_Comment  $comment_ID WP_Comment or ID of the comment for which to get the date.
       
   536  *                                    Default current comment.
   493  * @return string The comment's date.
   537  * @return string The comment's date.
   494  */
   538  */
   495 function get_comment_date( $d = '', $comment_ID = 0 ) {
   539 function get_comment_date( $d = '', $comment_ID = 0 ) {
   496 	$comment = get_comment( $comment_ID );
   540 	$comment = get_comment( $comment_ID );
   497 	if ( '' == $d )
   541 	if ( '' == $d )
   498 		$date = mysql2date(get_option('date_format'), $comment->comment_date);
   542 		$date = mysql2date(get_option('date_format'), $comment->comment_date);
   499 	else
   543 	else
   500 		$date = mysql2date($d, $comment->comment_date);
   544 		$date = mysql2date($d, $comment->comment_date);
   501 	/**
   545 	/**
   502 	 * Filter the returned comment date.
   546 	 * Filters the returned comment date.
   503 	 *
   547 	 *
   504 	 * @since 1.5.0
   548 	 * @since 1.5.0
   505 	 *
   549 	 *
   506 	 * @param string|int $date    Formatted date string or Unix timestamp.
   550 	 * @param string|int $date    Formatted date string or Unix timestamp.
   507 	 * @param string     $d       The format of the date.
   551 	 * @param string     $d       The format of the date.
   508 	 * @param object     $comment The comment object.
   552 	 * @param WP_Comment $comment The comment object.
   509 	 */
   553 	 */
   510 	return apply_filters( 'get_comment_date', $date, $d, $comment );
   554 	return apply_filters( 'get_comment_date', $date, $d, $comment );
   511 }
   555 }
   512 
   556 
   513 /**
   557 /**
   514  * Display the comment date of the current comment.
   558  * Display the comment date of the current comment.
   515  *
   559  *
   516  * @since 0.71
   560  * @since 0.71
   517  *
   561  * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
   518  * @param string $d          Optional. The format of the date. Default user's settings.
   562  *
   519  * @param int    $comment_ID ID of the comment for which to print the date. Default current comment.
   563  * @param string         $d          Optional. The format of the date. Default user's settings.
       
   564  * @param int|WP_Comment $comment_ID WP_Comment or ID of the comment for which to print the date.
       
   565  *                                   Default current comment.
   520  */
   566  */
   521 function comment_date( $d = '', $comment_ID = 0 ) {
   567 function comment_date( $d = '', $comment_ID = 0 ) {
   522 	echo get_comment_date( $d, $comment_ID );
   568 	echo get_comment_date( $d, $comment_ID );
   523 }
   569 }
   524 
   570 
   528  * Will cut each word and only output the first 20 words with '&hellip;' at the end.
   574  * Will cut each word and only output the first 20 words with '&hellip;' at the end.
   529  * If the word count is less than 20, then no truncating is done and no '&hellip;'
   575  * If the word count is less than 20, then no truncating is done and no '&hellip;'
   530  * will appear.
   576  * will appear.
   531  *
   577  *
   532  * @since 1.5.0
   578  * @since 1.5.0
   533  *
   579  * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
   534  * @param int $comment_ID ID of the comment for which to get the excerpt.
   580  *
   535  *                        Default current comment.
   581  * @param int|WP_Comment $comment_ID  WP_Comment or ID of the comment for which to get the excerpt.
       
   582  *                                    Default current comment.
   536  * @return string The maybe truncated comment with 20 words or less.
   583  * @return string The maybe truncated comment with 20 words or less.
   537  */
   584  */
   538 function get_comment_excerpt( $comment_ID = 0 ) {
   585 function get_comment_excerpt( $comment_ID = 0 ) {
   539 	$comment = get_comment( $comment_ID );
   586 	$comment = get_comment( $comment_ID );
   540 	$comment_text = strip_tags($comment->comment_content);
   587 	$comment_text = strip_tags( str_replace( array( "\n", "\r" ), ' ', $comment->comment_content ) );
   541 	$blah = explode(' ', $comment_text);
   588 	$words = explode( ' ', $comment_text );
   542 
   589 
   543 	if (count($blah) > 20) {
   590 	/**
   544 		$k = 20;
   591 	 * Filters the amount of words used in the comment excerpt.
   545 		$use_dotdotdot = 1;
   592 	 *
   546 	} else {
   593 	 * @since 4.4.0
   547 		$k = count($blah);
   594 	 *
   548 		$use_dotdotdot = 0;
   595 	 * @param int $comment_excerpt_length The amount of words you want to display in the comment excerpt.
   549 	}
   596 	 */
   550 
   597 	$comment_excerpt_length = apply_filters( 'comment_excerpt_length', 20 );
   551 	$excerpt = '';
   598 
   552 	for ($i=0; $i<$k; $i++) {
   599 	$use_ellipsis = count( $words ) > $comment_excerpt_length;
   553 		$excerpt .= $blah[$i] . ' ';
   600 	if ( $use_ellipsis ) {
   554 	}
   601 		$words = array_slice( $words, 0, $comment_excerpt_length );
   555 	$excerpt .= ($use_dotdotdot) ? '&hellip;' : '';
   602 	}
   556 
   603 
   557 	/**
   604 	$excerpt = trim( join( ' ', $words ) );
   558 	 * Filter the retrieved comment excerpt.
   605 	if ( $use_ellipsis ) {
       
   606 		$excerpt .= '&hellip;';
       
   607 	}
       
   608 	/**
       
   609 	 * Filters the retrieved comment excerpt.
   559 	 *
   610 	 *
   560 	 * @since 1.5.0
   611 	 * @since 1.5.0
   561 	 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added.
   612 	 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added.
   562 	 *
   613 	 *
   563 	 * @param string $excerpt    The comment excerpt text.
   614 	 * @param string     $excerpt    The comment excerpt text.
   564 	 * @param int    $comment_ID The comment ID.
   615 	 * @param int        $comment_ID The comment ID.
   565 	 * @param object $comment    The comment object.
   616 	 * @param WP_Comment $comment    The comment object.
   566 	 */
   617 	 */
   567 	return apply_filters( 'get_comment_excerpt', $excerpt, $comment_ID, $comment );
   618 	return apply_filters( 'get_comment_excerpt', $excerpt, $comment->comment_ID, $comment );
   568 }
   619 }
   569 
   620 
   570 /**
   621 /**
   571  * Display the excerpt of the current comment.
   622  * Display the excerpt of the current comment.
   572  *
   623  *
   573  * @since 1.2.0
   624  * @since 1.2.0
   574  *
   625  * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
   575  * @param int $comment_ID ID of the comment for which to print the excerpt.
   626  *
   576  *                        Default current comment.
   627  * @param int|WP_Comment $comment_ID  WP_Comment or ID of the comment for which to print the excerpt.
       
   628  *                                    Default current comment.
   577  */
   629  */
   578 function comment_excerpt( $comment_ID = 0 ) {
   630 function comment_excerpt( $comment_ID = 0 ) {
   579 	$comment_excerpt = get_comment_excerpt($comment_ID);
   631 	$comment         = get_comment( $comment_ID );
   580 
   632 	$comment_excerpt = get_comment_excerpt( $comment );
   581 	/**
   633 
   582 	 * Filter the comment excerpt for display.
   634 	/**
       
   635 	 * Filters the comment excerpt for display.
   583 	 *
   636 	 *
   584 	 * @since 1.2.0
   637 	 * @since 1.2.0
   585 	 * @since 4.1.0 The `$comment_ID` parameter was added.
   638 	 * @since 4.1.0 The `$comment_ID` parameter was added.
   586 	 *
   639 	 *
   587 	 * @param string $comment_excerpt The comment excerpt text.
   640 	 * @param string $comment_excerpt The comment excerpt text.
   588 	 * @param int    $comment_ID      The comment ID.
   641 	 * @param int    $comment_ID      The comment ID.
   589 	 */
   642 	 */
   590 	echo apply_filters( 'comment_excerpt', $comment_excerpt, $comment_ID );
   643 	echo apply_filters( 'comment_excerpt', $comment_excerpt, $comment->comment_ID );
   591 }
   644 }
   592 
   645 
   593 /**
   646 /**
   594  * Retrieve the comment id of the current comment.
   647  * Retrieve the comment id of the current comment.
   595  *
   648  *
   596  * @since 1.5.0
   649  * @since 1.5.0
   597  *
   650  *
   598  * @return int The comment ID.
   651  * @return int The comment ID.
   599  */
   652  */
   600 function get_comment_ID() {
   653 function get_comment_ID() {
   601 	global $comment;
   654 	$comment = get_comment();
   602 
   655 
   603 	/**
   656 	/**
   604 	 * Filter the returned comment ID.
   657 	 * Filters the returned comment ID.
   605 	 *
   658 	 *
   606 	 * @since 1.5.0
   659 	 * @since 1.5.0
   607 	 * @since 4.1.0 The `$comment_ID` parameter was added.
   660 	 * @since 4.1.0 The `$comment_ID` parameter was added.
   608 	 *
   661 	 *
   609 	 * @param int    $comment_ID The current comment ID.
   662 	 * @param int        $comment_ID The current comment ID.
   610 	 * @param object $comment    The comment object.
   663 	 * @param WP_Comment $comment    The comment object.
   611 	 */
   664 	 */
   612 	return apply_filters( 'get_comment_ID', $comment->comment_ID, $comment );
   665 	return apply_filters( 'get_comment_ID', $comment->comment_ID, $comment );
   613 }
   666 }
   614 
   667 
   615 /**
   668 /**
   623 
   676 
   624 /**
   677 /**
   625  * Retrieve the link to a given comment.
   678  * Retrieve the link to a given comment.
   626  *
   679  *
   627  * @since 1.5.0
   680  * @since 1.5.0
       
   681  * @since 4.4.0 Added the ability for `$comment` to also accept a WP_Comment object. Added `$cpage` argument.
   628  *
   682  *
   629  * @see get_page_of_comment()
   683  * @see get_page_of_comment()
   630  *
   684  *
   631  * @param mixed $comment Comment to retrieve. Default current comment.
   685  * @global WP_Rewrite $wp_rewrite
   632  * @param array $args    Optional. An array of arguments to override the defaults.
   686  * @global bool       $in_comment_loop
       
   687  *
       
   688  * @param WP_Comment|int|null $comment Comment to retrieve. Default current comment.
       
   689  * @param array               $args {
       
   690  *     An array of optional arguments to override the defaults.
       
   691  *
       
   692  *     @type string     $type      Passed to get_page_of_comment().
       
   693  *     @type int        $page      Current page of comments, for calculating comment pagination.
       
   694  *     @type int        $per_page  Per-page value for comment pagination.
       
   695  *     @type int        $max_depth Passed to get_page_of_comment().
       
   696  *     @type int|string $cpage     Value to use for the comment's "comment-page" or "cpage" value.
       
   697  *                                 If provided, this value overrides any value calculated from `$page`
       
   698  *                                 and `$per_page`.
       
   699  * }
   633  * @return string The permalink to the given comment.
   700  * @return string The permalink to the given comment.
   634  */
   701  */
   635 function get_comment_link( $comment = null, $args = array() ) {
   702 function get_comment_link( $comment = null, $args = array() ) {
   636 	global $wp_rewrite, $in_comment_loop;
   703 	global $wp_rewrite, $in_comment_loop;
   637 
   704 
   638 	$comment = get_comment($comment);
   705 	$comment = get_comment($comment);
   639 
   706 
   640 	// Backwards compat
   707 	// Back-compat.
   641 	if ( ! is_array( $args ) ) {
   708 	if ( ! is_array( $args ) ) {
   642 		$args = array( 'page' => $args );
   709 		$args = array( 'page' => $args );
   643 	}
   710 	}
   644 
   711 
   645 	$defaults = array( 'type' => 'all', 'page' => '', 'per_page' => '', 'max_depth' => '' );
   712 	$defaults = array(
       
   713 		'type'      => 'all',
       
   714 		'page'      => '',
       
   715 		'per_page'  => '',
       
   716 		'max_depth' => '',
       
   717 		'cpage'     => null,
       
   718 	);
   646 	$args = wp_parse_args( $args, $defaults );
   719 	$args = wp_parse_args( $args, $defaults );
   647 
   720 
   648 	if ( '' === $args['per_page'] && get_option('page_comments') )
   721 	$link = get_permalink( $comment->comment_post_ID );
   649 		$args['per_page'] = get_option('comments_per_page');
   722 
   650 
   723 	// The 'cpage' param takes precedence.
   651 	if ( empty($args['per_page']) ) {
   724 	if ( ! is_null( $args['cpage'] ) ) {
   652 		$args['per_page'] = 0;
   725 		$cpage = $args['cpage'];
   653 		$args['page'] = 0;
   726 
   654 	}
   727 	// No 'cpage' is provided, so we calculate one.
   655 
       
   656 	if ( $args['per_page'] ) {
       
   657 		if ( '' == $args['page'] )
       
   658 			$args['page'] = ( !empty($in_comment_loop) ) ? get_query_var('cpage') : get_page_of_comment( $comment->comment_ID, $args );
       
   659 
       
   660 		if ( $wp_rewrite->using_permalinks() )
       
   661 			$link = user_trailingslashit( trailingslashit( get_permalink( $comment->comment_post_ID ) ) . $wp_rewrite->comments_pagination_base . '-' . $args['page'], 'comment' );
       
   662 		else
       
   663 			$link = add_query_arg( 'cpage', $args['page'], get_permalink( $comment->comment_post_ID ) );
       
   664 	} else {
   728 	} else {
   665 		$link = get_permalink( $comment->comment_post_ID );
   729 		if ( '' === $args['per_page'] && get_option( 'page_comments' ) ) {
       
   730 			$args['per_page'] = get_option('comments_per_page');
       
   731 		}
       
   732 
       
   733 		if ( empty( $args['per_page'] ) ) {
       
   734 			$args['per_page'] = 0;
       
   735 			$args['page'] = 0;
       
   736 		}
       
   737 
       
   738 		$cpage = $args['page'];
       
   739 
       
   740 		if ( '' == $cpage ) {
       
   741 			if ( ! empty( $in_comment_loop ) ) {
       
   742 				$cpage = get_query_var( 'cpage' );
       
   743 			} else {
       
   744 				// Requires a database hit, so we only do it when we can't figure out from context.
       
   745 				$cpage = get_page_of_comment( $comment->comment_ID, $args );
       
   746 			}
       
   747 		}
       
   748 
       
   749 		/*
       
   750 		 * If the default page displays the oldest comments, the permalinks for comments on the default page
       
   751 		 * do not need a 'cpage' query var.
       
   752 		 */
       
   753 		if ( 'oldest' === get_option( 'default_comments_page' ) && 1 === $cpage ) {
       
   754 			$cpage = '';
       
   755 		}
       
   756 	}
       
   757 
       
   758 	if ( $cpage && get_option( 'page_comments' ) ) {
       
   759 		if ( $wp_rewrite->using_permalinks() ) {
       
   760 			if ( $cpage ) {
       
   761 				$link = trailingslashit( $link ) . $wp_rewrite->comments_pagination_base . '-' . $cpage;
       
   762 			}
       
   763 
       
   764 			$link = user_trailingslashit( $link, 'comment' );
       
   765 		} elseif ( $cpage ) {
       
   766 			$link = add_query_arg( 'cpage', $cpage, $link );
       
   767 		}
       
   768 
       
   769 	}
       
   770 
       
   771 	if ( $wp_rewrite->using_permalinks() ) {
       
   772 		$link = user_trailingslashit( $link, 'comment' );
   666 	}
   773 	}
   667 
   774 
   668 	$link = $link . '#comment-' . $comment->comment_ID;
   775 	$link = $link . '#comment-' . $comment->comment_ID;
   669 	/**
   776 
   670 	 * Filter the returned single comment permalink.
   777 	/**
       
   778 	 * Filters the returned single comment permalink.
   671 	 *
   779 	 *
   672 	 * @since 2.8.0
   780 	 * @since 2.8.0
       
   781 	 * @since 4.4.0 Added the `$cpage` parameter.
   673 	 *
   782 	 *
   674 	 * @see get_page_of_comment()
   783 	 * @see get_page_of_comment()
   675 	 *
   784 	 *
   676 	 * @param string $link    The comment permalink with '#comment-$id' appended.
   785 	 * @param string     $link    The comment permalink with '#comment-$id' appended.
   677 	 * @param object $comment The current comment object.
   786 	 * @param WP_Comment $comment The current comment object.
   678 	 * @param array  $args    An array of arguments to override the defaults.
   787 	 * @param array      $args    An array of arguments to override the defaults.
   679 	 */
   788 	 * @param int        $cpage   The calculated 'cpage' value.
   680 	return apply_filters( 'get_comment_link', $link, $comment, $args );
   789 	 */
   681 }
   790 	return apply_filters( 'get_comment_link', $link, $comment, $args, $cpage );
   682 
   791 }
   683 /**
   792 
   684  * Retrieve the link to the current post comments.
   793 /**
       
   794  * Retrieves the link to the current post comments.
   685  *
   795  *
   686  * @since 1.5.0
   796  * @since 1.5.0
   687  *
   797  *
   688  * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post.
   798  * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post.
   689  * @return string The link to the comments.
   799  * @return string The link to the comments.
   690  */
   800  */
   691 function get_comments_link( $post_id = 0 ) {
   801 function get_comments_link( $post_id = 0 ) {
   692 	$comments_link = get_permalink( $post_id ) . '#comments';
   802 	$hash = get_comments_number( $post_id ) ? '#comments' : '#respond';
   693 	/**
   803 	$comments_link = get_permalink( $post_id ) . $hash;
   694 	 * Filter the returned post comments permalink.
   804 
       
   805 	/**
       
   806 	 * Filters the returned post comments permalink.
   695 	 *
   807 	 *
   696 	 * @since 3.6.0
   808 	 * @since 3.6.0
   697 	 *
   809 	 *
   698 	 * @param string      $comments_link Post comments permalink with '#comments' appended.
   810 	 * @param string      $comments_link Post comments permalink with '#comments' appended.
   699 	 * @param int|WP_Post $post_id       Post ID or WP_Post object.
   811 	 * @param int|WP_Post $post_id       Post ID or WP_Post object.
   711  */
   823  */
   712 function comments_link( $deprecated = '', $deprecated_2 = '' ) {
   824 function comments_link( $deprecated = '', $deprecated_2 = '' ) {
   713 	if ( !empty( $deprecated ) )
   825 	if ( !empty( $deprecated ) )
   714 		_deprecated_argument( __FUNCTION__, '0.72' );
   826 		_deprecated_argument( __FUNCTION__, '0.72' );
   715 	if ( !empty( $deprecated_2 ) )
   827 	if ( !empty( $deprecated_2 ) )
   716 		_deprecated_argument( __FUNCTION__, '1.3' );
   828 		_deprecated_argument( __FUNCTION__, '1.3.0' );
   717 	echo esc_url( get_comments_link() );
   829 	echo esc_url( get_comments_link() );
   718 }
   830 }
   719 
   831 
   720 /**
   832 /**
   721  * Retrieve the amount of comments a post has.
   833  * Retrieves the amount of comments a post has.
   722  *
   834  *
   723  * @since 1.5.0
   835  * @since 1.5.0
   724  *
   836  *
   725  * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post.
   837  * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is the global `$post`.
   726  * @return int The number of comments a post has.
   838  * @return string|int If the post exists, a numeric string representing the number of comments
       
   839  *                    the post has, otherwise 0.
   727  */
   840  */
   728 function get_comments_number( $post_id = 0 ) {
   841 function get_comments_number( $post_id = 0 ) {
   729 	$post = get_post( $post_id );
   842 	$post = get_post( $post_id );
   730 
   843 
   731 	if ( ! $post ) {
   844 	if ( ! $post ) {
   734 		$count = $post->comment_count;
   847 		$count = $post->comment_count;
   735 		$post_id = $post->ID;
   848 		$post_id = $post->ID;
   736 	}
   849 	}
   737 
   850 
   738 	/**
   851 	/**
   739 	 * Filter the returned comment count for a post.
   852 	 * Filters the returned comment count for a post.
   740 	 *
   853 	 *
   741 	 * @since 1.5.0
   854 	 * @since 1.5.0
   742 	 *
   855 	 *
   743 	 * @param int $count   Number of comments a post has.
   856 	 * @param string|int $count   A string representing the number of comments a post has, otherwise 0.
   744 	 * @param int $post_id Post ID.
   857 	 * @param int        $post_id Post ID.
   745 	 */
   858 	 */
   746 	return apply_filters( 'get_comments_number', $count, $post_id );
   859 	return apply_filters( 'get_comments_number', $count, $post_id );
   747 }
   860 }
   748 
   861 
   749 /**
   862 /**
   756  * @param string $more       Optional. Text for more than one comment. Default false.
   869  * @param string $more       Optional. Text for more than one comment. Default false.
   757  * @param string $deprecated Not used.
   870  * @param string $deprecated Not used.
   758  */
   871  */
   759 function comments_number( $zero = false, $one = false, $more = false, $deprecated = '' ) {
   872 function comments_number( $zero = false, $one = false, $more = false, $deprecated = '' ) {
   760 	if ( ! empty( $deprecated ) ) {
   873 	if ( ! empty( $deprecated ) ) {
   761 		_deprecated_argument( __FUNCTION__, '1.3' );
   874 		_deprecated_argument( __FUNCTION__, '1.3.0' );
   762 	}
   875 	}
   763 	echo get_comments_number_text( $zero, $one, $more );
   876 	echo get_comments_number_text( $zero, $one, $more );
   764 }
   877 }
   765 
   878 
   766 /**
   879 /**
   774  */
   887  */
   775 function get_comments_number_text( $zero = false, $one = false, $more = false ) {
   888 function get_comments_number_text( $zero = false, $one = false, $more = false ) {
   776 	$number = get_comments_number();
   889 	$number = get_comments_number();
   777 
   890 
   778 	if ( $number > 1 ) {
   891 	if ( $number > 1 ) {
   779 		$output = str_replace( '%', number_format_i18n( $number ), ( false === $more ) ? __( '% Comments' ) : $more );
   892 		if ( false === $more ) {
       
   893 			/* translators: %s: number of comments */
       
   894 			$output = sprintf( _n( '%s Comment', '%s Comments', $number ), number_format_i18n( $number ) );
       
   895 		} else {
       
   896 			// % Comments
       
   897 			/* translators: If comment number in your language requires declension,
       
   898 			 * translate this to 'on'. Do not translate into your own language.
       
   899 			 */
       
   900 			if ( 'on' === _x( 'off', 'Comment number declension: on or off' ) ) {
       
   901 				$text = preg_replace( '#<span class="screen-reader-text">.+?</span>#', '', $more );
       
   902 				$text = preg_replace( '/&.+?;/', '', $text ); // Kill entities
       
   903 				$text = trim( strip_tags( $text ), '% ' );
       
   904 
       
   905 				// Replace '% Comments' with a proper plural form
       
   906 				if ( $text && ! preg_match( '/[0-9]+/', $text ) && false !== strpos( $more, '%' ) ) {
       
   907 					/* translators: %s: number of comments */
       
   908 					$new_text = _n( '%s Comment', '%s Comments', $number );
       
   909 					$new_text = trim( sprintf( $new_text, '' ) );
       
   910 
       
   911 					$more = str_replace( $text, $new_text, $more );
       
   912 					if ( false === strpos( $more, '%' ) ) {
       
   913 						$more = '% ' . $more;
       
   914 					}
       
   915 				}
       
   916 			}
       
   917 
       
   918 			$output = str_replace( '%', number_format_i18n( $number ), $more );
       
   919 		}
   780 	} elseif ( $number == 0 ) {
   920 	} elseif ( $number == 0 ) {
   781 		$output = ( false === $zero ) ? __( 'No Comments' ) : $zero;
   921 		$output = ( false === $zero ) ? __( 'No Comments' ) : $zero;
   782 	} else { // must be one
   922 	} else { // must be one
   783 		$output = ( false === $one ) ? __( '1 Comment' ) : $one;
   923 		$output = ( false === $one ) ? __( '1 Comment' ) : $one;
   784 	}
   924 	}
   785 	/**
   925 	/**
   786 	 * Filter the comments count for display.
   926 	 * Filters the comments count for display.
   787 	 *
   927 	 *
   788 	 * @since 1.5.0
   928 	 * @since 1.5.0
   789 	 *
   929 	 *
   790 	 * @see _n()
   930 	 * @see _n()
   791 	 *
   931 	 *
   798 
   938 
   799 /**
   939 /**
   800  * Retrieve the text of the current comment.
   940  * Retrieve the text of the current comment.
   801  *
   941  *
   802  * @since 1.5.0
   942  * @since 1.5.0
       
   943  * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
   803  *
   944  *
   804  * @see Walker_Comment::comment()
   945  * @see Walker_Comment::comment()
   805  *
   946  *
   806  * @param int   $comment_ID ID of the comment for which to get the text. Default current comment.
   947  * @param int|WP_Comment  $comment_ID WP_Comment or ID of the comment for which to get the text.
   807  * @param array $args       Optional. An array of arguments. Default empty.
   948  *                                    Default current comment.
       
   949  * @param array           $args       Optional. An array of arguments. Default empty.
   808  * @return string The comment content.
   950  * @return string The comment content.
   809  */
   951  */
   810 function get_comment_text( $comment_ID = 0, $args = array() ) {
   952 function get_comment_text( $comment_ID = 0, $args = array() ) {
   811 	$comment = get_comment( $comment_ID );
   953 	$comment = get_comment( $comment_ID );
   812 
   954 
   813 	/**
   955 	/**
   814 	 * Filter the text of a comment.
   956 	 * Filters the text of a comment.
   815 	 *
   957 	 *
   816 	 * @since 1.5.0
   958 	 * @since 1.5.0
   817 	 *
   959 	 *
   818 	 * @see Walker_Comment::comment()
   960 	 * @see Walker_Comment::comment()
   819 	 *
   961 	 *
   820 	 * @param string $comment_content Text of the comment.
   962 	 * @param string     $comment_content Text of the comment.
   821 	 * @param object $comment         The comment object.
   963 	 * @param WP_Comment $comment         The comment object.
   822 	 * @param array  $args            An array of arguments.
   964 	 * @param array      $args            An array of arguments.
   823 	 */
   965 	 */
   824 	return apply_filters( 'get_comment_text', $comment->comment_content, $comment, $args );
   966 	return apply_filters( 'get_comment_text', $comment->comment_content, $comment, $args );
   825 }
   967 }
   826 
   968 
   827 /**
   969 /**
   828  * Display the text of the current comment.
   970  * Display the text of the current comment.
   829  *
   971  *
   830  * @since 0.71
   972  * @since 0.71
       
   973  * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
   831  *
   974  *
   832  * @see Walker_Comment::comment()
   975  * @see Walker_Comment::comment()
   833  *
   976  *
   834  * @param int   $comment_ID ID of the comment for which to print the text. Default 0.
   977  * @param int|WP_Comment  $comment_ID WP_Comment or ID of the comment for which to print the text.
   835  * @param array $args       Optional. An array of arguments. Default empty array. Default empty.
   978  *                                    Default current comment.
       
   979  * @param array           $args       Optional. An array of arguments. Default empty array. Default empty.
   836  */
   980  */
   837 function comment_text( $comment_ID = 0, $args = array() ) {
   981 function comment_text( $comment_ID = 0, $args = array() ) {
   838 	$comment = get_comment( $comment_ID );
   982 	$comment = get_comment( $comment_ID );
   839 
   983 
   840 	$comment_text = get_comment_text( $comment_ID , $args );
   984 	$comment_text = get_comment_text( $comment, $args );
   841 	/**
   985 	/**
   842 	 * Filter the text of a comment to be displayed.
   986 	 * Filters the text of a comment to be displayed.
   843 	 *
   987 	 *
   844 	 * @since 1.2.0
   988 	 * @since 1.2.0
   845 	 *
   989 	 *
   846 	 * @see Walker_Comment::comment()
   990 	 * @see Walker_Comment::comment()
   847 	 *
   991 	 *
   848 	 * @param string $comment_text Text of the current comment.
   992 	 * @param string          $comment_text Text of the current comment.
   849 	 * @param object $comment      The comment object.
   993 	 * @param WP_Comment|null $comment      The comment object.
   850 	 * @param array  $args         An array of arguments.
   994 	 * @param array           $args         An array of arguments.
   851 	 */
   995 	 */
   852 	echo apply_filters( 'comment_text', $comment_text, $comment, $args );
   996 	echo apply_filters( 'comment_text', $comment_text, $comment, $args );
   853 }
   997 }
   854 
   998 
   855 /**
   999 /**
   862  * @param bool   $translate Optional. Whether to translate the time (for use in feeds).
  1006  * @param bool   $translate Optional. Whether to translate the time (for use in feeds).
   863  *                          Default true.
  1007  *                          Default true.
   864  * @return string The formatted time.
  1008  * @return string The formatted time.
   865  */
  1009  */
   866 function get_comment_time( $d = '', $gmt = false, $translate = true ) {
  1010 function get_comment_time( $d = '', $gmt = false, $translate = true ) {
   867 	global $comment;
  1011 	$comment = get_comment();
       
  1012 
   868 	$comment_date = $gmt ? $comment->comment_date_gmt : $comment->comment_date;
  1013 	$comment_date = $gmt ? $comment->comment_date_gmt : $comment->comment_date;
   869 	if ( '' == $d )
  1014 	if ( '' == $d )
   870 		$date = mysql2date(get_option('time_format'), $comment_date, $translate);
  1015 		$date = mysql2date(get_option('time_format'), $comment_date, $translate);
   871 	else
  1016 	else
   872 		$date = mysql2date($d, $comment_date, $translate);
  1017 		$date = mysql2date($d, $comment_date, $translate);
   873 
  1018 
   874 	/**
  1019 	/**
   875 	 * Filter the returned comment time.
  1020 	 * Filters the returned comment time.
   876 	 *
  1021 	 *
   877 	 * @since 1.5.0
  1022 	 * @since 1.5.0
   878 	 *
  1023 	 *
   879 	 * @param string|int $date      The comment time, formatted as a date string or Unix timestamp.
  1024 	 * @param string|int $date      The comment time, formatted as a date string or Unix timestamp.
   880 	 * @param string     $d         Date format.
  1025 	 * @param string     $d         Date format.
   881 	 * @param bool       $gmt       Whether the GMT date is in use.
  1026 	 * @param bool       $gmt       Whether the GMT date is in use.
   882 	 * @param bool       $translate Whether the time is translated.
  1027 	 * @param bool       $translate Whether the time is translated.
   883 	 * @param object     $comment   The comment object.
  1028 	 * @param WP_Comment $comment   The comment object.
   884 	 */
  1029 	 */
   885 	return apply_filters( 'get_comment_time', $date, $d, $gmt, $translate, $comment );
  1030 	return apply_filters( 'get_comment_time', $date, $d, $gmt, $translate, $comment );
   886 }
  1031 }
   887 
  1032 
   888 /**
  1033 /**
   898 
  1043 
   899 /**
  1044 /**
   900  * Retrieve the comment type of the current comment.
  1045  * Retrieve the comment type of the current comment.
   901  *
  1046  *
   902  * @since 1.5.0
  1047  * @since 1.5.0
   903  *
  1048  * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
   904  * @param int $comment_ID ID of the comment for which to get the type. Default current comment.
  1049  *
       
  1050  * @param int|WP_Comment $comment_ID Optional. WP_Comment or ID of the comment for which to get the type.
       
  1051  *                                   Default current comment.
   905  * @return string The comment type.
  1052  * @return string The comment type.
   906  */
  1053  */
   907 function get_comment_type( $comment_ID = 0 ) {
  1054 function get_comment_type( $comment_ID = 0 ) {
   908 	$comment = get_comment( $comment_ID );
  1055 	$comment = get_comment( $comment_ID );
   909 	if ( '' == $comment->comment_type )
  1056 	if ( '' == $comment->comment_type )
   910 		$comment->comment_type = 'comment';
  1057 		$comment->comment_type = 'comment';
   911 
  1058 
   912 	/**
  1059 	/**
   913 	 * Filter the returned comment type.
  1060 	 * Filters the returned comment type.
   914 	 *
  1061 	 *
   915 	 * @since 1.5.0
  1062 	 * @since 1.5.0
   916 	 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added.
  1063 	 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added.
   917 	 *
  1064 	 *
   918 	 * @param string $comment_type The type of comment, such as 'comment', 'pingback', or 'trackback'.
  1065 	 * @param string     $comment_type The type of comment, such as 'comment', 'pingback', or 'trackback'.
   919 	 * @param int 	 $comment_ID   The comment ID.
  1066 	 * @param int 	     $comment_ID   The comment ID.
   920 	 * @param object $comment      The comment object.
  1067 	 * @param WP_Comment $comment      The comment object.
   921 	 */
  1068 	 */
   922 	return apply_filters( 'get_comment_type', $comment->comment_type, $comment_ID, $comment );
  1069 	return apply_filters( 'get_comment_type', $comment->comment_type, $comment->comment_ID, $comment );
   923 }
  1070 }
   924 
  1071 
   925 /**
  1072 /**
   926  * Display the comment type of the current comment.
  1073  * Display the comment type of the current comment.
   927  *
  1074  *
   964 		$tb_url = trailingslashit(get_permalink()) . user_trailingslashit('trackback', 'single_trackback');
  1111 		$tb_url = trailingslashit(get_permalink()) . user_trailingslashit('trackback', 'single_trackback');
   965 	else
  1112 	else
   966 		$tb_url = get_option('siteurl') . '/wp-trackback.php?p=' . get_the_ID();
  1113 		$tb_url = get_option('siteurl') . '/wp-trackback.php?p=' . get_the_ID();
   967 
  1114 
   968 	/**
  1115 	/**
   969 	 * Filter the returned trackback URL.
  1116 	 * Filters the returned trackback URL.
   970 	 *
  1117 	 *
   971 	 * @since 2.2.0
  1118 	 * @since 2.2.0
   972 	 *
  1119 	 *
   973 	 * @param string $tb_url The trackback URL.
  1120 	 * @param string $tb_url The trackback URL.
   974 	 */
  1121 	 */
   983  * @param bool $deprecated_echo Not used.
  1130  * @param bool $deprecated_echo Not used.
   984  * @return void|string Should only be used to echo the trackback URL, use get_trackback_url()
  1131  * @return void|string Should only be used to echo the trackback URL, use get_trackback_url()
   985  *                     for the result instead.
  1132  *                     for the result instead.
   986  */
  1133  */
   987 function trackback_url( $deprecated_echo = true ) {
  1134 function trackback_url( $deprecated_echo = true ) {
   988 	if ( $deprecated_echo !== true )
  1135 	if ( true !== $deprecated_echo ) {
   989 		_deprecated_argument( __FUNCTION__, '2.5', __('Use <code>get_trackback_url()</code> instead if you do not want the value echoed.') );
  1136 		_deprecated_argument( __FUNCTION__, '2.5.0',
   990 	if ( $deprecated_echo )
  1137 			/* translators: %s: get_trackback_url() */
       
  1138 			sprintf( __( 'Use %s instead if you do not want the value echoed.' ),
       
  1139 				'<code>get_trackback_url()</code>'
       
  1140 			)
       
  1141 		);
       
  1142 	}
       
  1143 
       
  1144 	if ( $deprecated_echo ) {
   991 		echo get_trackback_url();
  1145 		echo get_trackback_url();
   992 	else
  1146 	} else {
   993 		return get_trackback_url();
  1147 		return get_trackback_url();
       
  1148 	}
   994 }
  1149 }
   995 
  1150 
   996 /**
  1151 /**
   997  * Generate and display the RDF for the trackback information of current post.
  1152  * Generate and display the RDF for the trackback information of current post.
   998  *
  1153  *
  1002  *
  1157  *
  1003  * @param int $deprecated Not used (Was $timezone = 0).
  1158  * @param int $deprecated Not used (Was $timezone = 0).
  1004  */
  1159  */
  1005 function trackback_rdf( $deprecated = '' ) {
  1160 function trackback_rdf( $deprecated = '' ) {
  1006 	if ( ! empty( $deprecated ) ) {
  1161 	if ( ! empty( $deprecated ) ) {
  1007 		_deprecated_argument( __FUNCTION__, '2.5' );
  1162 		_deprecated_argument( __FUNCTION__, '2.5.0' );
  1008 	}
  1163 	}
  1009 
  1164 
  1010 	if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && false !== stripos( $_SERVER['HTTP_USER_AGENT'], 'W3C_Validator' ) ) {
  1165 	if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && false !== stripos( $_SERVER['HTTP_USER_AGENT'], 'W3C_Validator' ) ) {
  1011 		return;
  1166 		return;
  1012 	}
  1167 	}
  1035  */
  1190  */
  1036 function comments_open( $post_id = null ) {
  1191 function comments_open( $post_id = null ) {
  1037 
  1192 
  1038 	$_post = get_post($post_id);
  1193 	$_post = get_post($post_id);
  1039 
  1194 
       
  1195 	$post_id = $_post ? $_post->ID : 0;
  1040 	$open = ( 'open' == $_post->comment_status );
  1196 	$open = ( 'open' == $_post->comment_status );
  1041 
  1197 
  1042 	/**
  1198 	/**
  1043 	 * Filter whether the current post is open for comments.
  1199 	 * Filters whether the current post is open for comments.
  1044 	 *
  1200 	 *
  1045 	 * @since 2.5.0
  1201 	 * @since 2.5.0
  1046 	 *
  1202 	 *
  1047 	 * @param bool        $open    Whether the current post is open for comments.
  1203 	 * @param bool $open    Whether the current post is open for comments.
  1048 	 * @param int|WP_Post $post_id The post ID or WP_Post object.
  1204 	 * @param int  $post_id The post ID.
  1049 	 */
  1205 	 */
  1050 	return apply_filters( 'comments_open', $open, $post_id );
  1206 	return apply_filters( 'comments_open', $open, $post_id );
  1051 }
  1207 }
  1052 
  1208 
  1053 /**
  1209 /**
  1060  */
  1216  */
  1061 function pings_open( $post_id = null ) {
  1217 function pings_open( $post_id = null ) {
  1062 
  1218 
  1063 	$_post = get_post($post_id);
  1219 	$_post = get_post($post_id);
  1064 
  1220 
       
  1221 	$post_id = $_post ? $_post->ID : 0;
  1065 	$open = ( 'open' == $_post->ping_status );
  1222 	$open = ( 'open' == $_post->ping_status );
  1066 
  1223 
  1067 	/**
  1224 	/**
  1068 	 * Filter whether the current post is open for pings.
  1225 	 * Filters whether the current post is open for pings.
  1069 	 *
  1226 	 *
  1070 	 * @since 2.5.0
  1227 	 * @since 2.5.0
  1071 	 *
  1228 	 *
  1072 	 * @param bool        $open    Whether the current post is open for pings.
  1229 	 * @param bool $open    Whether the current post is open for pings.
  1073 	 * @param int|WP_Post $post_id The post ID or WP_Post object.
  1230 	 * @param int  $post_id The post ID.
  1074 	 */
  1231 	 */
  1075 	return apply_filters( 'pings_open', $open, $post_id );
  1232 	return apply_filters( 'pings_open', $open, $post_id );
  1076 }
  1233 }
  1077 
  1234 
  1078 /**
  1235 /**
  1104  *
  1261  *
  1105  * Will not display the comments template if not on single post or page, or if
  1262  * Will not display the comments template if not on single post or page, or if
  1106  * the post does not have comments.
  1263  * the post does not have comments.
  1107  *
  1264  *
  1108  * Uses the WordPress database object to query for the comments. The comments
  1265  * Uses the WordPress database object to query for the comments. The comments
  1109  * are passed through the 'comments_array' filter hook with the list of comments
  1266  * are passed through the {@see 'comments_array'} filter hook with the list of comments
  1110  * and the post ID respectively.
  1267  * and the post ID respectively.
  1111  *
  1268  *
  1112  * The $file path is passed through a filter hook called, 'comments_template'
  1269  * The `$file` path is passed through a filter hook called {@see 'comments_template'},
  1113  * which includes the TEMPLATEPATH and $file combined. Tries the $filtered path
  1270  * which includes the TEMPLATEPATH and $file combined. Tries the $filtered path
  1114  * first and if it fails it will require the default comment template from the
  1271  * first and if it fails it will require the default comment template from the
  1115  * default theme. If either does not exist, then the WordPress process will be
  1272  * default theme. If either does not exist, then the WordPress process will be
  1116  * halted. It is advised for that reason, that the default theme is not deleted.
  1273  * halted. It is advised for that reason, that the default theme is not deleted.
  1117  *
  1274  *
  1118  * @todo Document globals
  1275  * Will not try to get the comments if the post has none.
  1119  * @uses $withcomments Will not try to get the comments if the post has none.
       
  1120  *
  1276  *
  1121  * @since 1.5.0
  1277  * @since 1.5.0
       
  1278  *
       
  1279  * @global WP_Query   $wp_query
       
  1280  * @global WP_Post    $post
       
  1281  * @global wpdb       $wpdb
       
  1282  * @global int        $id
       
  1283  * @global WP_Comment $comment
       
  1284  * @global string     $user_login
       
  1285  * @global int        $user_ID
       
  1286  * @global string     $user_identity
       
  1287  * @global bool       $overridden_cpage
       
  1288  * @global bool       $withcomments
  1122  *
  1289  *
  1123  * @param string $file              Optional. The file to load. Default '/comments.php'.
  1290  * @param string $file              Optional. The file to load. Default '/comments.php'.
  1124  * @param bool   $separate_comments Optional. Whether to separate the comments by comment type.
  1291  * @param bool   $separate_comments Optional. Whether to separate the comments by comment type.
  1125  *                                  Default false.
  1292  *                                  Default false.
  1126  * @return null Returns null if no comments appear.
       
  1127  */
  1293  */
  1128 function comments_template( $file = '/comments.php', $separate_comments = false ) {
  1294 function comments_template( $file = '/comments.php', $separate_comments = false ) {
  1129 	global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity, $overridden_cpage;
  1295 	global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity, $overridden_cpage;
  1130 
  1296 
  1131 	if ( !(is_single() || is_page() || $withcomments) || empty($post) )
  1297 	if ( !(is_single() || is_page() || $withcomments) || empty($post) )
  1157 	 * The url of the current comment author escaped for use in attributes.
  1323 	 * The url of the current comment author escaped for use in attributes.
  1158 	 */
  1324 	 */
  1159 	$comment_author_url = esc_url($commenter['comment_author_url']);
  1325 	$comment_author_url = esc_url($commenter['comment_author_url']);
  1160 
  1326 
  1161 	$comment_args = array(
  1327 	$comment_args = array(
  1162 		'order'   => 'ASC',
       
  1163 		'orderby' => 'comment_date_gmt',
  1328 		'orderby' => 'comment_date_gmt',
       
  1329 		'order' => 'ASC',
  1164 		'status'  => 'approve',
  1330 		'status'  => 'approve',
  1165 		'post_id' => $post->ID,
  1331 		'post_id' => $post->ID,
       
  1332 		'no_found_rows' => false,
       
  1333 		'update_comment_meta_cache' => false, // We lazy-load comment meta for performance.
  1166 	);
  1334 	);
       
  1335 
       
  1336 	if ( get_option('thread_comments') ) {
       
  1337 		$comment_args['hierarchical'] = 'threaded';
       
  1338 	} else {
       
  1339 		$comment_args['hierarchical'] = false;
       
  1340 	}
  1167 
  1341 
  1168 	if ( $user_ID ) {
  1342 	if ( $user_ID ) {
  1169 		$comment_args['include_unapproved'] = array( $user_ID );
  1343 		$comment_args['include_unapproved'] = array( $user_ID );
  1170 	} elseif ( ! empty( $comment_author_email ) ) {
  1344 	} elseif ( ! empty( $comment_author_email ) ) {
  1171 		$comment_args['include_unapproved'] = array( $comment_author_email );
  1345 		$comment_args['include_unapproved'] = array( $comment_author_email );
  1172 	}
  1346 	}
  1173 
  1347 
  1174 	$comments = get_comments( $comment_args );
  1348 	$per_page = 0;
  1175 
  1349 	if ( get_option( 'page_comments' ) ) {
  1176 	/**
  1350 		$per_page = (int) get_query_var( 'comments_per_page' );
  1177 	 * Filter the comments array.
  1351 		if ( 0 === $per_page ) {
       
  1352 			$per_page = (int) get_option( 'comments_per_page' );
       
  1353 		}
       
  1354 
       
  1355 		$comment_args['number'] = $per_page;
       
  1356 		$page = (int) get_query_var( 'cpage' );
       
  1357 
       
  1358 		if ( $page ) {
       
  1359 			$comment_args['offset'] = ( $page - 1 ) * $per_page;
       
  1360 		} elseif ( 'oldest' === get_option( 'default_comments_page' ) ) {
       
  1361 			$comment_args['offset'] = 0;
       
  1362 		} else {
       
  1363 			// If fetching the first page of 'newest', we need a top-level comment count.
       
  1364 			$top_level_query = new WP_Comment_Query();
       
  1365 			$top_level_args  = array(
       
  1366 				'count'   => true,
       
  1367 				'orderby' => false,
       
  1368 				'post_id' => $post->ID,
       
  1369 				'status'  => 'approve',
       
  1370 			);
       
  1371 
       
  1372 			if ( $comment_args['hierarchical'] ) {
       
  1373 				$top_level_args['parent'] = 0;
       
  1374 			}
       
  1375 
       
  1376 			if ( isset( $comment_args['include_unapproved'] ) ) {
       
  1377 				$top_level_args['include_unapproved'] = $comment_args['include_unapproved'];
       
  1378 			}
       
  1379 
       
  1380 			$top_level_count = $top_level_query->query( $top_level_args );
       
  1381 
       
  1382 			$comment_args['offset'] = ( ceil( $top_level_count / $per_page ) - 1 ) * $per_page;
       
  1383 		}
       
  1384 	}
       
  1385 
       
  1386 	/**
       
  1387 	 * Filters the arguments used to query comments in comments_template().
       
  1388 	 *
       
  1389 	 * @since 4.5.0
       
  1390 	 *
       
  1391 	 * @see WP_Comment_Query::__construct()
       
  1392 	 *
       
  1393 	 * @param array $comment_args {
       
  1394 	 *     Array of WP_Comment_Query arguments.
       
  1395 	 *
       
  1396 	 *     @type string|array $orderby                   Field(s) to order by.
       
  1397 	 *     @type string       $order                     Order of results. Accepts 'ASC' or 'DESC'.
       
  1398 	 *     @type string       $status                    Comment status.
       
  1399 	 *     @type array        $include_unapproved        Array of IDs or email addresses whose unapproved comments
       
  1400 	 *                                                   will be included in results.
       
  1401 	 *     @type int          $post_id                   ID of the post.
       
  1402 	 *     @type bool         $no_found_rows             Whether to refrain from querying for found rows.
       
  1403 	 *     @type bool         $update_comment_meta_cache Whether to prime cache for comment meta.
       
  1404 	 *     @type bool|string  $hierarchical              Whether to query for comments hierarchically.
       
  1405 	 *     @type int          $offset                    Comment offset.
       
  1406 	 *     @type int          $number                    Number of comments to fetch.
       
  1407 	 * }
       
  1408 	 */
       
  1409 	$comment_args = apply_filters( 'comments_template_query_args', $comment_args );
       
  1410 	$comment_query = new WP_Comment_Query( $comment_args );
       
  1411 	$_comments = $comment_query->comments;
       
  1412 
       
  1413 	// Trees must be flattened before they're passed to the walker.
       
  1414 	if ( $comment_args['hierarchical'] ) {
       
  1415 		$comments_flat = array();
       
  1416 		foreach ( $_comments as $_comment ) {
       
  1417 			$comments_flat[]  = $_comment;
       
  1418 			$comment_children = $_comment->get_children( array(
       
  1419 				'format' => 'flat',
       
  1420 				'status' => $comment_args['status'],
       
  1421 				'orderby' => $comment_args['orderby']
       
  1422 			) );
       
  1423 
       
  1424 			foreach ( $comment_children as $comment_child ) {
       
  1425 				$comments_flat[] = $comment_child;
       
  1426 			}
       
  1427 		}
       
  1428 	} else {
       
  1429 		$comments_flat = $_comments;
       
  1430 	}
       
  1431 
       
  1432 	/**
       
  1433 	 * Filters the comments array.
  1178 	 *
  1434 	 *
  1179 	 * @since 2.1.0
  1435 	 * @since 2.1.0
  1180 	 *
  1436 	 *
  1181 	 * @param array $comments Array of comments supplied to the comments template.
  1437 	 * @param array $comments Array of comments supplied to the comments template.
  1182 	 * @param int   $post_ID  Post ID.
  1438 	 * @param int   $post_ID  Post ID.
  1183 	 */
  1439 	 */
  1184 	$wp_query->comments = apply_filters( 'comments_array', $comments, $post->ID );
  1440 	$wp_query->comments = apply_filters( 'comments_array', $comments_flat, $post->ID );
       
  1441 
  1185 	$comments = &$wp_query->comments;
  1442 	$comments = &$wp_query->comments;
  1186 	$wp_query->comment_count = count($wp_query->comments);
  1443 	$wp_query->comment_count = count($wp_query->comments);
  1187 	update_comment_cache($wp_query->comments);
  1444 	$wp_query->max_num_comment_pages = $comment_query->max_num_pages;
  1188 
  1445 
  1189 	if ( $separate_comments ) {
  1446 	if ( $separate_comments ) {
  1190 		$wp_query->comments_by_type = separate_comments($comments);
  1447 		$wp_query->comments_by_type = separate_comments($comments);
  1191 		$comments_by_type = &$wp_query->comments_by_type;
  1448 		$comments_by_type = &$wp_query->comments_by_type;
       
  1449 	} else {
       
  1450 		$wp_query->comments_by_type = array();
  1192 	}
  1451 	}
  1193 
  1452 
  1194 	$overridden_cpage = false;
  1453 	$overridden_cpage = false;
  1195 	if ( '' == get_query_var('cpage') && get_option('page_comments') ) {
  1454 	if ( '' == get_query_var( 'cpage' ) && $wp_query->max_num_comment_pages > 1 ) {
  1196 		set_query_var( 'cpage', 'newest' == get_option('default_comments_page') ? get_comment_pages_count() : 1 );
  1455 		set_query_var( 'cpage', 'newest' == get_option('default_comments_page') ? get_comment_pages_count() : 1 );
  1197 		$overridden_cpage = true;
  1456 		$overridden_cpage = true;
  1198 	}
  1457 	}
  1199 
  1458 
  1200 	if ( !defined('COMMENTS_TEMPLATE') )
  1459 	if ( !defined('COMMENTS_TEMPLATE') )
  1201 		define('COMMENTS_TEMPLATE', true);
  1460 		define('COMMENTS_TEMPLATE', true);
  1202 
  1461 
  1203 	$theme_template = STYLESHEETPATH . $file;
  1462 	$theme_template = STYLESHEETPATH . $file;
  1204 	/**
  1463 	/**
  1205 	 * Filter the path to the theme template file used for the comments template.
  1464 	 * Filters the path to the theme template file used for the comments template.
  1206 	 *
  1465 	 *
  1207 	 * @since 1.5.1
  1466 	 * @since 1.5.1
  1208 	 *
  1467 	 *
  1209 	 * @param string $theme_template The path to the theme template file.
  1468 	 * @param string $theme_template The path to the theme template file.
  1210 	 */
  1469 	 */
  1216 	else // Backward compat code will be removed in a future release
  1475 	else // Backward compat code will be removed in a future release
  1217 		require( ABSPATH . WPINC . '/theme-compat/comments.php');
  1476 		require( ABSPATH . WPINC . '/theme-compat/comments.php');
  1218 }
  1477 }
  1219 
  1478 
  1220 /**
  1479 /**
  1221  * Display the JS popup script to show a comment.
  1480  * Displays the link to the comments for the current post ID.
  1222  *
       
  1223  * If the $file parameter is empty, then the home page is assumed. The defaults
       
  1224  * for the window are 400px by 400px.
       
  1225  *
       
  1226  * For the comment link popup to work, this function has to be called or the
       
  1227  * normal comment link will be assumed.
       
  1228  *
       
  1229  * @global string $wpcommentspopupfile  The URL to use for the popup window.
       
  1230  * @global int    $wpcommentsjavascript Whether to use JavaScript. Set when function is called.
       
  1231  *
       
  1232  * @since 0.71
       
  1233  *
       
  1234  * @param int $width  Optional. The width of the popup window. Default 400.
       
  1235  * @param int $height Optional. The height of the popup window. Default 400.
       
  1236  * @param string $file Optional. Sets the location of the popup window.
       
  1237  */
       
  1238 function comments_popup_script( $width = 400, $height = 400, $file = '' ) {
       
  1239 	global $wpcommentspopupfile, $wpcommentsjavascript;
       
  1240 
       
  1241 	if (empty ($file)) {
       
  1242 		$wpcommentspopupfile = '';  // Use the index.
       
  1243 	} else {
       
  1244 		$wpcommentspopupfile = $file;
       
  1245 	}
       
  1246 
       
  1247 	$wpcommentsjavascript = 1;
       
  1248 	$javascript = "<script type='text/javascript'>\nfunction wpopen (macagna) {\n    window.open(macagna, '_blank', 'width=$width,height=$height,scrollbars=yes,status=yes');\n}\n</script>\n";
       
  1249 	echo $javascript;
       
  1250 }
       
  1251 
       
  1252 /**
       
  1253  * Displays the link to the comments popup window for the current post ID.
       
  1254  *
       
  1255  * Is not meant to be displayed on single posts and pages. Should be used
       
  1256  * on the lists of posts
       
  1257  *
       
  1258  * @global string $wpcommentspopupfile  The URL to use for the popup window.
       
  1259  * @global int    $wpcommentsjavascript Whether to use JavaScript. Set when function is called.
       
  1260  *
  1481  *
  1261  * @since 0.71
  1482  * @since 0.71
  1262  *
  1483  *
  1263  * @param string $zero      Optional. String to display when no comments. Default false.
  1484  * @param string $zero      Optional. String to display when no comments. Default false.
  1264  * @param string $one       Optional. String to display when only one comment is available.
  1485  * @param string $one       Optional. String to display when only one comment is available.
  1266  * @param string $more      Optional. String to display when there are more than one comment.
  1487  * @param string $more      Optional. String to display when there are more than one comment.
  1267  *                          Default false.
  1488  *                          Default false.
  1268  * @param string $css_class Optional. CSS class to use for comments. Default empty.
  1489  * @param string $css_class Optional. CSS class to use for comments. Default empty.
  1269  * @param string $none      Optional. String to display when comments have been turned off.
  1490  * @param string $none      Optional. String to display when comments have been turned off.
  1270  *                          Default false.
  1491  *                          Default false.
  1271  * @return null Returns null on single posts and pages.
       
  1272  */
  1492  */
  1273 function comments_popup_link( $zero = false, $one = false, $more = false, $css_class = '', $none = false ) {
  1493 function comments_popup_link( $zero = false, $one = false, $more = false, $css_class = '', $none = false ) {
  1274 	global $wpcommentspopupfile, $wpcommentsjavascript;
       
  1275 
       
  1276 	$id = get_the_ID();
  1494 	$id = get_the_ID();
  1277 	$title = get_the_title();
  1495 	$title = get_the_title();
  1278 	$number = get_comments_number( $id );
  1496 	$number = get_comments_number( $id );
  1279 
  1497 
  1280 	if ( false === $zero ) {
  1498 	if ( false === $zero ) {
  1302 		echo '<span' . ((!empty($css_class)) ? ' class="' . esc_attr( $css_class ) . '"' : '') . '>' . $none . '</span>';
  1520 		echo '<span' . ((!empty($css_class)) ? ' class="' . esc_attr( $css_class ) . '"' : '') . '>' . $none . '</span>';
  1303 		return;
  1521 		return;
  1304 	}
  1522 	}
  1305 
  1523 
  1306 	if ( post_password_required() ) {
  1524 	if ( post_password_required() ) {
  1307 		echo __('Enter your password to view comments.');
  1525 		_e( 'Enter your password to view comments.' );
  1308 		return;
  1526 		return;
  1309 	}
  1527 	}
  1310 
  1528 
  1311 	echo '<a href="';
  1529 	echo '<a href="';
  1312 	if ( $wpcommentsjavascript ) {
  1530 	if ( 0 == $number ) {
  1313 		if ( empty( $wpcommentspopupfile ) )
  1531 		$respond_link = get_permalink() . '#respond';
  1314 			$home = home_url();
  1532 		/**
  1315 		else
  1533 		 * Filters the respond link when a post has no comments.
  1316 			$home = get_option('siteurl');
  1534 		 *
  1317 		echo $home . '/' . $wpcommentspopupfile . '?comments_popup=' . $id;
  1535 		 * @since 4.4.0
  1318 		echo '" onclick="wpopen(this.href); return false"';
  1536 		 *
  1319 	} else { // if comments_popup_script() is not in the template, display simple comment link
  1537 		 * @param string $respond_link The default response link.
  1320 		if ( 0 == $number )
  1538 		 * @param integer $id The post ID.
  1321 			echo get_permalink() . '#respond';
  1539 		 */
  1322 		else
  1540 		echo apply_filters( 'respond_link', $respond_link, $id );
  1323 			comments_link();
  1541 	} else {
  1324 		echo '"';
  1542 		comments_link();
  1325 	}
  1543 	}
       
  1544 	echo '"';
  1326 
  1545 
  1327 	if ( !empty( $css_class ) ) {
  1546 	if ( !empty( $css_class ) ) {
  1328 		echo ' class="'.$css_class.'" ';
  1547 		echo ' class="'.$css_class.'" ';
  1329 	}
  1548 	}
  1330 
  1549 
  1331 	$attributes = '';
  1550 	$attributes = '';
  1332 	/**
  1551 	/**
  1333 	 * Filter the comments popup link attributes for display.
  1552 	 * Filters the comments link attributes for display.
  1334 	 *
  1553 	 *
  1335 	 * @since 2.5.0
  1554 	 * @since 2.5.0
  1336 	 *
  1555 	 *
  1337 	 * @param string $attributes The comments popup link attributes. Default empty.
  1556 	 * @param string $attributes The comments link attributes. Default empty.
  1338 	 */
  1557 	 */
  1339 	echo apply_filters( 'comments_popup_link_attributes', $attributes );
  1558 	echo apply_filters( 'comments_popup_link_attributes', $attributes );
  1340 
  1559 
  1341 	echo '>';
  1560 	echo '>';
  1342 	comments_number( $zero, $one, $more );
  1561 	comments_number( $zero, $one, $more );
  1345 
  1564 
  1346 /**
  1565 /**
  1347  * Retrieve HTML content for reply to comment link.
  1566  * Retrieve HTML content for reply to comment link.
  1348  *
  1567  *
  1349  * @since 2.7.0
  1568  * @since 2.7.0
       
  1569  * @since 4.4.0 Added the ability for `$comment` to also accept a WP_Comment object.
  1350  *
  1570  *
  1351  * @param array $args {
  1571  * @param array $args {
  1352  *     Optional. Override default arguments.
  1572  *     Optional. Override default arguments.
  1353  *
  1573  *
  1354  *     @type string $add_below  The first part of the selector used to identify the comment to respond below.
  1574  *     @type string $add_below  The first part of the selector used to identify the comment to respond below.
  1357  *     @type string $respond_id The selector identifying the responding comment. Passed as the third parameter
  1577  *     @type string $respond_id The selector identifying the responding comment. Passed as the third parameter
  1358  *                              to addComment.moveForm(), and appended to the link URL as a hash value.
  1578  *                              to addComment.moveForm(), and appended to the link URL as a hash value.
  1359  *                              Default 'respond'.
  1579  *                              Default 'respond'.
  1360  *     @type string $reply_text The text of the Reply link. Default 'Reply'.
  1580  *     @type string $reply_text The text of the Reply link. Default 'Reply'.
  1361  *     @type string $login_text The text of the link to reply if logged out. Default 'Log in to Reply'.
  1581  *     @type string $login_text The text of the link to reply if logged out. Default 'Log in to Reply'.
  1362  *     @type int    $depth'     The depth of the new comment. Must be greater than 0 and less than the value
  1582  *     @type int    $max_depth  The max depth of the comment tree. Default 0.
       
  1583  *     @type int    $depth      The depth of the new comment. Must be greater than 0 and less than the value
  1363  *                              of the 'thread_comments_depth' option set in Settings > Discussion. Default 0.
  1584  *                              of the 'thread_comments_depth' option set in Settings > Discussion. Default 0.
  1364  *     @type string $before     The text or HTML to add before the reply link. Default empty.
  1585  *     @type string $before     The text or HTML to add before the reply link. Default empty.
  1365  *     @type string $after      The text or HTML to add after the reply link. Default empty.
  1586  *     @type string $after      The text or HTML to add after the reply link. Default empty.
  1366  * }
  1587  * }
  1367  * @param int         $comment Comment being replied to. Default current comment.
  1588  * @param int|WP_Comment $comment Comment being replied to. Default current comment.
  1368  * @param int|WP_Post $post    Post ID or WP_Post object the comment is going to be displayed on.
  1589  * @param int|WP_Post    $post    Post ID or WP_Post object the comment is going to be displayed on.
  1369  *                             Default current post.
  1590  *                                Default current post.
  1370  * @return null|false|string Link to show comment form, if successful. False, if comments are closed.
  1591  * @return void|false|string Link to show comment form, if successful. False, if comments are closed.
  1371  */
  1592  */
  1372 function get_comment_reply_link( $args = array(), $comment = null, $post = null ) {
  1593 function get_comment_reply_link( $args = array(), $comment = null, $post = null ) {
  1373 
       
  1374 	$defaults = array(
  1594 	$defaults = array(
  1375 		'add_below'     => 'comment',
  1595 		'add_below'     => 'comment',
  1376 		'respond_id'    => 'respond',
  1596 		'respond_id'    => 'respond',
  1377 		'reply_text'    => __( 'Reply' ),
  1597 		'reply_text'    => __( 'Reply' ),
       
  1598 		/* translators: Comment reply button text. 1: Comment author name */
  1378 		'reply_to_text' => __( 'Reply to %s' ),
  1599 		'reply_to_text' => __( 'Reply to %s' ),
  1379 		'login_text'    => __( 'Log in to Reply' ),
  1600 		'login_text'    => __( 'Log in to Reply' ),
       
  1601 		'max_depth'     => 0,
  1380 		'depth'         => 0,
  1602 		'depth'         => 0,
  1381 		'before'        => '',
  1603 		'before'        => '',
  1382 		'after'         => ''
  1604 		'after'         => ''
  1383 	);
  1605 	);
  1384 
  1606 
  1399 	if ( ! comments_open( $post->ID ) ) {
  1621 	if ( ! comments_open( $post->ID ) ) {
  1400 		return false;
  1622 		return false;
  1401 	}
  1623 	}
  1402 
  1624 
  1403 	/**
  1625 	/**
  1404 	 * Filter the comment reply link arguments.
  1626 	 * Filters the comment reply link arguments.
  1405 	 *
  1627 	 *
  1406 	 * @since 4.1.0
  1628 	 * @since 4.1.0
  1407 	 *
  1629 	 *
  1408 	 * @param array   $args    Comment reply link arguments. See {@see get_comment_reply_link()}
  1630 	 * @param array      $args    Comment reply link arguments. See get_comment_reply_link()
  1409 	 *                         for more information on accepted arguments.
  1631 	 *                            for more information on accepted arguments.
  1410 	 * @param object  $comment The object of the comment being replied to.
  1632 	 * @param WP_Comment $comment The object of the comment being replied to.
  1411 	 * @param WP_Post $post    The {@see WP_Post} object.
  1633 	 * @param WP_Post    $post    The WP_Post object.
  1412 	 */
  1634 	 */
  1413 	$args = apply_filters( 'comment_reply_link_args', $args, $comment, $post );
  1635 	$args = apply_filters( 'comment_reply_link_args', $args, $comment, $post );
  1414 
  1636 
  1415 	if ( get_option( 'comment_registration' ) && ! is_user_logged_in() ) {
  1637 	if ( get_option( 'comment_registration' ) && ! is_user_logged_in() ) {
  1416 		$link = sprintf( '<a rel="nofollow" class="comment-reply-login" href="%s">%s</a>',
  1638 		$link = sprintf( '<a rel="nofollow" class="comment-reply-login" href="%s">%s</a>',
  1420 	} else {
  1642 	} else {
  1421 		$onclick = sprintf( 'return addComment.moveForm( "%1$s-%2$s", "%2$s", "%3$s", "%4$s" )',
  1643 		$onclick = sprintf( 'return addComment.moveForm( "%1$s-%2$s", "%2$s", "%3$s", "%4$s" )',
  1422 			$args['add_below'], $comment->comment_ID, $args['respond_id'], $post->ID
  1644 			$args['add_below'], $comment->comment_ID, $args['respond_id'], $post->ID
  1423 		);
  1645 		);
  1424 
  1646 
  1425 		$link = sprintf( "<a class='comment-reply-link' href='%s' onclick='%s' aria-label='%s'>%s</a>",
  1647 		$link = sprintf( "<a rel='nofollow' class='comment-reply-link' href='%s' onclick='%s' aria-label='%s'>%s</a>",
  1426 			esc_url( add_query_arg( 'replytocom', $comment->comment_ID ) ) . "#" . $args['respond_id'],
  1648 			esc_url( add_query_arg( 'replytocom', $comment->comment_ID, get_permalink( $post->ID ) ) ) . "#" . $args['respond_id'],
  1427 			$onclick,
  1649 			$onclick,
  1428 			esc_attr( sprintf( $args['reply_to_text'], $comment->comment_author ) ),
  1650 			esc_attr( sprintf( $args['reply_to_text'], $comment->comment_author ) ),
  1429 			$args['reply_text']
  1651 			$args['reply_text']
  1430 		);
  1652 		);
  1431 	}
  1653 	}
  1432 	/**
  1654 
  1433 	 * Filter the comment reply link.
  1655 	/**
       
  1656 	 * Filters the comment reply link.
  1434 	 *
  1657 	 *
  1435 	 * @since 2.7.0
  1658 	 * @since 2.7.0
  1436 	 *
  1659 	 *
  1437 	 * @param string  $link    The HTML markup for the comment reply link.
  1660 	 * @param string  $link    The HTML markup for the comment reply link.
  1438 	 * @param array   $args    An array of arguments overriding the defaults.
  1661 	 * @param array   $args    An array of arguments overriding the defaults.
  1515 			$onclick,
  1738 			$onclick,
  1516 			$args['reply_text']
  1739 			$args['reply_text']
  1517 		);
  1740 		);
  1518 	}
  1741 	}
  1519 	$formatted_link = $args['before'] . $link . $args['after'];
  1742 	$formatted_link = $args['before'] . $link . $args['after'];
  1520 	/**
  1743 
  1521 	 * Filter the formatted post comments link HTML.
  1744 	/**
       
  1745 	 * Filters the formatted post comments link HTML.
  1522 	 *
  1746 	 *
  1523 	 * @since 2.7.0
  1747 	 * @since 2.7.0
  1524 	 *
  1748 	 *
  1525 	 * @param string      $formatted The HTML-formatted post comments link.
  1749 	 * @param string      $formatted The HTML-formatted post comments link.
  1526 	 * @param int|WP_Post $post      The post ID or WP_Post object.
  1750 	 * @param int|WP_Post $post      The post ID or WP_Post object.
  1548  * Retrieve HTML content for cancel comment reply link.
  1772  * Retrieve HTML content for cancel comment reply link.
  1549  *
  1773  *
  1550  * @since 2.7.0
  1774  * @since 2.7.0
  1551  *
  1775  *
  1552  * @param string $text Optional. Text to display for cancel reply link. Default empty.
  1776  * @param string $text Optional. Text to display for cancel reply link. Default empty.
       
  1777  * @return string
  1553  */
  1778  */
  1554 function get_cancel_comment_reply_link( $text = '' ) {
  1779 function get_cancel_comment_reply_link( $text = '' ) {
  1555 	if ( empty($text) )
  1780 	if ( empty($text) )
  1556 		$text = __('Click here to cancel reply.');
  1781 		$text = __('Click here to cancel reply.');
  1557 
  1782 
  1558 	$style = isset($_GET['replytocom']) ? '' : ' style="display:none;"';
  1783 	$style = isset($_GET['replytocom']) ? '' : ' style="display:none;"';
  1559 	$link = esc_html( remove_query_arg('replytocom') ) . '#respond';
  1784 	$link = esc_html( remove_query_arg('replytocom') ) . '#respond';
  1560 
  1785 
  1561 	$formatted_link = '<a rel="nofollow" id="cancel-comment-reply-link" href="' . $link . '"' . $style . '>' . $text . '</a>';
  1786 	$formatted_link = '<a rel="nofollow" id="cancel-comment-reply-link" href="' . $link . '"' . $style . '>' . $text . '</a>';
  1562 	/**
  1787 
  1563 	 * Filter the cancel comment reply link HTML.
  1788 	/**
       
  1789 	 * Filters the cancel comment reply link HTML.
  1564 	 *
  1790 	 *
  1565 	 * @since 2.7.0
  1791 	 * @since 2.7.0
  1566 	 *
  1792 	 *
  1567 	 * @param string $formatted_link The HTML-formatted cancel comment reply link.
  1793 	 * @param string $formatted_link The HTML-formatted cancel comment reply link.
  1568 	 * @param string $link           Cancel comment reply link URL.
  1794 	 * @param string $link           Cancel comment reply link URL.
  1597 	$replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0;
  1823 	$replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0;
  1598 	$result  = "<input type='hidden' name='comment_post_ID' value='$id' id='comment_post_ID' />\n";
  1824 	$result  = "<input type='hidden' name='comment_post_ID' value='$id' id='comment_post_ID' />\n";
  1599 	$result .= "<input type='hidden' name='comment_parent' id='comment_parent' value='$replytoid' />\n";
  1825 	$result .= "<input type='hidden' name='comment_parent' id='comment_parent' value='$replytoid' />\n";
  1600 
  1826 
  1601 	/**
  1827 	/**
  1602 	 * Filter the returned comment id fields.
  1828 	 * Filters the returned comment id fields.
  1603 	 *
  1829 	 *
  1604 	 * @since 3.0.0
  1830 	 * @since 3.0.0
  1605 	 *
  1831 	 *
  1606 	 * @param string $result    The HTML-formatted hidden id field comment elements.
  1832 	 * @param string $result    The HTML-formatted hidden id field comment elements.
  1607 	 * @param int    $id        The post ID.
  1833 	 * @param int    $id        The post ID.
  1624 /**
  1850 /**
  1625  * Display text based on comment reply status.
  1851  * Display text based on comment reply status.
  1626  *
  1852  *
  1627  * Only affects users with JavaScript disabled.
  1853  * Only affects users with JavaScript disabled.
  1628  *
  1854  *
       
  1855  * @internal The $comment global must be present to allow template tags access to the current
       
  1856  *           comment. See https://core.trac.wordpress.org/changeset/36512.
       
  1857  *
  1629  * @since 2.7.0
  1858  * @since 2.7.0
       
  1859  *
       
  1860  * @global WP_Comment $comment Current comment.
  1630  *
  1861  *
  1631  * @param string $noreplytext  Optional. Text to display when not replying to a comment.
  1862  * @param string $noreplytext  Optional. Text to display when not replying to a comment.
  1632  *                             Default false.
  1863  *                             Default false.
  1633  * @param string $replytext    Optional. Text to display when replying to a comment.
  1864  * @param string $replytext    Optional. Text to display when replying to a comment.
  1634  *                             Default false. Accepts "%s" for the author of the comment
  1865  *                             Default false. Accepts "%s" for the author of the comment
  1645 	$replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0;
  1876 	$replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0;
  1646 
  1877 
  1647 	if ( 0 == $replytoid )
  1878 	if ( 0 == $replytoid )
  1648 		echo $noreplytext;
  1879 		echo $noreplytext;
  1649 	else {
  1880 	else {
       
  1881 		// Sets the global so that template tags can be used in the comment form.
  1650 		$comment = get_comment($replytoid);
  1882 		$comment = get_comment($replytoid);
  1651 		$author = ( $linktoparent ) ? '<a href="#comment-' . get_comment_ID() . '">' . get_comment_author() . '</a>' : get_comment_author();
  1883 		$author = ( $linktoparent ) ? '<a href="#comment-' . get_comment_ID() . '">' . get_comment_author( $comment ) . '</a>' : get_comment_author( $comment );
  1652 		printf( $replytext, $author );
  1884 		printf( $replytext, $author );
  1653 	}
  1885 	}
  1654 }
  1886 }
  1655 
  1887 
  1656 /**
  1888 /**
  1657  * HTML comment list class.
  1889  * List comments.
  1658  *
  1890  *
  1659  * @uses Walker
  1891  * Used in the comments.php template to list comments for a particular post.
       
  1892  *
  1660  * @since 2.7.0
  1893  * @since 2.7.0
  1661  */
       
  1662 class Walker_Comment extends Walker {
       
  1663 	/**
       
  1664 	 * What the class handles.
       
  1665 	 *
       
  1666 	 * @see Walker::$tree_type
       
  1667 	 *
       
  1668 	 * @since 2.7.0
       
  1669 	 * @var string
       
  1670 	 */
       
  1671 	public $tree_type = 'comment';
       
  1672 
       
  1673 	/**
       
  1674 	 * DB fields to use.
       
  1675 	 *
       
  1676 	 * @see Walker::$db_fields
       
  1677 	 *
       
  1678 	 * @since 2.7.0
       
  1679 	 * @var array
       
  1680 	 */
       
  1681 	public $db_fields = array ('parent' => 'comment_parent', 'id' => 'comment_ID');
       
  1682 
       
  1683 	/**
       
  1684 	 * Start the list before the elements are added.
       
  1685 	 *
       
  1686 	 * @see Walker::start_lvl()
       
  1687 	 *
       
  1688 	 * @since 2.7.0
       
  1689 	 *
       
  1690 	 * @param string $output Passed by reference. Used to append additional content.
       
  1691 	 * @param int $depth Depth of comment.
       
  1692 	 * @param array $args Uses 'style' argument for type of HTML list.
       
  1693 	 */
       
  1694 	public function start_lvl( &$output, $depth = 0, $args = array() ) {
       
  1695 		$GLOBALS['comment_depth'] = $depth + 1;
       
  1696 
       
  1697 		switch ( $args['style'] ) {
       
  1698 			case 'div':
       
  1699 				break;
       
  1700 			case 'ol':
       
  1701 				$output .= '<ol class="children">' . "\n";
       
  1702 				break;
       
  1703 			case 'ul':
       
  1704 			default:
       
  1705 				$output .= '<ul class="children">' . "\n";
       
  1706 				break;
       
  1707 		}
       
  1708 	}
       
  1709 
       
  1710 	/**
       
  1711 	 * End the list of items after the elements are added.
       
  1712 	 *
       
  1713 	 * @see Walker::end_lvl()
       
  1714 	 *
       
  1715 	 * @since 2.7.0
       
  1716 	 *
       
  1717 	 * @param string $output Passed by reference. Used to append additional content.
       
  1718 	 * @param int    $depth  Depth of comment.
       
  1719 	 * @param array  $args   Will only append content if style argument value is 'ol' or 'ul'.
       
  1720 	 */
       
  1721 	public function end_lvl( &$output, $depth = 0, $args = array() ) {
       
  1722 		$GLOBALS['comment_depth'] = $depth + 1;
       
  1723 
       
  1724 		switch ( $args['style'] ) {
       
  1725 			case 'div':
       
  1726 				break;
       
  1727 			case 'ol':
       
  1728 				$output .= "</ol><!-- .children -->\n";
       
  1729 				break;
       
  1730 			case 'ul':
       
  1731 			default:
       
  1732 				$output .= "</ul><!-- .children -->\n";
       
  1733 				break;
       
  1734 		}
       
  1735 	}
       
  1736 
       
  1737 	/**
       
  1738 	 * Traverse elements to create list from elements.
       
  1739 	 *
       
  1740 	 * This function is designed to enhance Walker::display_element() to
       
  1741 	 * display children of higher nesting levels than selected inline on
       
  1742 	 * the highest depth level displayed. This prevents them being orphaned
       
  1743 	 * at the end of the comment list.
       
  1744 	 *
       
  1745 	 * Example: max_depth = 2, with 5 levels of nested content.
       
  1746 	 * 1
       
  1747 	 *  1.1
       
  1748 	 *    1.1.1
       
  1749 	 *    1.1.1.1
       
  1750 	 *    1.1.1.1.1
       
  1751 	 *    1.1.2
       
  1752 	 *    1.1.2.1
       
  1753 	 * 2
       
  1754 	 *  2.2
       
  1755 	 *
       
  1756 	 * @see Walker::display_element()
       
  1757 	 * @see wp_list_comments()
       
  1758 	 *
       
  1759 	 * @since 2.7.0
       
  1760 	 *
       
  1761 	 * @param object $element           Data object.
       
  1762 	 * @param array  $children_elements List of elements to continue traversing.
       
  1763 	 * @param int    $max_depth         Max depth to traverse.
       
  1764 	 * @param int    $depth             Depth of current element.
       
  1765 	 * @param array  $args              An array of arguments.
       
  1766 	 * @param string $output            Passed by reference. Used to append additional content.
       
  1767 	 * @return null Null on failure with no changes to parameters.
       
  1768 	 */
       
  1769 	public function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) {
       
  1770 
       
  1771 		if ( !$element )
       
  1772 			return;
       
  1773 
       
  1774 		$id_field = $this->db_fields['id'];
       
  1775 		$id = $element->$id_field;
       
  1776 
       
  1777 		parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
       
  1778 
       
  1779 		// If we're at the max depth, and the current element still has children, loop over those and display them at this level
       
  1780 		// This is to prevent them being orphaned to the end of the list.
       
  1781 		if ( $max_depth <= $depth + 1 && isset( $children_elements[$id]) ) {
       
  1782 			foreach ( $children_elements[ $id ] as $child )
       
  1783 				$this->display_element( $child, $children_elements, $max_depth, $depth, $args, $output );
       
  1784 
       
  1785 			unset( $children_elements[ $id ] );
       
  1786 		}
       
  1787 
       
  1788 	}
       
  1789 
       
  1790 	/**
       
  1791 	 * Start the element output.
       
  1792 	 *
       
  1793 	 * @since 2.7.0
       
  1794 	 *
       
  1795 	 * @see Walker::start_el()
       
  1796 	 * @see wp_list_comments()
       
  1797 	 *
       
  1798 	 * @param string $output  Passed by reference. Used to append additional content.
       
  1799 	 * @param object $comment Comment data object.
       
  1800 	 * @param int    $depth   Depth of comment in reference to parents.
       
  1801 	 * @param array  $args    An array of arguments.
       
  1802 	 */
       
  1803 	public function start_el( &$output, $comment, $depth = 0, $args = array(), $id = 0 ) {
       
  1804 		$depth++;
       
  1805 		$GLOBALS['comment_depth'] = $depth;
       
  1806 		$GLOBALS['comment'] = $comment;
       
  1807 
       
  1808 		if ( !empty( $args['callback'] ) ) {
       
  1809 			ob_start();
       
  1810 			call_user_func( $args['callback'], $comment, $args, $depth );
       
  1811 			$output .= ob_get_clean();
       
  1812 			return;
       
  1813 		}
       
  1814 
       
  1815 		if ( ( 'pingback' == $comment->comment_type || 'trackback' == $comment->comment_type ) && $args['short_ping'] ) {
       
  1816 			ob_start();
       
  1817 			$this->ping( $comment, $depth, $args );
       
  1818 			$output .= ob_get_clean();
       
  1819 		} elseif ( 'html5' === $args['format'] ) {
       
  1820 			ob_start();
       
  1821 			$this->html5_comment( $comment, $depth, $args );
       
  1822 			$output .= ob_get_clean();
       
  1823 		} else {
       
  1824 			ob_start();
       
  1825 			$this->comment( $comment, $depth, $args );
       
  1826 			$output .= ob_get_clean();
       
  1827 		}
       
  1828 	}
       
  1829 
       
  1830 	/**
       
  1831 	 * Ends the element output, if needed.
       
  1832 	 *
       
  1833 	 * @since 2.7.0
       
  1834 	 *
       
  1835 	 * @see Walker::end_el()
       
  1836 	 * @see wp_list_comments()
       
  1837 	 *
       
  1838 	 * @param string $output  Passed by reference. Used to append additional content.
       
  1839 	 * @param object $comment The comment object. Default current comment.
       
  1840 	 * @param int    $depth   Depth of comment.
       
  1841 	 * @param array  $args    An array of arguments.
       
  1842 	 */
       
  1843 	public function end_el( &$output, $comment, $depth = 0, $args = array() ) {
       
  1844 		if ( !empty( $args['end-callback'] ) ) {
       
  1845 			ob_start();
       
  1846 			call_user_func( $args['end-callback'], $comment, $args, $depth );
       
  1847 			$output .= ob_get_clean();
       
  1848 			return;
       
  1849 		}
       
  1850 		if ( 'div' == $args['style'] )
       
  1851 			$output .= "</div><!-- #comment-## -->\n";
       
  1852 		else
       
  1853 			$output .= "</li><!-- #comment-## -->\n";
       
  1854 	}
       
  1855 
       
  1856 	/**
       
  1857 	 * Output a pingback comment.
       
  1858 	 *
       
  1859 	 * @access protected
       
  1860 	 * @since 3.6.0
       
  1861 	 *
       
  1862 	 * @see wp_list_comments()
       
  1863 	 *
       
  1864 	 * @param object $comment The comment object.
       
  1865 	 * @param int    $depth   Depth of comment.
       
  1866 	 * @param array  $args    An array of arguments.
       
  1867 	 */
       
  1868 	protected function ping( $comment, $depth, $args ) {
       
  1869 		$tag = ( 'div' == $args['style'] ) ? 'div' : 'li';
       
  1870 ?>
       
  1871 		<<?php echo $tag; ?> id="comment-<?php comment_ID(); ?>" <?php comment_class(); ?>>
       
  1872 			<div class="comment-body">
       
  1873 				<?php _e( 'Pingback:' ); ?> <?php comment_author_link(); ?> <?php edit_comment_link( __( 'Edit' ), '<span class="edit-link">', '</span>' ); ?>
       
  1874 			</div>
       
  1875 <?php
       
  1876 	}
       
  1877 
       
  1878 	/**
       
  1879 	 * Output a single comment.
       
  1880 	 *
       
  1881 	 * @access protected
       
  1882 	 * @since 3.6.0
       
  1883 	 *
       
  1884 	 * @see wp_list_comments()
       
  1885 	 *
       
  1886 	 * @param object $comment Comment to display.
       
  1887 	 * @param int    $depth   Depth of comment.
       
  1888 	 * @param array  $args    An array of arguments.
       
  1889 	 */
       
  1890 	protected function comment( $comment, $depth, $args ) {
       
  1891 		if ( 'div' == $args['style'] ) {
       
  1892 			$tag = 'div';
       
  1893 			$add_below = 'comment';
       
  1894 		} else {
       
  1895 			$tag = 'li';
       
  1896 			$add_below = 'div-comment';
       
  1897 		}
       
  1898 ?>
       
  1899 		<<?php echo $tag; ?> <?php comment_class( $this->has_children ? 'parent' : '' ); ?> id="comment-<?php comment_ID(); ?>">
       
  1900 		<?php if ( 'div' != $args['style'] ) : ?>
       
  1901 		<div id="div-comment-<?php comment_ID(); ?>" class="comment-body">
       
  1902 		<?php endif; ?>
       
  1903 		<div class="comment-author vcard">
       
  1904 			<?php if ( 0 != $args['avatar_size'] ) echo get_avatar( $comment, $args['avatar_size'] ); ?>
       
  1905 			<?php printf( __( '<cite class="fn">%s</cite> <span class="says">says:</span>' ), get_comment_author_link() ); ?>
       
  1906 		</div>
       
  1907 		<?php if ( '0' == $comment->comment_approved ) : ?>
       
  1908 		<em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.' ) ?></em>
       
  1909 		<br />
       
  1910 		<?php endif; ?>
       
  1911 
       
  1912 		<div class="comment-meta commentmetadata"><a href="<?php echo esc_url( get_comment_link( $comment->comment_ID, $args ) ); ?>">
       
  1913 			<?php
       
  1914 				/* translators: 1: date, 2: time */
       
  1915 				printf( __( '%1$s at %2$s' ), get_comment_date(),  get_comment_time() ); ?></a><?php edit_comment_link( __( '(Edit)' ), '&nbsp;&nbsp;', '' );
       
  1916 			?>
       
  1917 		</div>
       
  1918 
       
  1919 		<?php comment_text( get_comment_id(), array_merge( $args, array( 'add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
       
  1920 
       
  1921 		<?php
       
  1922 		comment_reply_link( array_merge( $args, array(
       
  1923 			'add_below' => $add_below,
       
  1924 			'depth'     => $depth,
       
  1925 			'max_depth' => $args['max_depth'],
       
  1926 			'before'    => '<div class="reply">',
       
  1927 			'after'     => '</div>'
       
  1928 		) ) );
       
  1929 		?>
       
  1930 
       
  1931 		<?php if ( 'div' != $args['style'] ) : ?>
       
  1932 		</div>
       
  1933 		<?php endif; ?>
       
  1934 <?php
       
  1935 	}
       
  1936 
       
  1937 	/**
       
  1938 	 * Output a comment in the HTML5 format.
       
  1939 	 *
       
  1940 	 * @access protected
       
  1941 	 * @since 3.6.0
       
  1942 	 *
       
  1943 	 * @see wp_list_comments()
       
  1944 	 *
       
  1945 	 * @param object $comment Comment to display.
       
  1946 	 * @param int    $depth   Depth of comment.
       
  1947 	 * @param array  $args    An array of arguments.
       
  1948 	 */
       
  1949 	protected function html5_comment( $comment, $depth, $args ) {
       
  1950 		$tag = ( 'div' === $args['style'] ) ? 'div' : 'li';
       
  1951 ?>
       
  1952 		<<?php echo $tag; ?> id="comment-<?php comment_ID(); ?>" <?php comment_class( $this->has_children ? 'parent' : '' ); ?>>
       
  1953 			<article id="div-comment-<?php comment_ID(); ?>" class="comment-body">
       
  1954 				<footer class="comment-meta">
       
  1955 					<div class="comment-author vcard">
       
  1956 						<?php if ( 0 != $args['avatar_size'] ) echo get_avatar( $comment, $args['avatar_size'] ); ?>
       
  1957 						<?php printf( __( '%s <span class="says">says:</span>' ), sprintf( '<b class="fn">%s</b>', get_comment_author_link() ) ); ?>
       
  1958 					</div><!-- .comment-author -->
       
  1959 
       
  1960 					<div class="comment-metadata">
       
  1961 						<a href="<?php echo esc_url( get_comment_link( $comment->comment_ID, $args ) ); ?>">
       
  1962 							<time datetime="<?php comment_time( 'c' ); ?>">
       
  1963 								<?php printf( _x( '%1$s at %2$s', '1: date, 2: time' ), get_comment_date(), get_comment_time() ); ?>
       
  1964 							</time>
       
  1965 						</a>
       
  1966 						<?php edit_comment_link( __( 'Edit' ), '<span class="edit-link">', '</span>' ); ?>
       
  1967 					</div><!-- .comment-metadata -->
       
  1968 
       
  1969 					<?php if ( '0' == $comment->comment_approved ) : ?>
       
  1970 					<p class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.' ); ?></p>
       
  1971 					<?php endif; ?>
       
  1972 				</footer><!-- .comment-meta -->
       
  1973 
       
  1974 				<div class="comment-content">
       
  1975 					<?php comment_text(); ?>
       
  1976 				</div><!-- .comment-content -->
       
  1977 
       
  1978 				<?php
       
  1979 				comment_reply_link( array_merge( $args, array(
       
  1980 					'add_below' => 'div-comment',
       
  1981 					'depth'     => $depth,
       
  1982 					'max_depth' => $args['max_depth'],
       
  1983 					'before'    => '<div class="reply">',
       
  1984 					'after'     => '</div>'
       
  1985 				) ) );
       
  1986 				?>
       
  1987 			</article><!-- .comment-body -->
       
  1988 <?php
       
  1989 	}
       
  1990 }
       
  1991 
       
  1992 /**
       
  1993  * List comments.
       
  1994  *
       
  1995  * Used in the comments.php template to list comments for a particular post.
       
  1996  *
       
  1997  * @since 2.7.0
       
  1998  *
  1894  *
  1999  * @see WP_Query->comments
  1895  * @see WP_Query->comments
       
  1896  *
       
  1897  * @global WP_Query $wp_query
       
  1898  * @global int      $comment_alt
       
  1899  * @global int      $comment_depth
       
  1900  * @global int      $comment_thread_alt
       
  1901  * @global bool     $overridden_cpage
       
  1902  * @global bool     $in_comment_loop
  2000  *
  1903  *
  2001  * @param string|array $args {
  1904  * @param string|array $args {
  2002  *     Optional. Formatting options.
  1905  *     Optional. Formatting options.
  2003  *
  1906  *
  2004  *     @type object $walker            Instance of a Walker class to list comments. Default null.
  1907  *     @type object $walker            Instance of a Walker class to list comments. Default null.
  2009  *     @type string $type              Type of comments to list.
  1912  *     @type string $type              Type of comments to list.
  2010  *                                     Default 'all'. Accepts 'all', 'comment', 'pingback', 'trackback', 'pings'.
  1913  *                                     Default 'all'. Accepts 'all', 'comment', 'pingback', 'trackback', 'pings'.
  2011  *     @type int    $page              Page ID to list comments for. Default empty.
  1914  *     @type int    $page              Page ID to list comments for. Default empty.
  2012  *     @type int    $per_page          Number of comments to list per page. Default empty.
  1915  *     @type int    $per_page          Number of comments to list per page. Default empty.
  2013  *     @type int    $avatar_size       Height and width dimensions of the avatar size. Default 32.
  1916  *     @type int    $avatar_size       Height and width dimensions of the avatar size. Default 32.
  2014  *     @type string $reverse_top_level Ordering of the listed comments. Default null. Accepts 'desc', 'asc'.
  1917  *     @type bool   $reverse_top_level Ordering of the listed comments. If true, will display newest comments first.
  2015  *     @type bool   $reverse_children  Whether to reverse child comments in the list. Default null.
  1918  *     @type bool   $reverse_children  Whether to reverse child comments in the list. Default null.
  2016  *     @type string $format            How to format the comments list.
  1919  *     @type string $format            How to format the comments list.
  2017  *                                     Default 'html5' if the theme supports it. Accepts 'html5', 'xhtml'.
  1920  *                                     Default 'html5' if the theme supports it. Accepts 'html5', 'xhtml'.
  2018  *     @type bool   $short_ping        Whether to output short pings. Default false.
  1921  *     @type bool   $short_ping        Whether to output short pings. Default false.
  2019  *     @type bool   $echo              Whether to echo the output or return it. Default true.
  1922  *     @type bool   $echo              Whether to echo the output or return it. Default true.
  2020  * }
  1923  * }
  2021  * @param array $comments Optional. Array of comment objects.
  1924  * @param array $comments Optional. Array of WP_Comment objects.
  2022  */
  1925  */
  2023 function wp_list_comments( $args = array(), $comments = null ) {
  1926 function wp_list_comments( $args = array(), $comments = null ) {
  2024 	global $wp_query, $comment_alt, $comment_depth, $comment_thread_alt, $overridden_cpage, $in_comment_loop;
  1927 	global $wp_query, $comment_alt, $comment_depth, $comment_thread_alt, $overridden_cpage, $in_comment_loop;
  2025 
  1928 
  2026 	$in_comment_loop = true;
  1929 	$in_comment_loop = true;
  2046 	);
  1949 	);
  2047 
  1950 
  2048 	$r = wp_parse_args( $args, $defaults );
  1951 	$r = wp_parse_args( $args, $defaults );
  2049 
  1952 
  2050 	/**
  1953 	/**
  2051 	 * Filter the arguments used in retrieving the comment list.
  1954 	 * Filters the arguments used in retrieving the comment list.
  2052 	 *
  1955 	 *
  2053 	 * @since 4.0.0
  1956 	 * @since 4.0.0
  2054 	 *
  1957 	 *
  2055 	 * @see wp_list_comments()
  1958 	 * @see wp_list_comments()
  2056 	 *
  1959 	 *
  2070 			$_comments = $comments_by_type[$r['type']];
  1973 			$_comments = $comments_by_type[$r['type']];
  2071 		} else {
  1974 		} else {
  2072 			$_comments = $comments;
  1975 			$_comments = $comments;
  2073 		}
  1976 		}
  2074 	} else {
  1977 	} else {
  2075 		if ( empty($wp_query->comments) )
  1978 		/*
  2076 			return;
  1979 		 * If 'page' or 'per_page' has been passed, and does not match what's in $wp_query,
  2077 		if ( 'all' != $r['type'] ) {
  1980 		 * perform a separate comment query and allow Walker_Comment to paginate.
  2078 			if ( empty($wp_query->comments_by_type) )
  1981 		 */
  2079 				$wp_query->comments_by_type = separate_comments($wp_query->comments);
  1982 		if ( $r['page'] || $r['per_page'] ) {
  2080 			if ( empty($wp_query->comments_by_type[$r['type']]) )
  1983 			$current_cpage = get_query_var( 'cpage' );
       
  1984 			if ( ! $current_cpage ) {
       
  1985 				$current_cpage = 'newest' === get_option( 'default_comments_page' ) ? 1 : $wp_query->max_num_comment_pages;
       
  1986 			}
       
  1987 
       
  1988 			$current_per_page = get_query_var( 'comments_per_page' );
       
  1989 			if ( $r['page'] != $current_cpage || $r['per_page'] != $current_per_page ) {
       
  1990 				$comment_args = array(
       
  1991 					'post_id' => get_the_ID(),
       
  1992 					'orderby' => 'comment_date_gmt',
       
  1993 					'order' => 'ASC',
       
  1994 					'status' => 'approve',
       
  1995 				);
       
  1996 
       
  1997 				if ( is_user_logged_in() ) {
       
  1998 					$comment_args['include_unapproved'] = get_current_user_id();
       
  1999 				} else {
       
  2000 					$commenter = wp_get_current_commenter();
       
  2001 					if ( $commenter['comment_author_email'] ) {
       
  2002 						$comment_args['include_unapproved'] = $commenter['comment_author_email'];
       
  2003 					}
       
  2004 				}
       
  2005 
       
  2006 				$comments = get_comments( $comment_args );
       
  2007 
       
  2008 				if ( 'all' != $r['type'] ) {
       
  2009 					$comments_by_type = separate_comments( $comments );
       
  2010 					if ( empty( $comments_by_type[ $r['type'] ] ) ) {
       
  2011 						return;
       
  2012 					}
       
  2013 
       
  2014 					$_comments = $comments_by_type[ $r['type'] ];
       
  2015 				} else {
       
  2016 					$_comments = $comments;
       
  2017 				}
       
  2018 			}
       
  2019 
       
  2020 		// Otherwise, fall back on the comments from `$wp_query->comments`.
       
  2021 		} else {
       
  2022 			if ( empty($wp_query->comments) )
  2081 				return;
  2023 				return;
  2082 			$_comments = $wp_query->comments_by_type[$r['type']];
  2024 			if ( 'all' != $r['type'] ) {
  2083 		} else {
  2025 				if ( empty($wp_query->comments_by_type) )
  2084 			$_comments = $wp_query->comments;
  2026 					$wp_query->comments_by_type = separate_comments($wp_query->comments);
       
  2027 				if ( empty($wp_query->comments_by_type[$r['type']]) )
       
  2028 					return;
       
  2029 				$_comments = $wp_query->comments_by_type[$r['type']];
       
  2030 			} else {
       
  2031 				$_comments = $wp_query->comments;
       
  2032 			}
       
  2033 
       
  2034 			if ( $wp_query->max_num_comment_pages ) {
       
  2035 				$default_comments_page = get_option( 'default_comments_page' );
       
  2036 				$cpage = get_query_var( 'cpage' );
       
  2037 				if ( 'newest' === $default_comments_page ) {
       
  2038 					$r['cpage'] = $cpage;
       
  2039 
       
  2040 				/*
       
  2041 				 * When first page shows oldest comments, post permalink is the same as
       
  2042 				 * the comment permalink.
       
  2043 				 */
       
  2044 				} elseif ( $cpage == 1 ) {
       
  2045 					$r['cpage'] = '';
       
  2046 				} else {
       
  2047 					$r['cpage'] = $cpage;
       
  2048 				}
       
  2049 
       
  2050 				$r['page'] = 0;
       
  2051 				$r['per_page'] = 0;
       
  2052 			}
  2085 		}
  2053 		}
  2086 	}
  2054 	}
  2087 
  2055 
  2088 	if ( '' === $r['per_page'] && get_option('page_comments') )
  2056 	if ( '' === $r['per_page'] && get_option( 'page_comments' ) ) {
  2089 		$r['per_page'] = get_query_var('comments_per_page');
  2057 		$r['per_page'] = get_query_var('comments_per_page');
       
  2058 	}
  2090 
  2059 
  2091 	if ( empty($r['per_page']) ) {
  2060 	if ( empty($r['per_page']) ) {
  2092 		$r['per_page'] = 0;
  2061 		$r['per_page'] = 0;
  2093 		$r['page'] = 0;
  2062 		$r['page'] = 0;
  2094 	}
  2063 	}
  2115 		$r['page'] = 1;
  2084 		$r['page'] = 1;
  2116 
  2085 
  2117 	if ( null === $r['reverse_top_level'] )
  2086 	if ( null === $r['reverse_top_level'] )
  2118 		$r['reverse_top_level'] = ( 'desc' == get_option('comment_order') );
  2087 		$r['reverse_top_level'] = ( 'desc' == get_option('comment_order') );
  2119 
  2088 
       
  2089 	wp_queue_comments_for_comment_meta_lazyload( $_comments );
       
  2090 
  2120 	if ( empty( $r['walker'] ) ) {
  2091 	if ( empty( $r['walker'] ) ) {
  2121 		$walker = new Walker_Comment;
  2092 		$walker = new Walker_Comment;
  2122 	} else {
  2093 	} else {
  2123 		$walker = $r['walker'];
  2094 		$walker = $r['walker'];
  2124 	}
  2095 	}
  2125 
  2096 
  2126 	$output = $walker->paged_walk( $_comments, $r['max_depth'], $r['page'], $r['per_page'], $r );
  2097 	$output = $walker->paged_walk( $_comments, $r['max_depth'], $r['page'], $r['per_page'], $r );
  2127 	$wp_query->max_num_comment_pages = $walker->max_pages;
       
  2128 
  2098 
  2129 	$in_comment_loop = false;
  2099 	$in_comment_loop = false;
  2130 
  2100 
  2131 	if ( $r['echo'] ) {
  2101 	if ( $r['echo'] ) {
  2132 		echo $output;
  2102 		echo $output;
  2134 		return $output;
  2104 		return $output;
  2135 	}
  2105 	}
  2136 }
  2106 }
  2137 
  2107 
  2138 /**
  2108 /**
  2139  * Output a complete commenting form for use within a template.
  2109  * Outputs a complete commenting form for use within a template.
  2140  *
  2110  *
  2141  * Most strings and form fields may be controlled through the $args array passed
  2111  * Most strings and form fields may be controlled through the $args array passed
  2142  * into the function, while you may also choose to use the comment_form_default_fields
  2112  * into the function, while you may also choose to use the {@see 'comment_form_default_fields'}
  2143  * filter to modify the array of default fields if you'd just like to add a new
  2113  * filter to modify the array of default fields if you'd just like to add a new
  2144  * one or remove a single field. All fields are also individually passed through
  2114  * one or remove a single field. All fields are also individually passed through
  2145  * a filter of the form comment_form_field_$name where $name is the key used
  2115  * a filter of the {@see 'comment_form_field_$name'} where $name is the key used
  2146  * in the array of fields.
  2116  * in the array of fields.
  2147  *
  2117  *
  2148  * @since 3.0.0
  2118  * @since 3.0.0
  2149  * @since 4.1.0 Introduced the 'class_submit' argument.
  2119  * @since 4.1.0 Introduced the 'class_submit' argument.
  2150  * @since 4.2.0 Introduced 'submit_button' and 'submit_fields' arguments.
  2120  * @since 4.2.0 Introduced the 'submit_button' and 'submit_fields' arguments.
       
  2121  * @since 4.4.0 Introduced the 'class_form', 'title_reply_before', 'title_reply_after',
       
  2122  *              'cancel_reply_before', and 'cancel_reply_after' arguments.
       
  2123  * @since 4.5.0 The 'author', 'email', and 'url' form fields are limited to 245, 100,
       
  2124  *              and 200 characters, respectively.
       
  2125  * @since 4.6.0 Introduced the 'action' argument.
       
  2126  * @since 4.9.6 Introduced the 'cookies' default comment field.
  2151  *
  2127  *
  2152  * @param array       $args {
  2128  * @param array       $args {
  2153  *     Optional. Default arguments and form fields to override.
  2129  *     Optional. Default arguments and form fields to override.
  2154  *
  2130  *
  2155  *     @type array $fields {
  2131  *     @type array $fields {
  2156  *         Default comment fields, filterable by default via the 'comment_form_default_fields' hook.
  2132  *         Default comment fields, filterable by default via the {@see 'comment_form_default_fields'} hook.
  2157  *
  2133  *
  2158  *         @type string $author Comment author field HTML.
  2134  *         @type string $author  Comment author field HTML.
  2159  *         @type string $email  Comment author email field HTML.
  2135  *         @type string $email   Comment author email field HTML.
  2160  *         @type string $url    Comment author URL field HTML.
  2136  *         @type string $url     Comment author URL field HTML.
       
  2137  *         @type string $cookies Comment cookie opt-in field HTML.
  2161  *     }
  2138  *     }
  2162  *     @type string $comment_field        The comment textarea field HTML.
  2139  *     @type string $comment_field        The comment textarea field HTML.
  2163  *     @type string $must_log_in          HTML element for a 'must be logged in to comment' message.
  2140  *     @type string $must_log_in          HTML element for a 'must be logged in to comment' message.
  2164  *     @type string $logged_in_as         HTML element for a 'logged in as [user]' message.
  2141  *     @type string $logged_in_as         HTML element for a 'logged in as [user]' message.
  2165  *     @type string $comment_notes_before HTML element for a message displayed before the comment form.
  2142  *     @type string $comment_notes_before HTML element for a message displayed before the comment fields
       
  2143  *                                        if the user is not logged in.
  2166  *                                        Default 'Your email address will not be published.'.
  2144  *                                        Default 'Your email address will not be published.'.
  2167  *     @type string $comment_notes_after  HTML element for a message displayed after the comment form.
  2145  *     @type string $comment_notes_after  HTML element for a message displayed after the textarea field.
  2168  *                                        Default 'You may use these HTML tags and attributes ...'.
  2146  *     @type string $action               The comment form element action attribute. Default '/wp-comments-post.php'.
  2169  *     @type string $id_form              The comment form element id attribute. Default 'commentform'.
  2147  *     @type string $id_form              The comment form element id attribute. Default 'commentform'.
  2170  *     @type string $id_submit            The comment submit element id attribute. Default 'submit'.
  2148  *     @type string $id_submit            The comment submit element id attribute. Default 'submit'.
       
  2149  *     @type string $class_form           The comment form element class attribute. Default 'comment-form'.
  2171  *     @type string $class_submit         The comment submit element class attribute. Default 'submit'.
  2150  *     @type string $class_submit         The comment submit element class attribute. Default 'submit'.
  2172  *     @type string $name_submit          The comment submit element name attribute. Default 'submit'.
  2151  *     @type string $name_submit          The comment submit element name attribute. Default 'submit'.
  2173  *     @type string $title_reply          The translatable 'reply' button label. Default 'Leave a Reply'.
  2152  *     @type string $title_reply          The translatable 'reply' button label. Default 'Leave a Reply'.
  2174  *     @type string $title_reply_to       The translatable 'reply-to' button label. Default 'Leave a Reply to %s',
  2153  *     @type string $title_reply_to       The translatable 'reply-to' button label. Default 'Leave a Reply to %s',
  2175  *                                        where %s is the author of the comment being replied to.
  2154  *                                        where %s is the author of the comment being replied to.
       
  2155  *     @type string $title_reply_before   HTML displayed before the comment form title.
       
  2156  *                                        Default: '<h3 id="reply-title" class="comment-reply-title">'.
       
  2157  *     @type string $title_reply_after    HTML displayed after the comment form title.
       
  2158  *                                        Default: '</h3>'.
       
  2159  *     @type string $cancel_reply_before  HTML displayed before the cancel reply link.
       
  2160  *     @type string $cancel_reply_after   HTML displayed after the cancel reply link.
  2176  *     @type string $cancel_reply_link    The translatable 'cancel reply' button label. Default 'Cancel reply'.
  2161  *     @type string $cancel_reply_link    The translatable 'cancel reply' button label. Default 'Cancel reply'.
  2177  *     @type string $label_submit         The translatable 'submit' button label. Default 'Post a comment'.
  2162  *     @type string $label_submit         The translatable 'submit' button label. Default 'Post a comment'.
  2178  *     @type string $submit_button        HTML format for the Submit button.
  2163  *     @type string $submit_button        HTML format for the Submit button.
  2179  *                                        Default: '<input name="%1$s" type="submit" id="%2$s" class="%3$s" value="%4$s" />'.
  2164  *                                        Default: '<input name="%1$s" type="submit" id="%2$s" class="%3$s" value="%4$s" />'.
  2180  *     @type string $submit_field         HTML format for the markup surrounding the Submit button and comment hidden
  2165  *     @type string $submit_field         HTML format for the markup surrounding the Submit button and comment hidden
  2181  *                                        fields. Default: '<p class="form-submit">%1$s %2$s</a>', where %1$s is the
  2166  *                                        fields. Default: '<p class="form-submit">%1$s %2$s</p>', where %1$s is the
  2182  *                                        submit button markup and %2$s is the comment hidden fields.
  2167  *                                        submit button markup and %2$s is the comment hidden fields.
  2183  *     @type string $format               The comment form format. Default 'xhtml'. Accepts 'xhtml', 'html5'.
  2168  *     @type string $format               The comment form format. Default 'xhtml'. Accepts 'xhtml', 'html5'.
  2184  * }
  2169  * }
  2185  * @param int|WP_Post $post_id Post ID or WP_Post object to generate the form for. Default current post.
  2170  * @param int|WP_Post $post_id Post ID or WP_Post object to generate the form for. Default current post.
  2186  */
  2171  */
  2187 function comment_form( $args = array(), $post_id = null ) {
  2172 function comment_form( $args = array(), $post_id = null ) {
  2188 	if ( null === $post_id )
  2173 	if ( null === $post_id )
  2189 		$post_id = get_the_ID();
  2174 		$post_id = get_the_ID();
  2190 
  2175 
       
  2176 	// Exit the function when comments for the post are closed.
       
  2177 	if ( ! comments_open( $post_id ) ) {
       
  2178 		/**
       
  2179 		 * Fires after the comment form if comments are closed.
       
  2180 		 *
       
  2181 		 * @since 3.0.0
       
  2182 		 */
       
  2183 		do_action( 'comment_form_comments_closed' );
       
  2184 
       
  2185 		return;
       
  2186 	}
       
  2187 
  2191 	$commenter = wp_get_current_commenter();
  2188 	$commenter = wp_get_current_commenter();
  2192 	$user = wp_get_current_user();
  2189 	$user = wp_get_current_user();
  2193 	$user_identity = $user->exists() ? $user->display_name : '';
  2190 	$user_identity = $user->exists() ? $user->display_name : '';
  2194 
  2191 
  2195 	$args = wp_parse_args( $args );
  2192 	$args = wp_parse_args( $args );
  2196 	if ( ! isset( $args['format'] ) )
  2193 	if ( ! isset( $args['format'] ) )
  2197 		$args['format'] = current_theme_supports( 'html5', 'comment-form' ) ? 'html5' : 'xhtml';
  2194 		$args['format'] = current_theme_supports( 'html5', 'comment-form' ) ? 'html5' : 'xhtml';
  2198 
  2195 
  2199 	$req      = get_option( 'require_name_email' );
  2196 	$req      = get_option( 'require_name_email' );
  2200 	$aria_req = ( $req ? " aria-required='true'" : '' );
       
  2201 	$html_req = ( $req ? " required='required'" : '' );
  2197 	$html_req = ( $req ? " required='required'" : '' );
  2202 	$html5    = 'html5' === $args['format'];
  2198 	$html5    = 'html5' === $args['format'];
  2203 	$fields   =  array(
  2199 	$fields   =  array(
  2204 		'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' .
  2200 		'author'  => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' .
  2205 		            '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . $html_req . ' /></p>',
  2201 					 '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30" maxlength="245"' . $html_req . ' /></p>',
  2206 		'email'  => '<p class="comment-form-email"><label for="email">' . __( 'Email' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' .
  2202 		'email'   => '<p class="comment-form-email"><label for="email">' . __( 'Email' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' .
  2207 		            '<input id="email" name="email" ' . ( $html5 ? 'type="email"' : 'type="text"' ) . ' value="' . esc_attr(  $commenter['comment_author_email'] ) . '" size="30" aria-describedby="email-notes"' . $aria_req . $html_req  . ' /></p>',
  2203 					 '<input id="email" name="email" ' . ( $html5 ? 'type="email"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30" maxlength="100" aria-describedby="email-notes"' . $html_req . ' /></p>',
  2208 		'url'    => '<p class="comment-form-url"><label for="url">' . __( 'Website' ) . '</label> ' .
  2204 		'url'     => '<p class="comment-form-url"><label for="url">' . __( 'Website' ) . '</label> ' .
  2209 		            '<input id="url" name="url" ' . ( $html5 ? 'type="url"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></p>',
  2205 					 '<input id="url" name="url" ' . ( $html5 ? 'type="url"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" maxlength="200" /></p>',
  2210 	);
  2206 	);
  2211 
  2207 
  2212 	$required_text = sprintf( ' ' . __('Required fields are marked %s'), '<span class="required">*</span>' );
  2208 	if ( has_action( 'set_comment_cookies', 'wp_set_comment_cookies' ) && get_option( 'show_comments_cookies_opt_in' ) ) {
  2213 
  2209 		$consent           = empty( $commenter['comment_author_email'] ) ? '' : ' checked="checked"';
  2214 	/**
  2210 		$fields['cookies'] = '<p class="comment-form-cookies-consent"><input id="wp-comment-cookies-consent" name="wp-comment-cookies-consent" type="checkbox" value="yes"' . $consent . ' />' .
  2215 	 * Filter the default comment form fields.
  2211 							 '<label for="wp-comment-cookies-consent">' . __( 'Save my name, email, and website in this browser for the next time I comment.' ) . '</label></p>';
       
  2212 
       
  2213 		// Ensure that the passed fields include cookies consent.
       
  2214 		if ( isset( $args['fields'] ) && ! isset( $args['fields']['cookies'] ) ) {
       
  2215 			$args['fields']['cookies'] = $fields['cookies'];
       
  2216 		}
       
  2217 	}
       
  2218 
       
  2219 	$required_text = sprintf( ' ' . __( 'Required fields are marked %s' ), '<span class="required">*</span>' );
       
  2220 
       
  2221 	/**
       
  2222 	 * Filters the default comment form fields.
  2216 	 *
  2223 	 *
  2217 	 * @since 3.0.0
  2224 	 * @since 3.0.0
  2218 	 *
  2225 	 *
  2219 	 * @param array $fields The default comment fields.
  2226 	 * @param array $fields The default comment fields.
  2220 	 */
  2227 	 */
  2221 	$fields = apply_filters( 'comment_form_default_fields', $fields );
  2228 	$fields = apply_filters( 'comment_form_default_fields', $fields );
  2222 	$defaults = array(
  2229 	$defaults = array(
  2223 		'fields'               => $fields,
  2230 		'fields'               => $fields,
  2224 		'comment_field'        => '<p class="comment-form-comment"><label for="comment">' . _x( 'Comment', 'noun' ) . '</label> <textarea id="comment" name="comment" cols="45" rows="8" aria-describedby="form-allowed-tags" aria-required="true" required="required"></textarea></p>',
  2231 		'comment_field'        => '<p class="comment-form-comment"><label for="comment">' . _x( 'Comment', 'noun' ) . '</label> <textarea id="comment" name="comment" cols="45" rows="8" maxlength="65525" required="required"></textarea></p>',
  2225 		/** This filter is documented in wp-includes/link-template.php */
  2232 		/** This filter is documented in wp-includes/link-template.php */
  2226 		'must_log_in'          => '<p class="must-log-in">' . sprintf( __( 'You must be <a href="%s">logged in</a> to post a comment.' ), wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '</p>',
  2233 		'must_log_in'          => '<p class="must-log-in">' . sprintf(
       
  2234 		                              /* translators: %s: login URL */
       
  2235 		                              __( 'You must be <a href="%s">logged in</a> to post a comment.' ),
       
  2236 		                              wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ), $post_id ) )
       
  2237 		                          ) . '</p>',
  2227 		/** This filter is documented in wp-includes/link-template.php */
  2238 		/** This filter is documented in wp-includes/link-template.php */
  2228 		'logged_in_as'         => '<p class="logged-in-as">' . sprintf( __( 'Logged in as <a href="%1$s">%2$s</a>. <a href="%3$s" title="Log out of this account">Log out?</a>' ), get_edit_user_link(), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '</p>',
  2239 		'logged_in_as'         => '<p class="logged-in-as">' . sprintf(
       
  2240 		                              /* translators: 1: edit user link, 2: accessibility text, 3: user name, 4: logout URL */
       
  2241 		                              __( '<a href="%1$s" aria-label="%2$s">Logged in as %3$s</a>. <a href="%4$s">Log out?</a>' ),
       
  2242 		                              get_edit_user_link(),
       
  2243 		                              /* translators: %s: user name */
       
  2244 		                              esc_attr( sprintf( __( 'Logged in as %s. Edit your profile.' ), $user_identity ) ),
       
  2245 		                              $user_identity,
       
  2246 		                              wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ), $post_id ) )
       
  2247 		                          ) . '</p>',
  2229 		'comment_notes_before' => '<p class="comment-notes"><span id="email-notes">' . __( 'Your email address will not be published.' ) . '</span>'. ( $req ? $required_text : '' ) . '</p>',
  2248 		'comment_notes_before' => '<p class="comment-notes"><span id="email-notes">' . __( 'Your email address will not be published.' ) . '</span>'. ( $req ? $required_text : '' ) . '</p>',
  2230 		'comment_notes_after'  => '<p class="form-allowed-tags" id="form-allowed-tags">' . sprintf( __( 'You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes: %s' ), ' <code>' . allowed_tags() . '</code>' ) . '</p>',
  2249 		'comment_notes_after'  => '',
       
  2250 		'action'               => site_url( '/wp-comments-post.php' ),
  2231 		'id_form'              => 'commentform',
  2251 		'id_form'              => 'commentform',
  2232 		'id_submit'            => 'submit',
  2252 		'id_submit'            => 'submit',
       
  2253 		'class_form'           => 'comment-form',
  2233 		'class_submit'         => 'submit',
  2254 		'class_submit'         => 'submit',
  2234 		'name_submit'          => 'submit',
  2255 		'name_submit'          => 'submit',
  2235 		'title_reply'          => __( 'Leave a Reply' ),
  2256 		'title_reply'          => __( 'Leave a Reply' ),
  2236 		'title_reply_to'       => __( 'Leave a Reply to %s' ),
  2257 		'title_reply_to'       => __( 'Leave a Reply to %s' ),
       
  2258 		'title_reply_before'   => '<h3 id="reply-title" class="comment-reply-title">',
       
  2259 		'title_reply_after'    => '</h3>',
       
  2260 		'cancel_reply_before'  => ' <small>',
       
  2261 		'cancel_reply_after'   => '</small>',
  2237 		'cancel_reply_link'    => __( 'Cancel reply' ),
  2262 		'cancel_reply_link'    => __( 'Cancel reply' ),
  2238 		'label_submit'         => __( 'Post Comment' ),
  2263 		'label_submit'         => __( 'Post Comment' ),
  2239 		'submit_button'        => '<input name="%1$s" type="submit" id="%2$s" class="%3$s" value="%4$s" />',
  2264 		'submit_button'        => '<input name="%1$s" type="submit" id="%2$s" class="%3$s" value="%4$s" />',
  2240 		'submit_field'         => '<p class="form-submit">%1$s %2$s</p>',
  2265 		'submit_field'         => '<p class="form-submit">%1$s %2$s</p>',
  2241 		'format'               => 'xhtml',
  2266 		'format'               => 'xhtml',
  2242 	);
  2267 	);
  2243 
  2268 
  2244 	/**
  2269 	/**
  2245 	 * Filter the comment form default arguments.
  2270 	 * Filters the comment form default arguments.
  2246 	 *
  2271 	 *
  2247 	 * Use 'comment_form_default_fields' to filter the comment fields.
  2272 	 * Use {@see 'comment_form_default_fields'} to filter the comment fields.
  2248 	 *
  2273 	 *
  2249 	 * @since 3.0.0
  2274 	 * @since 3.0.0
  2250 	 *
  2275 	 *
  2251 	 * @param array $defaults The default comment form arguments.
  2276 	 * @param array $defaults The default comment form arguments.
  2252 	 */
  2277 	 */
  2253 	$args = wp_parse_args( $args, apply_filters( 'comment_form_defaults', $defaults ) );
  2278 	$args = wp_parse_args( $args, apply_filters( 'comment_form_defaults', $defaults ) );
  2254 
  2279 
  2255 		if ( comments_open( $post_id ) ) : ?>
  2280 	// Ensure that the filtered args contain all required default values.
  2256 			<?php
  2281 	$args = array_merge( $defaults, $args );
       
  2282 
       
  2283 	/**
       
  2284 	 * Fires before the comment form.
       
  2285 	 *
       
  2286 	 * @since 3.0.0
       
  2287 	 */
       
  2288 	do_action( 'comment_form_before' );
       
  2289 	?>
       
  2290 	<div id="respond" class="comment-respond">
       
  2291 		<?php
       
  2292 		echo $args['title_reply_before'];
       
  2293 
       
  2294 		comment_form_title( $args['title_reply'], $args['title_reply_to'] );
       
  2295 
       
  2296 		echo $args['cancel_reply_before'];
       
  2297 
       
  2298 		cancel_comment_reply_link( $args['cancel_reply_link'] );
       
  2299 
       
  2300 		echo $args['cancel_reply_after'];
       
  2301 
       
  2302 		echo $args['title_reply_after'];
       
  2303 
       
  2304 		if ( get_option( 'comment_registration' ) && !is_user_logged_in() ) :
       
  2305 			echo $args['must_log_in'];
  2257 			/**
  2306 			/**
  2258 			 * Fires before the comment form.
  2307 			 * Fires after the HTML-formatted 'must log in after' message in the comment form.
  2259 			 *
  2308 			 *
  2260 			 * @since 3.0.0
  2309 			 * @since 3.0.0
  2261 			 */
  2310 			 */
  2262 			do_action( 'comment_form_before' );
  2311 			do_action( 'comment_form_must_log_in_after' );
  2263 			?>
  2312 		else : ?>
  2264 			<div id="respond" class="comment-respond">
  2313 			<form action="<?php echo esc_url( $args['action'] ); ?>" method="post" id="<?php echo esc_attr( $args['id_form'] ); ?>" class="<?php echo esc_attr( $args['class_form'] ); ?>"<?php echo $html5 ? ' novalidate' : ''; ?>>
  2265 				<h3 id="reply-title" class="comment-reply-title"><?php comment_form_title( $args['title_reply'], $args['title_reply_to'] ); ?> <small><?php cancel_comment_reply_link( $args['cancel_reply_link'] ); ?></small></h3>
  2314 				<?php
  2266 				<?php if ( get_option( 'comment_registration' ) && !is_user_logged_in() ) : ?>
  2315 				/**
  2267 					<?php echo $args['must_log_in']; ?>
  2316 				 * Fires at the top of the comment form, inside the form tag.
  2268 					<?php
  2317 				 *
       
  2318 				 * @since 3.0.0
       
  2319 				 */
       
  2320 				do_action( 'comment_form_top' );
       
  2321 
       
  2322 				if ( is_user_logged_in() ) :
  2269 					/**
  2323 					/**
  2270 					 * Fires after the HTML-formatted 'must log in after' message in the comment form.
  2324 					 * Filters the 'logged in' message for the comment form for display.
  2271 					 *
  2325 					 *
  2272 					 * @since 3.0.0
  2326 					 * @since 3.0.0
       
  2327 					 *
       
  2328 					 * @param string $args_logged_in The logged-in-as HTML-formatted message.
       
  2329 					 * @param array  $commenter      An array containing the comment author's
       
  2330 					 *                               username, email, and URL.
       
  2331 					 * @param string $user_identity  If the commenter is a registered user,
       
  2332 					 *                               the display name, blank otherwise.
  2273 					 */
  2333 					 */
  2274 					do_action( 'comment_form_must_log_in_after' );
  2334 					echo apply_filters( 'comment_form_logged_in', $args['logged_in_as'], $commenter, $user_identity );
  2275 					?>
  2335 
  2276 				<?php else : ?>
  2336 					/**
  2277 					<form action="<?php echo site_url( '/wp-comments-post.php' ); ?>" method="post" id="<?php echo esc_attr( $args['id_form'] ); ?>" class="comment-form"<?php echo $html5 ? ' novalidate' : ''; ?>>
  2337 					 * Fires after the is_user_logged_in() check in the comment form.
  2278 						<?php
  2338 					 *
       
  2339 					 * @since 3.0.0
       
  2340 					 *
       
  2341 					 * @param array  $commenter     An array containing the comment author's
       
  2342 					 *                              username, email, and URL.
       
  2343 					 * @param string $user_identity If the commenter is a registered user,
       
  2344 					 *                              the display name, blank otherwise.
       
  2345 					 */
       
  2346 					do_action( 'comment_form_logged_in_after', $commenter, $user_identity );
       
  2347 
       
  2348 				else :
       
  2349 
       
  2350 					echo $args['comment_notes_before'];
       
  2351 
       
  2352 				endif;
       
  2353 
       
  2354 				// Prepare an array of all fields, including the textarea
       
  2355 				$comment_fields = array( 'comment' => $args['comment_field'] ) + (array) $args['fields'];
       
  2356 
       
  2357 				/**
       
  2358 				 * Filters the comment form fields, including the textarea.
       
  2359 				 *
       
  2360 				 * @since 4.4.0
       
  2361 				 *
       
  2362 				 * @param array $comment_fields The comment fields.
       
  2363 				 */
       
  2364 				$comment_fields = apply_filters( 'comment_form_fields', $comment_fields );
       
  2365 
       
  2366 				// Get an array of field names, excluding the textarea
       
  2367 				$comment_field_keys = array_diff( array_keys( $comment_fields ), array( 'comment' ) );
       
  2368 
       
  2369 				// Get the first and the last field name, excluding the textarea
       
  2370 				$first_field = reset( $comment_field_keys );
       
  2371 				$last_field  = end( $comment_field_keys );
       
  2372 
       
  2373 				foreach ( $comment_fields as $name => $field ) {
       
  2374 
       
  2375 					if ( 'comment' === $name ) {
       
  2376 
  2279 						/**
  2377 						/**
  2280 						 * Fires at the top of the comment form, inside the form tag.
  2378 						 * Filters the content of the comment textarea field for display.
  2281 						 *
       
  2282 						 * @since 3.0.0
       
  2283 						 */
       
  2284 						do_action( 'comment_form_top' );
       
  2285 						?>
       
  2286 						<?php if ( is_user_logged_in() ) : ?>
       
  2287 							<?php
       
  2288 							/**
       
  2289 							 * Filter the 'logged in' message for the comment form for display.
       
  2290 							 *
       
  2291 							 * @since 3.0.0
       
  2292 							 *
       
  2293 							 * @param string $args_logged_in The logged-in-as HTML-formatted message.
       
  2294 							 * @param array  $commenter      An array containing the comment author's
       
  2295 							 *                               username, email, and URL.
       
  2296 							 * @param string $user_identity  If the commenter is a registered user,
       
  2297 							 *                               the display name, blank otherwise.
       
  2298 							 */
       
  2299 							echo apply_filters( 'comment_form_logged_in', $args['logged_in_as'], $commenter, $user_identity );
       
  2300 							?>
       
  2301 							<?php
       
  2302 							/**
       
  2303 							 * Fires after the is_user_logged_in() check in the comment form.
       
  2304 							 *
       
  2305 							 * @since 3.0.0
       
  2306 							 *
       
  2307 							 * @param array  $commenter     An array containing the comment author's
       
  2308 							 *                              username, email, and URL.
       
  2309 							 * @param string $user_identity If the commenter is a registered user,
       
  2310 							 *                              the display name, blank otherwise.
       
  2311 							 */
       
  2312 							do_action( 'comment_form_logged_in_after', $commenter, $user_identity );
       
  2313 							?>
       
  2314 						<?php else : ?>
       
  2315 							<?php echo $args['comment_notes_before']; ?>
       
  2316 							<?php
       
  2317 							/**
       
  2318 							 * Fires before the comment fields in the comment form.
       
  2319 							 *
       
  2320 							 * @since 3.0.0
       
  2321 							 */
       
  2322 							do_action( 'comment_form_before_fields' );
       
  2323 							foreach ( (array) $args['fields'] as $name => $field ) {
       
  2324 								/**
       
  2325 								 * Filter a comment form field for display.
       
  2326 								 *
       
  2327 								 * The dynamic portion of the filter hook, `$name`, refers to the name
       
  2328 								 * of the comment form field. Such as 'author', 'email', or 'url'.
       
  2329 								 *
       
  2330 								 * @since 3.0.0
       
  2331 								 *
       
  2332 								 * @param string $field The HTML-formatted output of the comment form field.
       
  2333 								 */
       
  2334 								echo apply_filters( "comment_form_field_{$name}", $field ) . "\n";
       
  2335 							}
       
  2336 							/**
       
  2337 							 * Fires after the comment fields in the comment form.
       
  2338 							 *
       
  2339 							 * @since 3.0.0
       
  2340 							 */
       
  2341 							do_action( 'comment_form_after_fields' );
       
  2342 							?>
       
  2343 						<?php endif; ?>
       
  2344 						<?php
       
  2345 						/**
       
  2346 						 * Filter the content of the comment textarea field for display.
       
  2347 						 *
  2379 						 *
  2348 						 * @since 3.0.0
  2380 						 * @since 3.0.0
  2349 						 *
  2381 						 *
  2350 						 * @param string $args_comment_field The content of the comment textarea field.
  2382 						 * @param string $args_comment_field The content of the comment textarea field.
  2351 						 */
  2383 						 */
  2352 						echo apply_filters( 'comment_form_field_comment', $args['comment_field'] );
  2384 						echo apply_filters( 'comment_form_field_comment', $field );
  2353 						?>
  2385 
  2354 						<?php echo $args['comment_notes_after']; ?>
  2386 						echo $args['comment_notes_after'];
  2355 
  2387 
  2356 						<?php
  2388 					} elseif ( ! is_user_logged_in() ) {
  2357 						$submit_button = sprintf(
  2389 
  2358 							$args['submit_button'],
  2390 						if ( $first_field === $name ) {
  2359 							esc_attr( $args['name_submit'] ),
  2391 							/**
  2360 							esc_attr( $args['id_submit'] ),
  2392 							 * Fires before the comment fields in the comment form, excluding the textarea.
  2361 							esc_attr( $args['class_submit'] ),
  2393 							 *
  2362 							esc_attr( $args['label_submit'] )
  2394 							 * @since 3.0.0
  2363 						);
  2395 							 */
       
  2396 							do_action( 'comment_form_before_fields' );
       
  2397 						}
  2364 
  2398 
  2365 						/**
  2399 						/**
  2366 						 * Filter the submit button for the comment form to display.
  2400 						 * Filters a comment form field for display.
  2367 						 *
  2401 						 *
  2368 						 * @since 4.2.0
  2402 						 * The dynamic portion of the filter hook, `$name`, refers to the name
       
  2403 						 * of the comment form field. Such as 'author', 'email', or 'url'.
  2369 						 *
  2404 						 *
  2370 						 * @param string $submit_button HTML markup for the submit button.
  2405 						 * @since 3.0.0
  2371 						 * @param array  $args          Arguments passed to `comment_form()`.
  2406 						 *
       
  2407 						 * @param string $field The HTML-formatted output of the comment form field.
  2372 						 */
  2408 						 */
  2373 						$submit_button = apply_filters( 'comment_form_submit_button', $submit_button, $args );
  2409 						echo apply_filters( "comment_form_field_{$name}", $field ) . "\n";
  2374 
  2410 
  2375 						$submit_field = sprintf(
  2411 						if ( $last_field === $name ) {
  2376 							$args['submit_field'],
  2412 							/**
  2377 							$submit_button,
  2413 							 * Fires after the comment fields in the comment form, excluding the textarea.
  2378 							get_comment_id_fields( $post_id )
  2414 							 *
  2379 						);
  2415 							 * @since 3.0.0
  2380 
  2416 							 */
  2381 						/**
  2417 							do_action( 'comment_form_after_fields' );
  2382 						 * Filter the submit field for the comment form to display.
  2418 						}
  2383 						 *
  2419 					}
  2384 						 * The submit field includes the submit button, hidden fields for the
  2420 				}
  2385 						 * comment form, and any wrapper markup.
  2421 
  2386 						 *
  2422 				$submit_button = sprintf(
  2387 						 * @since 4.2.0
  2423 					$args['submit_button'],
  2388 						 *
  2424 					esc_attr( $args['name_submit'] ),
  2389 						 * @param string $submit_field HTML markup for the submit field.
  2425 					esc_attr( $args['id_submit'] ),
  2390 						 * @param array  $args         Arguments passed to comment_form().
  2426 					esc_attr( $args['class_submit'] ),
  2391 						 */
  2427 					esc_attr( $args['label_submit'] )
  2392 						echo apply_filters( 'comment_form_submit_field', $submit_field, $args );
  2428 				);
  2393 
  2429 
  2394 						/**
  2430 				/**
  2395 						 * Fires at the bottom of the comment form, inside the closing </form> tag.
  2431 				 * Filters the submit button for the comment form to display.
  2396 						 *
  2432 				 *
  2397 						 * @since 1.5.0
  2433 				 * @since 4.2.0
  2398 						 *
  2434 				 *
  2399 						 * @param int $post_id The post ID.
  2435 				 * @param string $submit_button HTML markup for the submit button.
  2400 						 */
  2436 				 * @param array  $args          Arguments passed to `comment_form()`.
  2401 						do_action( 'comment_form', $post_id );
  2437 				 */
  2402 						?>
  2438 				$submit_button = apply_filters( 'comment_form_submit_button', $submit_button, $args );
  2403 					</form>
  2439 
  2404 				<?php endif; ?>
  2440 				$submit_field = sprintf(
  2405 			</div><!-- #respond -->
  2441 					$args['submit_field'],
  2406 			<?php
  2442 					$submit_button,
  2407 			/**
  2443 					get_comment_id_fields( $post_id )
  2408 			 * Fires after the comment form.
  2444 				);
  2409 			 *
  2445 
  2410 			 * @since 3.0.0
  2446 				/**
  2411 			 */
  2447 				 * Filters the submit field for the comment form to display.
  2412 			do_action( 'comment_form_after' );
  2448 				 *
  2413 		else :
  2449 				 * The submit field includes the submit button, hidden fields for the
  2414 			/**
  2450 				 * comment form, and any wrapper markup.
  2415 			 * Fires after the comment form if comments are closed.
  2451 				 *
  2416 			 *
  2452 				 * @since 4.2.0
  2417 			 * @since 3.0.0
  2453 				 *
  2418 			 */
  2454 				 * @param string $submit_field HTML markup for the submit field.
  2419 			do_action( 'comment_form_comments_closed' );
  2455 				 * @param array  $args         Arguments passed to comment_form().
  2420 		endif;
  2456 				 */
  2421 }
  2457 				echo apply_filters( 'comment_form_submit_field', $submit_field, $args );
       
  2458 
       
  2459 				/**
       
  2460 				 * Fires at the bottom of the comment form, inside the closing </form> tag.
       
  2461 				 *
       
  2462 				 * @since 1.5.0
       
  2463 				 *
       
  2464 				 * @param int $post_id The post ID.
       
  2465 				 */
       
  2466 				do_action( 'comment_form', $post_id );
       
  2467 				?>
       
  2468 			</form>
       
  2469 		<?php endif; ?>
       
  2470 	</div><!-- #respond -->
       
  2471 	<?php
       
  2472 
       
  2473 	/**
       
  2474 	 * Fires after the comment form.
       
  2475 	 *
       
  2476 	 * @since 3.0.0
       
  2477 	 */
       
  2478 	do_action( 'comment_form_after' );
       
  2479 }