get_comment_date

Definition:
function get_comment_date( $d = '', $comment_ID = 0 ) {}

Retrieve the comment date of the current comment.

Parameters

  • string $d: The format of the date (defaults to user’s config)
  • int $comment_ID: The ID of the comment for which to get the date. Optional.

Return values

returns:The comment’s date

Defined filters

  • get_comment_date
    apply_filters('get_comment_date', $date, $d)

Source code

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

		$date = mysql2date($d, $comment->comment_date);

	return apply_filters('get_comment_date', $date, $d);

}

1310

get_comment_count

Definition:
function get_comment_count( $post_id = 0 ) {}

The amount of comments in a post or total comments.
A lot like wp_count_comments(), in that they both return comment stats (albeit with different types). The wp_count_comments() actual caches, but this function does not.

Parameters

  • int $post_id: Optional. Comment amount in post if > 0, else total comments blog wide.

Return values

returns:The amount of spam, approved, awaiting moderation, and total comments.

Source code

function get_comment_count( $post_id = 0 ) {

	global $wpdb;



	$post_id = (int) $post_id;



	$where = '';

	if ( $post_id > 0 ) {

		$where = $wpdb->prepare("WHERE comment_post_ID = %d", $post_id);

	}



	$totals = (array) $wpdb->get_results("

		SELECT comment_approved, COUNT( * ) AS total

		FROM {$wpdb->comments}

1308

get_comment_class

Definition:
function get_comment_class( $class = '', $comment_id = null, $post_id = null ) {}

Returns the classes for the comment div as an array

Parameters

  • string|array $class: One or more classes to add to the class list
  • int $comment_id: An optional comment ID
  • int $post_id: An optional post ID

Return values

returns:Array of classes

Defined filters

  • comment_class
    apply_filters('comment_class', $classes, $class, $comment_id, $post_id)

Source code

function get_comment_class( $class = '', $comment_id = null, $post_id = null ) {

	global $comment_alt, $comment_depth, $comment_thread_alt;



	$comment = get_comment($comment_id);



	$classes = array();



	// Get the comment type (comment, trackback),

	$classes[] = ( empty( $comment->comment_type ) ) ? 'comment' : $comment->comment_type;



	// If the comment author has an id (registered), then print the log in name

	if ( $comment->user_id > 0 && $user = get_userdata($comment->user_id) ) {

		// For all registered users, 'byuser'

		$classes[] = 'byuser';

		$classes[] = 'comment-author-' . sanitize_html_class($user->user_nicename, $comment->user_id);

		// For comment authors who are the author of the post

		if ( $post = get_post($post_id) ) {

			if ( $comment->user_id === $post->post_author )

				$classes[] = 'bypostauthor';

		}

	}



	if ( empty($comment_alt) )

		$comment_alt = 0;

	if ( empty($comment_depth) )

		$comment_depth = 1;

	if ( empty($comment_thread_alt) )

		$comment_thread_alt = 0;



	if ( $comment_alt % 2 ) {

		$classes[] = 'odd';

		$classes[] = 'alt';

	} else {

		$classes[] = 'even';

	}



	$comment_alt++;



	// Alt for top-level comments

	if ( 1 == $comment_depth ) {

		if ( $comment_thread_alt % 2 ) {

			$classes[] = 'thread-odd';

			$classes[] = 'thread-alt';

		} else {

			$classes[] = 'thread-even';

		}

		$comment_thread_alt++;

	}



	$classes[] = "depth-$comment_depth";



	if ( !empty($class) ) {

		if ( !is_array( $class ) )

			$class = preg_split('#\s+#', $class);

		$classes = array_merge($classes, $class);

	}



	$classes = array_map('esc_attr', $classes);



	return apply_filters('comment_class', $classes, $class, $comment_id, $post_id);

}

1306

get_comment_author_url_link

Definition:
function get_comment_author_url_link( $linktext = '', $before = '', $after = '' ) {}

Retrieves the HTML link of the url of the author of the current comment.
$linktext parameter is only used if the URL does not exist for the comment author. If the URL does exist then the URL will be used and the $linktext will be ignored.

Parameters

  • string $linktext: The text to display instead of the comment author’s email address
  • string $before: The text or HTML to display before the email link.
  • string $after: The text or HTML to display after the email link.

Return values

returns:The HTML link between the $before and $after parameters

Defined filters

  • get_comment_author_url_link
    apply_filters('get_comment_author_url_link', $return)

Source code

function get_comment_author_url_link( $linktext = '', $before = '', $after = '' ) {

	$url = get_comment_author_url();

	$display = ($linktext != '') ? $linktext : $url;

	$display = str_replace( 'http://www.', '', $display );

	$display = str_replace( 'http://', '', $display );

	if ( '/' == substr($display, -1) )

		$display = substr($display, 0, -1);

	$return = "$before<a href='$url' rel='external'>$display</a>$after";

	return apply_filters('get_comment_author_url_link', $return);

}

1304

get_comment_author_url

Definition:
function get_comment_author_url( $comment_ID = 0 ) {}

Retrieve the url of the author of the current comment.

Parameters

  • int $comment_ID: The ID of the comment for which to get the author’s URL. Optional.

Defined filters

  • get_comment_author_url
    apply_filters('get_comment_author_url', $url)

Source code

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);

}

1302