<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[12821] trunk/wp-includes/comment-template.php:
  Add optional comment ID argument to comment template functions.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/12821">12821</a></dd>
<dt>Author</dt> <dd>ryan</dd>
<dt>Date</dt> <dd>2010-01-25 17:34:13 +0000 (Mon, 25 Jan 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add optional comment ID argument to comment template functions. Props filosofo. fixes <a href="http://trac.wordpress.org/ticket/12006">#12006</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpincludescommenttemplatephp">trunk/wp-includes/comment-template.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpincludescommenttemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/comment-template.php (12820 => 12821)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/comment-template.php        2010-01-24 20:50:50 UTC (rev 12820)
+++ trunk/wp-includes/comment-template.php        2010-01-25 17:34:13 UTC (rev 12821)
</span><span class="lines">@@ -17,10 +17,11 @@
</span><span class="cx">  * @since 1.5.0
</span><span class="cx">  * @uses apply_filters() Calls 'get_comment_author' hook on the comment author
</span><span class="cx">  *
</span><ins>+ * @param int $comment_ID The ID of the comment for which to retrieve the author. Optional.
</ins><span class="cx">  * @return string The comment author
</span><span class="cx">  */
</span><del>-function get_comment_author() {
-        global $comment;
</del><ins>+function get_comment_author( $comment_ID = 0 ) {
+        $comment = get_comment( $comment_ID );
</ins><span class="cx">         if ( empty($comment-&gt;comment_author) ) {
</span><span class="cx">                 if (!empty($comment-&gt;user_id)){
</span><span class="cx">                         $user=get_userdata($comment-&gt;user_id);
</span><span class="lines">@@ -39,9 +40,11 @@
</span><span class="cx">  *
</span><span class="cx">  * @since 0.71
</span><span class="cx">  * @uses apply_filters() Calls 'comment_author' on comment author before displaying
</span><ins>+ * 
+ * @param int $comment_ID The ID of the comment for which to print the author. Optional.
</ins><span class="cx">  */
</span><del>-function comment_author() {
-        $author = apply_filters('comment_author', get_comment_author() );
</del><ins>+function comment_author( $comment_ID = 0 ) {
+        $author = apply_filters('comment_author', get_comment_author( $comment_ID ) );
</ins><span class="cx">         echo $author;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -52,10 +55,11 @@
</span><span class="cx">  * @uses apply_filters() Calls the 'get_comment_author_email' hook on the comment author email
</span><span class="cx">  * @uses $comment
</span><span class="cx">  *
</span><ins>+ * @param int $comment_ID The ID of the comment for which to get the author's email.  Optional.
</ins><span class="cx">  * @return string The current comment author's email
</span><span class="cx">  */
</span><del>-function get_comment_author_email() {
-        global $comment;
</del><ins>+function get_comment_author_email( $comment_ID = 0 ) {
+        $comment = get_comment( $comment_ID );
</ins><span class="cx">         return apply_filters('get_comment_author_email', $comment-&gt;comment_author_email);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -70,9 +74,11 @@
</span><span class="cx">  *
</span><span class="cx">  * @since 0.71
</span><span class="cx">  * @uses apply_filters() Calls 'author_email' hook on the author email
</span><ins>+ *
+ * @param int $comment_ID The ID of the comment for which to print the author's email. Optional.
</ins><span class="cx">  */
</span><del>-function comment_author_email() {
-        echo apply_filters('author_email', get_comment_author_email() );
</del><ins>+function comment_author_email( $comment_ID = 0 ) {
+        echo apply_filters('author_email', get_comment_author_email( $comment_ID ) );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><span class="lines">@@ -135,12 +141,13 @@
</span><span class="cx">  * @since 1.5.0
</span><span class="cx">  * @uses apply_filters() Calls 'get_comment_author_link' hook on the complete link HTML or author
</span><span class="cx">  *
</span><ins>+ * @param int $comment_ID The ID of the comment for which to get the author's link.  Optional.
</ins><span class="cx">  * @return string Comment Author name or HTML link for author's URL
</span><span class="cx">  */
</span><del>-function get_comment_author_link() {
</del><ins>+function get_comment_author_link( $comment_ID = 0 ) {
</ins><span class="cx">         /** @todo Only call these functions when they are needed. Include in if... else blocks */
</span><del>-        $url    = get_comment_author_url();
-        $author = get_comment_author();
</del><ins>+        $url    = get_comment_author_url( $comment_ID );
+        $author = get_comment_author( $comment_ID );
</ins><span class="cx"> 
</span><span class="cx">         if ( empty( $url ) || 'http://' == $url )
</span><span class="cx">                 $return = $author;
</span><span class="lines">@@ -154,9 +161,11 @@
</span><span class="cx">  *
</span><span class="cx">  * @since 0.71
</span><span class="cx">  * @see get_comment_author_link() Echos result
</span><ins>+ *
+ * @param int The ID of the comment for which to print the author's link. Optional.
</ins><span class="cx">  */
</span><del>-function comment_author_link() {
-        echo get_comment_author_link();
</del><ins>+function comment_author_link( $comment_ID = 0 ) {
+        echo get_comment_author_link( $comment_ID );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><span class="lines">@@ -166,10 +175,11 @@
</span><span class="cx">  * @uses $comment
</span><span class="cx">  * @uses apply_filters()
</span><span class="cx">  *
</span><del>- * @return unknown
</del><ins>+ * @param int $comment_ID The ID of the comment for which to get the author's IP address. Optional.
+ * @return string The comment author's IP address.
</ins><span class="cx">  */
</span><del>-function get_comment_author_IP() {
-        global $comment;
</del><ins>+function get_comment_author_IP( $comment_ID = 0 ) {
+        $comment = get_comment( $comment_ID );
</ins><span class="cx">         return apply_filters('get_comment_author_IP', $comment-&gt;comment_author_IP);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -178,9 +188,11 @@
</span><span class="cx">  *
</span><span class="cx">  * @since 0.71
</span><span class="cx">  * @see get_comment_author_IP() Echos Result
</span><ins>+ *
+ * @param int $comment_ID The ID of the comment for which to print the author's IP address.  Optional.
</ins><span class="cx">  */
</span><del>-function comment_author_IP() {
-        echo get_comment_author_IP();
</del><ins>+function comment_author_IP( $comment_ID = 0 ) {
+        echo get_comment_author_IP( $comment_ID );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><span class="lines">@@ -189,10 +201,11 @@
</span><span class="cx">  * @since 1.5.0
</span><span class="cx">  * @uses apply_filters() Calls 'get_comment_author_url' hook on the comment author's URL
</span><span class="cx">  *
</span><ins>+ * @param int $comment_ID The ID of the comment for which to get the author's URL.  Optional.
</ins><span class="cx">  * @return string
</span><span class="cx">  */
</span><del>-function get_comment_author_url() {
-        global $comment;
</del><ins>+function get_comment_author_url( $comment_ID = 0 ) {
+        $comment = get_comment( $comment_ID );
</ins><span class="cx">         $url = ('http://' == $comment-&gt;comment_author_url) ? '' : $comment-&gt;comment_author_url;
</span><span class="cx">         $url = esc_url( $url, array('http', 'https') );
</span><span class="cx">         return apply_filters('get_comment_author_url', $url);
</span><span class="lines">@@ -204,9 +217,11 @@
</span><span class="cx">  * @since 0.71
</span><span class="cx">  * @uses apply_filters()
</span><span class="cx">  * @uses get_comment_author_url() Retrieves the comment author's URL
</span><ins>+ *
+ * @param int $comment_ID The ID of the comment for which to print the author's URL. Optional.
</ins><span class="cx">  */
</span><del>-function comment_author_url() {
-        echo apply_filters('comment_url', get_comment_author_url());
</del><ins>+function comment_author_url( $comment_ID = 0 ) {
+        echo apply_filters('comment_url', get_comment_author_url( $comment_ID ));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><span class="lines">@@ -351,10 +366,11 @@
</span><span class="cx">  * @uses $comment
</span><span class="cx">  *
</span><span class="cx">  * @param string $d The format of the date (defaults to user's config)
</span><ins>+ * @param int $comment_ID The ID of the comment for which to get the date. Optional.
</ins><span class="cx">  * @return string The comment's date
</span><span class="cx">  */
</span><del>-function get_comment_date( $d = '' ) {
-        global $comment;
</del><ins>+function get_comment_date( $d = '', $comment_ID = 0 ) {
+        $comment = get_comment( $comment_ID );
</ins><span class="cx">         if ( '' == $d )
</span><span class="cx">                 $date = mysql2date(get_option('date_format'), $comment-&gt;comment_date);
</span><span class="cx">         else
</span><span class="lines">@@ -368,9 +384,10 @@
</span><span class="cx">  * @since 0.71
</span><span class="cx">  *
</span><span class="cx">  * @param string $d The format of the date (defaults to user's config)
</span><ins>+ * @param int $comment_ID The ID of the comment for which to print the date.  Optional.
</ins><span class="cx">  */
</span><del>-function comment_date( $d = '' ) {
-        echo get_comment_date( $d );
</del><ins>+function comment_date( $d = '', $comment_ID = 0 ) {
+        echo get_comment_date( $d, $comment_ID );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><span class="lines">@@ -384,10 +401,11 @@
</span><span class="cx">  * @uses $comment
</span><span class="cx">  * @uses apply_filters() Calls 'get_comment_excerpt' on truncated comment
</span><span class="cx">  *
</span><ins>+ * @param int $comment_ID The ID of the comment for which to get the excerpt. Optional.
</ins><span class="cx">  * @return string The maybe truncated comment with 20 words or less
</span><span class="cx">  */
</span><del>-function get_comment_excerpt() {
-        global $comment;
</del><ins>+function get_comment_excerpt( $comment_ID = 0 ) {
+        $comment = get_comment( $comment_ID );
</ins><span class="cx">         $comment_text = strip_tags($comment-&gt;comment_content);
</span><span class="cx">         $blah = explode(' ', $comment_text);
</span><span class="cx">         if (count($blah) &gt; 20) {
</span><span class="lines">@@ -410,8 +428,10 @@
</span><span class="cx">  *
</span><span class="cx">  * @since 1.2.0
</span><span class="cx">  * @uses apply_filters() Calls 'comment_excerpt' hook before displaying excerpt
</span><ins>+ *
+ * @param int $comment_ID The ID of the comment for which to print the excerpt. Optional.
</ins><span class="cx">  */
</span><del>-function comment_excerpt() {
</del><ins>+function comment_excerpt( $comment_ID = 0 ) {
</ins><span class="cx">         echo apply_filters('comment_excerpt', get_comment_excerpt() );
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -575,10 +595,11 @@
</span><span class="cx">  * @since 1.5.0
</span><span class="cx">  * @uses $comment
</span><span class="cx">  *
</span><ins>+ * @param int $comment_ID The ID of the comment for which to get the text. Optional.
</ins><span class="cx">  * @return string The comment content
</span><span class="cx">  */
</span><del>-function get_comment_text() {
-        global $comment;
</del><ins>+function get_comment_text( $comment_ID = 0 ) {
+        $comment = get_comment( $comment_ID );
</ins><span class="cx">         return apply_filters('get_comment_text', $comment-&gt;comment_content);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -588,8 +609,10 @@
</span><span class="cx">  * @since 0.71
</span><span class="cx">  * @uses apply_filters() Passes the comment content through the 'comment_text' hook before display
</span><span class="cx">  * @uses get_comment_text() Gets the comment content
</span><ins>+ *
+ * @param int $comment_ID The ID of the comment for which to print the text. Optional.
</ins><span class="cx">  */
</span><del>-function comment_text() {
</del><ins>+function comment_text( $comment_ID = 0 ) {
</ins><span class="cx">         echo apply_filters('comment_text', get_comment_text() );
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -633,11 +656,11 @@
</span><span class="cx">  * @uses $comment
</span><span class="cx">  * @uses apply_filters() Calls the 'get_comment_type' hook on the comment type
</span><span class="cx">  *
</span><ins>+ * @param int $comment_ID The ID of the comment for which to get the type. Optional.
</ins><span class="cx">  * @return string The comment type
</span><span class="cx">  */
</span><del>-function get_comment_type() {
-        global $comment;
-
</del><ins>+function get_comment_type( $comment_ID = 0 ) {
+        $comment = get_comment( $comment_ID );
</ins><span class="cx">         if ( '' == $comment-&gt;comment_type )
</span><span class="cx">                 $comment-&gt;comment_type = 'comment';
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>