wp/wp-includes/comment-template.php
changeset 5 5e2f62d02dcd
parent 0 d970ebf37754
child 7 cf61fcea0001
equal deleted inserted replaced
4:346c88efed21 5:5e2f62d02dcd
    32 	}
    32 	}
    33 
    33 
    34 	/**
    34 	/**
    35 	 * Filter the returned comment author name.
    35 	 * Filter the returned comment author name.
    36 	 *
    36 	 *
    37 	 * @since 1.5.2
    37 	 * @since 1.5.0
    38 	 *
    38 	 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added.
    39 	 * @param string $author The comment author's username.
    39 	 *
    40 	 */
    40 	 * @param string $author     The comment author's username.
    41 	return apply_filters( 'get_comment_author', $author );
    41 	 * @param int    $comment_ID The comment ID.
       
    42 	 * @param object $comment    The comment object.
       
    43 	 */
       
    44 	return apply_filters( 'get_comment_author', $author, $comment_ID, $comment );
    42 }
    45 }
    43 
    46 
    44 /**
    47 /**
    45  * Displays the author of the current comment.
    48  * Displays the author of the current comment.
    46  *
    49  *
    48  *
    51  *
    49  * @param int $comment_ID Optional. The ID of the comment for which to print the author. Default current comment.
    52  * @param int $comment_ID Optional. The ID of the comment for which to print the author. Default current comment.
    50  */
    53  */
    51 function comment_author( $comment_ID = 0 ) {
    54 function comment_author( $comment_ID = 0 ) {
    52 	$author = get_comment_author( $comment_ID );
    55 	$author = get_comment_author( $comment_ID );
       
    56 
    53 	/**
    57 	/**
    54 	 * Filter the comment author's name for display.
    58 	 * Filter the comment author's name for display.
    55 	 *
    59 	 *
    56 	 * @since 1.2.1
    60 	 * @since 1.2.0
    57 	 *
    61 	 * @since 4.1.0 The `$comment_ID` parameter was added.
    58 	 * @param string $author The comment author's username.
    62 	 *
    59 	 */
    63 	 * @param string $author     The comment author's username.
    60 	$author = apply_filters( 'comment_author', $author );
    64 	 * @param int    $comment_ID The comment ID.
       
    65 	 */
       
    66 	$author = apply_filters( 'comment_author', $author, $comment_ID );
    61 	echo $author;
    67 	echo $author;
    62 }
    68 }
    63 
    69 
    64 /**
    70 /**
    65  * Retrieve the email of the author of the current comment.
    71  * Retrieve the email of the author of the current comment.
    69  * @param int $comment_ID Optional. The ID of the comment for which to get the author's email. Default current comment.
    75  * @param int $comment_ID Optional. The ID of the comment for which to get the author's email. Default current comment.
    70  * @return string The current comment author's email
    76  * @return string The current comment author's email
    71  */
    77  */
    72 function get_comment_author_email( $comment_ID = 0 ) {
    78 function get_comment_author_email( $comment_ID = 0 ) {
    73 	$comment = get_comment( $comment_ID );
    79 	$comment = get_comment( $comment_ID );
       
    80 
    74 	/**
    81 	/**
    75 	 * Filter the comment author's returned email address.
    82 	 * Filter the comment author's returned email address.
    76 	 *
    83 	 *
    77 	 * @since 1.5.2
    84 	 * @since 1.5.0
    78 	 *
    85 	 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added.
    79 	 * @param string $comment->comment_author_email The comment author's email address.
    86 	 *
    80 	 */
    87 	 * @param string $comment_author_email The comment author's email address.
    81 	return apply_filters( 'get_comment_author_email', $comment->comment_author_email );
    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 );
    82 }
    92 }
    83 
    93 
    84 /**
    94 /**
    85  * Display the email of the author of the current global $comment.
    95  * Display the email of the author of the current global $comment.
    86  *
    96  *
    94  *
   104  *
    95  * @param int $comment_ID Optional. The ID of the comment for which to print the author's email. Default current comment.
   105  * @param int $comment_ID Optional. The ID of the comment for which to print the author's email. Default current comment.
    96  */
   106  */
    97 function comment_author_email( $comment_ID = 0 ) {
   107 function comment_author_email( $comment_ID = 0 ) {
    98 	$author_email = get_comment_author_email( $comment_ID );
   108 	$author_email = get_comment_author_email( $comment_ID );
       
   109 
    99 	/**
   110 	/**
   100 	 * Filter the comment author's email for display.
   111 	 * Filter the comment author's email for display.
   101 	 *
   112 	 *
   102 	 * @since 1.2.1
   113 	 * @since 1.2.0
       
   114 	 * @since 4.1.0 The `$comment_ID` parameter was added.
   103 	 *
   115 	 *
   104 	 * @param string $author_email The comment author's email address.
   116 	 * @param string $author_email The comment author's email address.
   105 	 */
   117 	 * @param int    $comment_ID   The comment ID.
   106 	echo apply_filters( 'author_email', $author_email );
   118 	 */
       
   119 	echo apply_filters( 'author_email', $author_email, $comment_ID );
   107 }
   120 }
   108 
   121 
   109 /**
   122 /**
   110  * Display the html email link to the author of the current comment.
   123  * Display the html email link to the author of the current comment.
   111  *
   124  *
   113  * harvesters do not capture your commentors' email address. Most assume that
   126  * harvesters do not capture your commentors' email address. Most assume that
   114  * their email address will not appear in raw form on the blog. Doing so will
   127  * their email address will not appear in raw form on the blog. Doing so will
   115  * enable anyone, including those that people don't want to get the email
   128  * enable anyone, including those that people don't want to get the email
   116  * address and use it for their own means good and bad.
   129  * address and use it for their own means good and bad.
   117  *
   130  *
   118  * @global object $comment The current Comment row object
       
   119 
       
   120  * @since 0.71
   131  * @since 0.71
   121  *
   132  *
   122  * @param string $linktext Optional. The text to display instead of the comment author's email address. Default empty.
   133  * @param string $linktext Optional. Text to display instead of the comment author's email address.
   123  * @param string $before   Optional. The text or HTML to display before the email link.Default empty.
   134  *                         Default empty.
   124  * @param string $after    Optional. The text or HTML to display after the email link. 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.
   125  */
   137  */
   126 function comment_author_email_link( $linktext = '', $before = '', $after = '' ) {
   138 function comment_author_email_link( $linktext = '', $before = '', $after = '' ) {
   127 	if ( $link = get_comment_author_email_link( $linktext, $before, $after ) )
   139 	if ( $link = get_comment_author_email_link( $linktext, $before, $after ) )
   128 		echo $link;
   140 		echo $link;
   129 }
   141 }
   137  * enable anyone, including those that people don't want to get the email
   149  * enable anyone, including those that people don't want to get the email
   138  * address and use it for their own means good and bad.
   150  * address and use it for their own means good and bad.
   139  *
   151  *
   140  * @global object $comment The current Comment row object.
   152  * @global object $comment The current Comment row object.
   141  *
   153  *
   142  * @since 2.7
   154  * @since 2.7.0
   143  *
   155  *
   144  * @param string $linktext Optional. The text to display instead of the comment author's email address. Default empty.
   156  * @param string $linktext Optional. Text to display instead of the comment author's email address.
   145  * @param string $before   Optional. The text or HTML to display before the email link. Default empty.
   157  *                         Default empty.
   146  * @param string $after    Optional. The text or HTML to display after the email link. Default empty.
   158  * @param string $before   Optional. Text or HTML to display before the email link. Default empty.
       
   159  * @param string $after    Optional. Text or HTML to display after the email link. Default empty.
   147  */
   160  */
   148 function get_comment_author_email_link( $linktext = '', $before = '', $after = '' ) {
   161 function get_comment_author_email_link( $linktext = '', $before = '', $after = '' ) {
   149 	global $comment;
   162 	global $comment;
       
   163 
   150 	/**
   164 	/**
   151 	 * Filter the comment author's email for display.
   165 	 * Filter the comment author's email for display.
   152 	 *
   166 	 *
   153 	 * Care should be taken to protect the email address and assure that email
   167 	 * Care should be taken to protect the email address and assure that email
   154 	 * harvesters do not capture your commentors' email address.
   168 	 * harvesters do not capture your commenter's email address.
   155 	 *
   169 	 *
   156 	 * @since 1.2.1
   170 	 * @since 1.2.0
   157 	 *
   171 	 * @since 4.1.0 The `$comment` parameter was added.
   158 	 * @param string $comment->comment_author_email The comment author's email address.
   172 	 *
   159 	 */
   173 	 * @param string $comment_author_email The comment author's email address.
   160 	$email = apply_filters( 'comment_email', $comment->comment_author_email );
   174 	 * @param object $comment              The comment object.
       
   175 	 */
       
   176 	$email = apply_filters( 'comment_email', $comment->comment_author_email, $comment );
   161 	if ((!empty($email)) && ($email != '@')) {
   177 	if ((!empty($email)) && ($email != '@')) {
   162 	$display = ($linktext != '') ? $linktext : $email;
   178 	$display = ($linktext != '') ? $linktext : $email;
   163 		$return  = $before;
   179 		$return  = $before;
   164 		$return .= "<a href='mailto:$email'>$display</a>";
   180 		$return .= "<a href='mailto:$email'>$display</a>";
   165 	 	$return .= $after;
   181 	 	$return .= $after;
   175  * Both get_comment_author_url() and get_comment_author() rely on get_comment(),
   191  * Both get_comment_author_url() and get_comment_author() rely on get_comment(),
   176  * which falls back to the global comment variable if the $comment_ID argument is empty.
   192  * which falls back to the global comment variable if the $comment_ID argument is empty.
   177  *
   193  *
   178  * @since 1.5.0
   194  * @since 1.5.0
   179  *
   195  *
   180  * @param int $comment_ID Optional. The ID of the comment for which to get the author's link. Default current comment.
   196  * @param int $comment_ID ID of the comment for which to get the author's link.
       
   197  *                        Default current comment.
   181  * @return string The comment author name or HTML link for author's URL.
   198  * @return string The comment author name or HTML link for author's URL.
   182  */
   199  */
   183 function get_comment_author_link( $comment_ID = 0 ) {
   200 function get_comment_author_link( $comment_ID = 0 ) {
   184 	$url    = get_comment_author_url( $comment_ID );
   201 	$url    = get_comment_author_url( $comment_ID );
   185 	$author = get_comment_author( $comment_ID );
   202 	$author = get_comment_author( $comment_ID );
   190 		$return = "<a href='$url' rel='external nofollow' class='url'>$author</a>";
   207 		$return = "<a href='$url' rel='external nofollow' class='url'>$author</a>";
   191 
   208 
   192 	/**
   209 	/**
   193 	 * Filter the comment author's link for display.
   210 	 * Filter the comment author's link for display.
   194 	 *
   211 	 *
   195 	 * @since 1.5.2
   212 	 * @since 1.5.0
   196 	 *
   213 	 * @since 4.1.0 The `$author` and `$comment_ID` parameters were added.
   197 	 * @param string $return The HTML-formatted comment author link. Empty for an invalid URL.
   214 	 *
   198 	 */
   215 	 * @param string $return     The HTML-formatted comment author link.
   199 	return apply_filters( 'get_comment_author_link', $return );
   216 	 *                           Empty for an invalid URL.
       
   217 	 * @param string $author     The comment author's username.
       
   218 	 * @param int    $comment_ID The comment ID.
       
   219 	 */
       
   220 	return apply_filters( 'get_comment_author_link', $return, $author, $comment_ID );
   200 }
   221 }
   201 
   222 
   202 /**
   223 /**
   203  * Display the html link to the url of the author of the current comment.
   224  * Display the html link to the url of the author of the current comment.
   204  *
   225  *
   205  * @since 0.71
   226  * @since 0.71
       
   227  *
   206  * @see get_comment_author_link() Echoes result
   228  * @see get_comment_author_link() Echoes result
   207  *
   229  *
   208  * @param int $comment_ID Optional. The ID of the comment for which to print the author's link. Default current comment.
   230  * @param int $comment_ID ID of the comment for which to print the author's
       
   231  *                        link. Default current comment.
   209  */
   232  */
   210 function comment_author_link( $comment_ID = 0 ) {
   233 function comment_author_link( $comment_ID = 0 ) {
   211 	echo get_comment_author_link( $comment_ID );
   234 	echo get_comment_author_link( $comment_ID );
   212 }
   235 }
   213 
   236 
   214 /**
   237 /**
   215  * Retrieve the IP address of the author of the current comment.
   238  * Retrieve the IP address of the author of the current comment.
   216  *
   239  *
   217  * @since 1.5.0
   240  * @since 1.5.0
   218  *
   241  *
   219  * @param int $comment_ID Optional. The ID of the comment for which to get the author's IP address. Default current comment.
   242  * @param int $comment_ID ID of the comment for which to get the author's IP
   220  * @return string The comment author's IP address.
   243  *                        address. Default current comment.
       
   244  * @return string Comment author's IP address.
   221  */
   245  */
   222 function get_comment_author_IP( $comment_ID = 0 ) {
   246 function get_comment_author_IP( $comment_ID = 0 ) {
   223 	$comment = get_comment( $comment_ID );
   247 	$comment = get_comment( $comment_ID );
   224 
   248 
   225 	/**
   249 	/**
   226 	 * Filter the comment author's returned IP address.
   250 	 * Filter the comment author's returned IP address.
   227 	 *
   251 	 *
   228 	 * @since 1.5.2
   252 	 * @since 1.5.0
   229 	 *
   253 	 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added.
   230 	 * @param string $comment->comment_author_IP The comment author's IP address.
   254 	 *
   231 	 */
   255 	 * @param string $comment_author_IP The comment author's IP address.
   232 	return apply_filters( 'get_comment_author_IP', $comment->comment_author_IP );
   256 	 * @param int    $comment_ID        The comment ID.
       
   257 	 * @param object $comment           The comment object.
       
   258 	 */
       
   259 	return apply_filters( 'get_comment_author_IP', $comment->comment_author_IP, $comment_ID, $comment );
   233 }
   260 }
   234 
   261 
   235 /**
   262 /**
   236  * Display the IP address of the author of the current comment.
   263  * Display the IP address of the author of the current comment.
   237  *
   264  *
   238  * @since 0.71
   265  * @since 0.71
   239  *
   266  *
   240  * @param int $comment_ID Optional. The ID of the comment for which to print the author's IP address. Default current comment.
   267  * @param int $comment_ID ID of the comment for which to print the author's IP
       
   268  *                        address. Default current comment.
   241  */
   269  */
   242 function comment_author_IP( $comment_ID = 0 ) {
   270 function comment_author_IP( $comment_ID = 0 ) {
   243 	echo get_comment_author_IP( $comment_ID );
   271 	echo get_comment_author_IP( $comment_ID );
   244 }
   272 }
   245 
   273 
   246 /**
   274 /**
   247  * Retrieve the url of the author of the current comment.
   275  * Retrieve the url of the author of the current comment.
   248  *
   276  *
   249  * @since 1.5.0
   277  * @since 1.5.0
   250  *
   278  *
   251  * @param int $comment_ID Optional. The ID of the comment for which to get the author's URL. Default current comment.
   279  * @param int $comment_ID ID of the comment for which to get the author's URL.
       
   280  *                        Default current comment.
   252  * @return string
   281  * @return string
   253  */
   282  */
   254 function get_comment_author_url( $comment_ID = 0 ) {
   283 function get_comment_author_url( $comment_ID = 0 ) {
   255 	$comment = get_comment( $comment_ID );
   284 	$comment = get_comment( $comment_ID );
   256 	$url = ('http://' == $comment->comment_author_url) ? '' : $comment->comment_author_url;
   285 	$url = ('http://' == $comment->comment_author_url) ? '' : $comment->comment_author_url;
   257 	$url = esc_url( $url, array('http', 'https') );
   286 	$url = esc_url( $url, array('http', 'https') );
   258 	return apply_filters('get_comment_author_url', $url);
   287 
       
   288 	/**
       
   289 	 * Filter the comment author's URL.
       
   290 	 *
       
   291 	 * @since 1.5.0
       
   292 	 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added.
       
   293 	 *
       
   294 	 * @param string $url        The comment author's URL.
       
   295 	 * @param int    $comment_ID The comment ID.
       
   296 	 * @param object $comment    The comment object.
       
   297 	 */
       
   298 	return apply_filters( 'get_comment_author_url', $url, $comment_ID, $comment );
   259 }
   299 }
   260 
   300 
   261 /**
   301 /**
   262  * Display the url of the author of the current comment.
   302  * Display the url of the author of the current comment.
   263  *
   303  *
   264  * @since 0.71
   304  * @since 0.71
   265  *
   305  *
   266  * @param int $comment_ID Optional. The ID of the comment for which to print the author's URL. Default current comment.
   306  * @param int $comment_ID ID of the comment for which to print the author's URL.
       
   307  *                        Default current comment.
   267  */
   308  */
   268 function comment_author_url( $comment_ID = 0 ) {
   309 function comment_author_url( $comment_ID = 0 ) {
   269 	$author_url = get_comment_author_url( $comment_ID );
   310 	$author_url = get_comment_author_url( $comment_ID );
       
   311 
   270 	/**
   312 	/**
   271 	 * Filter the comment author's URL for display.
   313 	 * Filter the comment author's URL for display.
   272 	 *
   314 	 *
   273 	 * @since 1.2.1
   315 	 * @since 1.2.0
       
   316 	 * @since 4.1.0 The `$comment_ID` parameter was added.
   274 	 *
   317 	 *
   275 	 * @param string $author_url The comment author's URL.
   318 	 * @param string $author_url The comment author's URL.
   276 	 */
   319 	 * @param int    $comment_ID The comment ID.
   277 	echo apply_filters( 'comment_url', $author_url );
   320 	 */
       
   321 	echo apply_filters( 'comment_url', $author_url, $comment_ID );
   278 }
   322 }
   279 
   323 
   280 /**
   324 /**
   281  * Retrieves the HTML link of the url of the author of the current comment.
   325  * Retrieves the HTML link of the url of the author of the current comment.
   282  *
   326  *
   287  * Encapsulate the HTML link between the $before and $after. So it will appear
   331  * Encapsulate the HTML link between the $before and $after. So it will appear
   288  * in the order of $before, link, and finally $after.
   332  * in the order of $before, link, and finally $after.
   289  *
   333  *
   290  * @since 1.5.0
   334  * @since 1.5.0
   291  *
   335  *
   292  * @param string $linktext Optional. The text to display instead of the comment author's email address. Default empty.
   336  * @param string $linktext Optional. The text to display instead of the comment
   293  * @param string $before   Optional. The text or HTML to display before the email link. Default empty.
   337  *                         author's email address. Default empty.
   294  * @param string $after    Optional. The text or HTML to display after the email link. Default empty.
   338  * @param string $before   Optional. The text or HTML to display before the email link.
       
   339  *                         Default empty.
       
   340  * @param string $after    Optional. The text or HTML to display after the email link.
       
   341  *                         Default empty.
   295  * @return string The HTML link between the $before and $after parameters.
   342  * @return string The HTML link between the $before and $after parameters.
   296  */
   343  */
   297 function get_comment_author_url_link( $linktext = '', $before = '', $after = '' ) {
   344 function get_comment_author_url_link( $linktext = '', $before = '', $after = '' ) {
   298 	$url = get_comment_author_url();
   345 	$url = get_comment_author_url();
   299 	$display = ($linktext != '') ? $linktext : $url;
   346 	$display = ($linktext != '') ? $linktext : $url;
   300 	$display = str_replace( 'http://www.', '', $display );
   347 	$display = str_replace( 'http://www.', '', $display );
   301 	$display = str_replace( 'http://', '', $display );
   348 	$display = str_replace( 'http://', '', $display );
   302 	if ( '/' == substr($display, -1) )
   349 
       
   350 	if ( '/' == substr($display, -1) ) {
   303 		$display = substr($display, 0, -1);
   351 		$display = substr($display, 0, -1);
       
   352 	}
       
   353 
   304 	$return = "$before<a href='$url' rel='external'>$display</a>$after";
   354 	$return = "$before<a href='$url' rel='external'>$display</a>$after";
   305 
   355 
   306 	/**
   356 	/**
   307 	 * Filter the comment author's returned URL link.
   357 	 * Filter the comment author's returned URL link.
   308 	 *
   358 	 *
   309 	 * @since 1.5.2
   359 	 * @since 1.5.0
   310 	 *
   360 	 *
   311 	 * @param string $return The HTML-formatted comment author URL link.
   361 	 * @param string $return The HTML-formatted comment author URL link.
   312 	 */
   362 	 */
   313 	return apply_filters( 'get_comment_author_url_link', $return );
   363 	return apply_filters( 'get_comment_author_url_link', $return );
   314 }
   364 }
   316 /**
   366 /**
   317  * Displays the HTML link of the url of the author of the current comment.
   367  * Displays the HTML link of the url of the author of the current comment.
   318  *
   368  *
   319  * @since 0.71
   369  * @since 0.71
   320  *
   370  *
   321  * @param string $linktext Optional. The text to display instead of the comment author's email address. Default empty.
   371  * @param string $linktext Optional. Text to display instead of the comment author's
   322  * @param string $before   Optional. The text or HTML to display before the email link. Default empty.
   372  *                         email address. Default empty.
   323  * @param string $after    Optional. The text or HTML to display after the email link. Default empty.
   373  * @param string $before   Optional. Text or HTML to display before the email link.
       
   374  *                         Default empty.
       
   375  * @param string $after    Optional. Text or HTML to display after the email link.
       
   376  *                         Default empty.
   324  */
   377  */
   325 function comment_author_url_link( $linktext = '', $before = '', $after = '' ) {
   378 function comment_author_url_link( $linktext = '', $before = '', $after = '' ) {
   326 	echo get_comment_author_url_link( $linktext, $before, $after );
   379 	echo get_comment_author_url_link( $linktext, $before, $after );
   327 }
   380 }
   328 
   381 
   329 /**
   382 /**
   330  * Generates semantic classes for each comment element
   383  * Generates semantic classes for each comment element.
   331  *
   384  *
   332  * @since 2.7.0
   385  * @since 2.7.0
   333  *
   386  *
   334  * @param string|array $class      Optional. One or more classes to add to the class list. Default empty.
   387  * @param string|array $class      Optional. One or more classes to add to the class list.
   335  * @param int          $comment_id Optional. Comment ID. Default current comment.
   388  *                                 Default empty.
   336  * @param int|WP_Post  $post_id    Optional. Post ID or WP_Post object. Default current post.
   389  * @param int          $comment_id Comment ID. Default current comment.
   337  * @param bool         $echo       Optional. Whether comment_class should echo or return. Default true.
   390  * @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.
       
   392  *                                 Default true.
   338  */
   393  */
   339 function comment_class( $class = '', $comment_id = null, $post_id = null, $echo = true ) {
   394 function comment_class( $class = '', $comment_id = null, $post_id = null, $echo = true ) {
   340 	// Separates classes with a single space, collates classes for comment DIV
   395 	// Separates classes with a single space, collates classes for comment DIV
   341 	$class = 'class="' . join( ' ', get_comment_class( $class, $comment_id, $post_id ) ) . '"';
   396 	$class = 'class="' . join( ' ', get_comment_class( $class, $comment_id, $post_id ) ) . '"';
   342 	if ( $echo)
   397 	if ( $echo)
   344 	else
   399 	else
   345 		return $class;
   400 		return $class;
   346 }
   401 }
   347 
   402 
   348 /**
   403 /**
   349  * Returns the classes for the comment div as an array
   404  * Returns the classes for the comment div as an array.
   350  *
   405  *
   351  * @since 2.7.0
   406  * @since 2.7.0
   352  *
   407  *
   353  * @param string|array $class      Optional. One or more classes to add to the class list. Default empty.
   408  * @param string|array $class      Optional. One or more classes to add to the class list. Default empty.
   354  * @param int          $comment_id Optional. Comment ID. Default current comment.
   409  * @param int          $comment_id Comment ID. Default current comment.
   355  * @param int|WP_Post  $post_id    Optional. Post ID or WP_Post object. Default current post.
   410  * @param int|WP_Post  $post_id    Post ID or WP_Post object. Default current post.
   356  * @return array An array of classes.
   411  * @return array An array of classes.
   357  */
   412  */
   358 function get_comment_class( $class = '', $comment_id = null, $post_id = null ) {
   413 function get_comment_class( $class = '', $comment_id = null, $post_id = null ) {
   359 	global $comment_alt, $comment_depth, $comment_thread_alt;
   414 	global $comment_alt, $comment_depth, $comment_thread_alt;
   360 
   415 
   363 	$classes = array();
   418 	$classes = array();
   364 
   419 
   365 	// Get the comment type (comment, trackback),
   420 	// Get the comment type (comment, trackback),
   366 	$classes[] = ( empty( $comment->comment_type ) ) ? 'comment' : $comment->comment_type;
   421 	$classes[] = ( empty( $comment->comment_type ) ) ? 'comment' : $comment->comment_type;
   367 
   422 
   368 	// If the comment author has an id (registered), then print the log in name
   423 	// Add classes for comment authors that are registered users.
   369 	if ( $comment->user_id > 0 && $user = get_userdata($comment->user_id) ) {
   424 	if ( $comment->user_id > 0 && $user = get_userdata( $comment->user_id ) ) {
   370 		// For all registered users, 'byuser'
       
   371 		$classes[] = 'byuser';
   425 		$classes[] = 'byuser';
   372 		$classes[] = 'comment-author-' . sanitize_html_class($user->user_nicename, $comment->user_id);
   426 		$classes[] = 'comment-author-' . sanitize_html_class( $user->user_nicename, $comment->user_id );
   373 		// For comment authors who are the author of the post
   427 		// For comment authors who are the author of the post
   374 		if ( $post = get_post($post_id) ) {
   428 		if ( $post = get_post($post_id) ) {
   375 			if ( $comment->user_id === $post->post_author )
   429 			if ( $comment->user_id === $post->post_author ) {
   376 				$classes[] = 'bypostauthor';
   430 				$classes[] = 'bypostauthor';
       
   431 			}
   377 		}
   432 		}
   378 	}
   433 	}
   379 
   434 
   380 	if ( empty($comment_alt) )
   435 	if ( empty($comment_alt) )
   381 		$comment_alt = 0;
   436 		$comment_alt = 0;
   420 	 * @since 2.7.0
   475 	 * @since 2.7.0
   421 	 *
   476 	 *
   422 	 * @param array       $classes    An array of comment classes.
   477 	 * @param array       $classes    An array of comment classes.
   423 	 * @param string      $class      A comma-separated list of additional classes added to the list.
   478 	 * @param string      $class      A comma-separated list of additional classes added to the list.
   424 	 * @param int         $comment_id The comment id.
   479 	 * @param int         $comment_id The comment id.
       
   480 	 * @param object   	  $comment    The comment
   425 	 * @param int|WP_Post $post_id    The post ID or WP_Post object.
   481 	 * @param int|WP_Post $post_id    The post ID or WP_Post object.
   426 	 */
   482 	 */
   427 	return apply_filters( 'comment_class', $classes, $class, $comment_id, $post_id );
   483 	return apply_filters( 'comment_class', $classes, $class, $comment_id, $comment, $post_id );
   428 }
   484 }
   429 
   485 
   430 /**
   486 /**
   431  * Retrieve the comment date of the current comment.
   487  * Retrieve the comment date of the current comment.
   432  *
   488  *
   433  * @since 1.5.0
   489  * @since 1.5.0
   434  *
   490  *
   435  * @param string $d          Optional. The format of the date. Default user's setting.
   491  * @param string $d          Optional. The format of the date. Default user's setting.
   436  * @param int    $comment_ID Optional. The ID of the comment for which to get the date. Default current comment.
   492  * @param int    $comment_ID ID of the comment for which to get the date. Default current comment.
   437  * @return string The comment's date.
   493  * @return string The comment's date.
   438  */
   494  */
   439 function get_comment_date( $d = '', $comment_ID = 0 ) {
   495 function get_comment_date( $d = '', $comment_ID = 0 ) {
   440 	$comment = get_comment( $comment_ID );
   496 	$comment = get_comment( $comment_ID );
   441 	if ( '' == $d )
   497 	if ( '' == $d )
   443 	else
   499 	else
   444 		$date = mysql2date($d, $comment->comment_date);
   500 		$date = mysql2date($d, $comment->comment_date);
   445 	/**
   501 	/**
   446 	 * Filter the returned comment date.
   502 	 * Filter the returned comment date.
   447 	 *
   503 	 *
   448 	 * @since 1.5.2
   504 	 * @since 1.5.0
   449 	 *
   505 	 *
   450 	 * @param string|int $date Formatted date string or Unix timestamp.
   506 	 * @param string|int $date    Formatted date string or Unix timestamp.
   451 	 * @param string     $d    The format of the date.
   507 	 * @param string     $d       The format of the date.
   452 	 */
   508 	 * @param object     $comment The comment object.
   453 	return apply_filters( 'get_comment_date', $date, $d );
   509 	 */
       
   510 	return apply_filters( 'get_comment_date', $date, $d, $comment );
   454 }
   511 }
   455 
   512 
   456 /**
   513 /**
   457  * Display the comment date of the current comment.
   514  * Display the comment date of the current comment.
   458  *
   515  *
   459  * @since 0.71
   516  * @since 0.71
   460  *
   517  *
   461  * @param string $d          Optional. The format of the date. Default user's settings.
   518  * @param string $d          Optional. The format of the date. Default user's settings.
   462  * @param int    $comment_ID Optional. The ID of the comment for which to print the date. Default current comment.
   519  * @param int    $comment_ID ID of the comment for which to print the date. Default current comment.
   463  */
   520  */
   464 function comment_date( $d = '', $comment_ID = 0 ) {
   521 function comment_date( $d = '', $comment_ID = 0 ) {
   465 	echo get_comment_date( $d, $comment_ID );
   522 	echo get_comment_date( $d, $comment_ID );
   466 }
   523 }
   467 
   524 
   472  * If the word count is less than 20, then no truncating is done and no '&hellip;'
   529  * If the word count is less than 20, then no truncating is done and no '&hellip;'
   473  * will appear.
   530  * will appear.
   474  *
   531  *
   475  * @since 1.5.0
   532  * @since 1.5.0
   476  *
   533  *
   477  * @param int $comment_ID Optional. The ID of the comment for which to get the excerpt. Default current comment.
   534  * @param int $comment_ID ID of the comment for which to get the excerpt.
       
   535  *                        Default current comment.
   478  * @return string The maybe truncated comment with 20 words or less.
   536  * @return string The maybe truncated comment with 20 words or less.
   479  */
   537  */
   480 function get_comment_excerpt( $comment_ID = 0 ) {
   538 function get_comment_excerpt( $comment_ID = 0 ) {
   481 	$comment = get_comment( $comment_ID );
   539 	$comment = get_comment( $comment_ID );
   482 	$comment_text = strip_tags($comment->comment_content);
   540 	$comment_text = strip_tags($comment->comment_content);
   483 	$blah = explode(' ', $comment_text);
   541 	$blah = explode(' ', $comment_text);
       
   542 
   484 	if (count($blah) > 20) {
   543 	if (count($blah) > 20) {
   485 		$k = 20;
   544 		$k = 20;
   486 		$use_dotdotdot = 1;
   545 		$use_dotdotdot = 1;
   487 	} else {
   546 	} else {
   488 		$k = count($blah);
   547 		$k = count($blah);
   489 		$use_dotdotdot = 0;
   548 		$use_dotdotdot = 0;
   490 	}
   549 	}
       
   550 
   491 	$excerpt = '';
   551 	$excerpt = '';
   492 	for ($i=0; $i<$k; $i++) {
   552 	for ($i=0; $i<$k; $i++) {
   493 		$excerpt .= $blah[$i] . ' ';
   553 		$excerpt .= $blah[$i] . ' ';
   494 	}
   554 	}
   495 	$excerpt .= ($use_dotdotdot) ? '&hellip;' : '';
   555 	$excerpt .= ($use_dotdotdot) ? '&hellip;' : '';
   496 	return apply_filters('get_comment_excerpt', $excerpt);
   556 
       
   557 	/**
       
   558 	 * Filter the retrieved comment excerpt.
       
   559 	 *
       
   560 	 * @since 1.5.0
       
   561 	 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added.
       
   562 	 *
       
   563 	 * @param string $excerpt    The comment excerpt text.
       
   564 	 * @param int    $comment_ID The comment ID.
       
   565 	 * @param object $comment    The comment object.
       
   566 	 */
       
   567 	return apply_filters( 'get_comment_excerpt', $excerpt, $comment_ID, $comment );
   497 }
   568 }
   498 
   569 
   499 /**
   570 /**
   500  * Display the excerpt of the current comment.
   571  * Display the excerpt of the current comment.
   501  *
   572  *
   502  * @since 1.2.0
   573  * @since 1.2.0
   503  *
   574  *
   504  * @param int $comment_ID Optional. The ID of the comment for which to print the excerpt. Default current comment.
   575  * @param int $comment_ID ID of the comment for which to print the excerpt.
       
   576  *                        Default current comment.
   505  */
   577  */
   506 function comment_excerpt( $comment_ID = 0 ) {
   578 function comment_excerpt( $comment_ID = 0 ) {
   507 	$comment_excerpt = get_comment_excerpt($comment_ID);
   579 	$comment_excerpt = get_comment_excerpt($comment_ID);
       
   580 
   508 	/**
   581 	/**
   509 	 * Filter the comment excerpt for display.
   582 	 * Filter the comment excerpt for display.
   510 	 *
   583 	 *
   511 	 * @since 1.2.1
   584 	 * @since 1.2.0
       
   585 	 * @since 4.1.0 The `$comment_ID` parameter was added.
   512 	 *
   586 	 *
   513 	 * @param string $comment_excerpt The comment excerpt text.
   587 	 * @param string $comment_excerpt The comment excerpt text.
   514 	 */
   588 	 * @param int    $comment_ID      The comment ID.
   515 	echo apply_filters( 'comment_excerpt', $comment_excerpt );
   589 	 */
       
   590 	echo apply_filters( 'comment_excerpt', $comment_excerpt, $comment_ID );
   516 }
   591 }
   517 
   592 
   518 /**
   593 /**
   519  * Retrieve the comment id of the current comment.
   594  * Retrieve the comment id of the current comment.
   520  *
   595  *
   522  *
   597  *
   523  * @return int The comment ID.
   598  * @return int The comment ID.
   524  */
   599  */
   525 function get_comment_ID() {
   600 function get_comment_ID() {
   526 	global $comment;
   601 	global $comment;
       
   602 
   527 	/**
   603 	/**
   528 	 * Filter the returned comment ID.
   604 	 * Filter the returned comment ID.
   529 	 *
   605 	 *
   530 	 * @since 1.5.2
   606 	 * @since 1.5.0
   531 	 *
   607 	 * @since 4.1.0 The `$comment_ID` parameter was added.
   532 	 * @param int $comment->comment_ID The current comment ID.
   608 	 *
   533 	 */
   609 	 * @param int    $comment_ID The current comment ID.
   534 	return apply_filters( 'get_comment_ID', $comment->comment_ID );
   610 	 * @param object $comment    The comment object.
       
   611 	 */
       
   612 	return apply_filters( 'get_comment_ID', $comment->comment_ID, $comment );
   535 }
   613 }
   536 
   614 
   537 /**
   615 /**
   538  * Display the comment id of the current comment.
   616  * Display the comment id of the current comment.
   539  *
   617  *
   546 /**
   624 /**
   547  * Retrieve the link to a given comment.
   625  * Retrieve the link to a given comment.
   548  *
   626  *
   549  * @since 1.5.0
   627  * @since 1.5.0
   550  *
   628  *
   551  * @param mixed $comment Optional. Comment to retrieve. Default current comment.
   629  * @see get_page_of_comment()
   552  * @param array $args    Optional. An array of arguments to override the defaults. @see get_page_of_comment()
   630  *
       
   631  * @param mixed $comment Comment to retrieve. Default current comment.
       
   632  * @param array $args    Optional. An array of arguments to override the defaults.
   553  * @return string The permalink to the given comment.
   633  * @return string The permalink to the given comment.
   554  */
   634  */
   555 function get_comment_link( $comment = null, $args = array() ) {
   635 function get_comment_link( $comment = null, $args = array() ) {
   556 	global $wp_rewrite, $in_comment_loop;
   636 	global $wp_rewrite, $in_comment_loop;
   557 
   637 
   558 	$comment = get_comment($comment);
   638 	$comment = get_comment($comment);
   559 
   639 
   560 	// Backwards compat
   640 	// Backwards compat
   561 	if ( !is_array($args) ) {
   641 	if ( ! is_array( $args ) ) {
   562 		$page = $args;
   642 		$args = array( 'page' => $args );
   563 		$args = array();
       
   564 		$args['page'] = $page;
       
   565 	}
   643 	}
   566 
   644 
   567 	$defaults = array( 'type' => 'all', 'page' => '', 'per_page' => '', 'max_depth' => '' );
   645 	$defaults = array( 'type' => 'all', 'page' => '', 'per_page' => '', 'max_depth' => '' );
   568 	$args = wp_parse_args( $args, $defaults );
   646 	$args = wp_parse_args( $args, $defaults );
   569 
   647 
   578 	if ( $args['per_page'] ) {
   656 	if ( $args['per_page'] ) {
   579 		if ( '' == $args['page'] )
   657 		if ( '' == $args['page'] )
   580 			$args['page'] = ( !empty($in_comment_loop) ) ? get_query_var('cpage') : get_page_of_comment( $comment->comment_ID, $args );
   658 			$args['page'] = ( !empty($in_comment_loop) ) ? get_query_var('cpage') : get_page_of_comment( $comment->comment_ID, $args );
   581 
   659 
   582 		if ( $wp_rewrite->using_permalinks() )
   660 		if ( $wp_rewrite->using_permalinks() )
   583 			$link = user_trailingslashit( trailingslashit( get_permalink( $comment->comment_post_ID ) ) . 'comment-page-' . $args['page'], 'comment' );
   661 			$link = user_trailingslashit( trailingslashit( get_permalink( $comment->comment_post_ID ) ) . $wp_rewrite->comments_pagination_base . '-' . $args['page'], 'comment' );
   584 		else
   662 		else
   585 			$link = add_query_arg( 'cpage', $args['page'], get_permalink( $comment->comment_post_ID ) );
   663 			$link = add_query_arg( 'cpage', $args['page'], get_permalink( $comment->comment_post_ID ) );
   586 	} else {
   664 	} else {
   587 		$link = get_permalink( $comment->comment_post_ID );
   665 		$link = get_permalink( $comment->comment_post_ID );
   588 	}
   666 	}
   591 	/**
   669 	/**
   592 	 * Filter the returned single comment permalink.
   670 	 * Filter the returned single comment permalink.
   593 	 *
   671 	 *
   594 	 * @since 2.8.0
   672 	 * @since 2.8.0
   595 	 *
   673 	 *
       
   674 	 * @see get_page_of_comment()
       
   675 	 *
   596 	 * @param string $link    The comment permalink with '#comment-$id' appended.
   676 	 * @param string $link    The comment permalink with '#comment-$id' appended.
   597 	 * @param object $comment The current comment object.
   677 	 * @param object $comment The current comment object.
   598 	 * @param array  $args    An array of arguments to override the defaults. @see get_page_of_comment()
   678 	 * @param array  $args    An array of arguments to override the defaults.
   599 	 */
   679 	 */
   600 	return apply_filters( 'get_comment_link', $link, $comment, $args );
   680 	return apply_filters( 'get_comment_link', $link, $comment, $args );
   601 }
   681 }
   602 
   682 
   603 /**
   683 /**
   604  * Retrieve the link to the current post comments.
   684  * Retrieve the link to the current post comments.
   605  *
   685  *
   606  * @since 1.5.0
   686  * @since 1.5.0
   607  *
   687  *
   608  * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default current post.
   688  * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post.
   609  * @return string The link to the comments.
   689  * @return string The link to the comments.
   610  */
   690  */
   611 function get_comments_link( $post_id = 0 ) {
   691 function get_comments_link( $post_id = 0 ) {
   612 	$comments_link = get_permalink( $post_id ) . '#comments';
   692 	$comments_link = get_permalink( $post_id ) . '#comments';
   613 	/**
   693 	/**
   614 	 * Filter the returned post comments permalink.
   694 	 * Filter the returned post comments permalink.
   615 	 *
   695 	 *
   616 	 * @since
   696 	 * @since 3.6.0
   617 	 *
   697 	 *
   618 	 * @param string      $comments_link The post comments permalink with '#comments' appended.
   698 	 * @param string      $comments_link Post comments permalink with '#comments' appended.
   619 	 * @param int|WP_Post $post_id       The post ID or WP_Post object.
   699 	 * @param int|WP_Post $post_id       Post ID or WP_Post object.
   620 	 */
   700 	 */
   621 	return apply_filters( 'get_comments_link', $comments_link, $post_id );
   701 	return apply_filters( 'get_comments_link', $comments_link, $post_id );
   622 }
   702 }
   623 
   703 
   624 /**
   704 /**
   625  * Display the link to the current post comments.
   705  * Display the link to the current post comments.
   626  *
   706  *
   627  * @since 0.71
   707  * @since 0.71
   628  *
   708  *
   629  * @param string $deprecated   Not Used.
   709  * @param string $deprecated   Not Used.
   630  * @param bool   $deprecated_2 Not Used.
   710  * @param string $deprecated_2 Not Used.
   631  */
   711  */
   632 function comments_link( $deprecated = '', $deprecated_2 = '' ) {
   712 function comments_link( $deprecated = '', $deprecated_2 = '' ) {
   633 	if ( !empty( $deprecated ) )
   713 	if ( !empty( $deprecated ) )
   634 		_deprecated_argument( __FUNCTION__, '0.72' );
   714 		_deprecated_argument( __FUNCTION__, '0.72' );
   635 	if ( !empty( $deprecated_2 ) )
   715 	if ( !empty( $deprecated_2 ) )
   640 /**
   720 /**
   641  * Retrieve the amount of comments a post has.
   721  * Retrieve the amount of comments a post has.
   642  *
   722  *
   643  * @since 1.5.0
   723  * @since 1.5.0
   644  *
   724  *
   645  * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default current post.
   725  * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post.
   646  * @return int The number of comments a post has.
   726  * @return int The number of comments a post has.
   647  */
   727  */
   648 function get_comments_number( $post_id = 0 ) {
   728 function get_comments_number( $post_id = 0 ) {
   649 	$post_id = absint( $post_id );
   729 	$post = get_post( $post_id );
   650 
   730 
   651 	if ( !$post_id )
   731 	if ( ! $post ) {
   652 		$post_id = get_the_ID();
       
   653 
       
   654 	$post = get_post($post_id);
       
   655 	if ( ! isset($post->comment_count) )
       
   656 		$count = 0;
   732 		$count = 0;
   657 	else
   733 	} else {
   658 		$count = $post->comment_count;
   734 		$count = $post->comment_count;
       
   735 		$post_id = $post->ID;
       
   736 	}
   659 
   737 
   660 	/**
   738 	/**
   661 	 * Filter the returned comment count for a post.
   739 	 * Filter the returned comment count for a post.
   662 	 *
   740 	 *
   663 	 * @since 1.5.2
   741 	 * @since 1.5.0
   664 	 *
   742 	 *
   665 	 * @param int         $count   The number of comments a post has.
   743 	 * @param int $count   Number of comments a post has.
   666 	 * @param int|WP_Post $post_id The post ID or WP_Post object.
   744 	 * @param int $post_id Post ID.
   667 	 */
   745 	 */
   668 	return apply_filters( 'get_comments_number', $count, $post_id );
   746 	return apply_filters( 'get_comments_number', $count, $post_id );
   669 }
   747 }
   670 
   748 
   671 /**
   749 /**
   677  * @param string $one        Optional. Text for one comment. Default false.
   755  * @param string $one        Optional. Text for one comment. Default false.
   678  * @param string $more       Optional. Text for more than one comment. Default false.
   756  * @param string $more       Optional. Text for more than one comment. Default false.
   679  * @param string $deprecated Not used.
   757  * @param string $deprecated Not used.
   680  */
   758  */
   681 function comments_number( $zero = false, $one = false, $more = false, $deprecated = '' ) {
   759 function comments_number( $zero = false, $one = false, $more = false, $deprecated = '' ) {
   682 	if ( !empty( $deprecated ) )
   760 	if ( ! empty( $deprecated ) ) {
   683 		_deprecated_argument( __FUNCTION__, '1.3' );
   761 		_deprecated_argument( __FUNCTION__, '1.3' );
   684 
   762 	}
       
   763 	echo get_comments_number_text( $zero, $one, $more );
       
   764 }
       
   765 
       
   766 /**
       
   767  * Display the language string for the number of comments the current post has.
       
   768  *
       
   769  * @since 4.0.0
       
   770  *
       
   771  * @param string $zero Optional. Text for no comments. Default false.
       
   772  * @param string $one  Optional. Text for one comment. Default false.
       
   773  * @param string $more Optional. Text for more than one comment. Default false.
       
   774  */
       
   775 function get_comments_number_text( $zero = false, $one = false, $more = false ) {
   685 	$number = get_comments_number();
   776 	$number = get_comments_number();
   686 
   777 
   687 	if ( $number > 1 )
   778 	if ( $number > 1 ) {
   688 		$output = str_replace('%', number_format_i18n($number), ( false === $more ) ? __('% Comments') : $more);
   779 		$output = str_replace( '%', number_format_i18n( $number ), ( false === $more ) ? __( '% Comments' ) : $more );
   689 	elseif ( $number == 0 )
   780 	} elseif ( $number == 0 ) {
   690 		$output = ( false === $zero ) ? __('No Comments') : $zero;
   781 		$output = ( false === $zero ) ? __( 'No Comments' ) : $zero;
   691 	else // must be one
   782 	} else { // must be one
   692 		$output = ( false === $one ) ? __('1 Comment') : $one;
   783 		$output = ( false === $one ) ? __( '1 Comment' ) : $one;
   693 
   784 	}
   694 	/**
   785 	/**
   695 	 * Filter the comments count for display.
   786 	 * Filter the comments count for display.
   696 	 *
   787 	 *
   697 	 * @since 1.5.2
   788 	 * @since 1.5.0
   698 	 *
   789 	 *
   699 	 * @param string $output A translatable string formatted based on whether the count is equal to 0, 1, or 1+. @see _n()
   790 	 * @see _n()
       
   791 	 *
       
   792 	 * @param string $output A translatable string formatted based on whether the count
       
   793 	 *                       is equal to 0, 1, or 1+.
   700 	 * @param int    $number The number of post comments.
   794 	 * @param int    $number The number of post comments.
   701 	 */
   795 	 */
   702 	echo apply_filters( 'comments_number', $output, $number );
   796 	return apply_filters( 'comments_number', $output, $number );
   703 }
   797 }
   704 
   798 
   705 /**
   799 /**
   706  * Retrieve the text of the current comment.
   800  * Retrieve the text of the current comment.
   707  *
   801  *
   708  * @since 1.5.0
   802  * @since 1.5.0
   709  *
   803  *
   710  * @param int   $comment_ID Optional. The ID of the comment for which to get the text. Default current comment.
   804  * @see Walker_Comment::comment()
   711  * @param array $args       Optional. An array of arguments. @see Walker_Comment::comment()
   805  *
       
   806  * @param int   $comment_ID ID of the comment for which to get the text. Default current comment.
       
   807  * @param array $args       Optional. An array of arguments. Default empty.
   712  * @return string The comment content.
   808  * @return string The comment content.
   713  */
   809  */
   714 function get_comment_text( $comment_ID = 0, $args = array() ) {
   810 function get_comment_text( $comment_ID = 0, $args = array() ) {
   715 	$comment = get_comment( $comment_ID );
   811 	$comment = get_comment( $comment_ID );
   716 
   812 
   717 	/**
   813 	/**
   718 	 * Filter the text of a comment.
   814 	 * Filter the text of a comment.
   719 	 *
   815 	 *
   720 	 * @since 1.5.2
   816 	 * @since 1.5.0
   721 	 *
   817 	 *
   722 	 * @param string $comment->comment_content The text of the comment.
   818 	 * @see Walker_Comment::comment()
   723 	 * @param object $comment                  The comment object.
   819 	 *
   724 	 * @param array  $args                     An array of arguments. @see Walker_Comment::comment()
   820 	 * @param string $comment_content Text of the comment.
       
   821 	 * @param object $comment         The comment object.
       
   822 	 * @param array  $args            An array of arguments.
   725 	 */
   823 	 */
   726 	return apply_filters( 'get_comment_text', $comment->comment_content, $comment, $args );
   824 	return apply_filters( 'get_comment_text', $comment->comment_content, $comment, $args );
   727 }
   825 }
   728 
   826 
   729 /**
   827 /**
   730  * Display the text of the current comment.
   828  * Display the text of the current comment.
   731  *
   829  *
   732  * @since 0.71
   830  * @since 0.71
   733  *
   831  *
   734  * @param int   $comment_ID Optional. The ID of the comment for which to print the text.
   832  * @see Walker_Comment::comment()
   735  *                          Default 0.
   833  *
   736  * @param array $args       Optional. An array of arguments. @see Walker_Comment::comment()
   834  * @param int   $comment_ID ID of the comment for which to print the text. Default 0.
   737  *                          Default empty array.
   835  * @param array $args       Optional. An array of arguments. Default empty array. Default empty.
   738  */
   836  */
   739 function comment_text( $comment_ID = 0, $args = array() ) {
   837 function comment_text( $comment_ID = 0, $args = array() ) {
   740 	$comment = get_comment( $comment_ID );
   838 	$comment = get_comment( $comment_ID );
   741 
   839 
   742 	$comment_text = get_comment_text( $comment_ID , $args );
   840 	$comment_text = get_comment_text( $comment_ID , $args );
   743 	/**
   841 	/**
   744 	 * Filter the text of a comment to be displayed.
   842 	 * Filter the text of a comment to be displayed.
   745 	 *
   843 	 *
   746 	 * @since 1.2.1
   844 	 * @since 1.2.0
   747 	 *
   845 	 *
   748 	 * @param string $comment_text The text of the current comment.
   846 	 * @see Walker_Comment::comment()
       
   847 	 *
       
   848 	 * @param string $comment_text Text of the current comment.
   749 	 * @param object $comment      The comment object.
   849 	 * @param object $comment      The comment object.
   750 	 * @param array  $args         An array of arguments. @see Walker_Comment::comment()
   850 	 * @param array  $args         An array of arguments.
   751 	 */
   851 	 */
   752 	echo apply_filters( 'comment_text', $comment_text, $comment, $args );
   852 	echo apply_filters( 'comment_text', $comment_text, $comment, $args );
   753 }
   853 }
   754 
   854 
   755 /**
   855 /**
   757  *
   857  *
   758  * @since 1.5.0
   858  * @since 1.5.0
   759  *
   859  *
   760  * @param string $d         Optional. The format of the time. Default user's settings.
   860  * @param string $d         Optional. The format of the time. Default user's settings.
   761  * @param bool   $gmt       Optional. Whether to use the GMT date. Default false.
   861  * @param bool   $gmt       Optional. Whether to use the GMT date. Default false.
   762  * @param bool   $translate Optional. Whether to translate the time (for use in feeds). Default true.
   862  * @param bool   $translate Optional. Whether to translate the time (for use in feeds).
   763  * @return string The formatted time
   863  *                          Default true.
       
   864  * @return string The formatted time.
   764  */
   865  */
   765 function get_comment_time( $d = '', $gmt = false, $translate = true ) {
   866 function get_comment_time( $d = '', $gmt = false, $translate = true ) {
   766 	global $comment;
   867 	global $comment;
   767 	$comment_date = $gmt ? $comment->comment_date_gmt : $comment->comment_date;
   868 	$comment_date = $gmt ? $comment->comment_date_gmt : $comment->comment_date;
   768 	if ( '' == $d )
   869 	if ( '' == $d )
   771 		$date = mysql2date($d, $comment_date, $translate);
   872 		$date = mysql2date($d, $comment_date, $translate);
   772 
   873 
   773 	/**
   874 	/**
   774 	 * Filter the returned comment time.
   875 	 * Filter the returned comment time.
   775 	 *
   876 	 *
   776 	 * @since 1.5.2
   877 	 * @since 1.5.0
   777 	 *
   878 	 *
   778 	 * @param string|int $date      The comment time, formatted as a date string or Unix timestamp.
   879 	 * @param string|int $date      The comment time, formatted as a date string or Unix timestamp.
   779 	 * @param string     $d         The date format.
   880 	 * @param string     $d         Date format.
   780 	 * @param bool       $gmt       Whether the GMT date is in use.
   881 	 * @param bool       $gmt       Whether the GMT date is in use.
   781 	 * @param bool       $translate Whether the time is translated.
   882 	 * @param bool       $translate Whether the time is translated.
   782 	 */
   883 	 * @param object     $comment   The comment object.
   783 	return apply_filters( 'get_comment_time', $date, $d, $gmt, $translate );
   884 	 */
       
   885 	return apply_filters( 'get_comment_time', $date, $d, $gmt, $translate, $comment );
   784 }
   886 }
   785 
   887 
   786 /**
   888 /**
   787  * Display the comment time of the current comment.
   889  * Display the comment time of the current comment.
   788  *
   890  *
   797 /**
   899 /**
   798  * Retrieve the comment type of the current comment.
   900  * Retrieve the comment type of the current comment.
   799  *
   901  *
   800  * @since 1.5.0
   902  * @since 1.5.0
   801  *
   903  *
   802  * @param int $comment_ID Optional. The ID of the comment for which to get the type. Default current comment.
   904  * @param int $comment_ID ID of the comment for which to get the type. Default current comment.
   803  * @return string The comment type
   905  * @return string The comment type.
   804  */
   906  */
   805 function get_comment_type( $comment_ID = 0 ) {
   907 function get_comment_type( $comment_ID = 0 ) {
   806 	$comment = get_comment( $comment_ID );
   908 	$comment = get_comment( $comment_ID );
   807 	if ( '' == $comment->comment_type )
   909 	if ( '' == $comment->comment_type )
   808 		$comment->comment_type = 'comment';
   910 		$comment->comment_type = 'comment';
   809 
   911 
   810 	/**
   912 	/**
   811 	 * Filter the returned comment type.
   913 	 * Filter the returned comment type.
   812 	 *
   914 	 *
   813 	 * @since 1.5.2
   915 	 * @since 1.5.0
   814 	 *
   916 	 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added.
   815 	 * @param string $comment->comment_type The type of comment, such as 'comment', 'pingback', or 'trackback'.
   917 	 *
   816 	 */
   918 	 * @param string $comment_type The type of comment, such as 'comment', 'pingback', or 'trackback'.
   817 	return apply_filters( 'get_comment_type', $comment->comment_type );
   919 	 * @param int 	 $comment_ID   The comment ID.
       
   920 	 * @param object $comment      The comment object.
       
   921 	 */
       
   922 	return apply_filters( 'get_comment_type', $comment->comment_type, $comment_ID, $comment );
   818 }
   923 }
   819 
   924 
   820 /**
   925 /**
   821  * Display the comment type of the current comment.
   926  * Display the comment type of the current comment.
   822  *
   927  *
   823  * @since 0.71
   928  * @since 0.71
   824  *
   929  *
   825  * @param string $commenttxt   Optional. The string to display for comment type. Default false.
   930  * @param string $commenttxt   Optional. String to display for comment type. Default false.
   826  * @param string $trackbacktxt Optional. The string to display for trackback type. Default false.
   931  * @param string $trackbacktxt Optional. String to display for trackback type. Default false.
   827  * @param string $pingbacktxt  Optional. The string to display for pingback type. Default false.
   932  * @param string $pingbacktxt  Optional. String to display for pingback type. Default false.
   828  */
   933  */
   829 function comment_type( $commenttxt = false, $trackbacktxt = false, $pingbacktxt = false ) {
   934 function comment_type( $commenttxt = false, $trackbacktxt = false, $pingbacktxt = false ) {
   830 	if ( false === $commenttxt ) $commenttxt = _x( 'Comment', 'noun' );
   935 	if ( false === $commenttxt ) $commenttxt = _x( 'Comment', 'noun' );
   831 	if ( false === $trackbacktxt ) $trackbacktxt = __( 'Trackback' );
   936 	if ( false === $trackbacktxt ) $trackbacktxt = __( 'Trackback' );
   832 	if ( false === $pingbacktxt ) $pingbacktxt = __( 'Pingback' );
   937 	if ( false === $pingbacktxt ) $pingbacktxt = __( 'Pingback' );
   874  * Display the current post's trackback URL.
   979  * Display the current post's trackback URL.
   875  *
   980  *
   876  * @since 0.71
   981  * @since 0.71
   877  *
   982  *
   878  * @param bool $deprecated_echo Not used.
   983  * @param bool $deprecated_echo Not used.
   879  * @return void|string Should only be used to echo the trackback URL, use get_trackback_url() for the result instead.
   984  * @return void|string Should only be used to echo the trackback URL, use get_trackback_url()
       
   985  *                     for the result instead.
   880  */
   986  */
   881 function trackback_url( $deprecated_echo = true ) {
   987 function trackback_url( $deprecated_echo = true ) {
   882 	if ( $deprecated_echo !== true )
   988 	if ( $deprecated_echo !== true )
   883 		_deprecated_argument( __FUNCTION__, '2.5', __('Use <code>get_trackback_url()</code> instead if you do not want the value echoed.') );
   989 		_deprecated_argument( __FUNCTION__, '2.5', __('Use <code>get_trackback_url()</code> instead if you do not want the value echoed.') );
   884 	if ( $deprecated_echo )
   990 	if ( $deprecated_echo )
   895  * @since 0.71
  1001  * @since 0.71
   896  *
  1002  *
   897  * @param int $deprecated Not used (Was $timezone = 0).
  1003  * @param int $deprecated Not used (Was $timezone = 0).
   898  */
  1004  */
   899 function trackback_rdf( $deprecated = '' ) {
  1005 function trackback_rdf( $deprecated = '' ) {
   900 	if ( !empty( $deprecated ) )
  1006 	if ( ! empty( $deprecated ) ) {
   901 		_deprecated_argument( __FUNCTION__, '2.5' );
  1007 		_deprecated_argument( __FUNCTION__, '2.5' );
   902 
  1008 	}
   903 	if ( false !== stripos($_SERVER['HTTP_USER_AGENT'], 'W3C_Validator') )
  1009 
       
  1010 	if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && false !== stripos( $_SERVER['HTTP_USER_AGENT'], 'W3C_Validator' ) ) {
   904 		return;
  1011 		return;
       
  1012 	}
   905 
  1013 
   906 	echo '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  1014 	echo '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   907 			xmlns:dc="http://purl.org/dc/elements/1.1/"
  1015 			xmlns:dc="http://purl.org/dc/elements/1.1/"
   908 			xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  1016 			xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
   909 		<rdf:Description rdf:about="';
  1017 		<rdf:Description rdf:about="';
   920 /**
  1028 /**
   921  * Whether the current post is open for comments.
  1029  * Whether the current post is open for comments.
   922  *
  1030  *
   923  * @since 1.5.0
  1031  * @since 1.5.0
   924  *
  1032  *
   925  * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default current post.
  1033  * @param int|WP_Post $post_id Post ID or WP_Post object. Default current post.
   926  * @return bool True if the comments are open.
  1034  * @return bool True if the comments are open.
   927  */
  1035  */
   928 function comments_open( $post_id = null ) {
  1036 function comments_open( $post_id = null ) {
   929 
  1037 
   930 	$_post = get_post($post_id);
  1038 	$_post = get_post($post_id);
   932 	$open = ( 'open' == $_post->comment_status );
  1040 	$open = ( 'open' == $_post->comment_status );
   933 
  1041 
   934 	/**
  1042 	/**
   935 	 * Filter whether the current post is open for comments.
  1043 	 * Filter whether the current post is open for comments.
   936 	 *
  1044 	 *
   937 	 * @since
  1045 	 * @since 2.5.0
   938 	 *
  1046 	 *
   939 	 * @param bool        $open    Whether the current post is open for comments.
  1047 	 * @param bool        $open    Whether the current post is open for comments.
   940 	 * @param int|WP_Post $post_id The post ID or WP_Post object.
  1048 	 * @param int|WP_Post $post_id The post ID or WP_Post object.
   941 	 */
  1049 	 */
   942 	return apply_filters( 'comments_open', $open, $post_id );
  1050 	return apply_filters( 'comments_open', $open, $post_id );
   945 /**
  1053 /**
   946  * Whether the current post is open for pings.
  1054  * Whether the current post is open for pings.
   947  *
  1055  *
   948  * @since 1.5.0
  1056  * @since 1.5.0
   949  *
  1057  *
   950  * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default current post.
  1058  * @param int|WP_Post $post_id Post ID or WP_Post object. Default current post.
   951  * @return bool True if pings are accepted
  1059  * @return bool True if pings are accepted
   952  */
  1060  */
   953 function pings_open( $post_id = null ) {
  1061 function pings_open( $post_id = null ) {
   954 
  1062 
   955 	$_post = get_post($post_id);
  1063 	$_post = get_post($post_id);
   956 
  1064 
   957 	$open = ( 'open' == $_post->ping_status );
  1065 	$open = ( 'open' == $_post->ping_status );
       
  1066 
       
  1067 	/**
       
  1068 	 * Filter whether the current post is open for pings.
       
  1069 	 *
       
  1070 	 * @since 2.5.0
       
  1071 	 *
       
  1072 	 * @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.
       
  1074 	 */
   958 	return apply_filters( 'pings_open', $open, $post_id );
  1075 	return apply_filters( 'pings_open', $open, $post_id );
   959 }
  1076 }
   960 
  1077 
   961 /**
  1078 /**
   962  * Display form token for unfiltered comments.
  1079  * Display form token for unfiltered comments.
  1002  * @uses $withcomments 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.
  1003  *
  1120  *
  1004  * @since 1.5.0
  1121  * @since 1.5.0
  1005  *
  1122  *
  1006  * @param string $file              Optional. The file to load. Default '/comments.php'.
  1123  * @param string $file              Optional. The file to load. Default '/comments.php'.
  1007  * @param bool   $separate_comments Optional. Whether to separate the comments by comment type. Default false.
  1124  * @param bool   $separate_comments Optional. Whether to separate the comments by comment type.
       
  1125  *                                  Default false.
  1008  * @return null Returns null if no comments appear.
  1126  * @return null Returns null if no comments appear.
  1009  */
  1127  */
  1010 function comments_template( $file = '/comments.php', $separate_comments = false ) {
  1128 function comments_template( $file = '/comments.php', $separate_comments = false ) {
  1011 	global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity, $overridden_cpage;
  1129 	global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity, $overridden_cpage;
  1012 
  1130 
  1016 	if ( empty($file) )
  1134 	if ( empty($file) )
  1017 		$file = '/comments.php';
  1135 		$file = '/comments.php';
  1018 
  1136 
  1019 	$req = get_option('require_name_email');
  1137 	$req = get_option('require_name_email');
  1020 
  1138 
  1021 	/**
  1139 	/*
  1022 	 * Comment author information fetched from the comment cookies.
  1140 	 * Comment author information fetched from the comment cookies.
  1023 	 *
       
  1024 	 * @uses wp_get_current_commenter()
       
  1025 	 */
  1141 	 */
  1026 	$commenter = wp_get_current_commenter();
  1142 	$commenter = wp_get_current_commenter();
  1027 
  1143 
  1028 	/**
  1144 	/*
  1029 	 * The name of the current comment author escaped for use in attributes.
  1145 	 * The name of the current comment author escaped for use in attributes.
  1030 	 */
  1146 	 * Escaped by sanitize_comment_cookies().
  1031 	$comment_author = $commenter['comment_author']; // Escaped by sanitize_comment_cookies()
  1147 	 */
  1032 
  1148 	$comment_author = $commenter['comment_author'];
  1033 	/**
  1149 
       
  1150 	/*
  1034 	 * The email address of the current comment author escaped for use in attributes.
  1151 	 * The email address of the current comment author escaped for use in attributes.
  1035 	 */
  1152 	 * Escaped by sanitize_comment_cookies().
  1036 	$comment_author_email = $commenter['comment_author_email'];  // Escaped by sanitize_comment_cookies()
  1153 	 */
  1037 
  1154 	$comment_author_email = $commenter['comment_author_email'];
  1038 	/**
  1155 
       
  1156 	/*
  1039 	 * The url of the current comment author escaped for use in attributes.
  1157 	 * The url of the current comment author escaped for use in attributes.
  1040 	 */
  1158 	 */
  1041 	$comment_author_url = esc_url($commenter['comment_author_url']);
  1159 	$comment_author_url = esc_url($commenter['comment_author_url']);
  1042 
  1160 
  1043 	/** @todo Use API instead of SELECTs. */
  1161 	$comment_args = array(
  1044 	if ( $user_ID) {
  1162 		'order'   => 'ASC',
  1045 		$comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND (comment_approved = '1' OR ( user_id = %d AND comment_approved = '0' ) )  ORDER BY comment_date_gmt", $post->ID, $user_ID));
  1163 		'orderby' => 'comment_date_gmt',
  1046 	} else if ( empty($comment_author) ) {
  1164 		'status'  => 'approve',
  1047 		$comments = get_comments( array('post_id' => $post->ID, 'status' => 'approve', 'order' => 'ASC') );
  1165 		'post_id' => $post->ID,
  1048 	} else {
  1166 	);
  1049 		$comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND ( comment_approved = '1' OR ( comment_author = %s AND comment_author_email = %s AND comment_approved = '0' ) ) ORDER BY comment_date_gmt", $post->ID, wp_specialchars_decode($comment_author,ENT_QUOTES), $comment_author_email));
  1167 
  1050 	}
  1168 	if ( $user_ID ) {
  1051 
  1169 		$comment_args['include_unapproved'] = array( $user_ID );
  1052 	// keep $comments for legacy's sake
  1170 	} elseif ( ! empty( $comment_author_email ) ) {
       
  1171 		$comment_args['include_unapproved'] = array( $comment_author_email );
       
  1172 	}
       
  1173 
       
  1174 	$comments = get_comments( $comment_args );
       
  1175 
  1053 	/**
  1176 	/**
  1054 	 * Filter the comments array.
  1177 	 * Filter the comments array.
  1055 	 *
  1178 	 *
  1056 	 * @since 2.1.0
  1179 	 * @since 2.1.0
  1057 	 *
  1180 	 *
  1058 	 * @param array $comments The array of comments supplied to the comments template.
  1181 	 * @param array $comments Array of comments supplied to the comments template.
  1059 	 * @param int   $post->ID The post ID.
  1182 	 * @param int   $post_ID  Post ID.
  1060 	 */
  1183 	 */
  1061 	$wp_query->comments = apply_filters( 'comments_array', $comments, $post->ID );
  1184 	$wp_query->comments = apply_filters( 'comments_array', $comments, $post->ID );
  1062 	$comments = &$wp_query->comments;
  1185 	$comments = &$wp_query->comments;
  1063 	$wp_query->comment_count = count($wp_query->comments);
  1186 	$wp_query->comment_count = count($wp_query->comments);
  1064 	update_comment_cache($wp_query->comments);
  1187 	update_comment_cache($wp_query->comments);
  1079 
  1202 
  1080 	$theme_template = STYLESHEETPATH . $file;
  1203 	$theme_template = STYLESHEETPATH . $file;
  1081 	/**
  1204 	/**
  1082 	 * Filter the path to the theme template file used for the comments template.
  1205 	 * Filter the path to the theme template file used for the comments template.
  1083 	 *
  1206 	 *
  1084 	 * @since 1.5.2
  1207 	 * @since 1.5.1
  1085 	 *
  1208 	 *
  1086 	 * @param string $theme_template The path to the theme template file.
  1209 	 * @param string $theme_template The path to the theme template file.
  1087 	 */
  1210 	 */
  1088 	$include = apply_filters( 'comments_template', $theme_template );
  1211 	$include = apply_filters( 'comments_template', $theme_template );
  1089 	if ( file_exists( $include ) )
  1212 	if ( file_exists( $include ) )
  1127 }
  1250 }
  1128 
  1251 
  1129 /**
  1252 /**
  1130  * Displays the link to the comments popup window for the current post ID.
  1253  * Displays the link to the comments popup window for the current post ID.
  1131  *
  1254  *
  1132  * Is not meant to be displayed on single posts and pages. Should be used on the
  1255  * Is not meant to be displayed on single posts and pages. Should be used
  1133  * lists of posts
  1256  * on the lists of posts
  1134  *
  1257  *
  1135  * @global string $wpcommentspopupfile  The URL to use for the popup window.
  1258  * @global string $wpcommentspopupfile  The URL to use for the popup window.
  1136  * @global int    $wpcommentsjavascript Whether to use JavaScript. Set when function is called.
  1259  * @global int    $wpcommentsjavascript Whether to use JavaScript. Set when function is called.
  1137  *
  1260  *
  1138  * @since 0.71
  1261  * @since 0.71
  1139  *
  1262  *
  1140  * @param string $zero      Optional. The string to display when no comments. Default false.
  1263  * @param string $zero      Optional. String to display when no comments. Default false.
  1141  * @param string $one       Optional. The string to display when only one comment is available. Default false.
  1264  * @param string $one       Optional. String to display when only one comment is available.
  1142  * @param string $more      Optional. The string to display when there are more than one comment. Default false.
  1265  *                          Default false.
  1143  * @param string $css_class Optional. The CSS class to use for comments. Default empty.
  1266  * @param string $more      Optional. String to display when there are more than one comment.
  1144  * @param string $none      Optional. The string to display when comments have been turned off. Default false.
  1267  *                          Default false.
       
  1268  * @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.
       
  1270  *                          Default false.
  1145  * @return null Returns null on single posts and pages.
  1271  * @return null Returns null on single posts and pages.
  1146  */
  1272  */
  1147 function comments_popup_link( $zero = false, $one = false, $more = false, $css_class = '', $none = false ) {
  1273 function comments_popup_link( $zero = false, $one = false, $more = false, $css_class = '', $none = false ) {
  1148 	global $wpcommentspopupfile, $wpcommentsjavascript;
  1274 	global $wpcommentspopupfile, $wpcommentsjavascript;
  1149 
  1275 
  1150 	$id = get_the_ID();
  1276 	$id = get_the_ID();
  1151 
  1277 	$title = get_the_title();
  1152 	if ( false === $zero ) $zero = __( 'No Comments' );
       
  1153 	if ( false === $one ) $one = __( '1 Comment' );
       
  1154 	if ( false === $more ) $more = __( '% Comments' );
       
  1155 	if ( false === $none ) $none = __( 'Comments Off' );
       
  1156 
       
  1157 	$number = get_comments_number( $id );
  1278 	$number = get_comments_number( $id );
       
  1279 
       
  1280 	if ( false === $zero ) {
       
  1281 		/* translators: %s: post title */
       
  1282 		$zero = sprintf( __( 'No Comments<span class="screen-reader-text"> on %s</span>' ), $title );
       
  1283 	}
       
  1284 
       
  1285 	if ( false === $one ) {
       
  1286 		/* translators: %s: post title */
       
  1287 		$one = sprintf( __( '1 Comment<span class="screen-reader-text"> on %s</span>' ), $title );
       
  1288 	}
       
  1289 
       
  1290 	if ( false === $more ) {
       
  1291 		/* translators: 1: Number of comments 2: post title */
       
  1292 		$more = _n( '%1$s Comment<span class="screen-reader-text"> on %2$s</span>', '%1$s Comments<span class="screen-reader-text"> on %2$s</span>', $number );
       
  1293 		$more = sprintf( $more, number_format_i18n( $number ), $title );
       
  1294 	}
       
  1295 
       
  1296 	if ( false === $none ) {
       
  1297 		/* translators: %s: post title */
       
  1298 		$none = sprintf( __( 'Comments Off<span class="screen-reader-text"> on %s</span>' ), $title );
       
  1299 	}
  1158 
  1300 
  1159 	if ( 0 == $number && !comments_open() && !pings_open() ) {
  1301 	if ( 0 == $number && !comments_open() && !pings_open() ) {
  1160 		echo '<span' . ((!empty($css_class)) ? ' class="' . esc_attr( $css_class ) . '"' : '') . '>' . $none . '</span>';
  1302 		echo '<span' . ((!empty($css_class)) ? ' class="' . esc_attr( $css_class ) . '"' : '') . '>' . $none . '</span>';
  1161 		return;
  1303 		return;
  1162 	}
  1304 	}
  1183 	}
  1325 	}
  1184 
  1326 
  1185 	if ( !empty( $css_class ) ) {
  1327 	if ( !empty( $css_class ) ) {
  1186 		echo ' class="'.$css_class.'" ';
  1328 		echo ' class="'.$css_class.'" ';
  1187 	}
  1329 	}
  1188 	$title = the_title_attribute( array('echo' => 0 ) );
       
  1189 
  1330 
  1190 	$attributes = '';
  1331 	$attributes = '';
  1191 	/**
  1332 	/**
  1192 	 * Filter the comments popup link attributes for display.
  1333 	 * Filter the comments popup link attributes for display.
  1193 	 *
  1334 	 *
  1195 	 *
  1336 	 *
  1196 	 * @param string $attributes The comments popup link attributes. Default empty.
  1337 	 * @param string $attributes The comments popup link attributes. Default empty.
  1197 	 */
  1338 	 */
  1198 	echo apply_filters( 'comments_popup_link_attributes', $attributes );
  1339 	echo apply_filters( 'comments_popup_link_attributes', $attributes );
  1199 
  1340 
  1200 	echo ' title="' . esc_attr( sprintf( __('Comment on %s'), $title ) ) . '">';
  1341 	echo '>';
  1201 	comments_number( $zero, $one, $more );
  1342 	comments_number( $zero, $one, $more );
  1202 	echo '</a>';
  1343 	echo '</a>';
  1203 }
  1344 }
  1204 
  1345 
  1205 /**
  1346 /**
  1208  * @since 2.7.0
  1349  * @since 2.7.0
  1209  *
  1350  *
  1210  * @param array $args {
  1351  * @param array $args {
  1211  *     Optional. Override default arguments.
  1352  *     Optional. Override default arguments.
  1212  *
  1353  *
  1213  *     @type string 'add_below'  The first part of the selector used to identify the comment to respond below. The resulting
  1354  *     @type string $add_below  The first part of the selector used to identify the comment to respond below.
  1214  *                               value is passed as the first parameter to addComment.moveForm(), concatenated
  1355  *                              The resulting value is passed as the first parameter to addComment.moveForm(),
  1215  *                               as $add_below-$comment->comment_ID. Default 'comment'.
  1356  *                              concatenated as $add_below-$comment->comment_ID. Default 'comment'.
  1216  *     @type string 'respond_id' The selector identifying the responding comment. Passed as the third parameter to addComment.moveForm(),
  1357  *     @type string $respond_id The selector identifying the responding comment. Passed as the third parameter
  1217  *                               and appended to the link URL as a hash value. Default 'respond'.
  1358  *                              to addComment.moveForm(), and appended to the link URL as a hash value.
  1218  *     @type string 'reply_text' The text of the Reply link. Default 'Reply'.
  1359  *                              Default 'respond'.
  1219  *     @type string 'login_text' The text of the link to reply if logged out. Default 'Log in to Reply'.
  1360  *     @type string $reply_text The text of the Reply link. Default 'Reply'.
  1220  *     @type int    'depth'      The depth of the new comment. Must be greater than 0 and less than the value of the 'thread_comments_depth'
  1361  *     @type string $login_text The text of the link to reply if logged out. Default 'Log in to Reply'.
  1221  *                               option set in Settings > Discussion.
  1362  *     @type int    $depth'     The depth of the new comment. Must be greater than 0 and less than the value
  1222  *                               Default 0.
  1363  *                              of the 'thread_comments_depth' option set in Settings > Discussion. Default 0.
  1223  *     @type string 'before'     The text or HTML to add before the reply link. Default empty.
  1364  *     @type string $before     The text or HTML to add before the reply link. Default empty.
  1224  *     @type string 'after'      The text or HTML to add after the reply link. Default empty.
  1365  *     @type string $after      The text or HTML to add after the reply link. Default empty.
  1225  * }
  1366  * }
  1226  * @param int         $comment Optional. Comment being replied to. Default current comment.
  1367  * @param int         $comment Comment being replied to. Default current comment.
  1227  * @param int|WP_Post $post    Optional. Post ID or WP_Post object the comment is going to be displayed on. Default current post.
  1368  * @param int|WP_Post $post    Post ID or WP_Post object the comment is going to be displayed on.
  1228  * @return mixed Link to show comment form, if successful. False, if comments are closed.
  1369  *                             Default current post.
  1229  */
  1370  * @return null|false|string Link to show comment form, if successful. False, if comments are closed.
  1230 function get_comment_reply_link($args = array(), $comment = null, $post = null) {
  1371  */
       
  1372 function get_comment_reply_link( $args = array(), $comment = null, $post = null ) {
  1231 
  1373 
  1232 	$defaults = array(
  1374 	$defaults = array(
  1233 		'add_below'  => 'comment',
  1375 		'add_below'     => 'comment',
  1234 		'respond_id' => 'respond',
  1376 		'respond_id'    => 'respond',
  1235 		'reply_text' => __('Reply'),
  1377 		'reply_text'    => __( 'Reply' ),
  1236 		'login_text' => __('Log in to Reply'),
  1378 		'reply_to_text' => __( 'Reply to %s' ),
  1237 		'depth'      => 0,
  1379 		'login_text'    => __( 'Log in to Reply' ),
  1238 		'before'     => '',
  1380 		'depth'         => 0,
  1239 		'after'      => ''
  1381 		'before'        => '',
       
  1382 		'after'         => ''
  1240 	);
  1383 	);
  1241 
  1384 
  1242 	$args = wp_parse_args($args, $defaults);
  1385 	$args = wp_parse_args( $args, $defaults );
  1243 
  1386 
  1244 	if ( 0 == $args['depth'] || $args['max_depth'] <= $args['depth'] )
  1387 	if ( 0 == $args['depth'] || $args['max_depth'] <= $args['depth'] ) {
  1245 		return;
  1388 		return;
  1246 
  1389 	}
  1247 	extract($args, EXTR_SKIP);
  1390 
  1248 
  1391 	$comment = get_comment( $comment );
  1249 	$comment = get_comment($comment);
  1392 
  1250 	if ( empty($post) )
  1393 	if ( empty( $post ) ) {
  1251 		$post = $comment->comment_post_ID;
  1394 		$post = $comment->comment_post_ID;
  1252 	$post = get_post($post);
  1395 	}
  1253 
  1396 
  1254 	if ( !comments_open($post->ID) )
  1397 	$post = get_post( $post );
       
  1398 
       
  1399 	if ( ! comments_open( $post->ID ) ) {
  1255 		return false;
  1400 		return false;
  1256 
  1401 	}
  1257 	$link = '';
  1402 
  1258 
  1403 	/**
  1259 	if ( get_option('comment_registration') && ! is_user_logged_in() )
  1404 	 * Filter the comment reply link arguments.
  1260 		$link = '<a rel="nofollow" class="comment-reply-login" href="' . esc_url( wp_login_url( get_permalink() ) ) . '">' . $login_text . '</a>';
  1405 	 *
  1261 	else
  1406 	 * @since 4.1.0
  1262 		$link = "<a class='comment-reply-link' href='" . esc_url( add_query_arg( 'replytocom', $comment->comment_ID ) ) . "#" . $respond_id . "' onclick='return addComment.moveForm(\"$add_below-$comment->comment_ID\", \"$comment->comment_ID\", \"$respond_id\", \"$post->ID\")'>$reply_text</a>";
  1407 	 *
  1263 
  1408 	 * @param array   $args    Comment reply link arguments. See {@see get_comment_reply_link()}
       
  1409 	 *                         for more information on accepted arguments.
       
  1410 	 * @param object  $comment The object of the comment being replied to.
       
  1411 	 * @param WP_Post $post    The {@see WP_Post} object.
       
  1412 	 */
       
  1413 	$args = apply_filters( 'comment_reply_link_args', $args, $comment, $post );
       
  1414 
       
  1415 	if ( get_option( 'comment_registration' ) && ! is_user_logged_in() ) {
       
  1416 		$link = sprintf( '<a rel="nofollow" class="comment-reply-login" href="%s">%s</a>',
       
  1417 			esc_url( wp_login_url( get_permalink() ) ),
       
  1418 			$args['login_text']
       
  1419 		);
       
  1420 	} else {
       
  1421 		$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
       
  1423 		);
       
  1424 
       
  1425 		$link = sprintf( "<a 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'],
       
  1427 			$onclick,
       
  1428 			esc_attr( sprintf( $args['reply_to_text'], $comment->comment_author ) ),
       
  1429 			$args['reply_text']
       
  1430 		);
       
  1431 	}
  1264 	/**
  1432 	/**
  1265 	 * Filter the comment reply link.
  1433 	 * Filter the comment reply link.
  1266 	 *
  1434 	 *
  1267 	 * @since 2.7.0
  1435 	 * @since 2.7.0
  1268 	 *
  1436 	 *
  1269 	 * @param string  $before  Text or HTML displayed before the reply link.
       
  1270 	 * @param string  $link    The HTML markup for the comment reply link.
  1437 	 * @param string  $link    The HTML markup for the comment reply link.
  1271 	 * @param string  $after   Text or HTML displayed after the reply link.
       
  1272 	 * @param array   $args    An array of arguments overriding the defaults.
  1438 	 * @param array   $args    An array of arguments overriding the defaults.
  1273 	 * @param object  $comment The object of the comment being replied.
  1439 	 * @param object  $comment The object of the comment being replied.
  1274 	 * @param WP_Post $post    The WP_Post object.
  1440 	 * @param WP_Post $post    The WP_Post object.
  1275 	 */
  1441 	 */
  1276 	return apply_filters( 'comment_reply_link', $before . $link . $after, $args, $comment, $post );
  1442 	return apply_filters( 'comment_reply_link', $args['before'] . $link . $args['after'], $args, $comment, $post );
  1277 }
  1443 }
  1278 
  1444 
  1279 /**
  1445 /**
  1280  * Displays the HTML content for reply to comment link.
  1446  * Displays the HTML content for reply to comment link.
  1281  *
  1447  *
  1282  * @since 2.7.0
  1448  * @since 2.7.0
  1283  *
  1449  *
  1284  * @param array       $args    Optional. Override default options, @see get_comment_reply_link()
  1450  * @see get_comment_reply_link()
  1285  * @param int         $comment Optional. Comment being replied to. Default current comment.
  1451  *
  1286  * @param int|WP_Post $post    Optional. Post ID or WP_Post object the comment is going to be displayed on. Default current post.
  1452  * @param array       $args    Optional. Override default options.
       
  1453  * @param int         $comment Comment being replied to. Default current comment.
       
  1454  * @param int|WP_Post $post    Post ID or WP_Post object the comment is going to be displayed on.
       
  1455  *                             Default current post.
  1287  * @return mixed Link to show comment form, if successful. False, if comments are closed.
  1456  * @return mixed Link to show comment form, if successful. False, if comments are closed.
  1288  */
  1457  */
  1289 function comment_reply_link($args = array(), $comment = null, $post = null) {
  1458 function comment_reply_link($args = array(), $comment = null, $post = null) {
  1290 	echo get_comment_reply_link($args, $comment, $post);
  1459 	echo get_comment_reply_link($args, $comment, $post);
  1291 }
  1460 }
  1296  * @since 2.7.0
  1465  * @since 2.7.0
  1297  *
  1466  *
  1298  * @param array $args {
  1467  * @param array $args {
  1299  *     Optional. Override default arguments.
  1468  *     Optional. Override default arguments.
  1300  *
  1469  *
  1301  *     @type string 'add_below'  The first part of the selector used to identify the comment to respond below.
  1470  *     @type string $add_below  The first part of the selector used to identify the comment to respond below.
  1302  *                               The resulting value is passed as the first parameter to addComment.moveForm(),
  1471  *                              The resulting value is passed as the first parameter to addComment.moveForm(),
  1303  *                               concatenated as $add_below-$comment->comment_ID. Default is 'post'.
  1472  *                              concatenated as $add_below-$comment->comment_ID. Default is 'post'.
  1304  *     @type string 'respond_id' The selector identifying the responding comment. Passed as the third parameter
  1473  *     @type string $respond_id The selector identifying the responding comment. Passed as the third parameter
  1305  *                               to addComment.moveForm(), and appended to the link URL as a hash value. Default is 'respond'.
  1474  *                              to addComment.moveForm(), and appended to the link URL as a hash value.
  1306  *     @type string 'reply_text' The text of the Reply link. Default is 'Leave a Comment'.
  1475  *                              Default 'respond'.
  1307  *     @type string 'login_text' The text of the link to reply if logged out. Default is 'Log in to leave a Comment'.
  1476  *     @type string $reply_text Text of the Reply link. Default is 'Leave a Comment'.
  1308  *     @type string 'before'     The text or HTML to add before the reply link. Default empty.
  1477  *     @type string $login_text Text of the link to reply if logged out. Default is 'Log in to leave a Comment'.
  1309  *     @type string 'after'      The text or HTML to add after the reply link. Default empty.
  1478  *     @type string $before     Text or HTML to add before the reply link. Default empty.
       
  1479  *     @type string $after      Text or HTML to add after the reply link. Default empty.
  1310  * }
  1480  * }
  1311  * @param int|WP_Post $post    Optional. Post ID or WP_Post object the comment is going to be displayed on. Default current post.
  1481  * @param int|WP_Post $post    Optional. Post ID or WP_Post object the comment is going to be displayed on.
  1312  * @return string|bool|null Link to show comment form, if successful. False, if comments are closed.
  1482  *                             Default current post.
       
  1483  * @return false|null|string Link to show comment form, if successful. False, if comments are closed.
  1313  */
  1484  */
  1314 function get_post_reply_link($args = array(), $post = null) {
  1485 function get_post_reply_link($args = array(), $post = null) {
  1315 	$defaults = array(
  1486 	$defaults = array(
  1316 		'add_below'  => 'post',
  1487 		'add_below'  => 'post',
  1317 		'respond_id' => 'respond',
  1488 		'respond_id' => 'respond',
  1320 		'before'     => '',
  1491 		'before'     => '',
  1321 		'after'      => '',
  1492 		'after'      => '',
  1322 	);
  1493 	);
  1323 
  1494 
  1324 	$args = wp_parse_args($args, $defaults);
  1495 	$args = wp_parse_args($args, $defaults);
  1325 	extract($args, EXTR_SKIP);
  1496 
  1326 	$post = get_post($post);
  1497 	$post = get_post($post);
  1327 
  1498 
  1328 	if ( !comments_open($post->ID) )
  1499 	if ( ! comments_open( $post->ID ) ) {
  1329 		return false;
  1500 		return false;
  1330 
  1501 	}
  1331 	if ( get_option('comment_registration') && ! is_user_logged_in() )
  1502 
  1332 		$link = '<a rel="nofollow" href="' . wp_login_url( get_permalink() ) . '">' . $login_text . '</a>';
  1503 	if ( get_option('comment_registration') && ! is_user_logged_in() ) {
  1333 	else
  1504 		$link = sprintf( '<a rel="nofollow" class="comment-reply-login" href="%s">%s</a>',
  1334 		$link = "<a rel='nofollow' class='comment-reply-link' href='" . get_permalink($post->ID) . "#$respond_id' onclick='return addComment.moveForm(\"$add_below-$post->ID\", \"0\", \"$respond_id\", \"$post->ID\")'>$reply_text</a>";
  1505 			wp_login_url( get_permalink() ),
  1335 
  1506 			$args['login_text']
  1336 	$formatted_link = $before . $link . $after;
  1507 		);
       
  1508 	} else {
       
  1509 		$onclick = sprintf( 'return addComment.moveForm( "%1$s-%2$s", "0", "%3$s", "%2$s" )',
       
  1510 			$args['add_below'], $post->ID, $args['respond_id']
       
  1511 		);
       
  1512 
       
  1513 		$link = sprintf( "<a rel='nofollow' class='comment-reply-link' href='%s' onclick='%s'>%s</a>",
       
  1514 			get_permalink( $post->ID ) . '#' . $args['respond_id'],
       
  1515 			$onclick,
       
  1516 			$args['reply_text']
       
  1517 		);
       
  1518 	}
       
  1519 	$formatted_link = $args['before'] . $link . $args['after'];
  1337 	/**
  1520 	/**
  1338 	 * Filter the formatted post comments link HTML.
  1521 	 * Filter the formatted post comments link HTML.
  1339 	 *
  1522 	 *
  1340 	 * @since 2.7.0
  1523 	 * @since 2.7.0
  1341 	 *
  1524 	 *
  1348 /**
  1531 /**
  1349  * Displays the HTML content for reply to post link.
  1532  * Displays the HTML content for reply to post link.
  1350  *
  1533  *
  1351  * @since 2.7.0
  1534  * @since 2.7.0
  1352  *
  1535  *
  1353  * @param array       $args Optional. Override default options, @see get_post_reply_link()
  1536  * @see get_post_reply_link()
  1354  * @param int|WP_Post $post Optional. Post ID or WP_Post object the comment is going to be displayed on. Default current post.
  1537  *
       
  1538  * @param array       $args Optional. Override default options,
       
  1539  * @param int|WP_Post $post Post ID or WP_Post object the comment is going to be displayed on.
       
  1540  *                          Default current post.
  1355  * @return string|bool|null Link to show comment form, if successful. False, if comments are closed.
  1541  * @return string|bool|null Link to show comment form, if successful. False, if comments are closed.
  1356  */
  1542  */
  1357 function post_reply_link($args = array(), $post = null) {
  1543 function post_reply_link($args = array(), $post = null) {
  1358 	echo get_post_reply_link($args, $post);
  1544 	echo get_post_reply_link($args, $post);
  1359 }
  1545 }
  1377 	 * Filter the cancel comment reply link HTML.
  1563 	 * Filter the cancel comment reply link HTML.
  1378 	 *
  1564 	 *
  1379 	 * @since 2.7.0
  1565 	 * @since 2.7.0
  1380 	 *
  1566 	 *
  1381 	 * @param string $formatted_link The HTML-formatted cancel comment reply link.
  1567 	 * @param string $formatted_link The HTML-formatted cancel comment reply link.
  1382 	 * @param string $link           The cancel comment reply link URL.
  1568 	 * @param string $link           Cancel comment reply link URL.
  1383 	 * @param string $text           The cancel comment reply link text.
  1569 	 * @param string $text           Cancel comment reply link text.
  1384 	 */
  1570 	 */
  1385 	return apply_filters( 'cancel_comment_reply_link', $formatted_link, $link, $text );
  1571 	return apply_filters( 'cancel_comment_reply_link', $formatted_link, $link, $text );
  1386 }
  1572 }
  1387 
  1573 
  1388 /**
  1574 /**
  1436 }
  1622 }
  1437 
  1623 
  1438 /**
  1624 /**
  1439  * Display text based on comment reply status.
  1625  * Display text based on comment reply status.
  1440  *
  1626  *
  1441  * Only affects users with Javascript disabled.
  1627  * Only affects users with JavaScript disabled.
  1442  *
  1628  *
  1443  * @since 2.7.0
  1629  * @since 2.7.0
  1444  *
  1630  *
  1445  * @param string $noreplytext  Optional. Text to display when not replying to a comment. Default false.
  1631  * @param string $noreplytext  Optional. Text to display when not replying to a comment.
       
  1632  *                             Default false.
  1446  * @param string $replytext    Optional. Text to display when replying to a comment.
  1633  * @param string $replytext    Optional. Text to display when replying to a comment.
  1447  *                             Default false. Accepts "%s" for the author of the comment being replied to.
  1634  *                             Default false. Accepts "%s" for the author of the comment
  1448  * @param string $linktoparent Optional. Boolean to control making the author's name a link to their comment. Default true.
  1635  *                             being replied to.
       
  1636  * @param string $linktoparent Optional. Boolean to control making the author's name a link
       
  1637  *                             to their comment. Default true.
  1449  */
  1638  */
  1450 function comment_form_title( $noreplytext = false, $replytext = false, $linktoparent = true ) {
  1639 function comment_form_title( $noreplytext = false, $replytext = false, $linktoparent = true ) {
  1451 	global $comment;
  1640 	global $comment;
  1452 
  1641 
  1453 	if ( false === $noreplytext ) $noreplytext = __( 'Leave a Reply' );
  1642 	if ( false === $noreplytext ) $noreplytext = __( 'Leave a Reply' );
  1465 }
  1654 }
  1466 
  1655 
  1467 /**
  1656 /**
  1468  * HTML comment list class.
  1657  * HTML comment list class.
  1469  *
  1658  *
  1470  * @package WordPress
       
  1471  * @uses Walker
  1659  * @uses Walker
  1472  * @since 2.7.0
  1660  * @since 2.7.0
  1473  */
  1661  */
  1474 class Walker_Comment extends Walker {
  1662 class Walker_Comment extends Walker {
  1475 	/**
  1663 	/**
  1478 	 * @see Walker::$tree_type
  1666 	 * @see Walker::$tree_type
  1479 	 *
  1667 	 *
  1480 	 * @since 2.7.0
  1668 	 * @since 2.7.0
  1481 	 * @var string
  1669 	 * @var string
  1482 	 */
  1670 	 */
  1483 	var $tree_type = 'comment';
  1671 	public $tree_type = 'comment';
  1484 
  1672 
  1485 	/**
  1673 	/**
  1486 	 * DB fields to use.
  1674 	 * DB fields to use.
  1487 	 *
  1675 	 *
  1488 	 * @see Walker::$db_fields
  1676 	 * @see Walker::$db_fields
  1489 	 *
  1677 	 *
  1490 	 * @since 2.7.0
  1678 	 * @since 2.7.0
  1491 	 * @var array
  1679 	 * @var array
  1492 	 */
  1680 	 */
  1493 	var $db_fields = array ('parent' => 'comment_parent', 'id' => 'comment_ID');
  1681 	public $db_fields = array ('parent' => 'comment_parent', 'id' => 'comment_ID');
  1494 
  1682 
  1495 	/**
  1683 	/**
  1496 	 * Start the list before the elements are added.
  1684 	 * Start the list before the elements are added.
  1497 	 *
  1685 	 *
  1498 	 * @see Walker::start_lvl()
  1686 	 * @see Walker::start_lvl()
  1501 	 *
  1689 	 *
  1502 	 * @param string $output Passed by reference. Used to append additional content.
  1690 	 * @param string $output Passed by reference. Used to append additional content.
  1503 	 * @param int $depth Depth of comment.
  1691 	 * @param int $depth Depth of comment.
  1504 	 * @param array $args Uses 'style' argument for type of HTML list.
  1692 	 * @param array $args Uses 'style' argument for type of HTML list.
  1505 	 */
  1693 	 */
  1506 	function start_lvl( &$output, $depth = 0, $args = array() ) {
  1694 	public function start_lvl( &$output, $depth = 0, $args = array() ) {
  1507 		$GLOBALS['comment_depth'] = $depth + 1;
  1695 		$GLOBALS['comment_depth'] = $depth + 1;
  1508 
  1696 
  1509 		switch ( $args['style'] ) {
  1697 		switch ( $args['style'] ) {
  1510 			case 'div':
  1698 			case 'div':
  1511 				break;
  1699 				break;
  1512 			case 'ol':
  1700 			case 'ol':
  1513 				echo '<ol class="children">' . "\n";
  1701 				$output .= '<ol class="children">' . "\n";
  1514 				break;
  1702 				break;
       
  1703 			case 'ul':
  1515 			default:
  1704 			default:
  1516 			case 'ul':
  1705 				$output .= '<ul class="children">' . "\n";
  1517 				echo '<ul class="children">' . "\n";
       
  1518 				break;
  1706 				break;
  1519 		}
  1707 		}
  1520 	}
  1708 	}
  1521 
  1709 
  1522 	/**
  1710 	/**
  1528 	 *
  1716 	 *
  1529 	 * @param string $output Passed by reference. Used to append additional content.
  1717 	 * @param string $output Passed by reference. Used to append additional content.
  1530 	 * @param int    $depth  Depth of comment.
  1718 	 * @param int    $depth  Depth of comment.
  1531 	 * @param array  $args   Will only append content if style argument value is 'ol' or 'ul'.
  1719 	 * @param array  $args   Will only append content if style argument value is 'ol' or 'ul'.
  1532 	 */
  1720 	 */
  1533 	function end_lvl( &$output, $depth = 0, $args = array() ) {
  1721 	public function end_lvl( &$output, $depth = 0, $args = array() ) {
  1534 		$GLOBALS['comment_depth'] = $depth + 1;
  1722 		$GLOBALS['comment_depth'] = $depth + 1;
  1535 
  1723 
  1536 		switch ( $args['style'] ) {
  1724 		switch ( $args['style'] ) {
  1537 			case 'div':
  1725 			case 'div':
  1538 				break;
  1726 				break;
  1539 			case 'ol':
  1727 			case 'ol':
  1540 				echo "</ol><!-- .children -->\n";
  1728 				$output .= "</ol><!-- .children -->\n";
  1541 				break;
  1729 				break;
       
  1730 			case 'ul':
  1542 			default:
  1731 			default:
  1543 			case 'ul':
  1732 				$output .= "</ul><!-- .children -->\n";
  1544 				echo "</ul><!-- .children -->\n";
       
  1545 				break;
  1733 				break;
  1546 		}
  1734 		}
  1547 	}
  1735 	}
  1548 
  1736 
  1549 	/**
  1737 	/**
  1564 	 *    1.1.2.1
  1752 	 *    1.1.2.1
  1565 	 * 2
  1753 	 * 2
  1566 	 *  2.2
  1754 	 *  2.2
  1567 	 *
  1755 	 *
  1568 	 * @see Walker::display_element()
  1756 	 * @see Walker::display_element()
       
  1757 	 * @see wp_list_comments()
  1569 	 *
  1758 	 *
  1570 	 * @since 2.7.0
  1759 	 * @since 2.7.0
  1571 	 *
  1760 	 *
  1572 	 * @param object $element           Data object.
  1761 	 * @param object $element           Data object.
  1573 	 * @param array  $children_elements List of elements to continue traversing.
  1762 	 * @param array  $children_elements List of elements to continue traversing.
  1574 	 * @param int    $max_depth         Max depth to traverse.
  1763 	 * @param int    $max_depth         Max depth to traverse.
  1575 	 * @param int    $depth             Depth of current element.
  1764 	 * @param int    $depth             Depth of current element.
  1576 	 * @param array  $args              An array of arguments. @see wp_list_comments()
  1765 	 * @param array  $args              An array of arguments.
  1577 	 * @param string $output            Passed by reference. Used to append additional content.
  1766 	 * @param string $output            Passed by reference. Used to append additional content.
  1578 	 * @return null Null on failure with no changes to parameters.
  1767 	 * @return null Null on failure with no changes to parameters.
  1579 	 */
  1768 	 */
  1580 	function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) {
  1769 	public function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) {
  1581 
  1770 
  1582 		if ( !$element )
  1771 		if ( !$element )
  1583 			return;
  1772 			return;
  1584 
  1773 
  1585 		$id_field = $this->db_fields['id'];
  1774 		$id_field = $this->db_fields['id'];
  1599 	}
  1788 	}
  1600 
  1789 
  1601 	/**
  1790 	/**
  1602 	 * Start the element output.
  1791 	 * Start the element output.
  1603 	 *
  1792 	 *
       
  1793 	 * @since 2.7.0
       
  1794 	 *
  1604 	 * @see Walker::start_el()
  1795 	 * @see Walker::start_el()
  1605 	 *
  1796 	 * @see wp_list_comments()
  1606 	 * @since 2.7.0
       
  1607 	 *
  1797 	 *
  1608 	 * @param string $output  Passed by reference. Used to append additional content.
  1798 	 * @param string $output  Passed by reference. Used to append additional content.
  1609 	 * @param object $comment Comment data object.
  1799 	 * @param object $comment Comment data object.
  1610 	 * @param int    $depth   Depth of comment in reference to parents.
  1800 	 * @param int    $depth   Depth of comment in reference to parents.
  1611 	 * @param array  $args    An array of arguments. @see wp_list_comments()
  1801 	 * @param array  $args    An array of arguments.
  1612 	 */
  1802 	 */
  1613 	function start_el( &$output, $comment, $depth = 0, $args = array(), $id = 0 ) {
  1803 	public function start_el( &$output, $comment, $depth = 0, $args = array(), $id = 0 ) {
  1614 		$depth++;
  1804 		$depth++;
  1615 		$GLOBALS['comment_depth'] = $depth;
  1805 		$GLOBALS['comment_depth'] = $depth;
  1616 		$GLOBALS['comment'] = $comment;
  1806 		$GLOBALS['comment'] = $comment;
  1617 
  1807 
  1618 		if ( !empty( $args['callback'] ) ) {
  1808 		if ( !empty( $args['callback'] ) ) {
       
  1809 			ob_start();
  1619 			call_user_func( $args['callback'], $comment, $args, $depth );
  1810 			call_user_func( $args['callback'], $comment, $args, $depth );
       
  1811 			$output .= ob_get_clean();
  1620 			return;
  1812 			return;
  1621 		}
  1813 		}
  1622 
  1814 
  1623 		if ( ( 'pingback' == $comment->comment_type || 'trackback' == $comment->comment_type ) && $args['short_ping'] ) {
  1815 		if ( ( 'pingback' == $comment->comment_type || 'trackback' == $comment->comment_type ) && $args['short_ping'] ) {
       
  1816 			ob_start();
  1624 			$this->ping( $comment, $depth, $args );
  1817 			$this->ping( $comment, $depth, $args );
       
  1818 			$output .= ob_get_clean();
  1625 		} elseif ( 'html5' === $args['format'] ) {
  1819 		} elseif ( 'html5' === $args['format'] ) {
       
  1820 			ob_start();
  1626 			$this->html5_comment( $comment, $depth, $args );
  1821 			$this->html5_comment( $comment, $depth, $args );
       
  1822 			$output .= ob_get_clean();
  1627 		} else {
  1823 		} else {
       
  1824 			ob_start();
  1628 			$this->comment( $comment, $depth, $args );
  1825 			$this->comment( $comment, $depth, $args );
       
  1826 			$output .= ob_get_clean();
  1629 		}
  1827 		}
  1630 	}
  1828 	}
  1631 
  1829 
  1632 	/**
  1830 	/**
  1633 	 * Ends the element output, if needed.
  1831 	 * Ends the element output, if needed.
  1634 	 *
  1832 	 *
       
  1833 	 * @since 2.7.0
       
  1834 	 *
  1635 	 * @see Walker::end_el()
  1835 	 * @see Walker::end_el()
  1636 	 *
  1836 	 * @see wp_list_comments()
  1637 	 * @since 2.7.0
       
  1638 	 *
  1837 	 *
  1639 	 * @param string $output  Passed by reference. Used to append additional content.
  1838 	 * @param string $output  Passed by reference. Used to append additional content.
  1640 	 * @param object $comment The comment object. Default current comment.
  1839 	 * @param object $comment The comment object. Default current comment.
  1641 	 * @param int    $depth   Depth of comment.
  1840 	 * @param int    $depth   Depth of comment.
  1642 	 * @param array  $args    An array of arguments. @see wp_list_comments()
  1841 	 * @param array  $args    An array of arguments.
  1643 	 */
  1842 	 */
  1644 	function end_el( &$output, $comment, $depth = 0, $args = array() ) {
  1843 	public function end_el( &$output, $comment, $depth = 0, $args = array() ) {
  1645 		if ( !empty( $args['end-callback'] ) ) {
  1844 		if ( !empty( $args['end-callback'] ) ) {
       
  1845 			ob_start();
  1646 			call_user_func( $args['end-callback'], $comment, $args, $depth );
  1846 			call_user_func( $args['end-callback'], $comment, $args, $depth );
       
  1847 			$output .= ob_get_clean();
  1647 			return;
  1848 			return;
  1648 		}
  1849 		}
  1649 		if ( 'div' == $args['style'] )
  1850 		if ( 'div' == $args['style'] )
  1650 			echo "</div><!-- #comment-## -->\n";
  1851 			$output .= "</div><!-- #comment-## -->\n";
  1651 		else
  1852 		else
  1652 			echo "</li><!-- #comment-## -->\n";
  1853 			$output .= "</li><!-- #comment-## -->\n";
  1653 	}
  1854 	}
  1654 
  1855 
  1655 	/**
  1856 	/**
  1656 	 * Output a pingback comment.
  1857 	 * Output a pingback comment.
  1657 	 *
  1858 	 *
  1658 	 * @access protected
  1859 	 * @access protected
  1659 	 * @since 3.6.0
  1860 	 * @since 3.6.0
  1660 	 *
  1861 	 *
       
  1862 	 * @see wp_list_comments()
       
  1863 	 *
  1661 	 * @param object $comment The comment object.
  1864 	 * @param object $comment The comment object.
  1662 	 * @param int    $depth   Depth of comment.
  1865 	 * @param int    $depth   Depth of comment.
  1663 	 * @param array  $args    An array of arguments. @see wp_list_comments()
  1866 	 * @param array  $args    An array of arguments.
  1664 	 */
  1867 	 */
  1665 	protected function ping( $comment, $depth, $args ) {
  1868 	protected function ping( $comment, $depth, $args ) {
  1666 		$tag = ( 'div' == $args['style'] ) ? 'div' : 'li';
  1869 		$tag = ( 'div' == $args['style'] ) ? 'div' : 'li';
  1667 ?>
  1870 ?>
  1668 		<<?php echo $tag; ?> id="comment-<?php comment_ID(); ?>" <?php comment_class(); ?>>
  1871 		<<?php echo $tag; ?> id="comment-<?php comment_ID(); ?>" <?php comment_class(); ?>>
  1676 	 * Output a single comment.
  1879 	 * Output a single comment.
  1677 	 *
  1880 	 *
  1678 	 * @access protected
  1881 	 * @access protected
  1679 	 * @since 3.6.0
  1882 	 * @since 3.6.0
  1680 	 *
  1883 	 *
       
  1884 	 * @see wp_list_comments()
       
  1885 	 *
  1681 	 * @param object $comment Comment to display.
  1886 	 * @param object $comment Comment to display.
  1682 	 * @param int    $depth   Depth of comment.
  1887 	 * @param int    $depth   Depth of comment.
  1683 	 * @param array  $args    An array of arguments. @see wp_list_comments()
  1888 	 * @param array  $args    An array of arguments.
  1684 	 */
  1889 	 */
  1685 	protected function comment( $comment, $depth, $args ) {
  1890 	protected function comment( $comment, $depth, $args ) {
  1686 		if ( 'div' == $args['style'] ) {
  1891 		if ( 'div' == $args['style'] ) {
  1687 			$tag = 'div';
  1892 			$tag = 'div';
  1688 			$add_below = 'comment';
  1893 			$add_below = 'comment';
  1689 		} else {
  1894 		} else {
  1690 			$tag = 'li';
  1895 			$tag = 'li';
  1691 			$add_below = 'div-comment';
  1896 			$add_below = 'div-comment';
  1692 		}
  1897 		}
  1693 ?>
  1898 ?>
  1694 		<<?php echo $tag; ?> <?php comment_class( empty( $args['has_children'] ) ? '' : 'parent' ); ?> id="comment-<?php comment_ID(); ?>">
  1899 		<<?php echo $tag; ?> <?php comment_class( $this->has_children ? 'parent' : '' ); ?> id="comment-<?php comment_ID(); ?>">
  1695 		<?php if ( 'div' != $args['style'] ) : ?>
  1900 		<?php if ( 'div' != $args['style'] ) : ?>
  1696 		<div id="div-comment-<?php comment_ID(); ?>" class="comment-body">
  1901 		<div id="div-comment-<?php comment_ID(); ?>" class="comment-body">
  1697 		<?php endif; ?>
  1902 		<?php endif; ?>
  1698 		<div class="comment-author vcard">
  1903 		<div class="comment-author vcard">
  1699 			<?php if ( 0 != $args['avatar_size'] ) echo get_avatar( $comment, $args['avatar_size'] ); ?>
  1904 			<?php if ( 0 != $args['avatar_size'] ) echo get_avatar( $comment, $args['avatar_size'] ); ?>
  1702 		<?php if ( '0' == $comment->comment_approved ) : ?>
  1907 		<?php if ( '0' == $comment->comment_approved ) : ?>
  1703 		<em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.' ) ?></em>
  1908 		<em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.' ) ?></em>
  1704 		<br />
  1909 		<br />
  1705 		<?php endif; ?>
  1910 		<?php endif; ?>
  1706 
  1911 
  1707 		<div class="comment-meta commentmetadata"><a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>">
  1912 		<div class="comment-meta commentmetadata"><a href="<?php echo esc_url( get_comment_link( $comment->comment_ID, $args ) ); ?>">
  1708 			<?php
  1913 			<?php
  1709 				/* translators: 1: date, 2: time */
  1914 				/* translators: 1: date, 2: time */
  1710 				printf( __( '%1$s at %2$s' ), get_comment_date(),  get_comment_time() ); ?></a><?php edit_comment_link( __( '(Edit)' ), '&nbsp;&nbsp;', '' );
  1915 				printf( __( '%1$s at %2$s' ), get_comment_date(),  get_comment_time() ); ?></a><?php edit_comment_link( __( '(Edit)' ), '&nbsp;&nbsp;', '' );
  1711 			?>
  1916 			?>
  1712 		</div>
  1917 		</div>
  1713 
  1918 
  1714 		<?php comment_text( get_comment_id(), array_merge( $args, array( 'add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
  1919 		<?php comment_text( get_comment_id(), array_merge( $args, array( 'add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
  1715 
  1920 
  1716 		<div class="reply">
  1921 		<?php
  1717 			<?php comment_reply_link( array_merge( $args, array( 'add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
  1922 		comment_reply_link( array_merge( $args, array(
  1718 		</div>
  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 
  1719 		<?php if ( 'div' != $args['style'] ) : ?>
  1931 		<?php if ( 'div' != $args['style'] ) : ?>
  1720 		</div>
  1932 		</div>
  1721 		<?php endif; ?>
  1933 		<?php endif; ?>
  1722 <?php
  1934 <?php
  1723 	}
  1935 	}
  1726 	 * Output a comment in the HTML5 format.
  1938 	 * Output a comment in the HTML5 format.
  1727 	 *
  1939 	 *
  1728 	 * @access protected
  1940 	 * @access protected
  1729 	 * @since 3.6.0
  1941 	 * @since 3.6.0
  1730 	 *
  1942 	 *
       
  1943 	 * @see wp_list_comments()
       
  1944 	 *
  1731 	 * @param object $comment Comment to display.
  1945 	 * @param object $comment Comment to display.
  1732 	 * @param int    $depth   Depth of comment.
  1946 	 * @param int    $depth   Depth of comment.
  1733 	 * @param array  $args    An array of arguments. @see wp_list_comments()
  1947 	 * @param array  $args    An array of arguments.
  1734 	 */
  1948 	 */
  1735 	protected function html5_comment( $comment, $depth, $args ) {
  1949 	protected function html5_comment( $comment, $depth, $args ) {
  1736 		$tag = ( 'div' === $args['style'] ) ? 'div' : 'li';
  1950 		$tag = ( 'div' === $args['style'] ) ? 'div' : 'li';
  1737 ?>
  1951 ?>
  1738 		<<?php echo $tag; ?> id="comment-<?php comment_ID(); ?>" <?php comment_class( empty( $args['has_children'] ) ? '' : 'parent' ); ?>>
  1952 		<<?php echo $tag; ?> id="comment-<?php comment_ID(); ?>" <?php comment_class( $this->has_children ? 'parent' : '' ); ?>>
  1739 			<article id="div-comment-<?php comment_ID(); ?>" class="comment-body">
  1953 			<article id="div-comment-<?php comment_ID(); ?>" class="comment-body">
  1740 				<footer class="comment-meta">
  1954 				<footer class="comment-meta">
  1741 					<div class="comment-author vcard">
  1955 					<div class="comment-author vcard">
  1742 						<?php if ( 0 != $args['avatar_size'] ) echo get_avatar( $comment, $args['avatar_size'] ); ?>
  1956 						<?php if ( 0 != $args['avatar_size'] ) echo get_avatar( $comment, $args['avatar_size'] ); ?>
  1743 						<?php printf( __( '%s <span class="says">says:</span>' ), sprintf( '<b class="fn">%s</b>', get_comment_author_link() ) ); ?>
  1957 						<?php printf( __( '%s <span class="says">says:</span>' ), sprintf( '<b class="fn">%s</b>', get_comment_author_link() ) ); ?>
  1744 					</div><!-- .comment-author -->
  1958 					</div><!-- .comment-author -->
  1745 
  1959 
  1746 					<div class="comment-metadata">
  1960 					<div class="comment-metadata">
  1747 						<a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>">
  1961 						<a href="<?php echo esc_url( get_comment_link( $comment->comment_ID, $args ) ); ?>">
  1748 							<time datetime="<?php comment_time( 'c' ); ?>">
  1962 							<time datetime="<?php comment_time( 'c' ); ?>">
  1749 								<?php printf( _x( '%1$s at %2$s', '1: date, 2: time' ), get_comment_date(), get_comment_time() ); ?>
  1963 								<?php printf( _x( '%1$s at %2$s', '1: date, 2: time' ), get_comment_date(), get_comment_time() ); ?>
  1750 							</time>
  1964 							</time>
  1751 						</a>
  1965 						</a>
  1752 						<?php edit_comment_link( __( 'Edit' ), '<span class="edit-link">', '</span>' ); ?>
  1966 						<?php edit_comment_link( __( 'Edit' ), '<span class="edit-link">', '</span>' ); ?>
  1759 
  1973 
  1760 				<div class="comment-content">
  1974 				<div class="comment-content">
  1761 					<?php comment_text(); ?>
  1975 					<?php comment_text(); ?>
  1762 				</div><!-- .comment-content -->
  1976 				</div><!-- .comment-content -->
  1763 
  1977 
  1764 				<div class="reply">
  1978 				<?php
  1765 					<?php comment_reply_link( array_merge( $args, array( 'add_below' => 'div-comment', 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
  1979 				comment_reply_link( array_merge( $args, array(
  1766 				</div><!-- .reply -->
  1980 					'add_below' => 'div-comment',
       
  1981 					'depth'     => $depth,
       
  1982 					'max_depth' => $args['max_depth'],
       
  1983 					'before'    => '<div class="reply">',
       
  1984 					'after'     => '</div>'
       
  1985 				) ) );
       
  1986 				?>
  1767 			</article><!-- .comment-body -->
  1987 			</article><!-- .comment-body -->
  1768 <?php
  1988 <?php
  1769 	}
  1989 	}
  1770 }
  1990 }
  1771 
  1991 
  1774  *
  1994  *
  1775  * Used in the comments.php template to list comments for a particular post.
  1995  * Used in the comments.php template to list comments for a particular post.
  1776  *
  1996  *
  1777  * @since 2.7.0
  1997  * @since 2.7.0
  1778  *
  1998  *
       
  1999  * @see WP_Query->comments
       
  2000  *
  1779  * @param string|array $args {
  2001  * @param string|array $args {
  1780  *     Optional. Formatting options.
  2002  *     Optional. Formatting options.
  1781  *
  2003  *
  1782  *     @type string 'walker'            The Walker class used to list comments. Default null.
  2004  *     @type object $walker            Instance of a Walker class to list comments. Default null.
  1783  *     @type int    'max_depth'         The maximum comments depth. Default empty.
  2005  *     @type int    $max_depth         The maximum comments depth. Default empty.
  1784  *     @type string 'style'             The style of list ordering. Default 'ul'. Accepts 'ul', 'ol'.
  2006  *     @type string $style             The style of list ordering. Default 'ul'. Accepts 'ul', 'ol'.
  1785  *     @type string 'callback'          Callback function to use. Default null.
  2007  *     @type string $callback          Callback function to use. Default null.
  1786  *     @type string 'end-callback'      Callback function to use at the end. Default null.
  2008  *     @type string $end-callback      Callback function to use at the end. Default null.
  1787  *     @type string 'type'              Type of comments to list.
  2009  *     @type string $type              Type of comments to list.
  1788  *                                      Default 'all'. Accepts 'all', 'comment', 'pingback', 'trackback', 'pings'.
  2010  *                                     Default 'all'. Accepts 'all', 'comment', 'pingback', 'trackback', 'pings'.
  1789  *     @type int    'page'              Page ID to list comments for. Default empty.
  2011  *     @type int    $page              Page ID to list comments for. Default empty.
  1790  *     @type int    'per_page'          Number of comments to list per page. Default empty.
  2012  *     @type int    $per_page          Number of comments to list per page. Default empty.
  1791  *     @type int    'avatar_size'       Height and width dimensions of the avatar size. Default 32.
  2013  *     @type int    $avatar_size       Height and width dimensions of the avatar size. Default 32.
  1792  *     @type string 'reverse_top_level' Ordering of the listed comments. Default null. Accepts 'desc', 'asc'.
  2014  *     @type string $reverse_top_level Ordering of the listed comments. Default null. Accepts 'desc', 'asc'.
  1793  *     @type bool   'reverse_children'  Whether to reverse child comments in the list. Default null.
  2015  *     @type bool   $reverse_children  Whether to reverse child comments in the list. Default null.
  1794  *     @type string 'format'            How to format the comments list.
  2016  *     @type string $format            How to format the comments list.
  1795  *                                      Default 'html5' if the theme supports it. Accepts 'html5', 'xhtml'.
  2017  *                                     Default 'html5' if the theme supports it. Accepts 'html5', 'xhtml'.
  1796  *     @type bool   'short_ping'        Whether to output short pings. Default false.
  2018  *     @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.
  1797  * }
  2020  * }
  1798  * @param array $comments Optional. Array of comment objects. @see WP_Query->comments
  2021  * @param array $comments Optional. Array of comment objects.
  1799  */
  2022  */
  1800 function wp_list_comments( $args = array(), $comments = null ) {
  2023 function wp_list_comments( $args = array(), $comments = null ) {
  1801 	global $wp_query, $comment_alt, $comment_depth, $comment_thread_alt, $overridden_cpage, $in_comment_loop;
  2024 	global $wp_query, $comment_alt, $comment_depth, $comment_thread_alt, $overridden_cpage, $in_comment_loop;
  1802 
  2025 
  1803 	$in_comment_loop = true;
  2026 	$in_comment_loop = true;
  1817 		'avatar_size'       => 32,
  2040 		'avatar_size'       => 32,
  1818 		'reverse_top_level' => null,
  2041 		'reverse_top_level' => null,
  1819 		'reverse_children'  => '',
  2042 		'reverse_children'  => '',
  1820 		'format'            => current_theme_supports( 'html5', 'comment-list' ) ? 'html5' : 'xhtml',
  2043 		'format'            => current_theme_supports( 'html5', 'comment-list' ) ? 'html5' : 'xhtml',
  1821 		'short_ping'        => false,
  2044 		'short_ping'        => false,
       
  2045 		'echo'              => true,
  1822 	);
  2046 	);
  1823 
  2047 
  1824 	$r = wp_parse_args( $args, $defaults );
  2048 	$r = wp_parse_args( $args, $defaults );
       
  2049 
       
  2050 	/**
       
  2051 	 * Filter the arguments used in retrieving the comment list.
       
  2052 	 *
       
  2053 	 * @since 4.0.0
       
  2054 	 *
       
  2055 	 * @see wp_list_comments()
       
  2056 	 *
       
  2057 	 * @param array $r An array of arguments for displaying comments.
       
  2058 	 */
       
  2059 	$r = apply_filters( 'wp_list_comments_args', $r );
  1825 
  2060 
  1826 	// Figure out what comments we'll be looping through ($_comments)
  2061 	// Figure out what comments we'll be looping through ($_comments)
  1827 	if ( null !== $comments ) {
  2062 	if ( null !== $comments ) {
  1828 		$comments = (array) $comments;
  2063 		$comments = (array) $comments;
  1829 		if ( empty($comments) )
  2064 		if ( empty($comments) )
  1880 		$r['page'] = 1;
  2115 		$r['page'] = 1;
  1881 
  2116 
  1882 	if ( null === $r['reverse_top_level'] )
  2117 	if ( null === $r['reverse_top_level'] )
  1883 		$r['reverse_top_level'] = ( 'desc' == get_option('comment_order') );
  2118 		$r['reverse_top_level'] = ( 'desc' == get_option('comment_order') );
  1884 
  2119 
  1885 	extract( $r, EXTR_SKIP );
  2120 	if ( empty( $r['walker'] ) ) {
  1886 
       
  1887 	if ( empty($walker) )
       
  1888 		$walker = new Walker_Comment;
  2121 		$walker = new Walker_Comment;
  1889 
  2122 	} else {
  1890 	$walker->paged_walk($_comments, $max_depth, $page, $per_page, $r);
  2123 		$walker = $r['walker'];
       
  2124 	}
       
  2125 
       
  2126 	$output = $walker->paged_walk( $_comments, $r['max_depth'], $r['page'], $r['per_page'], $r );
  1891 	$wp_query->max_num_comment_pages = $walker->max_pages;
  2127 	$wp_query->max_num_comment_pages = $walker->max_pages;
  1892 
  2128 
  1893 	$in_comment_loop = false;
  2129 	$in_comment_loop = false;
       
  2130 
       
  2131 	if ( $r['echo'] ) {
       
  2132 		echo $output;
       
  2133 	} else {
       
  2134 		return $output;
       
  2135 	}
  1894 }
  2136 }
  1895 
  2137 
  1896 /**
  2138 /**
  1897  * Output a complete commenting form for use within a template.
  2139  * Output a complete commenting form for use within a template.
  1898  *
  2140  *
  1902  * one or remove a single field. All fields are also individually passed through
  2144  * one or remove a single field. All fields are also individually passed through
  1903  * a filter of the form comment_form_field_$name where $name is the key used
  2145  * a filter of the form comment_form_field_$name where $name is the key used
  1904  * in the array of fields.
  2146  * in the array of fields.
  1905  *
  2147  *
  1906  * @since 3.0.0
  2148  * @since 3.0.0
       
  2149  * @since 4.1.0 Introduced the 'class_submit' argument.
       
  2150  * @since 4.2.0 Introduced 'submit_button' and 'submit_fields' arguments.
  1907  *
  2151  *
  1908  * @param array       $args {
  2152  * @param array       $args {
  1909  *     Optional. Default arguments and form fields to override.
  2153  *     Optional. Default arguments and form fields to override.
  1910  *
  2154  *
  1911  *     @type array 'fields' {
  2155  *     @type array $fields {
  1912  *         Default comment fields, filterable by default via the 'comment_form_default_fields' hook.
  2156  *         Default comment fields, filterable by default via the 'comment_form_default_fields' hook.
  1913  *
  2157  *
  1914  *         @type string 'author' The comment author field HTML.
  2158  *         @type string $author Comment author field HTML.
  1915  *         @type string 'email'  The comment author email field HTML.
  2159  *         @type string $email  Comment author email field HTML.
  1916  *         @type string 'url'    The comment author URL field HTML.
  2160  *         @type string $url    Comment author URL field HTML.
  1917  *     }
  2161  *     }
  1918  *     @type string 'comment_field'        The comment textarea field HTML.
  2162  *     @type string $comment_field        The comment textarea field HTML.
  1919  *     @type string 'must_log_in'          HTML element for a 'must be logged in to comment' message.
  2163  *     @type string $must_log_in          HTML element for a 'must be logged in to comment' message.
  1920  *     @type string 'logged_in_as'         HTML element for a 'logged in as <user>' message.
  2164  *     @type string $logged_in_as         HTML element for a 'logged in as [user]' message.
  1921  *     @type string 'comment_notes_before' HTML element for a message displayed before the comment form.
  2165  *     @type string $comment_notes_before HTML element for a message displayed before the comment form.
  1922  *                                         Default 'Your email address will not be published.'.
  2166  *                                        Default 'Your email address will not be published.'.
  1923  *     @type string 'comment_notes_after'  HTML element for a message displayed after the comment form.
  2167  *     @type string $comment_notes_after  HTML element for a message displayed after the comment form.
  1924  *                                         Default 'You may use these HTML tags and attributes ...'.
  2168  *                                        Default 'You may use these HTML tags and attributes ...'.
  1925  *     @type string 'id_form'              The comment form element id attribute. Default 'commentform'.
  2169  *     @type string $id_form              The comment form element id attribute. Default 'commentform'.
  1926  *     @type string 'id_submit'            The comment submit element id attribute. Default 'submit'.
  2170  *     @type string $id_submit            The comment submit element id attribute. Default 'submit'.
  1927  *     @type string 'title_reply'          The translatable 'reply' button label. Default 'Leave a Reply'.
  2171  *     @type string $class_submit         The comment submit element class attribute. Default 'submit'.
  1928  *     @type string 'title_reply_to'       The translatable 'reply-to' button label. Default 'Leave a Reply to %s',
  2172  *     @type string $name_submit          The comment submit element name attribute. Default 'submit'.
  1929  *                                         where %s is the author of the comment being replied to.
  2173  *     @type string $title_reply          The translatable 'reply' button label. Default 'Leave a Reply'.
  1930  *     @type string 'cancel_reply_link'    The translatable 'cancel reply' button label. Default 'Cancel reply'.
  2174  *     @type string $title_reply_to       The translatable 'reply-to' button label. Default 'Leave a Reply to %s',
  1931  *     @type string 'label_submit'         The translatable 'submit' button label. Default 'Post a comment'.
  2175  *                                        where %s is the author of the comment being replied to.
  1932  *     @type string 'format'               The comment form format. Default 'xhtml'. Accepts 'xhtml', 'html5'.
  2176  *     @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'.
       
  2178  *     @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" />'.
       
  2180  *     @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
       
  2182  *                                        submit button markup and %2$s is the comment hidden fields.
       
  2183  *     @type string $format               The comment form format. Default 'xhtml'. Accepts 'xhtml', 'html5'.
  1933  * }
  2184  * }
  1934  * @param int|WP_Post $post_id Optional. Post ID or WP_Post object to generate the form for. Default current post.
  2185  * @param int|WP_Post $post_id Post ID or WP_Post object to generate the form for. Default current post.
  1935  */
  2186  */
  1936 function comment_form( $args = array(), $post_id = null ) {
  2187 function comment_form( $args = array(), $post_id = null ) {
  1937 	if ( null === $post_id )
  2188 	if ( null === $post_id )
  1938 		$post_id = get_the_ID();
  2189 		$post_id = get_the_ID();
  1939 	else
       
  1940 		$id = $post_id;
       
  1941 
  2190 
  1942 	$commenter = wp_get_current_commenter();
  2191 	$commenter = wp_get_current_commenter();
  1943 	$user = wp_get_current_user();
  2192 	$user = wp_get_current_user();
  1944 	$user_identity = $user->exists() ? $user->display_name : '';
  2193 	$user_identity = $user->exists() ? $user->display_name : '';
  1945 
  2194 
  1947 	if ( ! isset( $args['format'] ) )
  2196 	if ( ! isset( $args['format'] ) )
  1948 		$args['format'] = current_theme_supports( 'html5', 'comment-form' ) ? 'html5' : 'xhtml';
  2197 		$args['format'] = current_theme_supports( 'html5', 'comment-form' ) ? 'html5' : 'xhtml';
  1949 
  2198 
  1950 	$req      = get_option( 'require_name_email' );
  2199 	$req      = get_option( 'require_name_email' );
  1951 	$aria_req = ( $req ? " aria-required='true'" : '' );
  2200 	$aria_req = ( $req ? " aria-required='true'" : '' );
       
  2201 	$html_req = ( $req ? " required='required'" : '' );
  1952 	$html5    = 'html5' === $args['format'];
  2202 	$html5    = 'html5' === $args['format'];
  1953 	$fields   =  array(
  2203 	$fields   =  array(
  1954 		'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' .
  2204 		'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' .
  1955 		            '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' /></p>',
  2205 		            '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . $html_req . ' /></p>',
  1956 		'email'  => '<p class="comment-form-email"><label for="email">' . __( 'Email' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' .
  2206 		'email'  => '<p class="comment-form-email"><label for="email">' . __( 'Email' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' .
  1957 		            '<input id="email" name="email" ' . ( $html5 ? 'type="email"' : 'type="text"' ) . ' value="' . esc_attr(  $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' /></p>',
  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>',
  1958 		'url'    => '<p class="comment-form-url"><label for="url">' . __( 'Website' ) . '</label> ' .
  2208 		'url'    => '<p class="comment-form-url"><label for="url">' . __( 'Website' ) . '</label> ' .
  1959 		            '<input id="url" name="url" ' . ( $html5 ? 'type="url"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></p>',
  2209 		            '<input id="url" name="url" ' . ( $html5 ? 'type="url"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></p>',
  1960 	);
  2210 	);
  1961 
  2211 
  1962 	$required_text = sprintf( ' ' . __('Required fields are marked %s'), '<span class="required">*</span>' );
  2212 	$required_text = sprintf( ' ' . __('Required fields are marked %s'), '<span class="required">*</span>' );
  1969 	 * @param array $fields The default comment fields.
  2219 	 * @param array $fields The default comment fields.
  1970 	 */
  2220 	 */
  1971 	$fields = apply_filters( 'comment_form_default_fields', $fields );
  2221 	$fields = apply_filters( 'comment_form_default_fields', $fields );
  1972 	$defaults = array(
  2222 	$defaults = array(
  1973 		'fields'               => $fields,
  2223 		'fields'               => $fields,
  1974 		'comment_field'        => '<p class="comment-form-comment"><label for="comment">' . _x( 'Comment', 'noun' ) . '</label> <textarea id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea></p>',
  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>',
       
  2225 		/** This filter is documented in wp-includes/link-template.php */
  1975 		'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>',
  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>',
       
  2227 		/** This filter is documented in wp-includes/link-template.php */
  1976 		'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>',
  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>',
  1977 		'comment_notes_before' => '<p class="comment-notes">' . __( 'Your email address will not be published.' ) . ( $req ? $required_text : '' ) . '</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>',
  1978 		'comment_notes_after'  => '<p class="form-allowed-tags">' . sprintf( __( 'You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes: %s' ), ' <code>' . allowed_tags() . '</code>' ) . '</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>',
  1979 		'id_form'              => 'commentform',
  2231 		'id_form'              => 'commentform',
  1980 		'id_submit'            => 'submit',
  2232 		'id_submit'            => 'submit',
       
  2233 		'class_submit'         => 'submit',
       
  2234 		'name_submit'          => 'submit',
  1981 		'title_reply'          => __( 'Leave a Reply' ),
  2235 		'title_reply'          => __( 'Leave a Reply' ),
  1982 		'title_reply_to'       => __( 'Leave a Reply to %s' ),
  2236 		'title_reply_to'       => __( 'Leave a Reply to %s' ),
  1983 		'cancel_reply_link'    => __( 'Cancel reply' ),
  2237 		'cancel_reply_link'    => __( 'Cancel reply' ),
  1984 		'label_submit'         => __( 'Post Comment' ),
  2238 		'label_submit'         => __( 'Post Comment' ),
       
  2239 		'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>',
  1985 		'format'               => 'xhtml',
  2241 		'format'               => 'xhtml',
  1986 	);
  2242 	);
  1987 
  2243 
  1988 	/**
  2244 	/**
  1989 	 * Filter the comment form default arguments.
  2245 	 * Filter the comment form default arguments.
  1994 	 *
  2250 	 *
  1995 	 * @param array $defaults The default comment form arguments.
  2251 	 * @param array $defaults The default comment form arguments.
  1996 	 */
  2252 	 */
  1997 	$args = wp_parse_args( $args, apply_filters( 'comment_form_defaults', $defaults ) );
  2253 	$args = wp_parse_args( $args, apply_filters( 'comment_form_defaults', $defaults ) );
  1998 
  2254 
  1999 	?>
  2255 		if ( comments_open( $post_id ) ) : ?>
  2000 		<?php if ( comments_open( $post_id ) ) : ?>
       
  2001 			<?php
  2256 			<?php
  2002 			/**
  2257 			/**
  2003 			 * Fires before the comment form.
  2258 			 * Fires before the comment form.
  2004 			 *
  2259 			 *
  2005 			 * @since 3.0.0
  2260 			 * @since 3.0.0
  2020 					?>
  2275 					?>
  2021 				<?php else : ?>
  2276 				<?php else : ?>
  2022 					<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' : ''; ?>>
  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' : ''; ?>>
  2023 						<?php
  2278 						<?php
  2024 						/**
  2279 						/**
  2025 						 * Fires at the top of the comment form, inside the <form> tag.
  2280 						 * Fires at the top of the comment form, inside the form tag.
  2026 						 *
  2281 						 *
  2027 						 * @since 3.0.0
  2282 						 * @since 3.0.0
  2028 						 */
  2283 						 */
  2029 						do_action( 'comment_form_top' );
  2284 						do_action( 'comment_form_top' );
  2030 						?>
  2285 						?>
  2033 							/**
  2288 							/**
  2034 							 * Filter the 'logged in' message for the comment form for display.
  2289 							 * Filter the 'logged in' message for the comment form for display.
  2035 							 *
  2290 							 *
  2036 							 * @since 3.0.0
  2291 							 * @since 3.0.0
  2037 							 *
  2292 							 *
  2038 							 * @param string $args['logged_in_as'] The logged-in-as HTML-formatted message.
  2293 							 * @param string $args_logged_in The logged-in-as HTML-formatted message.
  2039 							 * @param array  $commenter            An array containing the comment author's username, email, and URL.
  2294 							 * @param array  $commenter      An array containing the comment author's
  2040 							 * @param string $user_identity        If the commenter is a registered user, the display name, blank otherwise.
  2295 							 *                               username, email, and URL.
       
  2296 							 * @param string $user_identity  If the commenter is a registered user,
       
  2297 							 *                               the display name, blank otherwise.
  2041 							 */
  2298 							 */
  2042 							echo apply_filters( 'comment_form_logged_in', $args['logged_in_as'], $commenter, $user_identity );
  2299 							echo apply_filters( 'comment_form_logged_in', $args['logged_in_as'], $commenter, $user_identity );
  2043 							?>
  2300 							?>
  2044 							<?php
  2301 							<?php
  2045 							/**
  2302 							/**
  2046 							 * Fires after the is_user_logged_in() check in the comment form.
  2303 							 * Fires after the is_user_logged_in() check in the comment form.
  2047 							 *
  2304 							 *
  2048 							 * @since 3.0.0
  2305 							 * @since 3.0.0
  2049 							 *
  2306 							 *
  2050 							 * @param array  $commenter     An array containing the comment author's username, email, and URL.
  2307 							 * @param array  $commenter     An array containing the comment author's
  2051 							 * @param string $user_identity If the commenter is a registered user, the display name, blank otherwise.
  2308 							 *                              username, email, and URL.
       
  2309 							 * @param string $user_identity If the commenter is a registered user,
       
  2310 							 *                              the display name, blank otherwise.
  2052 							 */
  2311 							 */
  2053 							do_action( 'comment_form_logged_in_after', $commenter, $user_identity );
  2312 							do_action( 'comment_form_logged_in_after', $commenter, $user_identity );
  2054 							?>
  2313 							?>
  2055 						<?php else : ?>
  2314 						<?php else : ?>
  2056 							<?php echo $args['comment_notes_before']; ?>
  2315 							<?php echo $args['comment_notes_before']; ?>
  2063 							do_action( 'comment_form_before_fields' );
  2322 							do_action( 'comment_form_before_fields' );
  2064 							foreach ( (array) $args['fields'] as $name => $field ) {
  2323 							foreach ( (array) $args['fields'] as $name => $field ) {
  2065 								/**
  2324 								/**
  2066 								 * Filter a comment form field for display.
  2325 								 * Filter a comment form field for display.
  2067 								 *
  2326 								 *
  2068 								 * The dynamic portion of the filter hook, $name, refers to the name
  2327 								 * The dynamic portion of the filter hook, `$name`, refers to the name
  2069 								 * of the comment form field. Such as 'author', 'email', or 'url'.
  2328 								 * of the comment form field. Such as 'author', 'email', or 'url'.
  2070 								 *
  2329 								 *
  2071 								 * @since 3.0.0
  2330 								 * @since 3.0.0
  2072 								 *
  2331 								 *
  2073 								 * @param string $field The HTML-formatted output of the comment form field.
  2332 								 * @param string $field The HTML-formatted output of the comment form field.
  2086 						/**
  2345 						/**
  2087 						 * Filter the content of the comment textarea field for display.
  2346 						 * Filter the content of the comment textarea field for display.
  2088 						 *
  2347 						 *
  2089 						 * @since 3.0.0
  2348 						 * @since 3.0.0
  2090 						 *
  2349 						 *
  2091 						 * @param string $args['comment_field'] The content of the comment textarea field.
  2350 						 * @param string $args_comment_field The content of the comment textarea field.
  2092 						 */
  2351 						 */
  2093 						echo apply_filters( 'comment_form_field_comment', $args['comment_field'] );
  2352 						echo apply_filters( 'comment_form_field_comment', $args['comment_field'] );
  2094 						?>
  2353 						?>
  2095 						<?php echo $args['comment_notes_after']; ?>
  2354 						<?php echo $args['comment_notes_after']; ?>
  2096 						<p class="form-submit">
  2355 
  2097 							<input name="submit" type="submit" id="<?php echo esc_attr( $args['id_submit'] ); ?>" value="<?php echo esc_attr( $args['label_submit'] ); ?>" />
       
  2098 							<?php comment_id_fields( $post_id ); ?>
       
  2099 						</p>
       
  2100 						<?php
  2356 						<?php
       
  2357 						$submit_button = sprintf(
       
  2358 							$args['submit_button'],
       
  2359 							esc_attr( $args['name_submit'] ),
       
  2360 							esc_attr( $args['id_submit'] ),
       
  2361 							esc_attr( $args['class_submit'] ),
       
  2362 							esc_attr( $args['label_submit'] )
       
  2363 						);
       
  2364 
       
  2365 						/**
       
  2366 						 * Filter the submit button for the comment form to display.
       
  2367 						 *
       
  2368 						 * @since 4.2.0
       
  2369 						 *
       
  2370 						 * @param string $submit_button HTML markup for the submit button.
       
  2371 						 * @param array  $args          Arguments passed to `comment_form()`.
       
  2372 						 */
       
  2373 						$submit_button = apply_filters( 'comment_form_submit_button', $submit_button, $args );
       
  2374 
       
  2375 						$submit_field = sprintf(
       
  2376 							$args['submit_field'],
       
  2377 							$submit_button,
       
  2378 							get_comment_id_fields( $post_id )
       
  2379 						);
       
  2380 
       
  2381 						/**
       
  2382 						 * Filter the submit field for the comment form to display.
       
  2383 						 *
       
  2384 						 * The submit field includes the submit button, hidden fields for the
       
  2385 						 * comment form, and any wrapper markup.
       
  2386 						 *
       
  2387 						 * @since 4.2.0
       
  2388 						 *
       
  2389 						 * @param string $submit_field HTML markup for the submit field.
       
  2390 						 * @param array  $args         Arguments passed to comment_form().
       
  2391 						 */
       
  2392 						echo apply_filters( 'comment_form_submit_field', $submit_field, $args );
       
  2393 
  2101 						/**
  2394 						/**
  2102 						 * Fires at the bottom of the comment form, inside the closing </form> tag.
  2395 						 * Fires at the bottom of the comment form, inside the closing </form> tag.
  2103 						 *
  2396 						 *
  2104 						 * @since 1.5.2
  2397 						 * @since 1.5.0
  2105 						 *
  2398 						 *
  2106 						 * @param int $post_id The post ID.
  2399 						 * @param int $post_id The post ID.
  2107 						 */
  2400 						 */
  2108 						do_action( 'comment_form', $post_id );
  2401 						do_action( 'comment_form', $post_id );
  2109 						?>
  2402 						?>