X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/98a4d31e52bd56c908617df281730bd4ba58d110..a5227bf01edbe6660486c9f5c0f0ed7b7fea3130:/wp-includes/comment-template.php
diff --git a/wp-includes/comment-template.php b/wp-includes/comment-template.php
index e87801b6..d3ee1906 100644
--- a/wp-includes/comment-template.php
+++ b/wp-includes/comment-template.php
@@ -17,10 +17,11 @@
* @since 1.5.0
* @uses apply_filters() Calls 'get_comment_author' hook on the comment author
*
+ * @param int $comment_ID The ID of the comment for which to retrieve the author. Optional.
* @return string The comment author
*/
-function get_comment_author() {
- global $comment;
+function get_comment_author( $comment_ID = 0 ) {
+ $comment = get_comment( $comment_ID );
if ( empty($comment->comment_author) ) {
if (!empty($comment->user_id)){
$user=get_userdata($comment->user_id);
@@ -39,9 +40,11 @@ function get_comment_author() {
*
* @since 0.71
* @uses apply_filters() Calls 'comment_author' on comment author before displaying
+ *
+ * @param int $comment_ID The ID of the comment for which to print the author. Optional.
*/
-function comment_author() {
- $author = apply_filters('comment_author', get_comment_author() );
+function comment_author( $comment_ID = 0 ) {
+ $author = apply_filters('comment_author', get_comment_author( $comment_ID ) );
echo $author;
}
@@ -52,10 +55,11 @@ function comment_author() {
* @uses apply_filters() Calls the 'get_comment_author_email' hook on the comment author email
* @uses $comment
*
+ * @param int $comment_ID The ID of the comment for which to get the author's email. Optional.
* @return string The current comment author's email
*/
-function get_comment_author_email() {
- global $comment;
+function get_comment_author_email( $comment_ID = 0 ) {
+ $comment = get_comment( $comment_ID );
return apply_filters('get_comment_author_email', $comment->comment_author_email);
}
@@ -70,9 +74,11 @@ function get_comment_author_email() {
*
* @since 0.71
* @uses apply_filters() Calls 'author_email' hook on the author email
+ *
+ * @param int $comment_ID The ID of the comment for which to print the author's email. Optional.
*/
-function comment_author_email() {
- echo apply_filters('author_email', get_comment_author_email() );
+function comment_author_email( $comment_ID = 0 ) {
+ echo apply_filters('author_email', get_comment_author_email( $comment_ID ) );
}
/**
@@ -135,12 +141,13 @@ function get_comment_author_email_link($linktext='', $before='', $after='') {
* @since 1.5.0
* @uses apply_filters() Calls 'get_comment_author_link' hook on the complete link HTML or author
*
+ * @param int $comment_ID The ID of the comment for which to get the author's link. Optional.
* @return string Comment Author name or HTML link for author's URL
*/
-function get_comment_author_link() {
+function get_comment_author_link( $comment_ID = 0 ) {
/** @todo Only call these functions when they are needed. Include in if... else blocks */
- $url = get_comment_author_url();
- $author = get_comment_author();
+ $url = get_comment_author_url( $comment_ID );
+ $author = get_comment_author( $comment_ID );
if ( empty( $url ) || 'http://' == $url )
$return = $author;
@@ -153,10 +160,12 @@ function get_comment_author_link() {
* Display the html link to the url of the author of the current comment.
*
* @since 0.71
- * @see get_comment_author_link() Echos result
+ * @see get_comment_author_link() Echoes result
+ *
+ * @param int The ID of the comment for which to print the author's link. Optional.
*/
-function comment_author_link() {
- echo get_comment_author_link();
+function comment_author_link( $comment_ID = 0 ) {
+ echo get_comment_author_link( $comment_ID );
}
/**
@@ -166,10 +175,11 @@ function comment_author_link() {
* @uses $comment
* @uses apply_filters()
*
- * @return unknown
+ * @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.
*/
-function get_comment_author_IP() {
- global $comment;
+function get_comment_author_IP( $comment_ID = 0 ) {
+ $comment = get_comment( $comment_ID );
return apply_filters('get_comment_author_IP', $comment->comment_author_IP);
}
@@ -177,10 +187,12 @@ function get_comment_author_IP() {
* Display the IP address of the author of the current comment.
*
* @since 0.71
- * @see get_comment_author_IP() Echos Result
+ * @see get_comment_author_IP() Echoes Result
+ *
+ * @param int $comment_ID The ID of the comment for which to print the author's IP address. Optional.
*/
-function comment_author_IP() {
- echo get_comment_author_IP();
+function comment_author_IP( $comment_ID = 0 ) {
+ echo get_comment_author_IP( $comment_ID );
}
/**
@@ -189,10 +201,11 @@ function comment_author_IP() {
* @since 1.5.0
* @uses apply_filters() Calls 'get_comment_author_url' hook on the comment author's URL
*
+ * @param int $comment_ID The ID of the comment for which to get the author's URL. Optional.
* @return string
*/
-function get_comment_author_url() {
- global $comment;
+function get_comment_author_url( $comment_ID = 0 ) {
+ $comment = get_comment( $comment_ID );
$url = ('http://' == $comment->comment_author_url) ? '' : $comment->comment_author_url;
$url = esc_url( $url, array('http', 'https') );
return apply_filters('get_comment_author_url', $url);
@@ -204,9 +217,11 @@ function get_comment_author_url() {
* @since 0.71
* @uses apply_filters()
* @uses get_comment_author_url() Retrieves the comment author's URL
+ *
+ * @param int $comment_ID The ID of the comment for which to print the author's URL. Optional.
*/
-function comment_author_url() {
- echo apply_filters('comment_url', get_comment_author_url());
+function comment_author_url( $comment_ID = 0 ) {
+ echo apply_filters('comment_url', get_comment_author_url( $comment_ID ));
}
/**
@@ -242,7 +257,7 @@ function get_comment_author_url_link( $linktext = '', $before = '', $after = ''
* Displays the HTML link of the url of the author of the current comment.
*
* @since 0.71
- * @see get_comment_author_url_link() Echos result
+ * @see get_comment_author_url_link() Echoes result
*
* @param string $linktext The text to display instead of the comment author's email address
* @param string $before The text or HTML to display before the email link.
@@ -338,6 +353,8 @@ function get_comment_class( $class = '', $comment_id = null, $post_id = null ) {
$classes = array_merge($classes, $class);
}
+ $classes = array_map('esc_attr', $classes);
+
return apply_filters('comment_class', $classes, $class, $comment_id, $post_id);
}
@@ -349,10 +366,11 @@ function get_comment_class( $class = '', $comment_id = null, $post_id = null ) {
* @uses $comment
*
* @param string $d The format of the date (defaults to user's config)
+ * @param int $comment_ID The ID of the comment for which to get the date. Optional.
* @return string The comment's date
*/
-function get_comment_date( $d = '' ) {
- global $comment;
+function get_comment_date( $d = '', $comment_ID = 0 ) {
+ $comment = get_comment( $comment_ID );
if ( '' == $d )
$date = mysql2date(get_option('date_format'), $comment->comment_date);
else
@@ -366,9 +384,10 @@ function get_comment_date( $d = '' ) {
* @since 0.71
*
* @param string $d The format of the date (defaults to user's config)
+ * @param int $comment_ID The ID of the comment for which to print the date. Optional.
*/
-function comment_date( $d = '' ) {
- echo get_comment_date( $d );
+function comment_date( $d = '', $comment_ID = 0 ) {
+ echo get_comment_date( $d, $comment_ID );
}
/**
@@ -382,10 +401,11 @@ function comment_date( $d = '' ) {
* @uses $comment
* @uses apply_filters() Calls 'get_comment_excerpt' on truncated comment
*
+ * @param int $comment_ID The ID of the comment for which to get the excerpt. Optional.
* @return string The maybe truncated comment with 20 words or less
*/
-function get_comment_excerpt() {
- global $comment;
+function get_comment_excerpt( $comment_ID = 0 ) {
+ $comment = get_comment( $comment_ID );
$comment_text = strip_tags($comment->comment_content);
$blah = explode(' ', $comment_text);
if (count($blah) > 20) {
@@ -408,9 +428,11 @@ function get_comment_excerpt() {
*
* @since 1.2.0
* @uses apply_filters() Calls 'comment_excerpt' hook before displaying excerpt
+ *
+ * @param int $comment_ID The ID of the comment for which to print the excerpt. Optional.
*/
-function comment_excerpt() {
- echo apply_filters('comment_excerpt', get_comment_excerpt() );
+function comment_excerpt( $comment_ID = 0 ) {
+ echo apply_filters('comment_excerpt', get_comment_excerpt($comment_ID) );
}
/**
@@ -431,7 +453,7 @@ function get_comment_ID() {
* Displays the comment id of the current comment.
*
* @since 0.71
- * @see get_comment_ID() Echos Result
+ * @see get_comment_ID() Echoes Result
*/
function comment_ID() {
echo get_comment_ID();
@@ -490,10 +512,11 @@ function get_comment_link( $comment = null, $args = array() ) {
*
* @since 1.5.0
*
+ * @param int $post_id Optional post id
* @return string The link to the comments
*/
-function get_comments_link() {
- return get_permalink() . '#comments';
+function get_comments_link($post_id = 0) {
+ return get_permalink($post_id) . '#comments';
}
/**
@@ -502,9 +525,13 @@ function get_comments_link() {
* @since 0.71
*
* @param string $deprecated Not Used
- * @param bool $deprecated Not Used
+ * @param bool $deprecated_2 Not Used
*/
-function comments_link( $deprecated = '', $deprecated = '' ) {
+function comments_link( $deprecated = '', $deprecated_2 = '' ) {
+ if ( !empty( $deprecated ) )
+ _deprecated_argument( __FUNCTION__, '0.72' );
+ if ( !empty( $deprecated_2 ) )
+ _deprecated_argument( __FUNCTION__, '1.3' );
echo get_comments_link();
}
@@ -530,7 +557,7 @@ function get_comments_number( $post_id = 0 ) {
else
$count = $post->comment_count;
- return apply_filters('get_comments_number', $count);
+ return apply_filters('get_comments_number', $count, $post_id);
}
/**
@@ -547,6 +574,10 @@ function get_comments_number( $post_id = 0 ) {
*/
function comments_number( $zero = false, $one = false, $more = false, $deprecated = '' ) {
global $id;
+
+ if ( !empty( $deprecated ) )
+ _deprecated_argument( __FUNCTION__, '1.3' );
+
$number = get_comments_number($id);
if ( $number > 1 )
@@ -565,10 +596,11 @@ function comments_number( $zero = false, $one = false, $more = false, $deprecate
* @since 1.5.0
* @uses $comment
*
+ * @param int $comment_ID The ID of the comment for which to get the text. Optional.
* @return string The comment content
*/
-function get_comment_text() {
- global $comment;
+function get_comment_text( $comment_ID = 0 ) {
+ $comment = get_comment( $comment_ID );
return apply_filters('get_comment_text', $comment->comment_content);
}
@@ -578,8 +610,10 @@ function get_comment_text() {
* @since 0.71
* @uses apply_filters() Passes the comment content through the 'comment_text' hook before display
* @uses get_comment_text() Gets the comment content
+ *
+ * @param int $comment_ID The ID of the comment for which to print the text. Optional.
*/
-function comment_text() {
+function comment_text( $comment_ID = 0 ) {
echo apply_filters('comment_text', get_comment_text() );
}
@@ -597,12 +631,12 @@ function comment_text() {
*/
function get_comment_time( $d = '', $gmt = false, $translate = true ) {
global $comment;
- $comment_date = $gmt? $comment->comment_date_gmt : $comment->comment_date;
+ $comment_date = $gmt ? $comment->comment_date_gmt : $comment->comment_date;
if ( '' == $d )
$date = mysql2date(get_option('time_format'), $comment_date, $translate);
else
$date = mysql2date($d, $comment_date, $translate);
- return apply_filters('get_comment_time', $date, $d, $gmt);
+ return apply_filters('get_comment_time', $date, $d, $gmt, $translate);
}
/**
@@ -623,11 +657,11 @@ function comment_time( $d = '' ) {
* @uses $comment
* @uses apply_filters() Calls the 'get_comment_type' hook on the comment type
*
+ * @param int $comment_ID The ID of the comment for which to get the type. Optional.
* @return string The comment type
*/
-function get_comment_type() {
- global $comment;
-
+function get_comment_type( $comment_ID = 0 ) {
+ $comment = get_comment( $comment_ID );
if ( '' == $comment->comment_type )
$comment->comment_type = 'comment';
@@ -689,36 +723,43 @@ function get_trackback_url() {
* @since 0.71
* @uses get_trackback_url() Gets the trackback url for the current post
*
- * @param bool $deprecated Remove backwards compat in 2.5
+ * @param bool $deprecated_echo Remove backwards compat in 2.5
* @return void|string Should only be used to echo the trackback URL, use get_trackback_url() for the result instead.
*/
-function trackback_url($deprecated = true) {
- if ($deprecated) echo get_trackback_url();
- else return get_trackback_url();
+function trackback_url( $deprecated_echo = true ) {
+ if ( $deprecated_echo !== true )
+ _deprecated_argument( __FUNCTION__, '2.5', __('Use get_trackback_url()
instead if you do not want the value echoed.') );
+ if ( $deprecated_echo )
+ echo get_trackback_url();
+ else
+ return get_trackback_url();
}
/**
* Generates and displays the RDF for the trackback information of current post.
*
+ * Deprecated in 3.0.0, and restored in 3.0.1.
+ *
* @since 0.71
*
* @param int $deprecated Not used (Was $timezone = 0)
*/
-function trackback_rdf($deprecated = '') {
- if (stripos($_SERVER['HTTP_USER_AGENT'], 'W3C_Validator') === false) {
- echo '
' . ( $req ? '*' : '' ) . + '
', + 'url' => '' . + '
', + ); + + $required_text = sprintf( ' ' . __('Required fields are marked %s'), '*' ); + $defaults = array( + 'fields' => apply_filters( 'comment_form_default_fields', $fields ), + 'comment_field' => '', + 'must_log_in' => '' . sprintf( __( 'You must be logged in to post a comment.' ), wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '
', + 'logged_in_as' => '' . sprintf( __( 'Logged in as %2$s. Log out?' ), admin_url( 'profile.php' ), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '
', + 'comment_notes_before' => '' . __( 'Your email address will not be published.' ) . ( $req ? $required_text : '' ) . '
', + 'comment_notes_after' => ' ', + 'id_form' => 'commentform', + 'id_submit' => 'submit', + 'title_reply' => __( 'Leave a Reply' ), + 'title_reply_to' => __( 'Leave a Reply to %s' ), + 'cancel_reply_link' => __( 'Cancel reply' ), + 'label_submit' => __( 'Post Comment' ), + ); + + $args = wp_parse_args( $args, apply_filters( 'comment_form_defaults', $defaults ) ); + + ?> + + +
-