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