wp/wp-includes/comment-template.php
author ymh <ymh.work@gmail.com>
Mon, 14 Oct 2019 17:39:30 +0200
changeset 7 cf61fcea0001
parent 5 5e2f62d02dcd
child 9 177826044cd9
permissions -rw-r--r--
resynchronize code repo with production
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
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    18
 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    20
 * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to retrieve the author.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    21
 *									 Default current comment.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
 * @return string The comment author
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
function get_comment_author( $comment_ID = 0 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
	$comment = get_comment( $comment_ID );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    27
	if ( empty( $comment->comment_author ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    28
		if ( $comment->user_id && $user = get_userdata( $comment->user_id ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    29
			$author = $user->display_name;
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 = __('Anonymous');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    32
	} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    33
		$author = $comment->comment_author;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    34
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    35
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    36
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    37
	 * Filters the returned comment author name.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    38
	 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    39
	 * @since 1.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    40
	 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    41
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    42
	 * @param string     $author     The comment author's username.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    43
	 * @param int        $comment_ID The comment ID.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    44
	 * @param WP_Comment $comment    The comment object.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    45
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    46
	return apply_filters( 'get_comment_author', $author, $comment->comment_ID, $comment );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    47
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    48
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    49
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    50
 * Displays the author of the current comment.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    51
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    52
 * @since 0.71
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    53
 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    54
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    55
 * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    56
 *									 Default current comment.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    57
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    58
function comment_author( $comment_ID = 0 ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    59
	$comment = get_comment( $comment_ID );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    60
	$author  = get_comment_author( $comment );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    61
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    62
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    63
	 * Filters the comment author's name for display.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    64
	 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    65
	 * @since 1.2.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    66
	 * @since 4.1.0 The `$comment_ID` parameter was added.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    67
	 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    68
	 * @param string $author     The comment author's username.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    69
	 * @param int    $comment_ID The comment ID.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    70
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    71
	echo apply_filters( 'comment_author', $author, $comment->comment_ID );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    72
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    73
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    74
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    75
 * Retrieve the email of the author of the current comment.
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.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    78
 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    79
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    80
 * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to get the author's email.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    81
 *									 Default current comment.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    82
 * @return string The current comment author's email
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    83
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    84
function get_comment_author_email( $comment_ID = 0 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    85
	$comment = get_comment( $comment_ID );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    86
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    87
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    88
	 * Filters the comment author's returned email address.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    89
	 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    90
	 * @since 1.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    91
	 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    92
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    93
	 * @param string     $comment_author_email The comment author's email address.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    94
	 * @param int        $comment_ID           The comment ID.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    95
	 * @param WP_Comment $comment              The comment object.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    96
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    97
	return apply_filters( 'get_comment_author_email', $comment->comment_author_email, $comment->comment_ID, $comment );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    98
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    99
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   100
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   101
 * Display the email of the author of the current global $comment.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   102
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   103
 * Care should be taken to protect the email address and assure that email
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   104
 * harvesters do not capture your commentors' email address. Most assume that
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   105
 * their email address will not appear in raw form on the site. Doing so will
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   106
 * enable anyone, including those that people don't want to get the email
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   107
 * address and use it for their own means good and bad.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   108
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   109
 * @since 0.71
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   110
 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   111
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   112
 * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author's email.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   113
 *									 Default current comment.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   114
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   115
function comment_author_email( $comment_ID = 0 ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   116
	$comment      = get_comment( $comment_ID );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   117
	$author_email = get_comment_author_email( $comment );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   118
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   119
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   120
	 * Filters the comment author's email for display.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   121
	 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   122
	 * @since 1.2.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   123
	 * @since 4.1.0 The `$comment_ID` parameter was added.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   124
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   125
	 * @param string $author_email The comment author's email address.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   126
	 * @param int    $comment_ID   The comment ID.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   127
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   128
	echo apply_filters( 'author_email', $author_email, $comment->comment_ID );
0
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
 * Display 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
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   136
 * their email address will not appear in raw form on the site. Doing so will
0
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
 * @since 0.71
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   141
 * @since 4.6.0 Added the `$comment` parameter.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   142
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   143
 * @param string         $linktext Optional. Text to display instead of the comment author's email address.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   144
 *                                 Default empty.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   145
 * @param string         $before   Optional. Text or HTML to display before the email link. Default empty.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   146
 * @param string         $after    Optional. Text or HTML to display after the email link. Default empty.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   147
 * @param int|WP_Comment $comment  Optional. Comment ID or WP_Comment object. Default is the current comment.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   148
 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   149
function comment_author_email_link( $linktext = '', $before = '', $after = '', $comment = null ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   150
	if ( $link = get_comment_author_email_link( $linktext, $before, $after, $comment ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   151
		echo $link;
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   152
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   153
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   154
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   155
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   156
 * Return the html email link to the author of the current comment.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   157
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   158
 * Care should be taken to protect the email address and assure that email
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   159
 * harvesters do not capture your commentors' email address. Most assume that
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   160
 * their email address will not appear in raw form on the site. Doing so will
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   161
 * enable anyone, including those that people don't want to get the email
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   162
 * address and use it for their own means good and bad.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   163
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   164
 * @since 2.7.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   165
 * @since 4.6.0 Added the `$comment` parameter.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   166
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   167
 * @param string         $linktext Optional. Text to display instead of the comment author's email address.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   168
 *                                 Default empty.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   169
 * @param string         $before   Optional. Text or HTML to display before the email link. Default empty.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   170
 * @param string         $after    Optional. Text or HTML to display after the email link. Default empty.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   171
 * @param int|WP_Comment $comment  Optional. Comment ID or WP_Comment object. Default is the current comment.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   172
 * @return string HTML markup for the comment author email link. By default, the email address is obfuscated
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   173
 *                via the {@see 'comment_email'} filter with antispambot().
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   174
 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   175
function get_comment_author_email_link( $linktext = '', $before = '', $after = '', $comment = null ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   176
	$comment = get_comment( $comment );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   177
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   178
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   179
	 * Filters the comment author's email for display.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   180
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   181
	 * Care should be taken to protect the email address and assure that email
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   182
	 * harvesters do not capture your commenter's email address.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   183
	 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   184
	 * @since 1.2.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   185
	 * @since 4.1.0 The `$comment` parameter was added.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   186
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   187
	 * @param string     $comment_author_email The comment author's email address.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   188
	 * @param WP_Comment $comment              The comment object.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   189
	 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   190
	$email = apply_filters( 'comment_email', $comment->comment_author_email, $comment );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   191
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   192
	if ((!empty($email)) && ($email != '@')) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   193
	$display = ($linktext != '') ? $linktext : $email;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   194
		$return  = $before;
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   195
		$return .= sprintf( '<a href="%1$s">%2$s</a>', esc_url( 'mailto:' . $email ), esc_html( $display ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   196
	 	$return .= $after;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   197
		return $return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   198
	} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   199
		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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   204
 * 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
   205
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   206
 * Both get_comment_author_url() and get_comment_author() rely on get_comment(),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   207
 * 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
   208
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   209
 * @since 1.5.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   210
 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   211
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   212
 * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to get the author's link.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   213
 *									 Default current comment.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   214
 * @return string The comment author name or HTML link for author's URL.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   215
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   216
function get_comment_author_link( $comment_ID = 0 ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   217
	$comment = get_comment( $comment_ID );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   218
	$url     = get_comment_author_url( $comment );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   219
	$author  = get_comment_author( $comment );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   220
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   221
	if ( empty( $url ) || 'http://' == $url )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   222
		$return = $author;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   223
	else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   224
		$return = "<a href='$url' rel='external nofollow' class='url'>$author</a>";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   225
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   226
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   227
	 * Filters the comment author's link for display.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   228
	 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   229
	 * @since 1.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   230
	 * @since 4.1.0 The `$author` and `$comment_ID` parameters were added.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   231
	 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   232
	 * @param string $return     The HTML-formatted comment author link.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   233
	 *                           Empty for an invalid URL.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   234
	 * @param string $author     The comment author's username.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   235
	 * @param int    $comment_ID The comment ID.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   236
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   237
	return apply_filters( 'get_comment_author_link', $return, $author, $comment->comment_ID );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   238
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   239
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   240
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   241
 * 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
   242
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   243
 * @since 0.71
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   244
 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   245
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   246
 * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author's link.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   247
 *									 Default current comment.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   248
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   249
function comment_author_link( $comment_ID = 0 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   250
	echo get_comment_author_link( $comment_ID );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   251
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   252
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   253
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   254
 * Retrieve the IP address of the author of the current comment.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   255
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   256
 * @since 1.5.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   257
 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   258
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   259
 * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to get the author's IP address.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   260
 *									 Default current comment.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   261
 * @return string Comment author's IP address.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   262
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   263
function get_comment_author_IP( $comment_ID = 0 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   264
	$comment = get_comment( $comment_ID );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   265
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   266
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   267
	 * Filters the comment author's returned IP address.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   268
	 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   269
	 * @since 1.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   270
	 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   271
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   272
	 * @param string     $comment_author_IP The comment author's IP address.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   273
	 * @param int        $comment_ID        The comment ID.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   274
	 * @param WP_Comment $comment           The comment object.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   275
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   276
	return apply_filters( 'get_comment_author_IP', $comment->comment_author_IP, $comment->comment_ID, $comment );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   277
}
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
 * Display the IP address of the author of the current comment.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   281
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   282
 * @since 0.71
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   283
 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   284
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   285
 * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author's IP address.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   286
 *									 Default current comment.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   287
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   288
function comment_author_IP( $comment_ID = 0 ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   289
	echo esc_html( get_comment_author_IP( $comment_ID ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   290
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   291
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   292
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   293
 * Retrieve the url of the author of the current comment.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   294
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   295
 * @since 1.5.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   296
 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   297
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   298
 * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to get the author's URL.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   299
 *									 Default current comment.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   300
 * @return string Comment author URL.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   301
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   302
function get_comment_author_url( $comment_ID = 0 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   303
	$comment = get_comment( $comment_ID );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   304
	$url = '';
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   305
	$id = 0;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   306
	if ( ! empty( $comment ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   307
		$author_url = ( 'http://' == $comment->comment_author_url ) ? '' : $comment->comment_author_url;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   308
		$url = esc_url( $author_url, array( 'http', 'https' ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   309
		$id = $comment->comment_ID;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   310
	}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   311
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   312
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   313
	 * Filters the comment author's URL.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   314
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   315
	 * @since 1.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   316
	 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   317
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   318
	 * @param string     $url        The comment author's URL.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   319
	 * @param int        $comment_ID The comment ID.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   320
	 * @param WP_Comment $comment    The comment object.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   321
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   322
	return apply_filters( 'get_comment_author_url', $url, $id, $comment );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   323
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   324
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   325
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   326
 * Display the url of the author of the current comment.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   327
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   328
 * @since 0.71
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   329
 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   330
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   331
 * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author's URL.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   332
 *									 Default current comment.
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
function comment_author_url( $comment_ID = 0 ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   335
	$comment    = get_comment( $comment_ID );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   336
	$author_url = get_comment_author_url( $comment );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   337
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   338
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   339
	 * Filters the comment author's URL for display.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   340
	 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   341
	 * @since 1.2.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   342
	 * @since 4.1.0 The `$comment_ID` parameter was added.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   343
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   344
	 * @param string $author_url The comment author's URL.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   345
	 * @param int    $comment_ID The comment ID.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   346
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   347
	echo apply_filters( 'comment_url', $author_url, $comment->comment_ID );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   348
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   349
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   350
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   351
 * 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
   352
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   353
 * $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
   354
 * 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
   355
 * will be ignored.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   356
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   357
 * Encapsulate the HTML link between the $before and $after. So it will appear
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   358
 * in the order of $before, link, and finally $after.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   359
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   360
 * @since 1.5.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   361
 * @since 4.6.0 Added the `$comment` parameter.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   362
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   363
 * @param string         $linktext Optional. The text to display instead of the comment
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   364
 *                                 author's email address. Default empty.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   365
 * @param string         $before   Optional. The text or HTML to display before the email link.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   366
 *                                 Default empty.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   367
 * @param string         $after    Optional. The text or HTML to display after the email link.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   368
 *                                 Default empty.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   369
 * @param int|WP_Comment $comment  Optional. Comment ID or WP_Comment object.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   370
 *                                 Default is the current comment.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   371
 * @return string The HTML link between the $before and $after parameters.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   372
 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   373
function get_comment_author_url_link( $linktext = '', $before = '', $after = '', $comment = 0 ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   374
	$url = get_comment_author_url( $comment );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   375
	$display = ($linktext != '') ? $linktext : $url;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   376
	$display = str_replace( 'http://www.', '', $display );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   377
	$display = str_replace( 'http://', '', $display );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   378
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   379
	if ( '/' == substr($display, -1) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   380
		$display = substr($display, 0, -1);
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   381
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   382
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   383
	$return = "$before<a href='$url' rel='external'>$display</a>$after";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   384
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   385
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   386
	 * Filters the comment author's returned URL link.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   387
	 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   388
	 * @since 1.5.0
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   389
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   390
	 * @param string $return The HTML-formatted comment author URL link.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   391
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   392
	return apply_filters( 'get_comment_author_url_link', $return );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   393
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   394
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   395
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   396
 * 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
   397
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   398
 * @since 0.71
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   399
 * @since 4.6.0 Added the `$comment` parameter.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   400
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   401
 * @param string         $linktext Optional. Text to display instead of the comment author's
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   402
 *                                 email address. Default empty.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   403
 * @param string         $before   Optional. Text or HTML to display before the email link.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   404
 *                                 Default empty.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   405
 * @param string         $after    Optional. Text or HTML to display after the email link.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   406
 *                                 Default empty.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   407
 * @param int|WP_Comment $comment  Optional. Comment ID or WP_Comment object.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   408
 *                                 Default is the current comment.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   409
 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   410
function comment_author_url_link( $linktext = '', $before = '', $after = '', $comment = 0 ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   411
	echo get_comment_author_url_link( $linktext, $before, $after, $comment );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   412
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   413
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   414
/**
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   415
 * Generates semantic classes for each comment element.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   416
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   417
 * @since 2.7.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   418
 * @since 4.4.0 Added the ability for `$comment` to also accept a WP_Comment object.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   419
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   420
 * @param string|array   $class    Optional. One or more classes to add to the class list.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   421
 *                                 Default empty.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   422
 * @param int|WP_Comment $comment  Comment ID or WP_Comment object. Default current comment.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   423
 * @param int|WP_Post    $post_id  Post ID or WP_Post object. Default current post.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   424
 * @param bool           $echo     Optional. Whether to cho or return the output.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   425
 *                                 Default true.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   426
 * @return string If `$echo` is false, the class will be returned. Void otherwise.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   427
 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   428
function comment_class( $class = '', $comment = null, $post_id = null, $echo = true ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   429
	// Separates classes with a single space, collates classes for comment DIV
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   430
	$class = 'class="' . join( ' ', get_comment_class( $class, $comment, $post_id ) ) . '"';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   431
	if ( $echo)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   432
		echo $class;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   433
	else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   434
		return $class;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   435
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   436
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   437
/**
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   438
 * Returns the classes for the comment div as an array.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   439
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   440
 * @since 2.7.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   441
 * @since 4.4.0 Added the ability for `$comment_id` to also accept a WP_Comment object.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   442
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   443
 * @global int $comment_alt
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   444
 * @global int $comment_depth
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   445
 * @global int $comment_thread_alt
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   446
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   447
 * @param string|array   $class      Optional. One or more classes to add to the class list. Default empty.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   448
 * @param int|WP_Comment $comment_id Comment ID or WP_Comment object. Default current comment.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   449
 * @param int|WP_Post    $post_id    Post ID or WP_Post object. Default current post.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   450
 * @return array An array of classes.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   451
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   452
function get_comment_class( $class = '', $comment_id = null, $post_id = null ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   453
	global $comment_alt, $comment_depth, $comment_thread_alt;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   454
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   455
	$classes = array();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   456
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   457
	$comment = get_comment( $comment_id );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   458
	if ( ! $comment ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   459
		return $classes;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   460
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   461
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   462
	// Get the comment type (comment, trackback),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   463
	$classes[] = ( empty( $comment->comment_type ) ) ? 'comment' : $comment->comment_type;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   464
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   465
	// Add classes for comment authors that are registered users.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   466
	if ( $comment->user_id > 0 && $user = get_userdata( $comment->user_id ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   467
		$classes[] = 'byuser';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   468
		$classes[] = 'comment-author-' . sanitize_html_class( $user->user_nicename, $comment->user_id );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   469
		// For comment authors who are the author of the post
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   470
		if ( $post = get_post($post_id) ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   471
			if ( $comment->user_id === $post->post_author ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   472
				$classes[] = 'bypostauthor';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   473
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   474
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   475
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   476
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   477
	if ( empty($comment_alt) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   478
		$comment_alt = 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   479
	if ( empty($comment_depth) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   480
		$comment_depth = 1;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   481
	if ( empty($comment_thread_alt) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   482
		$comment_thread_alt = 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   483
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   484
	if ( $comment_alt % 2 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   485
		$classes[] = 'odd';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   486
		$classes[] = 'alt';
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
		$classes[] = 'even';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   489
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   490
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   491
	$comment_alt++;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   492
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   493
	// Alt for top-level comments
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   494
	if ( 1 == $comment_depth ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   495
		if ( $comment_thread_alt % 2 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   496
			$classes[] = 'thread-odd';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   497
			$classes[] = 'thread-alt';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   498
		} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   499
			$classes[] = 'thread-even';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   500
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   501
		$comment_thread_alt++;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   502
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   503
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   504
	$classes[] = "depth-$comment_depth";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   505
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   506
	if ( !empty($class) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   507
		if ( !is_array( $class ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   508
			$class = preg_split('#\s+#', $class);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   509
		$classes = array_merge($classes, $class);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   510
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   511
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   512
	$classes = array_map('esc_attr', $classes);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   513
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   514
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   515
	 * Filters the returned CSS classes for the current comment.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   516
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   517
	 * @since 2.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   518
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   519
	 * @param array       $classes    An array of comment classes.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   520
	 * @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
   521
	 * @param int         $comment_id The comment id.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   522
	 * @param WP_Comment  $comment    The comment object.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   523
	 * @param int|WP_Post $post_id    The post ID or WP_Post object.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   524
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   525
	return apply_filters( 'comment_class', $classes, $class, $comment->comment_ID, $comment, $post_id );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   526
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   527
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   528
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   529
 * Retrieve the comment date of the current comment.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   530
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   531
 * @since 1.5.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   532
 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   533
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   534
 * @param string          $d          Optional. The format of the date. Default user's setting.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   535
 * @param int|WP_Comment  $comment_ID WP_Comment or ID of the comment for which to get the date.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   536
 *                                    Default current comment.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   537
 * @return string The comment's date.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   538
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   539
function get_comment_date( $d = '', $comment_ID = 0 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   540
	$comment = get_comment( $comment_ID );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   541
	if ( '' == $d )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   542
		$date = mysql2date(get_option('date_format'), $comment->comment_date);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   543
	else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   544
		$date = mysql2date($d, $comment->comment_date);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   545
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   546
	 * Filters the returned comment date.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   547
	 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   548
	 * @since 1.5.0
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   549
	 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   550
	 * @param string|int $date    Formatted date string or Unix timestamp.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   551
	 * @param string     $d       The format of the date.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   552
	 * @param WP_Comment $comment The comment object.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   553
	 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   554
	return apply_filters( 'get_comment_date', $date, $d, $comment );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   555
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   556
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   557
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   558
 * Display the comment date of the current 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
 * @since 0.71
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   561
 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   562
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   563
 * @param string         $d          Optional. The format of the date. Default user's settings.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   564
 * @param int|WP_Comment $comment_ID WP_Comment or ID of the comment for which to print the date.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   565
 *                                   Default current comment.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   566
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   567
function comment_date( $d = '', $comment_ID = 0 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   568
	echo get_comment_date( $d, $comment_ID );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   569
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   570
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   571
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   572
 * Retrieve the excerpt of the current comment.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   573
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   574
 * 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
   575
 * 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
   576
 * will appear.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   577
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   578
 * @since 1.5.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   579
 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   580
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   581
 * @param int|WP_Comment $comment_ID  WP_Comment or ID of the comment for which to get the excerpt.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   582
 *                                    Default current comment.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   583
 * @return string The maybe truncated comment with 20 words or less.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   584
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   585
function get_comment_excerpt( $comment_ID = 0 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   586
	$comment = get_comment( $comment_ID );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   587
	$comment_text = strip_tags( str_replace( array( "\n", "\r" ), ' ', $comment->comment_content ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   588
	$words = explode( ' ', $comment_text );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   589
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   590
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   591
	 * Filters the amount of words used in the comment excerpt.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   592
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   593
	 * @since 4.4.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   594
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   595
	 * @param int $comment_excerpt_length The amount of words you want to display in the comment excerpt.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   596
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   597
	$comment_excerpt_length = apply_filters( 'comment_excerpt_length', 20 );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   598
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   599
	$use_ellipsis = count( $words ) > $comment_excerpt_length;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   600
	if ( $use_ellipsis ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   601
		$words = array_slice( $words, 0, $comment_excerpt_length );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   602
	}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   603
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   604
	$excerpt = trim( join( ' ', $words ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   605
	if ( $use_ellipsis ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   606
		$excerpt .= '&hellip;';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   607
	}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   608
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   609
	 * Filters the retrieved comment excerpt.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   610
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   611
	 * @since 1.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   612
	 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   613
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   614
	 * @param string     $excerpt    The comment excerpt text.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   615
	 * @param int        $comment_ID The comment ID.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   616
	 * @param WP_Comment $comment    The comment object.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   617
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   618
	return apply_filters( 'get_comment_excerpt', $excerpt, $comment->comment_ID, $comment );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   619
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   620
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   621
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   622
 * Display the excerpt of the current comment.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   623
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   624
 * @since 1.2.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   625
 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   626
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   627
 * @param int|WP_Comment $comment_ID  WP_Comment or ID of the comment for which to print the excerpt.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   628
 *                                    Default current comment.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   629
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   630
function comment_excerpt( $comment_ID = 0 ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   631
	$comment         = get_comment( $comment_ID );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   632
	$comment_excerpt = get_comment_excerpt( $comment );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   633
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   634
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   635
	 * Filters the comment excerpt for display.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   636
	 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   637
	 * @since 1.2.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   638
	 * @since 4.1.0 The `$comment_ID` parameter was added.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   639
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   640
	 * @param string $comment_excerpt The comment excerpt text.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   641
	 * @param int    $comment_ID      The comment ID.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   642
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   643
	echo apply_filters( 'comment_excerpt', $comment_excerpt, $comment->comment_ID );
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
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   646
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   647
 * Retrieve the comment id of the current comment.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   648
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   649
 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   650
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   651
 * @return int The comment ID.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   652
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   653
function get_comment_ID() {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   654
	$comment = get_comment();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   655
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   656
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   657
	 * Filters the returned comment ID.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   658
	 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   659
	 * @since 1.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   660
	 * @since 4.1.0 The `$comment_ID` parameter was added.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   661
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   662
	 * @param int        $comment_ID The current comment ID.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   663
	 * @param WP_Comment $comment    The comment object.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   664
	 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   665
	return apply_filters( 'get_comment_ID', $comment->comment_ID, $comment );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   666
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   667
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   668
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   669
 * Display the comment id of the current comment.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   670
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   671
 * @since 0.71
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   672
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   673
function comment_ID() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   674
	echo get_comment_ID();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   675
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   676
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   677
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   678
 * Retrieve the link to a given comment.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   679
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   680
 * @since 1.5.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   681
 * @since 4.4.0 Added the ability for `$comment` to also accept a WP_Comment object. Added `$cpage` argument.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   682
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   683
 * @see get_page_of_comment()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   684
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   685
 * @global WP_Rewrite $wp_rewrite
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   686
 * @global bool       $in_comment_loop
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   687
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   688
 * @param WP_Comment|int|null $comment Comment to retrieve. Default current comment.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   689
 * @param array               $args {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   690
 *     An array of optional arguments to override the defaults.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   691
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   692
 *     @type string     $type      Passed to get_page_of_comment().
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   693
 *     @type int        $page      Current page of comments, for calculating comment pagination.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   694
 *     @type int        $per_page  Per-page value for comment pagination.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   695
 *     @type int        $max_depth Passed to get_page_of_comment().
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   696
 *     @type int|string $cpage     Value to use for the comment's "comment-page" or "cpage" value.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   697
 *                                 If provided, this value overrides any value calculated from `$page`
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   698
 *                                 and `$per_page`.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   699
 * }
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   700
 * @return string The permalink to the given comment.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   701
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   702
function get_comment_link( $comment = null, $args = array() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   703
	global $wp_rewrite, $in_comment_loop;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   704
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   705
	$comment = get_comment($comment);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   706
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   707
	// Back-compat.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   708
	if ( ! is_array( $args ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   709
		$args = array( 'page' => $args );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   710
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   711
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   712
	$defaults = array(
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   713
		'type'      => 'all',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   714
		'page'      => '',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   715
		'per_page'  => '',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   716
		'max_depth' => '',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   717
		'cpage'     => null,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   718
	);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   719
	$args = wp_parse_args( $args, $defaults );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   720
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   721
	$link = get_permalink( $comment->comment_post_ID );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   722
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   723
	// The 'cpage' param takes precedence.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   724
	if ( ! is_null( $args['cpage'] ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   725
		$cpage = $args['cpage'];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   726
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   727
	// No 'cpage' is provided, so we calculate one.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   728
	} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   729
		if ( '' === $args['per_page'] && get_option( 'page_comments' ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   730
			$args['per_page'] = get_option('comments_per_page');
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   731
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   732
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   733
		if ( empty( $args['per_page'] ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   734
			$args['per_page'] = 0;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   735
			$args['page'] = 0;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   736
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   737
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   738
		$cpage = $args['page'];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   739
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   740
		if ( '' == $cpage ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   741
			if ( ! empty( $in_comment_loop ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   742
				$cpage = get_query_var( 'cpage' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   743
			} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   744
				// Requires a database hit, so we only do it when we can't figure out from context.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   745
				$cpage = get_page_of_comment( $comment->comment_ID, $args );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   746
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   747
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   748
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   749
		/*
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   750
		 * If the default page displays the oldest comments, the permalinks for comments on the default page
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   751
		 * do not need a 'cpage' query var.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   752
		 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   753
		if ( 'oldest' === get_option( 'default_comments_page' ) && 1 === $cpage ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   754
			$cpage = '';
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   755
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   756
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   757
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   758
	if ( $cpage && get_option( 'page_comments' ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   759
		if ( $wp_rewrite->using_permalinks() ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   760
			if ( $cpage ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   761
				$link = trailingslashit( $link ) . $wp_rewrite->comments_pagination_base . '-' . $cpage;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   762
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   763
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   764
			$link = user_trailingslashit( $link, 'comment' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   765
		} elseif ( $cpage ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   766
			$link = add_query_arg( 'cpage', $cpage, $link );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   767
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   768
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   769
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   770
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   771
	if ( $wp_rewrite->using_permalinks() ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   772
		$link = user_trailingslashit( $link, 'comment' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   773
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   774
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   775
	$link = $link . '#comment-' . $comment->comment_ID;
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   776
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   777
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   778
	 * Filters the returned single comment permalink.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   779
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   780
	 * @since 2.8.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   781
	 * @since 4.4.0 Added the `$cpage` parameter.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   782
	 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   783
	 * @see get_page_of_comment()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   784
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   785
	 * @param string     $link    The comment permalink with '#comment-$id' appended.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   786
	 * @param WP_Comment $comment The current comment object.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   787
	 * @param array      $args    An array of arguments to override the defaults.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   788
	 * @param int        $cpage   The calculated 'cpage' value.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   789
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   790
	return apply_filters( 'get_comment_link', $link, $comment, $args, $cpage );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   791
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   792
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   793
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   794
 * Retrieves the link to the current post comments.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   795
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   796
 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   797
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   798
 * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   799
 * @return string The link to the comments.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   800
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   801
function get_comments_link( $post_id = 0 ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   802
	$hash = get_comments_number( $post_id ) ? '#comments' : '#respond';
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   803
	$comments_link = get_permalink( $post_id ) . $hash;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   804
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   805
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   806
	 * Filters the returned post comments permalink.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   807
	 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   808
	 * @since 3.6.0
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   809
	 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   810
	 * @param string      $comments_link Post comments permalink with '#comments' appended.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   811
	 * @param int|WP_Post $post_id       Post ID or WP_Post object.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   812
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   813
	return apply_filters( 'get_comments_link', $comments_link, $post_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   814
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   815
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   816
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   817
 * Display the link to the current post comments.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   818
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   819
 * @since 0.71
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   820
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   821
 * @param string $deprecated   Not Used.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   822
 * @param string $deprecated_2 Not Used.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   823
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   824
function comments_link( $deprecated = '', $deprecated_2 = '' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   825
	if ( !empty( $deprecated ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   826
		_deprecated_argument( __FUNCTION__, '0.72' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   827
	if ( !empty( $deprecated_2 ) )
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   828
		_deprecated_argument( __FUNCTION__, '1.3.0' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   829
	echo esc_url( get_comments_link() );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   830
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   831
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   832
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   833
 * Retrieves the amount of comments a post has.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   834
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   835
 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   836
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   837
 * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is the global `$post`.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   838
 * @return string|int If the post exists, a numeric string representing the number of comments
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   839
 *                    the post has, otherwise 0.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   840
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   841
function get_comments_number( $post_id = 0 ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   842
	$post = get_post( $post_id );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   843
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   844
	if ( ! $post ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   845
		$count = 0;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   846
	} else {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   847
		$count = $post->comment_count;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   848
		$post_id = $post->ID;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   849
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   850
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   851
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   852
	 * Filters the returned comment count for a post.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   853
	 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   854
	 * @since 1.5.0
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   855
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   856
	 * @param string|int $count   A string representing the number of comments a post has, otherwise 0.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   857
	 * @param int        $post_id Post ID.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   858
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   859
	return apply_filters( 'get_comments_number', $count, $post_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   860
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   861
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   862
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   863
 * Display the language string for the number of comments the current post has.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   864
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   865
 * @since 0.71
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   866
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   867
 * @param string $zero       Optional. Text for no comments. Default false.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   868
 * @param string $one        Optional. Text for one comment. Default false.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   869
 * @param string $more       Optional. Text for more than one comment. Default false.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   870
 * @param string $deprecated Not used.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   871
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   872
function comments_number( $zero = false, $one = false, $more = false, $deprecated = '' ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   873
	if ( ! empty( $deprecated ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   874
		_deprecated_argument( __FUNCTION__, '1.3.0' );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   875
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   876
	echo get_comments_number_text( $zero, $one, $more );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   877
}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   878
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   879
/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   880
 * Display the language string for the number of comments the current post has.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   881
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   882
 * @since 4.0.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   883
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   884
 * @param string $zero Optional. Text for no comments. Default false.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   885
 * @param string $one  Optional. Text for one comment. Default false.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   886
 * @param string $more Optional. Text for more than one comment. Default false.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   887
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   888
function get_comments_number_text( $zero = false, $one = false, $more = false ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   889
	$number = get_comments_number();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   890
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   891
	if ( $number > 1 ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   892
		if ( false === $more ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   893
			/* translators: %s: number of comments */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   894
			$output = sprintf( _n( '%s Comment', '%s Comments', $number ), number_format_i18n( $number ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   895
		} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   896
			// % Comments
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   897
			/* translators: If comment number in your language requires declension,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   898
			 * translate this to 'on'. Do not translate into your own language.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   899
			 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   900
			if ( 'on' === _x( 'off', 'Comment number declension: on or off' ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   901
				$text = preg_replace( '#<span class="screen-reader-text">.+?</span>#', '', $more );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   902
				$text = preg_replace( '/&.+?;/', '', $text ); // Kill entities
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   903
				$text = trim( strip_tags( $text ), '% ' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   904
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   905
				// Replace '% Comments' with a proper plural form
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   906
				if ( $text && ! preg_match( '/[0-9]+/', $text ) && false !== strpos( $more, '%' ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   907
					/* translators: %s: number of comments */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   908
					$new_text = _n( '%s Comment', '%s Comments', $number );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   909
					$new_text = trim( sprintf( $new_text, '' ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   910
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   911
					$more = str_replace( $text, $new_text, $more );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   912
					if ( false === strpos( $more, '%' ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   913
						$more = '% ' . $more;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   914
					}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   915
				}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   916
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   917
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   918
			$output = str_replace( '%', number_format_i18n( $number ), $more );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   919
		}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   920
	} elseif ( $number == 0 ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   921
		$output = ( false === $zero ) ? __( 'No Comments' ) : $zero;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   922
	} else { // must be one
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   923
		$output = ( false === $one ) ? __( '1 Comment' ) : $one;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   924
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   925
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   926
	 * Filters the comments count for display.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   927
	 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   928
	 * @since 1.5.0
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   929
	 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   930
	 * @see _n()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   931
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   932
	 * @param string $output A translatable string formatted based on whether the count
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   933
	 *                       is equal to 0, 1, or 1+.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   934
	 * @param int    $number The number of post comments.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   935
	 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   936
	return apply_filters( 'comments_number', $output, $number );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   937
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   938
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   939
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   940
 * Retrieve the text of the current comment.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   941
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   942
 * @since 1.5.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   943
 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   944
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   945
 * @see Walker_Comment::comment()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   946
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   947
 * @param int|WP_Comment  $comment_ID WP_Comment or ID of the comment for which to get the text.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   948
 *                                    Default current comment.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   949
 * @param array           $args       Optional. An array of arguments. Default empty.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   950
 * @return string The comment content.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   951
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   952
function get_comment_text( $comment_ID = 0, $args = array() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   953
	$comment = get_comment( $comment_ID );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   954
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   955
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   956
	 * Filters the text of a comment.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   957
	 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   958
	 * @since 1.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   959
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   960
	 * @see Walker_Comment::comment()
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   961
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   962
	 * @param string     $comment_content Text of the comment.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   963
	 * @param WP_Comment $comment         The comment object.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   964
	 * @param array      $args            An array of arguments.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   965
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   966
	return apply_filters( 'get_comment_text', $comment->comment_content, $comment, $args );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   967
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   968
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   969
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   970
 * Display the text of the current comment.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   971
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   972
 * @since 0.71
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   973
 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   974
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   975
 * @see Walker_Comment::comment()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   976
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   977
 * @param int|WP_Comment  $comment_ID WP_Comment or ID of the comment for which to print the text.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   978
 *                                    Default current comment.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   979
 * @param array           $args       Optional. An array of arguments. Default empty array. Default empty.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   980
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   981
function comment_text( $comment_ID = 0, $args = array() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   982
	$comment = get_comment( $comment_ID );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   983
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   984
	$comment_text = get_comment_text( $comment, $args );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   985
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   986
	 * Filters the text of a comment to be displayed.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   987
	 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   988
	 * @since 1.2.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   989
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   990
	 * @see Walker_Comment::comment()
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   991
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   992
	 * @param string          $comment_text Text of the current comment.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   993
	 * @param WP_Comment|null $comment      The comment object.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   994
	 * @param array           $args         An array of arguments.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   995
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   996
	echo apply_filters( 'comment_text', $comment_text, $comment, $args );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   997
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   998
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   999
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1000
 * Retrieve the comment time of the current comment.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1001
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1002
 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1003
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1004
 * @param string $d         Optional. The format of the time. Default user's settings.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1005
 * @param bool   $gmt       Optional. Whether to use the GMT date. Default false.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1006
 * @param bool   $translate Optional. Whether to translate the time (for use in feeds).
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1007
 *                          Default true.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1008
 * @return string The formatted time.
0
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 get_comment_time( $d = '', $gmt = false, $translate = true ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1011
	$comment = get_comment();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1012
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1013
	$comment_date = $gmt ? $comment->comment_date_gmt : $comment->comment_date;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1014
	if ( '' == $d )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1015
		$date = mysql2date(get_option('time_format'), $comment_date, $translate);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1016
	else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1017
		$date = mysql2date($d, $comment_date, $translate);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1018
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1019
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1020
	 * Filters the returned comment time.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1021
	 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1022
	 * @since 1.5.0
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1023
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1024
	 * @param string|int $date      The comment time, formatted as a date string or Unix timestamp.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1025
	 * @param string     $d         Date format.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1026
	 * @param bool       $gmt       Whether the GMT date is in use.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1027
	 * @param bool       $translate Whether the time is translated.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1028
	 * @param WP_Comment $comment   The comment object.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1029
	 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1030
	return apply_filters( 'get_comment_time', $date, $d, $gmt, $translate, $comment );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1031
}
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
 * Display the comment time of the current comment.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1035
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1036
 * @since 0.71
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1037
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1038
 * @param string $d Optional. The format of the time. Default user's settings.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1039
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1040
function comment_time( $d = '' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1041
	echo get_comment_time($d);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1042
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1043
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1044
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1045
 * Retrieve the comment type of the current comment.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1046
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1047
 * @since 1.5.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1048
 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1049
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1050
 * @param int|WP_Comment $comment_ID Optional. WP_Comment or ID of the comment for which to get the type.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1051
 *                                   Default current comment.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1052
 * @return string The comment type.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1053
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1054
function get_comment_type( $comment_ID = 0 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1055
	$comment = get_comment( $comment_ID );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1056
	if ( '' == $comment->comment_type )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1057
		$comment->comment_type = 'comment';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1058
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1059
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1060
	 * Filters the returned comment type.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1061
	 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1062
	 * @since 1.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1063
	 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1064
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1065
	 * @param string     $comment_type The type of comment, such as 'comment', 'pingback', or 'trackback'.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1066
	 * @param int 	     $comment_ID   The comment ID.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1067
	 * @param WP_Comment $comment      The comment object.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1068
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1069
	return apply_filters( 'get_comment_type', $comment->comment_type, $comment->comment_ID, $comment );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1070
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1071
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1072
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1073
 * Display the comment type of the current comment.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1074
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1075
 * @since 0.71
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1076
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1077
 * @param string $commenttxt   Optional. String to display for comment type. Default false.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1078
 * @param string $trackbacktxt Optional. String to display for trackback type. Default false.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1079
 * @param string $pingbacktxt  Optional. String to display for pingback type. Default false.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1080
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1081
function comment_type( $commenttxt = false, $trackbacktxt = false, $pingbacktxt = false ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1082
	if ( false === $commenttxt ) $commenttxt = _x( 'Comment', 'noun' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1083
	if ( false === $trackbacktxt ) $trackbacktxt = __( 'Trackback' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1084
	if ( false === $pingbacktxt ) $pingbacktxt = __( 'Pingback' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1085
	$type = get_comment_type();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1086
	switch( $type ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1087
		case 'trackback' :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1088
			echo $trackbacktxt;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1089
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1090
		case 'pingback' :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1091
			echo $pingbacktxt;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1092
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1093
		default :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1094
			echo $commenttxt;
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1099
 * Retrieve The current post's trackback URL.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1100
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1101
 * 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
  1102
 * retrieve the pretty path. If permalinks weren't enabled, the ID of the
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1103
 * current post is used and appended to the correct page to go to.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1104
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1105
 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1106
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1107
 * @return string The trackback URL after being filtered.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1108
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1109
function get_trackback_url() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1110
	if ( '' != get_option('permalink_structure') )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1111
		$tb_url = trailingslashit(get_permalink()) . user_trailingslashit('trackback', 'single_trackback');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1112
	else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1113
		$tb_url = get_option('siteurl') . '/wp-trackback.php?p=' . get_the_ID();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1114
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1115
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1116
	 * Filters the returned trackback URL.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1117
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1118
	 * @since 2.2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1119
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1120
	 * @param string $tb_url The trackback URL.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1121
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1122
	return apply_filters( 'trackback_url', $tb_url );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1123
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1124
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1125
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1126
 * Display the current post's trackback URL.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1127
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1128
 * @since 0.71
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1129
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1130
 * @param bool $deprecated_echo Not used.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1131
 * @return void|string Should only be used to echo the trackback URL, use get_trackback_url()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1132
 *                     for the result instead.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1133
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1134
function trackback_url( $deprecated_echo = true ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1135
	if ( true !== $deprecated_echo ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1136
		_deprecated_argument( __FUNCTION__, '2.5.0',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1137
			/* translators: %s: get_trackback_url() */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1138
			sprintf( __( 'Use %s instead if you do not want the value echoed.' ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1139
				'<code>get_trackback_url()</code>'
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1140
			)
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1141
		);
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1142
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1143
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1144
	if ( $deprecated_echo ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1145
		echo get_trackback_url();
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1146
	} else {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1147
		return get_trackback_url();
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1148
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1149
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1150
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1151
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1152
 * Generate and display the RDF for the trackback information of current post.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1153
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1154
 * Deprecated in 3.0.0, and restored in 3.0.1.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1155
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1156
 * @since 0.71
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1157
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1158
 * @param int $deprecated Not used (Was $timezone = 0).
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1159
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1160
function trackback_rdf( $deprecated = '' ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1161
	if ( ! empty( $deprecated ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1162
		_deprecated_argument( __FUNCTION__, '2.5.0' );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1163
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1164
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1165
	if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && false !== stripos( $_SERVER['HTTP_USER_AGENT'], 'W3C_Validator' ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1166
		return;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1167
	}
0
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 '<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
  1170
			xmlns:dc="http://purl.org/dc/elements/1.1/"
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1171
			xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1172
		<rdf:Description rdf:about="';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1173
	the_permalink();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1174
	echo '"'."\n";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1175
	echo '    dc:identifier="';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1176
	the_permalink();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1177
	echo '"'."\n";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1178
	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
  1179
	echo '    trackback:ping="'.get_trackback_url().'"'." />\n";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1180
	echo '</rdf:RDF>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1181
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1182
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1183
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1184
 * Whether the current post is open for comments.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1185
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1186
 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1187
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1188
 * @param int|WP_Post $post_id Post ID or WP_Post object. Default current post.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1189
 * @return bool True if the comments are open.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1190
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1191
function comments_open( $post_id = null ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1192
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1193
	$_post = get_post($post_id);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1194
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1195
	$post_id = $_post ? $_post->ID : 0;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1196
	$open = ( 'open' == $_post->comment_status );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1197
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1198
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1199
	 * Filters whether the current post is open for comments.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1200
	 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1201
	 * @since 2.5.0
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1202
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1203
	 * @param bool $open    Whether the current post is open for comments.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1204
	 * @param int  $post_id The post ID.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1205
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1206
	return apply_filters( 'comments_open', $open, $post_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1207
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1208
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1209
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1210
 * Whether the current post is open for pings.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1211
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1212
 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1213
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1214
 * @param int|WP_Post $post_id Post ID or WP_Post object. Default current post.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1215
 * @return bool True if pings are accepted
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1216
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1217
function pings_open( $post_id = null ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1218
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1219
	$_post = get_post($post_id);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1220
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1221
	$post_id = $_post ? $_post->ID : 0;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1222
	$open = ( 'open' == $_post->ping_status );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1223
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1224
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1225
	 * Filters whether the current post is open for pings.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1226
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1227
	 * @since 2.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1228
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1229
	 * @param bool $open    Whether the current post is open for pings.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1230
	 * @param int  $post_id The post ID.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1231
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1232
	return apply_filters( 'pings_open', $open, $post_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1233
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1234
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1235
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1236
 * Display form token for unfiltered comments.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1237
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1238
 * Will only display nonce token if the current user has permissions for
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1239
 * unfiltered html. Won't display the token for other users.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1240
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1241
 * 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
  1242
 * 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
  1243
 * 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
  1244
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1245
 * Backported to 2.0.10.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1246
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1247
 * @since 2.1.3
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1248
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1249
function wp_comment_form_unfiltered_html_nonce() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1250
	$post = get_post();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1251
	$post_id = $post ? $post->ID : 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1252
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1253
	if ( current_user_can( 'unfiltered_html' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1254
		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
  1255
		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
  1256
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1257
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1258
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1259
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1260
 * Load the comment template specified in $file.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1261
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1262
 * 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
  1263
 * the post does not have comments.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1264
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1265
 * Uses the WordPress database object to query for the comments. The comments
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1266
 * are passed through the {@see 'comments_array'} filter hook with the list of comments
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1267
 * and the post ID respectively.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1268
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1269
 * The `$file` path is passed through a filter hook called {@see 'comments_template'},
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1270
 * which includes the TEMPLATEPATH and $file combined. Tries the $filtered path
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1271
 * 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
  1272
 * default theme. If either does not exist, then the WordPress process will be
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1273
 * 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
  1274
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1275
 * Will not try to get the comments if the post has none.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1276
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1277
 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1278
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1279
 * @global WP_Query   $wp_query
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1280
 * @global WP_Post    $post
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1281
 * @global wpdb       $wpdb
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1282
 * @global int        $id
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1283
 * @global WP_Comment $comment
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1284
 * @global string     $user_login
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1285
 * @global int        $user_ID
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1286
 * @global string     $user_identity
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1287
 * @global bool       $overridden_cpage
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1288
 * @global bool       $withcomments
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1289
 *
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1290
 * @param string $file              Optional. The file to load. Default '/comments.php'.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1291
 * @param bool   $separate_comments Optional. Whether to separate the comments by comment type.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1292
 *                                  Default false.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1293
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1294
function comments_template( $file = '/comments.php', $separate_comments = false ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1295
	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
  1296
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1297
	if ( !(is_single() || is_page() || $withcomments) || empty($post) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1298
		return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1299
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1300
	if ( empty($file) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1301
		$file = '/comments.php';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1302
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1303
	$req = get_option('require_name_email');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1304
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1305
	/*
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1306
	 * Comment author information fetched from the comment cookies.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1307
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1308
	$commenter = wp_get_current_commenter();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1309
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1310
	/*
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1311
	 * The name of the current comment author escaped for use in attributes.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1312
	 * Escaped by sanitize_comment_cookies().
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1313
	 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1314
	$comment_author = $commenter['comment_author'];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1315
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1316
	/*
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1317
	 * The email address of the current comment author escaped for use in attributes.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1318
	 * Escaped by sanitize_comment_cookies().
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1319
	 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1320
	$comment_author_email = $commenter['comment_author_email'];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1321
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1322
	/*
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1323
	 * The url of the current comment author escaped for use in attributes.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1324
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1325
	$comment_author_url = esc_url($commenter['comment_author_url']);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1326
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1327
	$comment_args = array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1328
		'orderby' => 'comment_date_gmt',
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1329
		'order' => 'ASC',
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1330
		'status'  => 'approve',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1331
		'post_id' => $post->ID,
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1332
		'no_found_rows' => false,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1333
		'update_comment_meta_cache' => false, // We lazy-load comment meta for performance.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1334
	);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1335
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1336
	if ( get_option('thread_comments') ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1337
		$comment_args['hierarchical'] = 'threaded';
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1338
	} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1339
		$comment_args['hierarchical'] = false;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1340
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1341
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1342
	if ( $user_ID ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1343
		$comment_args['include_unapproved'] = array( $user_ID );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1344
	} elseif ( ! empty( $comment_author_email ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1345
		$comment_args['include_unapproved'] = array( $comment_author_email );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1346
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1347
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1348
	$per_page = 0;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1349
	if ( get_option( 'page_comments' ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1350
		$per_page = (int) get_query_var( 'comments_per_page' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1351
		if ( 0 === $per_page ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1352
			$per_page = (int) get_option( 'comments_per_page' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1353
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1354
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1355
		$comment_args['number'] = $per_page;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1356
		$page = (int) get_query_var( 'cpage' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1357
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1358
		if ( $page ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1359
			$comment_args['offset'] = ( $page - 1 ) * $per_page;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1360
		} elseif ( 'oldest' === get_option( 'default_comments_page' ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1361
			$comment_args['offset'] = 0;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1362
		} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1363
			// If fetching the first page of 'newest', we need a top-level comment count.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1364
			$top_level_query = new WP_Comment_Query();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1365
			$top_level_args  = array(
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1366
				'count'   => true,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1367
				'orderby' => false,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1368
				'post_id' => $post->ID,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1369
				'status'  => 'approve',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1370
			);
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1371
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1372
			if ( $comment_args['hierarchical'] ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1373
				$top_level_args['parent'] = 0;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1374
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1375
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1376
			if ( isset( $comment_args['include_unapproved'] ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1377
				$top_level_args['include_unapproved'] = $comment_args['include_unapproved'];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1378
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1379
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1380
			$top_level_count = $top_level_query->query( $top_level_args );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1381
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1382
			$comment_args['offset'] = ( ceil( $top_level_count / $per_page ) - 1 ) * $per_page;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1383
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1384
	}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1385
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1386
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1387
	 * Filters the arguments used to query comments in comments_template().
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1388
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1389
	 * @since 4.5.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1390
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1391
	 * @see WP_Comment_Query::__construct()
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1392
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1393
	 * @param array $comment_args {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1394
	 *     Array of WP_Comment_Query arguments.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1395
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1396
	 *     @type string|array $orderby                   Field(s) to order by.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1397
	 *     @type string       $order                     Order of results. Accepts 'ASC' or 'DESC'.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1398
	 *     @type string       $status                    Comment status.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1399
	 *     @type array        $include_unapproved        Array of IDs or email addresses whose unapproved comments
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1400
	 *                                                   will be included in results.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1401
	 *     @type int          $post_id                   ID of the post.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1402
	 *     @type bool         $no_found_rows             Whether to refrain from querying for found rows.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1403
	 *     @type bool         $update_comment_meta_cache Whether to prime cache for comment meta.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1404
	 *     @type bool|string  $hierarchical              Whether to query for comments hierarchically.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1405
	 *     @type int          $offset                    Comment offset.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1406
	 *     @type int          $number                    Number of comments to fetch.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1407
	 * }
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1408
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1409
	$comment_args = apply_filters( 'comments_template_query_args', $comment_args );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1410
	$comment_query = new WP_Comment_Query( $comment_args );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1411
	$_comments = $comment_query->comments;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1412
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1413
	// Trees must be flattened before they're passed to the walker.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1414
	if ( $comment_args['hierarchical'] ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1415
		$comments_flat = array();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1416
		foreach ( $_comments as $_comment ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1417
			$comments_flat[]  = $_comment;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1418
			$comment_children = $_comment->get_children( array(
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1419
				'format' => 'flat',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1420
				'status' => $comment_args['status'],
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1421
				'orderby' => $comment_args['orderby']
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1422
			) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1423
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1424
			foreach ( $comment_children as $comment_child ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1425
				$comments_flat[] = $comment_child;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1426
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1427
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1428
	} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1429
		$comments_flat = $_comments;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1430
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1431
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1432
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1433
	 * Filters the comments array.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1434
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1435
	 * @since 2.1.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1436
	 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1437
	 * @param array $comments Array of comments supplied to the comments template.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1438
	 * @param int   $post_ID  Post ID.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1439
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1440
	$wp_query->comments = apply_filters( 'comments_array', $comments_flat, $post->ID );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1441
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1442
	$comments = &$wp_query->comments;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1443
	$wp_query->comment_count = count($wp_query->comments);
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1444
	$wp_query->max_num_comment_pages = $comment_query->max_num_pages;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1445
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1446
	if ( $separate_comments ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1447
		$wp_query->comments_by_type = separate_comments($comments);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1448
		$comments_by_type = &$wp_query->comments_by_type;
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1449
	} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1450
		$wp_query->comments_by_type = array();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1451
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1452
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1453
	$overridden_cpage = false;
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1454
	if ( '' == get_query_var( 'cpage' ) && $wp_query->max_num_comment_pages > 1 ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1455
		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
  1456
		$overridden_cpage = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1457
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1458
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1459
	if ( !defined('COMMENTS_TEMPLATE') )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1460
		define('COMMENTS_TEMPLATE', true);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1461
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1462
	$theme_template = STYLESHEETPATH . $file;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1463
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1464
	 * Filters the path to the theme template file used for the comments template.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1465
	 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1466
	 * @since 1.5.1
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1467
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1468
	 * @param string $theme_template The path to the theme template file.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1469
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1470
	$include = apply_filters( 'comments_template', $theme_template );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1471
	if ( file_exists( $include ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1472
		require( $include );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1473
	elseif ( file_exists( TEMPLATEPATH . $file ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1474
		require( TEMPLATEPATH . $file );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1475
	else // Backward compat code will be removed in a future release
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1476
		require( ABSPATH . WPINC . '/theme-compat/comments.php');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1477
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1478
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1479
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1480
 * Displays the link to the comments for the current post ID.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1481
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1482
 * @since 0.71
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1483
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1484
 * @param string $zero      Optional. String to display when no comments. Default false.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1485
 * @param string $one       Optional. String to display when only one comment is available.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1486
 *                          Default false.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1487
 * @param string $more      Optional. String to display when there are more than one comment.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1488
 *                          Default false.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1489
 * @param string $css_class Optional. CSS class to use for comments. Default empty.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1490
 * @param string $none      Optional. String to display when comments have been turned off.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1491
 *                          Default false.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1492
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1493
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
  1494
	$id = get_the_ID();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1495
	$title = get_the_title();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1496
	$number = get_comments_number( $id );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1497
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1498
	if ( false === $zero ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1499
		/* translators: %s: post title */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1500
		$zero = sprintf( __( 'No Comments<span class="screen-reader-text"> on %s</span>' ), $title );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1501
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1502
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1503
	if ( false === $one ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1504
		/* translators: %s: post title */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1505
		$one = sprintf( __( '1 Comment<span class="screen-reader-text"> on %s</span>' ), $title );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1506
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1507
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1508
	if ( false === $more ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1509
		/* translators: 1: Number of comments 2: post title */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1510
		$more = _n( '%1$s Comment<span class="screen-reader-text"> on %2$s</span>', '%1$s Comments<span class="screen-reader-text"> on %2$s</span>', $number );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1511
		$more = sprintf( $more, number_format_i18n( $number ), $title );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1512
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1513
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1514
	if ( false === $none ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1515
		/* translators: %s: post title */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1516
		$none = sprintf( __( 'Comments Off<span class="screen-reader-text"> on %s</span>' ), $title );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1517
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1518
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1519
	if ( 0 == $number && !comments_open() && !pings_open() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1520
		echo '<span' . ((!empty($css_class)) ? ' class="' . esc_attr( $css_class ) . '"' : '') . '>' . $none . '</span>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1521
		return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1522
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1523
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1524
	if ( post_password_required() ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1525
		_e( 'Enter your password to view comments.' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1526
		return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1527
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1528
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1529
	echo '<a href="';
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1530
	if ( 0 == $number ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1531
		$respond_link = get_permalink() . '#respond';
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1532
		/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1533
		 * Filters the respond link when a post has no comments.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1534
		 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1535
		 * @since 4.4.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1536
		 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1537
		 * @param string $respond_link The default response link.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1538
		 * @param integer $id The post ID.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1539
		 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1540
		echo apply_filters( 'respond_link', $respond_link, $id );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1541
	} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1542
		comments_link();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1543
	}
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1544
	echo '"';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1545
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1546
	if ( !empty( $css_class ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1547
		echo ' class="'.$css_class.'" ';
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
	$attributes = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1551
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1552
	 * Filters the comments link attributes for display.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1553
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1554
	 * @since 2.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1555
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1556
	 * @param string $attributes The comments link attributes. Default empty.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1557
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1558
	echo apply_filters( 'comments_popup_link_attributes', $attributes );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1559
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1560
	echo '>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1561
	comments_number( $zero, $one, $more );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1562
	echo '</a>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1563
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1564
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1565
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1566
 * Retrieve HTML content for reply to comment link.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1567
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1568
 * @since 2.7.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1569
 * @since 4.4.0 Added the ability for `$comment` to also accept a WP_Comment object.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1570
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1571
 * @param array $args {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1572
 *     Optional. Override default arguments.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1573
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1574
 *     @type string $add_below  The first part of the selector used to identify the comment to respond below.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1575
 *                              The resulting value is passed as the first parameter to addComment.moveForm(),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1576
 *                              concatenated as $add_below-$comment->comment_ID. Default 'comment'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1577
 *     @type string $respond_id The selector identifying the responding comment. Passed as the third parameter
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1578
 *                              to addComment.moveForm(), and appended to the link URL as a hash value.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1579
 *                              Default 'respond'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1580
 *     @type string $reply_text The text of the Reply link. Default 'Reply'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1581
 *     @type string $login_text The text of the link to reply if logged out. Default 'Log in to Reply'.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1582
 *     @type int    $max_depth  The max depth of the comment tree. Default 0.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1583
 *     @type int    $depth      The depth of the new comment. Must be greater than 0 and less than the value
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1584
 *                              of the 'thread_comments_depth' option set in Settings > Discussion. Default 0.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1585
 *     @type string $before     The text or HTML to add before the reply link. Default empty.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1586
 *     @type string $after      The text or HTML to add after the reply link. Default empty.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1587
 * }
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1588
 * @param int|WP_Comment $comment Comment being replied to. Default current comment.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1589
 * @param int|WP_Post    $post    Post ID or WP_Post object the comment is going to be displayed on.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1590
 *                                Default current post.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1591
 * @return void|false|string Link to show comment form, if successful. False, if comments are closed.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1592
 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1593
function get_comment_reply_link( $args = array(), $comment = null, $post = null ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1594
	$defaults = array(
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1595
		'add_below'     => 'comment',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1596
		'respond_id'    => 'respond',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1597
		'reply_text'    => __( 'Reply' ),
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1598
		/* translators: Comment reply button text. 1: Comment author name */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1599
		'reply_to_text' => __( 'Reply to %s' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1600
		'login_text'    => __( 'Log in to Reply' ),
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1601
		'max_depth'     => 0,
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1602
		'depth'         => 0,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1603
		'before'        => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1604
		'after'         => ''
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1605
	);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1606
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1607
	$args = wp_parse_args( $args, $defaults );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1608
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1609
	if ( 0 == $args['depth'] || $args['max_depth'] <= $args['depth'] ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1610
		return;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1611
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1612
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1613
	$comment = get_comment( $comment );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1614
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1615
	if ( empty( $post ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1616
		$post = $comment->comment_post_ID;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1617
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1618
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1619
	$post = get_post( $post );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1620
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1621
	if ( ! comments_open( $post->ID ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1622
		return false;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1623
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1624
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1625
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1626
	 * Filters the comment reply link arguments.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1627
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1628
	 * @since 4.1.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1629
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1630
	 * @param array      $args    Comment reply link arguments. See get_comment_reply_link()
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1631
	 *                            for more information on accepted arguments.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1632
	 * @param WP_Comment $comment The object of the comment being replied to.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1633
	 * @param WP_Post    $post    The WP_Post object.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1634
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1635
	$args = apply_filters( 'comment_reply_link_args', $args, $comment, $post );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1636
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1637
	if ( get_option( 'comment_registration' ) && ! is_user_logged_in() ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1638
		$link = sprintf( '<a rel="nofollow" class="comment-reply-login" href="%s">%s</a>',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1639
			esc_url( wp_login_url( get_permalink() ) ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1640
			$args['login_text']
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1641
		);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1642
	} else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1643
		$onclick = sprintf( 'return addComment.moveForm( "%1$s-%2$s", "%2$s", "%3$s", "%4$s" )',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1644
			$args['add_below'], $comment->comment_ID, $args['respond_id'], $post->ID
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1645
		);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1646
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1647
		$link = sprintf( "<a rel='nofollow' class='comment-reply-link' href='%s' onclick='%s' aria-label='%s'>%s</a>",
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1648
			esc_url( add_query_arg( 'replytocom', $comment->comment_ID, get_permalink( $post->ID ) ) ) . "#" . $args['respond_id'],
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1649
			$onclick,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1650
			esc_attr( sprintf( $args['reply_to_text'], $comment->comment_author ) ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1651
			$args['reply_text']
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1652
		);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1653
	}
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1654
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1655
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1656
	 * Filters the comment reply link.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1657
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1658
	 * @since 2.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1659
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1660
	 * @param string  $link    The HTML markup for the comment reply link.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1661
	 * @param array   $args    An array of arguments overriding the defaults.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1662
	 * @param object  $comment The object of the comment being replied.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1663
	 * @param WP_Post $post    The WP_Post object.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1664
	 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1665
	return apply_filters( 'comment_reply_link', $args['before'] . $link . $args['after'], $args, $comment, $post );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1666
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1667
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1668
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1669
 * Displays the HTML content for reply to comment link.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1670
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1671
 * @since 2.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1672
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1673
 * @see get_comment_reply_link()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1674
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1675
 * @param array       $args    Optional. Override default options.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1676
 * @param int         $comment Comment being replied to. Default current comment.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1677
 * @param int|WP_Post $post    Post ID or WP_Post object the comment is going to be displayed on.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1678
 *                             Default current post.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1679
 * @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
  1680
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1681
function comment_reply_link($args = array(), $comment = null, $post = null) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1682
	echo get_comment_reply_link($args, $comment, $post);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1683
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1684
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1685
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1686
 * Retrieve HTML content for reply to post link.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1687
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1688
 * @since 2.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1689
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1690
 * @param array $args {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1691
 *     Optional. Override default arguments.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1692
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1693
 *     @type string $add_below  The first part of the selector used to identify the comment to respond below.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1694
 *                              The resulting value is passed as the first parameter to addComment.moveForm(),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1695
 *                              concatenated as $add_below-$comment->comment_ID. Default is 'post'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1696
 *     @type string $respond_id The selector identifying the responding comment. Passed as the third parameter
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1697
 *                              to addComment.moveForm(), and appended to the link URL as a hash value.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1698
 *                              Default 'respond'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1699
 *     @type string $reply_text Text of the Reply link. Default is 'Leave a Comment'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1700
 *     @type string $login_text Text of the link to reply if logged out. Default is 'Log in to leave a Comment'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1701
 *     @type string $before     Text or HTML to add before the reply link. Default empty.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1702
 *     @type string $after      Text or HTML to add after the reply link. Default empty.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1703
 * }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1704
 * @param int|WP_Post $post    Optional. Post ID or WP_Post object the comment is going to be displayed on.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1705
 *                             Default current post.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1706
 * @return false|null|string Link to show comment form, if successful. False, if comments are closed.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1707
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1708
function get_post_reply_link($args = array(), $post = null) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1709
	$defaults = array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1710
		'add_below'  => 'post',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1711
		'respond_id' => 'respond',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1712
		'reply_text' => __('Leave a Comment'),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1713
		'login_text' => __('Log in to leave a Comment'),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1714
		'before'     => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1715
		'after'      => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1716
	);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1717
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1718
	$args = wp_parse_args($args, $defaults);
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1719
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1720
	$post = get_post($post);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1721
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1722
	if ( ! comments_open( $post->ID ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1723
		return false;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1724
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1725
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1726
	if ( get_option('comment_registration') && ! is_user_logged_in() ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1727
		$link = sprintf( '<a rel="nofollow" class="comment-reply-login" href="%s">%s</a>',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1728
			wp_login_url( get_permalink() ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1729
			$args['login_text']
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1730
		);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1731
	} else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1732
		$onclick = sprintf( 'return addComment.moveForm( "%1$s-%2$s", "0", "%3$s", "%2$s" )',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1733
			$args['add_below'], $post->ID, $args['respond_id']
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1734
		);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1735
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1736
		$link = sprintf( "<a rel='nofollow' class='comment-reply-link' href='%s' onclick='%s'>%s</a>",
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1737
			get_permalink( $post->ID ) . '#' . $args['respond_id'],
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1738
			$onclick,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1739
			$args['reply_text']
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1740
		);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1741
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1742
	$formatted_link = $args['before'] . $link . $args['after'];
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1743
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1744
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1745
	 * Filters the formatted post comments link HTML.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1746
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1747
	 * @since 2.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1748
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1749
	 * @param string      $formatted The HTML-formatted post comments link.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1750
	 * @param int|WP_Post $post      The post ID or WP_Post object.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1751
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1752
	return apply_filters( 'post_comments_link', $formatted_link, $post );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1753
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1754
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1755
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1756
 * Displays the HTML content for reply to post link.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1757
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1758
 * @since 2.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1759
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1760
 * @see get_post_reply_link()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1761
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1762
 * @param array       $args Optional. Override default options,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1763
 * @param int|WP_Post $post Post ID or WP_Post object the comment is going to be displayed on.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1764
 *                          Default current post.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1765
 * @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
  1766
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1767
function post_reply_link($args = array(), $post = null) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1768
	echo get_post_reply_link($args, $post);
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
 * Retrieve HTML content for cancel comment reply link.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1773
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1774
 * @since 2.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1775
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1776
 * @param string $text Optional. Text to display for cancel reply link. Default empty.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1777
 * @return string
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
function get_cancel_comment_reply_link( $text = '' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1780
	if ( empty($text) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1781
		$text = __('Click here to cancel reply.');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1782
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1783
	$style = isset($_GET['replytocom']) ? '' : ' style="display:none;"';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1784
	$link = esc_html( remove_query_arg('replytocom') ) . '#respond';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1785
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1786
	$formatted_link = '<a rel="nofollow" id="cancel-comment-reply-link" href="' . $link . '"' . $style . '>' . $text . '</a>';
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1787
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1788
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1789
	 * Filters the cancel comment reply link HTML.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1790
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1791
	 * @since 2.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1792
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1793
	 * @param string $formatted_link The HTML-formatted cancel comment reply link.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1794
	 * @param string $link           Cancel comment reply link URL.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1795
	 * @param string $text           Cancel comment reply link text.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1796
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1797
	return apply_filters( 'cancel_comment_reply_link', $formatted_link, $link, $text );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1798
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1799
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1800
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1801
 * Display HTML content for cancel comment reply link.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1802
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1803
 * @since 2.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1804
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1805
 * @param string $text Optional. Text to display for cancel reply link. Default empty.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1806
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1807
function cancel_comment_reply_link( $text = '' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1808
	echo get_cancel_comment_reply_link($text);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1809
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1810
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1811
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1812
 * Retrieve hidden input HTML for replying to comments.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1813
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1814
 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1815
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1816
 * @param int $id Optional. Post ID. Default current post ID.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1817
 * @return string Hidden input HTML for replying to comments
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1818
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1819
function get_comment_id_fields( $id = 0 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1820
	if ( empty( $id ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1821
		$id = get_the_ID();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1822
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1823
	$replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1824
	$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
  1825
	$result .= "<input type='hidden' name='comment_parent' id='comment_parent' value='$replytoid' />\n";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1826
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1827
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1828
	 * Filters the returned comment id fields.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1829
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1830
	 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1831
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1832
	 * @param string $result    The HTML-formatted hidden id field comment elements.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1833
	 * @param int    $id        The post ID.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1834
	 * @param int    $replytoid The id of the comment being replied to.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1835
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1836
	return apply_filters( 'comment_id_fields', $result, $id, $replytoid );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1837
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1838
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1839
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1840
 * Output hidden input HTML for replying to comments.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1841
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1842
 * @since 2.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1843
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1844
 * @param int $id Optional. Post ID. Default current post ID.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1845
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1846
function comment_id_fields( $id = 0 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1847
	echo get_comment_id_fields( $id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1848
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1849
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1850
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1851
 * Display text based on comment reply status.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1852
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1853
 * Only affects users with JavaScript disabled.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1854
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1855
 * @internal The $comment global must be present to allow template tags access to the current
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1856
 *           comment. See https://core.trac.wordpress.org/changeset/36512.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1857
 *
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1858
 * @since 2.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1859
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1860
 * @global WP_Comment $comment Current comment.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1861
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1862
 * @param string $noreplytext  Optional. Text to display when not replying to a comment.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1863
 *                             Default false.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1864
 * @param string $replytext    Optional. Text to display when replying to a comment.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1865
 *                             Default false. Accepts "%s" for the author of the comment
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1866
 *                             being replied to.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1867
 * @param string $linktoparent Optional. Boolean to control making the author's name a link
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1868
 *                             to their comment. Default true.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1869
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1870
function comment_form_title( $noreplytext = false, $replytext = false, $linktoparent = true ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1871
	global $comment;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1872
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1873
	if ( false === $noreplytext ) $noreplytext = __( 'Leave a Reply' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1874
	if ( false === $replytext ) $replytext = __( 'Leave a Reply to %s' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1875
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1876
	$replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1877
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1878
	if ( 0 == $replytoid )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1879
		echo $noreplytext;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1880
	else {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1881
		// Sets the global so that template tags can be used in the comment form.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1882
		$comment = get_comment($replytoid);
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1883
		$author = ( $linktoparent ) ? '<a href="#comment-' . get_comment_ID() . '">' . get_comment_author( $comment ) . '</a>' : get_comment_author( $comment );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1884
		printf( $replytext, $author );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1885
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1886
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1887
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1888
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1889
 * List comments.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1890
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1891
 * Used in the comments.php template to list comments for a particular post.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1892
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1893
 * @since 2.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1894
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1895
 * @see WP_Query->comments
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1896
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1897
 * @global WP_Query $wp_query
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1898
 * @global int      $comment_alt
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1899
 * @global int      $comment_depth
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1900
 * @global int      $comment_thread_alt
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1901
 * @global bool     $overridden_cpage
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1902
 * @global bool     $in_comment_loop
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1903
 *
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1904
 * @param string|array $args {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1905
 *     Optional. Formatting options.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1906
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1907
 *     @type object $walker            Instance of a Walker class to list comments. Default null.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1908
 *     @type int    $max_depth         The maximum comments depth. Default empty.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1909
 *     @type string $style             The style of list ordering. Default 'ul'. Accepts 'ul', 'ol'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1910
 *     @type string $callback          Callback function to use. Default null.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1911
 *     @type string $end-callback      Callback function to use at the end. Default null.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1912
 *     @type string $type              Type of comments to list.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1913
 *                                     Default 'all'. Accepts 'all', 'comment', 'pingback', 'trackback', 'pings'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1914
 *     @type int    $page              Page ID to list comments for. Default empty.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1915
 *     @type int    $per_page          Number of comments to list per page. Default empty.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1916
 *     @type int    $avatar_size       Height and width dimensions of the avatar size. Default 32.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1917
 *     @type bool   $reverse_top_level Ordering of the listed comments. If true, will display newest comments first.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1918
 *     @type bool   $reverse_children  Whether to reverse child comments in the list. Default null.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1919
 *     @type string $format            How to format the comments list.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1920
 *                                     Default 'html5' if the theme supports it. Accepts 'html5', 'xhtml'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1921
 *     @type bool   $short_ping        Whether to output short pings. Default false.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1922
 *     @type bool   $echo              Whether to echo the output or return it. Default true.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1923
 * }
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1924
 * @param array $comments Optional. Array of WP_Comment objects.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1925
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1926
function wp_list_comments( $args = array(), $comments = null ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1927
	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
  1928
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1929
	$in_comment_loop = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1930
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1931
	$comment_alt = $comment_thread_alt = 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1932
	$comment_depth = 1;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1933
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1934
	$defaults = array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1935
		'walker'            => null,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1936
		'max_depth'         => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1937
		'style'             => 'ul',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1938
		'callback'          => null,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1939
		'end-callback'      => null,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1940
		'type'              => 'all',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1941
		'page'              => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1942
		'per_page'          => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1943
		'avatar_size'       => 32,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1944
		'reverse_top_level' => null,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1945
		'reverse_children'  => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1946
		'format'            => current_theme_supports( 'html5', 'comment-list' ) ? 'html5' : 'xhtml',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1947
		'short_ping'        => false,
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1948
		'echo'              => true,
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1949
	);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1950
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1951
	$r = wp_parse_args( $args, $defaults );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1952
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1953
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1954
	 * Filters the arguments used in retrieving the comment list.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1955
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1956
	 * @since 4.0.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1957
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1958
	 * @see wp_list_comments()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1959
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1960
	 * @param array $r An array of arguments for displaying comments.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1961
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1962
	$r = apply_filters( 'wp_list_comments_args', $r );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1963
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1964
	// Figure out what comments we'll be looping through ($_comments)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1965
	if ( null !== $comments ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1966
		$comments = (array) $comments;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1967
		if ( empty($comments) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1968
			return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1969
		if ( 'all' != $r['type'] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1970
			$comments_by_type = separate_comments($comments);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1971
			if ( empty($comments_by_type[$r['type']]) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1972
				return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1973
			$_comments = $comments_by_type[$r['type']];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1974
		} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1975
			$_comments = $comments;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1976
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1977
	} else {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1978
		/*
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1979
		 * If 'page' or 'per_page' has been passed, and does not match what's in $wp_query,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1980
		 * perform a separate comment query and allow Walker_Comment to paginate.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1981
		 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1982
		if ( $r['page'] || $r['per_page'] ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1983
			$current_cpage = get_query_var( 'cpage' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1984
			if ( ! $current_cpage ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1985
				$current_cpage = 'newest' === get_option( 'default_comments_page' ) ? 1 : $wp_query->max_num_comment_pages;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1986
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1987
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1988
			$current_per_page = get_query_var( 'comments_per_page' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1989
			if ( $r['page'] != $current_cpage || $r['per_page'] != $current_per_page ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1990
				$comment_args = array(
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1991
					'post_id' => get_the_ID(),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1992
					'orderby' => 'comment_date_gmt',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1993
					'order' => 'ASC',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1994
					'status' => 'approve',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1995
				);
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1996
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1997
				if ( is_user_logged_in() ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1998
					$comment_args['include_unapproved'] = get_current_user_id();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1999
				} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2000
					$commenter = wp_get_current_commenter();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2001
					if ( $commenter['comment_author_email'] ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2002
						$comment_args['include_unapproved'] = $commenter['comment_author_email'];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2003
					}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2004
				}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2005
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2006
				$comments = get_comments( $comment_args );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2007
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2008
				if ( 'all' != $r['type'] ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2009
					$comments_by_type = separate_comments( $comments );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2010
					if ( empty( $comments_by_type[ $r['type'] ] ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2011
						return;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2012
					}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2013
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2014
					$_comments = $comments_by_type[ $r['type'] ];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2015
				} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2016
					$_comments = $comments;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2017
				}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2018
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2019
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2020
		// Otherwise, fall back on the comments from `$wp_query->comments`.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2021
		} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2022
			if ( empty($wp_query->comments) )
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2023
				return;
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2024
			if ( 'all' != $r['type'] ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2025
				if ( empty($wp_query->comments_by_type) )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2026
					$wp_query->comments_by_type = separate_comments($wp_query->comments);
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2027
				if ( empty($wp_query->comments_by_type[$r['type']]) )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2028
					return;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2029
				$_comments = $wp_query->comments_by_type[$r['type']];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2030
			} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2031
				$_comments = $wp_query->comments;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2032
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2033
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2034
			if ( $wp_query->max_num_comment_pages ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2035
				$default_comments_page = get_option( 'default_comments_page' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2036
				$cpage = get_query_var( 'cpage' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2037
				if ( 'newest' === $default_comments_page ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2038
					$r['cpage'] = $cpage;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2039
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2040
				/*
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2041
				 * When first page shows oldest comments, post permalink is the same as
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2042
				 * the comment permalink.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2043
				 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2044
				} elseif ( $cpage == 1 ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2045
					$r['cpage'] = '';
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2046
				} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2047
					$r['cpage'] = $cpage;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2048
				}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2049
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2050
				$r['page'] = 0;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2051
				$r['per_page'] = 0;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2052
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2053
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2054
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2055
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2056
	if ( '' === $r['per_page'] && get_option( 'page_comments' ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2057
		$r['per_page'] = get_query_var('comments_per_page');
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2058
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2059
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2060
	if ( empty($r['per_page']) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2061
		$r['per_page'] = 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2062
		$r['page'] = 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2063
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2064
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2065
	if ( '' === $r['max_depth'] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2066
		if ( get_option('thread_comments') )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2067
			$r['max_depth'] = get_option('thread_comments_depth');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2068
		else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2069
			$r['max_depth'] = -1;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2070
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2071
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2072
	if ( '' === $r['page'] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2073
		if ( empty($overridden_cpage) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2074
			$r['page'] = get_query_var('cpage');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2075
		} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2076
			$threaded = ( -1 != $r['max_depth'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2077
			$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
  2078
			set_query_var( 'cpage', $r['page'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2079
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2080
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2081
	// Validation check
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2082
	$r['page'] = intval($r['page']);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2083
	if ( 0 == $r['page'] && 0 != $r['per_page'] )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2084
		$r['page'] = 1;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2085
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2086
	if ( null === $r['reverse_top_level'] )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2087
		$r['reverse_top_level'] = ( 'desc' == get_option('comment_order') );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2088
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2089
	wp_queue_comments_for_comment_meta_lazyload( $_comments );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2090
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2091
	if ( empty( $r['walker'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2092
		$walker = new Walker_Comment;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2093
	} else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2094
		$walker = $r['walker'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2095
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2096
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2097
	$output = $walker->paged_walk( $_comments, $r['max_depth'], $r['page'], $r['per_page'], $r );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2098
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2099
	$in_comment_loop = false;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2100
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2101
	if ( $r['echo'] ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2102
		echo $output;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2103
	} else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2104
		return $output;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2105
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2106
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2107
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2108
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2109
 * Outputs a complete commenting form for use within a template.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2110
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2111
 * Most strings and form fields may be controlled through the $args array passed
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2112
 * into the function, while you may also choose to use the {@see 'comment_form_default_fields'}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2113
 * 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
  2114
 * one or remove a single field. All fields are also individually passed through
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2115
 * a filter of the {@see 'comment_form_field_$name'} where $name is the key used
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2116
 * in the array of fields.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2117
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2118
 * @since 3.0.0
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2119
 * @since 4.1.0 Introduced the 'class_submit' argument.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2120
 * @since 4.2.0 Introduced the 'submit_button' and 'submit_fields' arguments.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2121
 * @since 4.4.0 Introduced the 'class_form', 'title_reply_before', 'title_reply_after',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2122
 *              'cancel_reply_before', and 'cancel_reply_after' arguments.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2123
 * @since 4.5.0 The 'author', 'email', and 'url' form fields are limited to 245, 100,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2124
 *              and 200 characters, respectively.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2125
 * @since 4.6.0 Introduced the 'action' argument.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2126
 * @since 4.9.6 Introduced the 'cookies' default comment field.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2127
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2128
 * @param array       $args {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2129
 *     Optional. Default arguments and form fields to override.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2130
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2131
 *     @type array $fields {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2132
 *         Default comment fields, filterable by default via the {@see 'comment_form_default_fields'} hook.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2133
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2134
 *         @type string $author  Comment author field HTML.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2135
 *         @type string $email   Comment author email field HTML.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2136
 *         @type string $url     Comment author URL field HTML.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2137
 *         @type string $cookies Comment cookie opt-in field HTML.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2138
 *     }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2139
 *     @type string $comment_field        The comment textarea field HTML.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2140
 *     @type string $must_log_in          HTML element for a 'must be logged in to comment' message.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2141
 *     @type string $logged_in_as         HTML element for a 'logged in as [user]' message.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2142
 *     @type string $comment_notes_before HTML element for a message displayed before the comment fields
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2143
 *                                        if the user is not logged in.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2144
 *                                        Default 'Your email address will not be published.'.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2145
 *     @type string $comment_notes_after  HTML element for a message displayed after the textarea field.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2146
 *     @type string $action               The comment form element action attribute. Default '/wp-comments-post.php'.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2147
 *     @type string $id_form              The comment form element id attribute. Default 'commentform'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2148
 *     @type string $id_submit            The comment submit element id attribute. Default 'submit'.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2149
 *     @type string $class_form           The comment form element class attribute. Default 'comment-form'.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2150
 *     @type string $class_submit         The comment submit element class attribute. Default 'submit'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2151
 *     @type string $name_submit          The comment submit element name attribute. Default 'submit'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2152
 *     @type string $title_reply          The translatable 'reply' button label. Default 'Leave a Reply'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2153
 *     @type string $title_reply_to       The translatable 'reply-to' button label. Default 'Leave a Reply to %s',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2154
 *                                        where %s is the author of the comment being replied to.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2155
 *     @type string $title_reply_before   HTML displayed before the comment form title.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2156
 *                                        Default: '<h3 id="reply-title" class="comment-reply-title">'.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2157
 *     @type string $title_reply_after    HTML displayed after the comment form title.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2158
 *                                        Default: '</h3>'.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2159
 *     @type string $cancel_reply_before  HTML displayed before the cancel reply link.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2160
 *     @type string $cancel_reply_after   HTML displayed after the cancel reply link.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2161
 *     @type string $cancel_reply_link    The translatable 'cancel reply' button label. Default 'Cancel reply'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2162
 *     @type string $label_submit         The translatable 'submit' button label. Default 'Post a comment'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2163
 *     @type string $submit_button        HTML format for the Submit button.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2164
 *                                        Default: '<input name="%1$s" type="submit" id="%2$s" class="%3$s" value="%4$s" />'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2165
 *     @type string $submit_field         HTML format for the markup surrounding the Submit button and comment hidden
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2166
 *                                        fields. Default: '<p class="form-submit">%1$s %2$s</p>', where %1$s is the
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2167
 *                                        submit button markup and %2$s is the comment hidden fields.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2168
 *     @type string $format               The comment form format. Default 'xhtml'. Accepts 'xhtml', 'html5'.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2169
 * }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2170
 * @param int|WP_Post $post_id Post ID or WP_Post object to generate the form for. Default current post.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2171
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2172
function comment_form( $args = array(), $post_id = null ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2173
	if ( null === $post_id )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2174
		$post_id = get_the_ID();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2175
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2176
	// Exit the function when comments for the post are closed.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2177
	if ( ! comments_open( $post_id ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2178
		/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2179
		 * Fires after the comment form if comments are closed.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2180
		 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2181
		 * @since 3.0.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2182
		 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2183
		do_action( 'comment_form_comments_closed' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2184
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2185
		return;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2186
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2187
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2188
	$commenter = wp_get_current_commenter();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2189
	$user = wp_get_current_user();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2190
	$user_identity = $user->exists() ? $user->display_name : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2191
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2192
	$args = wp_parse_args( $args );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2193
	if ( ! isset( $args['format'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2194
		$args['format'] = current_theme_supports( 'html5', 'comment-form' ) ? 'html5' : 'xhtml';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2195
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2196
	$req      = get_option( 'require_name_email' );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2197
	$html_req = ( $req ? " required='required'" : '' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2198
	$html5    = 'html5' === $args['format'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2199
	$fields   =  array(
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2200
		'author'  => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' .
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2201
					 '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30" maxlength="245"' . $html_req . ' /></p>',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2202
		'email'   => '<p class="comment-form-email"><label for="email">' . __( 'Email' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' .
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2203
					 '<input id="email" name="email" ' . ( $html5 ? 'type="email"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30" maxlength="100" aria-describedby="email-notes"' . $html_req . ' /></p>',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2204
		'url'     => '<p class="comment-form-url"><label for="url">' . __( 'Website' ) . '</label> ' .
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2205
					 '<input id="url" name="url" ' . ( $html5 ? 'type="url"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" maxlength="200" /></p>',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2206
	);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2207
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2208
	if ( has_action( 'set_comment_cookies', 'wp_set_comment_cookies' ) && get_option( 'show_comments_cookies_opt_in' ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2209
		$consent           = empty( $commenter['comment_author_email'] ) ? '' : ' checked="checked"';
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2210
		$fields['cookies'] = '<p class="comment-form-cookies-consent"><input id="wp-comment-cookies-consent" name="wp-comment-cookies-consent" type="checkbox" value="yes"' . $consent . ' />' .
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2211
							 '<label for="wp-comment-cookies-consent">' . __( 'Save my name, email, and website in this browser for the next time I comment.' ) . '</label></p>';
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2212
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2213
		// Ensure that the passed fields include cookies consent.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2214
		if ( isset( $args['fields'] ) && ! isset( $args['fields']['cookies'] ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2215
			$args['fields']['cookies'] = $fields['cookies'];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2216
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2217
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2218
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2219
	$required_text = sprintf( ' ' . __( 'Required fields are marked %s' ), '<span class="required">*</span>' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2220
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2221
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2222
	 * Filters the default comment form fields.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2223
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2224
	 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2225
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2226
	 * @param array $fields The default comment fields.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2227
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2228
	$fields = apply_filters( 'comment_form_default_fields', $fields );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2229
	$defaults = array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2230
		'fields'               => $fields,
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2231
		'comment_field'        => '<p class="comment-form-comment"><label for="comment">' . _x( 'Comment', 'noun' ) . '</label> <textarea id="comment" name="comment" cols="45" rows="8" maxlength="65525" required="required"></textarea></p>',
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2232
		/** This filter is documented in wp-includes/link-template.php */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2233
		'must_log_in'          => '<p class="must-log-in">' . sprintf(
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2234
		                              /* translators: %s: login URL */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2235
		                              __( 'You must be <a href="%s">logged in</a> to post a comment.' ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2236
		                              wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ), $post_id ) )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2237
		                          ) . '</p>',
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2238
		/** This filter is documented in wp-includes/link-template.php */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2239
		'logged_in_as'         => '<p class="logged-in-as">' . sprintf(
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2240
		                              /* translators: 1: edit user link, 2: accessibility text, 3: user name, 4: logout URL */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2241
		                              __( '<a href="%1$s" aria-label="%2$s">Logged in as %3$s</a>. <a href="%4$s">Log out?</a>' ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2242
		                              get_edit_user_link(),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2243
		                              /* translators: %s: user name */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2244
		                              esc_attr( sprintf( __( 'Logged in as %s. Edit your profile.' ), $user_identity ) ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2245
		                              $user_identity,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2246
		                              wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ), $post_id ) )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2247
		                          ) . '</p>',
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2248
		'comment_notes_before' => '<p class="comment-notes"><span id="email-notes">' . __( 'Your email address will not be published.' ) . '</span>'. ( $req ? $required_text : '' ) . '</p>',
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2249
		'comment_notes_after'  => '',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2250
		'action'               => site_url( '/wp-comments-post.php' ),
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2251
		'id_form'              => 'commentform',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2252
		'id_submit'            => 'submit',
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2253
		'class_form'           => 'comment-form',
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2254
		'class_submit'         => 'submit',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2255
		'name_submit'          => 'submit',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2256
		'title_reply'          => __( 'Leave a Reply' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2257
		'title_reply_to'       => __( 'Leave a Reply to %s' ),
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2258
		'title_reply_before'   => '<h3 id="reply-title" class="comment-reply-title">',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2259
		'title_reply_after'    => '</h3>',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2260
		'cancel_reply_before'  => ' <small>',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2261
		'cancel_reply_after'   => '</small>',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2262
		'cancel_reply_link'    => __( 'Cancel reply' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2263
		'label_submit'         => __( 'Post Comment' ),
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2264
		'submit_button'        => '<input name="%1$s" type="submit" id="%2$s" class="%3$s" value="%4$s" />',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2265
		'submit_field'         => '<p class="form-submit">%1$s %2$s</p>',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2266
		'format'               => 'xhtml',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2267
	);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2268
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2269
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2270
	 * Filters the comment form default arguments.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2271
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2272
	 * Use {@see 'comment_form_default_fields'} to filter the comment fields.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2273
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2274
	 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2275
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2276
	 * @param array $defaults The default comment form arguments.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2277
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2278
	$args = wp_parse_args( $args, apply_filters( 'comment_form_defaults', $defaults ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2279
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2280
	// Ensure that the filtered args contain all required default values.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2281
	$args = array_merge( $defaults, $args );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2282
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2283
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2284
	 * Fires before the comment form.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2285
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2286
	 * @since 3.0.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2287
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2288
	do_action( 'comment_form_before' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2289
	?>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2290
	<div id="respond" class="comment-respond">
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2291
		<?php
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2292
		echo $args['title_reply_before'];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2293
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2294
		comment_form_title( $args['title_reply'], $args['title_reply_to'] );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2295
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2296
		echo $args['cancel_reply_before'];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2297
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2298
		cancel_comment_reply_link( $args['cancel_reply_link'] );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2299
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2300
		echo $args['cancel_reply_after'];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2301
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2302
		echo $args['title_reply_after'];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2303
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2304
		if ( get_option( 'comment_registration' ) && !is_user_logged_in() ) :
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2305
			echo $args['must_log_in'];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2306
			/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2307
			 * Fires after the HTML-formatted 'must log in after' message in the comment form.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2308
			 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2309
			 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2310
			 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2311
			do_action( 'comment_form_must_log_in_after' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2312
		else : ?>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2313
			<form action="<?php echo esc_url( $args['action'] ); ?>" method="post" id="<?php echo esc_attr( $args['id_form'] ); ?>" class="<?php echo esc_attr( $args['class_form'] ); ?>"<?php echo $html5 ? ' novalidate' : ''; ?>>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2314
				<?php
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2315
				/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2316
				 * Fires at the top of the comment form, inside the form tag.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2317
				 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2318
				 * @since 3.0.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2319
				 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2320
				do_action( 'comment_form_top' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2321
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2322
				if ( is_user_logged_in() ) :
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2323
					/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2324
					 * Filters the 'logged in' message for the comment form for display.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2325
					 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2326
					 * @since 3.0.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2327
					 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2328
					 * @param string $args_logged_in The logged-in-as HTML-formatted message.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2329
					 * @param array  $commenter      An array containing the comment author's
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2330
					 *                               username, email, and URL.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2331
					 * @param string $user_identity  If the commenter is a registered user,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2332
					 *                               the display name, blank otherwise.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2333
					 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2334
					echo apply_filters( 'comment_form_logged_in', $args['logged_in_as'], $commenter, $user_identity );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2335
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2336
					/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2337
					 * Fires after the is_user_logged_in() check in the comment form.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2338
					 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2339
					 * @since 3.0.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2340
					 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2341
					 * @param array  $commenter     An array containing the comment author's
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2342
					 *                              username, email, and URL.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2343
					 * @param string $user_identity If the commenter is a registered user,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2344
					 *                              the display name, blank otherwise.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2345
					 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2346
					do_action( 'comment_form_logged_in_after', $commenter, $user_identity );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2347
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2348
				else :
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2349
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2350
					echo $args['comment_notes_before'];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2351
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2352
				endif;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2353
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2354
				// Prepare an array of all fields, including the textarea
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2355
				$comment_fields = array( 'comment' => $args['comment_field'] ) + (array) $args['fields'];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2356
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2357
				/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2358
				 * Filters the comment form fields, including the textarea.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2359
				 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2360
				 * @since 4.4.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2361
				 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2362
				 * @param array $comment_fields The comment fields.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2363
				 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2364
				$comment_fields = apply_filters( 'comment_form_fields', $comment_fields );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2365
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2366
				// Get an array of field names, excluding the textarea
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2367
				$comment_field_keys = array_diff( array_keys( $comment_fields ), array( 'comment' ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2368
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2369
				// Get the first and the last field name, excluding the textarea
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2370
				$first_field = reset( $comment_field_keys );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2371
				$last_field  = end( $comment_field_keys );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2372
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2373
				foreach ( $comment_fields as $name => $field ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2374
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2375
					if ( 'comment' === $name ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2376
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2377
						/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2378
						 * Filters the content of the comment textarea field for display.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2379
						 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2380
						 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2381
						 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2382
						 * @param string $args_comment_field The content of the comment textarea field.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2383
						 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2384
						echo apply_filters( 'comment_form_field_comment', $field );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2385
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2386
						echo $args['comment_notes_after'];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2387
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2388
					} elseif ( ! is_user_logged_in() ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2389
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2390
						if ( $first_field === $name ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2391
							/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2392
							 * Fires before the comment fields in the comment form, excluding the textarea.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2393
							 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2394
							 * @since 3.0.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2395
							 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2396
							do_action( 'comment_form_before_fields' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2397
						}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2398
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2399
						/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2400
						 * Filters a comment form field for display.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2401
						 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2402
						 * The dynamic portion of the filter hook, `$name`, refers to the name
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2403
						 * of the comment form field. Such as 'author', 'email', or 'url'.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2404
						 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2405
						 * @since 3.0.0
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2406
						 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2407
						 * @param string $field The HTML-formatted output of the comment form field.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2408
						 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2409
						echo apply_filters( "comment_form_field_{$name}", $field ) . "\n";
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2410
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2411
						if ( $last_field === $name ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2412
							/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2413
							 * Fires after the comment fields in the comment form, excluding the textarea.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2414
							 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2415
							 * @since 3.0.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2416
							 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2417
							do_action( 'comment_form_after_fields' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2418
						}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2419
					}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2420
				}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2421
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2422
				$submit_button = sprintf(
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2423
					$args['submit_button'],
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2424
					esc_attr( $args['name_submit'] ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2425
					esc_attr( $args['id_submit'] ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2426
					esc_attr( $args['class_submit'] ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2427
					esc_attr( $args['label_submit'] )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2428
				);
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2429
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2430
				/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2431
				 * Filters the submit button for the comment form to display.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2432
				 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2433
				 * @since 4.2.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2434
				 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2435
				 * @param string $submit_button HTML markup for the submit button.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2436
				 * @param array  $args          Arguments passed to `comment_form()`.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2437
				 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2438
				$submit_button = apply_filters( 'comment_form_submit_button', $submit_button, $args );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2439
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2440
				$submit_field = sprintf(
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2441
					$args['submit_field'],
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2442
					$submit_button,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2443
					get_comment_id_fields( $post_id )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2444
				);
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2445
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2446
				/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2447
				 * Filters the submit field for the comment form to display.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2448
				 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2449
				 * The submit field includes the submit button, hidden fields for the
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2450
				 * comment form, and any wrapper markup.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2451
				 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2452
				 * @since 4.2.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2453
				 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2454
				 * @param string $submit_field HTML markup for the submit field.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2455
				 * @param array  $args         Arguments passed to comment_form().
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2456
				 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2457
				echo apply_filters( 'comment_form_submit_field', $submit_field, $args );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2458
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2459
				/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2460
				 * Fires at the bottom of the comment form, inside the closing </form> tag.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2461
				 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2462
				 * @since 1.5.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2463
				 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2464
				 * @param int $post_id The post ID.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2465
				 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2466
				do_action( 'comment_form', $post_id );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2467
				?>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2468
			</form>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2469
		<?php endif; ?>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2470
	</div><!-- #respond -->
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2471
	<?php
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2472
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2473
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2474
	 * Fires after the comment form.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2475
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2476
	 * @since 3.0.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2477
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2478
	do_action( 'comment_form_after' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2479
}