Edit File by line
/home/barbar84/www/wp-inclu...
File: comment-template.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Comment template functions
[2] Fix | Delete
*
[3] Fix | Delete
* These functions are meant to live inside of the WordPress loop.
[4] Fix | Delete
*
[5] Fix | Delete
* @package WordPress
[6] Fix | Delete
* @subpackage Template
[7] Fix | Delete
*/
[8] Fix | Delete
[9] Fix | Delete
/**
[10] Fix | Delete
* Retrieves the author of the current comment.
[11] Fix | Delete
*
[12] Fix | Delete
* If the comment has an empty comment_author field, then 'Anonymous' person is
[13] Fix | Delete
* assumed.
[14] Fix | Delete
*
[15] Fix | Delete
* @since 1.5.0
[16] Fix | Delete
* @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
[17] Fix | Delete
*
[18] Fix | Delete
* @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to retrieve the author.
[19] Fix | Delete
* Default current comment.
[20] Fix | Delete
* @return string The comment author
[21] Fix | Delete
*/
[22] Fix | Delete
function get_comment_author( $comment_ID = 0 ) {
[23] Fix | Delete
$comment = get_comment( $comment_ID );
[24] Fix | Delete
[25] Fix | Delete
if ( empty( $comment->comment_author ) ) {
[26] Fix | Delete
$user = $comment->user_id ? get_userdata( $comment->user_id ) : false;
[27] Fix | Delete
if ( $user ) {
[28] Fix | Delete
$author = $user->display_name;
[29] Fix | Delete
} else {
[30] Fix | Delete
$author = __( 'Anonymous' );
[31] Fix | Delete
}
[32] Fix | Delete
} else {
[33] Fix | Delete
$author = $comment->comment_author;
[34] Fix | Delete
}
[35] Fix | Delete
[36] Fix | Delete
/**
[37] Fix | Delete
* Filters the returned comment author name.
[38] Fix | Delete
*
[39] Fix | Delete
* @since 1.5.0
[40] Fix | Delete
* @since 4.1.0 The `$comment_ID` and `$comment` parameters were added.
[41] Fix | Delete
*
[42] Fix | Delete
* @param string $author The comment author's username.
[43] Fix | Delete
* @param int $comment_ID The comment ID.
[44] Fix | Delete
* @param WP_Comment $comment The comment object.
[45] Fix | Delete
*/
[46] Fix | Delete
return apply_filters( 'get_comment_author', $author, $comment->comment_ID, $comment );
[47] Fix | Delete
}
[48] Fix | Delete
[49] Fix | Delete
/**
[50] Fix | Delete
* Displays the author of the current comment.
[51] Fix | Delete
*
[52] Fix | Delete
* @since 0.71
[53] Fix | Delete
* @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
[54] Fix | Delete
*
[55] Fix | Delete
* @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author.
[56] Fix | Delete
* Default current comment.
[57] Fix | Delete
*/
[58] Fix | Delete
function comment_author( $comment_ID = 0 ) {
[59] Fix | Delete
$comment = get_comment( $comment_ID );
[60] Fix | Delete
$author = get_comment_author( $comment );
[61] Fix | Delete
[62] Fix | Delete
/**
[63] Fix | Delete
* Filters the comment author's name for display.
[64] Fix | Delete
*
[65] Fix | Delete
* @since 1.2.0
[66] Fix | Delete
* @since 4.1.0 The `$comment_ID` parameter was added.
[67] Fix | Delete
*
[68] Fix | Delete
* @param string $author The comment author's username.
[69] Fix | Delete
* @param int $comment_ID The comment ID.
[70] Fix | Delete
*/
[71] Fix | Delete
echo apply_filters( 'comment_author', $author, $comment->comment_ID );
[72] Fix | Delete
}
[73] Fix | Delete
[74] Fix | Delete
/**
[75] Fix | Delete
* Retrieves the email of the author of the current comment.
[76] Fix | Delete
*
[77] Fix | Delete
* @since 1.5.0
[78] Fix | Delete
* @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
[79] Fix | Delete
*
[80] Fix | Delete
* @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to get the author's email.
[81] Fix | Delete
* Default current comment.
[82] Fix | Delete
* @return string The current comment author's email
[83] Fix | Delete
*/
[84] Fix | Delete
function get_comment_author_email( $comment_ID = 0 ) {
[85] Fix | Delete
$comment = get_comment( $comment_ID );
[86] Fix | Delete
[87] Fix | Delete
/**
[88] Fix | Delete
* Filters the comment author's returned email address.
[89] Fix | Delete
*
[90] Fix | Delete
* @since 1.5.0
[91] Fix | Delete
* @since 4.1.0 The `$comment_ID` and `$comment` parameters were added.
[92] Fix | Delete
*
[93] Fix | Delete
* @param string $comment_author_email The comment author's email address.
[94] Fix | Delete
* @param int $comment_ID The comment ID.
[95] Fix | Delete
* @param WP_Comment $comment The comment object.
[96] Fix | Delete
*/
[97] Fix | Delete
return apply_filters( 'get_comment_author_email', $comment->comment_author_email, $comment->comment_ID, $comment );
[98] Fix | Delete
}
[99] Fix | Delete
[100] Fix | Delete
/**
[101] Fix | Delete
* Displays the email of the author of the current global $comment.
[102] Fix | Delete
*
[103] Fix | Delete
* Care should be taken to protect the email address and assure that email
[104] Fix | Delete
* harvesters do not capture your commenter's email address. Most assume that
[105] Fix | Delete
* their email address will not appear in raw form on the site. Doing so will
[106] Fix | Delete
* enable anyone, including those that people don't want to get the email
[107] Fix | Delete
* address and use it for their own means good and bad.
[108] Fix | Delete
*
[109] Fix | Delete
* @since 0.71
[110] Fix | Delete
* @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
[111] Fix | Delete
*
[112] Fix | Delete
* @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author's email.
[113] Fix | Delete
* Default current comment.
[114] Fix | Delete
*/
[115] Fix | Delete
function comment_author_email( $comment_ID = 0 ) {
[116] Fix | Delete
$comment = get_comment( $comment_ID );
[117] Fix | Delete
$author_email = get_comment_author_email( $comment );
[118] Fix | Delete
[119] Fix | Delete
/**
[120] Fix | Delete
* Filters the comment author's email for display.
[121] Fix | Delete
*
[122] Fix | Delete
* @since 1.2.0
[123] Fix | Delete
* @since 4.1.0 The `$comment_ID` parameter was added.
[124] Fix | Delete
*
[125] Fix | Delete
* @param string $author_email The comment author's email address.
[126] Fix | Delete
* @param int $comment_ID The comment ID.
[127] Fix | Delete
*/
[128] Fix | Delete
echo apply_filters( 'author_email', $author_email, $comment->comment_ID );
[129] Fix | Delete
}
[130] Fix | Delete
[131] Fix | Delete
/**
[132] Fix | Delete
* Displays the HTML email link to the author of the current comment.
[133] Fix | Delete
*
[134] Fix | Delete
* Care should be taken to protect the email address and assure that email
[135] Fix | Delete
* harvesters do not capture your commenter's email address. Most assume that
[136] Fix | Delete
* their email address will not appear in raw form on the site. Doing so will
[137] Fix | Delete
* enable anyone, including those that people don't want to get the email
[138] Fix | Delete
* address and use it for their own means good and bad.
[139] Fix | Delete
*
[140] Fix | Delete
* @since 0.71
[141] Fix | Delete
* @since 4.6.0 Added the `$comment` parameter.
[142] Fix | Delete
*
[143] Fix | Delete
* @param string $linktext Optional. Text to display instead of the comment author's email address.
[144] Fix | Delete
* Default empty.
[145] Fix | Delete
* @param string $before Optional. Text or HTML to display before the email link. Default empty.
[146] Fix | Delete
* @param string $after Optional. Text or HTML to display after the email link. Default empty.
[147] Fix | Delete
* @param int|WP_Comment $comment Optional. Comment ID or WP_Comment object. Default is the current comment.
[148] Fix | Delete
*/
[149] Fix | Delete
function comment_author_email_link( $linktext = '', $before = '', $after = '', $comment = null ) {
[150] Fix | Delete
$link = get_comment_author_email_link( $linktext, $before, $after, $comment );
[151] Fix | Delete
if ( $link ) {
[152] Fix | Delete
echo $link;
[153] Fix | Delete
}
[154] Fix | Delete
}
[155] Fix | Delete
[156] Fix | Delete
/**
[157] Fix | Delete
* Returns the HTML email link to the author of the current comment.
[158] Fix | Delete
*
[159] Fix | Delete
* Care should be taken to protect the email address and assure that email
[160] Fix | Delete
* harvesters do not capture your commenter's email address. Most assume that
[161] Fix | Delete
* their email address will not appear in raw form on the site. Doing so will
[162] Fix | Delete
* enable anyone, including those that people don't want to get the email
[163] Fix | Delete
* address and use it for their own means good and bad.
[164] Fix | Delete
*
[165] Fix | Delete
* @since 2.7.0
[166] Fix | Delete
* @since 4.6.0 Added the `$comment` parameter.
[167] Fix | Delete
*
[168] Fix | Delete
* @param string $linktext Optional. Text to display instead of the comment author's email address.
[169] Fix | Delete
* Default empty.
[170] Fix | Delete
* @param string $before Optional. Text or HTML to display before the email link. Default empty.
[171] Fix | Delete
* @param string $after Optional. Text or HTML to display after the email link. Default empty.
[172] Fix | Delete
* @param int|WP_Comment $comment Optional. Comment ID or WP_Comment object. Default is the current comment.
[173] Fix | Delete
* @return string HTML markup for the comment author email link. By default, the email address is obfuscated
[174] Fix | Delete
* via the {@see 'comment_email'} filter with antispambot().
[175] Fix | Delete
*/
[176] Fix | Delete
function get_comment_author_email_link( $linktext = '', $before = '', $after = '', $comment = null ) {
[177] Fix | Delete
$comment = get_comment( $comment );
[178] Fix | Delete
[179] Fix | Delete
/**
[180] Fix | Delete
* Filters the comment author's email for display.
[181] Fix | Delete
*
[182] Fix | Delete
* Care should be taken to protect the email address and assure that email
[183] Fix | Delete
* harvesters do not capture your commenter's email address.
[184] Fix | Delete
*
[185] Fix | Delete
* @since 1.2.0
[186] Fix | Delete
* @since 4.1.0 The `$comment` parameter was added.
[187] Fix | Delete
*
[188] Fix | Delete
* @param string $comment_author_email The comment author's email address.
[189] Fix | Delete
* @param WP_Comment $comment The comment object.
[190] Fix | Delete
*/
[191] Fix | Delete
$email = apply_filters( 'comment_email', $comment->comment_author_email, $comment );
[192] Fix | Delete
[193] Fix | Delete
if ( ( ! empty( $email ) ) && ( '@' !== $email ) ) {
[194] Fix | Delete
$display = ( '' !== $linktext ) ? $linktext : $email;
[195] Fix | Delete
$return = $before;
[196] Fix | Delete
$return .= sprintf( '<a href="%1$s">%2$s</a>', esc_url( 'mailto:' . $email ), esc_html( $display ) );
[197] Fix | Delete
$return .= $after;
[198] Fix | Delete
return $return;
[199] Fix | Delete
} else {
[200] Fix | Delete
return '';
[201] Fix | Delete
}
[202] Fix | Delete
}
[203] Fix | Delete
[204] Fix | Delete
/**
[205] Fix | Delete
* Retrieves the HTML link to the URL of the author of the current comment.
[206] Fix | Delete
*
[207] Fix | Delete
* Both get_comment_author_url() and get_comment_author() rely on get_comment(),
[208] Fix | Delete
* which falls back to the global comment variable if the $comment_ID argument is empty.
[209] Fix | Delete
*
[210] Fix | Delete
* @since 1.5.0
[211] Fix | Delete
* @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
[212] Fix | Delete
*
[213] Fix | Delete
* @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to get the author's link.
[214] Fix | Delete
* Default current comment.
[215] Fix | Delete
* @return string The comment author name or HTML link for author's URL.
[216] Fix | Delete
*/
[217] Fix | Delete
function get_comment_author_link( $comment_ID = 0 ) {
[218] Fix | Delete
$comment = get_comment( $comment_ID );
[219] Fix | Delete
$url = get_comment_author_url( $comment );
[220] Fix | Delete
$author = get_comment_author( $comment );
[221] Fix | Delete
[222] Fix | Delete
if ( empty( $url ) || 'http://' === $url ) {
[223] Fix | Delete
$return = $author;
[224] Fix | Delete
} else {
[225] Fix | Delete
$return = "<a href='$url' rel='external nofollow ugc' class='url'>$author</a>";
[226] Fix | Delete
}
[227] Fix | Delete
[228] Fix | Delete
/**
[229] Fix | Delete
* Filters the comment author's link for display.
[230] Fix | Delete
*
[231] Fix | Delete
* @since 1.5.0
[232] Fix | Delete
* @since 4.1.0 The `$author` and `$comment_ID` parameters were added.
[233] Fix | Delete
*
[234] Fix | Delete
* @param string $return The HTML-formatted comment author link.
[235] Fix | Delete
* Empty for an invalid URL.
[236] Fix | Delete
* @param string $author The comment author's username.
[237] Fix | Delete
* @param int $comment_ID The comment ID.
[238] Fix | Delete
*/
[239] Fix | Delete
return apply_filters( 'get_comment_author_link', $return, $author, $comment->comment_ID );
[240] Fix | Delete
}
[241] Fix | Delete
[242] Fix | Delete
/**
[243] Fix | Delete
* Displays the HTML link to the URL of the author of the current comment.
[244] Fix | Delete
*
[245] Fix | Delete
* @since 0.71
[246] Fix | Delete
* @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
[247] Fix | Delete
*
[248] Fix | Delete
* @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author's link.
[249] Fix | Delete
* Default current comment.
[250] Fix | Delete
*/
[251] Fix | Delete
function comment_author_link( $comment_ID = 0 ) {
[252] Fix | Delete
echo get_comment_author_link( $comment_ID );
[253] Fix | Delete
}
[254] Fix | Delete
[255] Fix | Delete
/**
[256] Fix | Delete
* Retrieve the IP address of the author of the current comment.
[257] Fix | Delete
*
[258] Fix | Delete
* @since 1.5.0
[259] Fix | Delete
* @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
[260] Fix | Delete
*
[261] Fix | Delete
* @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to get the author's IP address.
[262] Fix | Delete
* Default current comment.
[263] Fix | Delete
* @return string Comment author's IP address.
[264] Fix | Delete
*/
[265] Fix | Delete
function get_comment_author_IP( $comment_ID = 0 ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
[266] Fix | Delete
$comment = get_comment( $comment_ID );
[267] Fix | Delete
[268] Fix | Delete
/**
[269] Fix | Delete
* Filters the comment author's returned IP address.
[270] Fix | Delete
*
[271] Fix | Delete
* @since 1.5.0
[272] Fix | Delete
* @since 4.1.0 The `$comment_ID` and `$comment` parameters were added.
[273] Fix | Delete
*
[274] Fix | Delete
* @param string $comment_author_IP The comment author's IP address.
[275] Fix | Delete
* @param int $comment_ID The comment ID.
[276] Fix | Delete
* @param WP_Comment $comment The comment object.
[277] Fix | Delete
*/
[278] Fix | Delete
return apply_filters( 'get_comment_author_IP', $comment->comment_author_IP, $comment->comment_ID, $comment ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
[279] Fix | Delete
}
[280] Fix | Delete
[281] Fix | Delete
/**
[282] Fix | Delete
* Displays the IP address of the author of the current comment.
[283] Fix | Delete
*
[284] Fix | Delete
* @since 0.71
[285] Fix | Delete
* @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
[286] Fix | Delete
*
[287] Fix | Delete
* @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author's IP address.
[288] Fix | Delete
* Default current comment.
[289] Fix | Delete
*/
[290] Fix | Delete
function comment_author_IP( $comment_ID = 0 ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
[291] Fix | Delete
echo esc_html( get_comment_author_IP( $comment_ID ) );
[292] Fix | Delete
}
[293] Fix | Delete
[294] Fix | Delete
/**
[295] Fix | Delete
* Retrieves the URL of the author of the current comment, not linked.
[296] Fix | Delete
*
[297] Fix | Delete
* @since 1.5.0
[298] Fix | Delete
* @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
[299] Fix | Delete
*
[300] Fix | Delete
* @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to get the author's URL.
[301] Fix | Delete
* Default current comment.
[302] Fix | Delete
* @return string Comment author URL, if provided, an empty string otherwise.
[303] Fix | Delete
*/
[304] Fix | Delete
function get_comment_author_url( $comment_ID = 0 ) {
[305] Fix | Delete
$comment = get_comment( $comment_ID );
[306] Fix | Delete
$url = '';
[307] Fix | Delete
$id = 0;
[308] Fix | Delete
[309] Fix | Delete
if ( ! empty( $comment ) ) {
[310] Fix | Delete
$author_url = ( 'http://' === $comment->comment_author_url ) ? '' : $comment->comment_author_url;
[311] Fix | Delete
$url = esc_url( $author_url, array( 'http', 'https' ) );
[312] Fix | Delete
$id = $comment->comment_ID;
[313] Fix | Delete
}
[314] Fix | Delete
[315] Fix | Delete
/**
[316] Fix | Delete
* Filters the comment author's URL.
[317] Fix | Delete
*
[318] Fix | Delete
* @since 1.5.0
[319] Fix | Delete
* @since 4.1.0 The `$comment_ID` and `$comment` parameters were added.
[320] Fix | Delete
*
[321] Fix | Delete
* @param string $url The comment author's URL.
[322] Fix | Delete
* @param int $comment_ID The comment ID.
[323] Fix | Delete
* @param WP_Comment $comment The comment object.
[324] Fix | Delete
*/
[325] Fix | Delete
return apply_filters( 'get_comment_author_url', $url, $id, $comment );
[326] Fix | Delete
}
[327] Fix | Delete
[328] Fix | Delete
/**
[329] Fix | Delete
* Displays the URL of the author of the current comment, not linked.
[330] Fix | Delete
*
[331] Fix | Delete
* @since 0.71
[332] Fix | Delete
* @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
[333] Fix | Delete
*
[334] Fix | Delete
* @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author's URL.
[335] Fix | Delete
* Default current comment.
[336] Fix | Delete
*/
[337] Fix | Delete
function comment_author_url( $comment_ID = 0 ) {
[338] Fix | Delete
$comment = get_comment( $comment_ID );
[339] Fix | Delete
$author_url = get_comment_author_url( $comment );
[340] Fix | Delete
[341] Fix | Delete
/**
[342] Fix | Delete
* Filters the comment author's URL for display.
[343] Fix | Delete
*
[344] Fix | Delete
* @since 1.2.0
[345] Fix | Delete
* @since 4.1.0 The `$comment_ID` parameter was added.
[346] Fix | Delete
*
[347] Fix | Delete
* @param string $author_url The comment author's URL.
[348] Fix | Delete
* @param int $comment_ID The comment ID.
[349] Fix | Delete
*/
[350] Fix | Delete
echo apply_filters( 'comment_url', $author_url, $comment->comment_ID );
[351] Fix | Delete
}
[352] Fix | Delete
[353] Fix | Delete
/**
[354] Fix | Delete
* Retrieves the HTML link of the URL of the author of the current comment.
[355] Fix | Delete
*
[356] Fix | Delete
* $linktext parameter is only used if the URL does not exist for the comment
[357] Fix | Delete
* author. If the URL does exist then the URL will be used and the $linktext
[358] Fix | Delete
* will be ignored.
[359] Fix | Delete
*
[360] Fix | Delete
* Encapsulate the HTML link between the $before and $after. So it will appear
[361] Fix | Delete
* in the order of $before, link, and finally $after.
[362] Fix | Delete
*
[363] Fix | Delete
* @since 1.5.0
[364] Fix | Delete
* @since 4.6.0 Added the `$comment` parameter.
[365] Fix | Delete
*
[366] Fix | Delete
* @param string $linktext Optional. The text to display instead of the comment
[367] Fix | Delete
* author's email address. Default empty.
[368] Fix | Delete
* @param string $before Optional. The text or HTML to display before the email link.
[369] Fix | Delete
* Default empty.
[370] Fix | Delete
* @param string $after Optional. The text or HTML to display after the email link.
[371] Fix | Delete
* Default empty.
[372] Fix | Delete
* @param int|WP_Comment $comment Optional. Comment ID or WP_Comment object.
[373] Fix | Delete
* Default is the current comment.
[374] Fix | Delete
* @return string The HTML link between the $before and $after parameters.
[375] Fix | Delete
*/
[376] Fix | Delete
function get_comment_author_url_link( $linktext = '', $before = '', $after = '', $comment = 0 ) {
[377] Fix | Delete
$url = get_comment_author_url( $comment );
[378] Fix | Delete
$display = ( '' !== $linktext ) ? $linktext : $url;
[379] Fix | Delete
$display = str_replace( 'http://www.', '', $display );
[380] Fix | Delete
$display = str_replace( 'http://', '', $display );
[381] Fix | Delete
[382] Fix | Delete
if ( '/' === substr( $display, -1 ) ) {
[383] Fix | Delete
$display = substr( $display, 0, -1 );
[384] Fix | Delete
}
[385] Fix | Delete
[386] Fix | Delete
$return = "$before<a href='$url' rel='external'>$display</a>$after";
[387] Fix | Delete
[388] Fix | Delete
/**
[389] Fix | Delete
* Filters the comment author's returned URL link.
[390] Fix | Delete
*
[391] Fix | Delete
* @since 1.5.0
[392] Fix | Delete
*
[393] Fix | Delete
* @param string $return The HTML-formatted comment author URL link.
[394] Fix | Delete
*/
[395] Fix | Delete
return apply_filters( 'get_comment_author_url_link', $return );
[396] Fix | Delete
}
[397] Fix | Delete
[398] Fix | Delete
/**
[399] Fix | Delete
* Displays the HTML link of the URL of the author of the current comment.
[400] Fix | Delete
*
[401] Fix | Delete
* @since 0.71
[402] Fix | Delete
* @since 4.6.0 Added the `$comment` parameter.
[403] Fix | Delete
*
[404] Fix | Delete
* @param string $linktext Optional. Text to display instead of the comment author's
[405] Fix | Delete
* email address. Default empty.
[406] Fix | Delete
* @param string $before Optional. Text or HTML to display before the email link.
[407] Fix | Delete
* Default empty.
[408] Fix | Delete
* @param string $after Optional. Text or HTML to display after the email link.
[409] Fix | Delete
* Default empty.
[410] Fix | Delete
* @param int|WP_Comment $comment Optional. Comment ID or WP_Comment object.
[411] Fix | Delete
* Default is the current comment.
[412] Fix | Delete
*/
[413] Fix | Delete
function comment_author_url_link( $linktext = '', $before = '', $after = '', $comment = 0 ) {
[414] Fix | Delete
echo get_comment_author_url_link( $linktext, $before, $after, $comment );
[415] Fix | Delete
}
[416] Fix | Delete
[417] Fix | Delete
/**
[418] Fix | Delete
* Generates semantic classes for each comment element.
[419] Fix | Delete
*
[420] Fix | Delete
* @since 2.7.0
[421] Fix | Delete
* @since 4.4.0 Added the ability for `$comment` to also accept a WP_Comment object.
[422] Fix | Delete
*
[423] Fix | Delete
* @param string|string[] $class Optional. One or more classes to add to the class list.
[424] Fix | Delete
* Default empty.
[425] Fix | Delete
* @param int|WP_Comment $comment Comment ID or WP_Comment object. Default current comment.
[426] Fix | Delete
* @param int|WP_Post $post_id Post ID or WP_Post object. Default current post.
[427] Fix | Delete
* @param bool $echo Optional. Whether to echo or return the output.
[428] Fix | Delete
* Default true.
[429] Fix | Delete
* @return void|string Void if `$echo` argument is true, comment classes if `$echo` is false.
[430] Fix | Delete
*/
[431] Fix | Delete
function comment_class( $class = '', $comment = null, $post_id = null, $echo = true ) {
[432] Fix | Delete
// Separates classes with a single space, collates classes for comment DIV.
[433] Fix | Delete
$class = 'class="' . implode( ' ', get_comment_class( $class, $comment, $post_id ) ) . '"';
[434] Fix | Delete
[435] Fix | Delete
if ( $echo ) {
[436] Fix | Delete
echo $class;
[437] Fix | Delete
} else {
[438] Fix | Delete
return $class;
[439] Fix | Delete
}
[440] Fix | Delete
}
[441] Fix | Delete
[442] Fix | Delete
/**
[443] Fix | Delete
* Returns the classes for the comment div as an array.
[444] Fix | Delete
*
[445] Fix | Delete
* @since 2.7.0
[446] Fix | Delete
* @since 4.4.0 Added the ability for `$comment_id` to also accept a WP_Comment object.
[447] Fix | Delete
*
[448] Fix | Delete
* @global int $comment_alt
[449] Fix | Delete
* @global int $comment_depth
[450] Fix | Delete
* @global int $comment_thread_alt
[451] Fix | Delete
*
[452] Fix | Delete
* @param string|string[] $class Optional. One or more classes to add to the class list. Default empty.
[453] Fix | Delete
* @param int|WP_Comment $comment_id Comment ID or WP_Comment object. Default current comment.
[454] Fix | Delete
* @param int|WP_Post $post_id Post ID or WP_Post object. Default current post.
[455] Fix | Delete
* @return string[] An array of classes.
[456] Fix | Delete
*/
[457] Fix | Delete
function get_comment_class( $class = '', $comment_id = null, $post_id = null ) {
[458] Fix | Delete
global $comment_alt, $comment_depth, $comment_thread_alt;
[459] Fix | Delete
[460] Fix | Delete
$classes = array();
[461] Fix | Delete
[462] Fix | Delete
$comment = get_comment( $comment_id );
[463] Fix | Delete
if ( ! $comment ) {
[464] Fix | Delete
return $classes;
[465] Fix | Delete
}
[466] Fix | Delete
[467] Fix | Delete
// Get the comment type (comment, trackback).
[468] Fix | Delete
$classes[] = ( empty( $comment->comment_type ) ) ? 'comment' : $comment->comment_type;
[469] Fix | Delete
[470] Fix | Delete
// Add classes for comment authors that are registered users.
[471] Fix | Delete
$user = $comment->user_id ? get_userdata( $comment->user_id ) : false;
[472] Fix | Delete
if ( $user ) {
[473] Fix | Delete
$classes[] = 'byuser';
[474] Fix | Delete
$classes[] = 'comment-author-' . sanitize_html_class( $user->user_nicename, $comment->user_id );
[475] Fix | Delete
// For comment authors who are the author of the post.
[476] Fix | Delete
$post = get_post( $post_id );
[477] Fix | Delete
if ( $post ) {
[478] Fix | Delete
if ( $comment->user_id === $post->post_author ) {
[479] Fix | Delete
$classes[] = 'bypostauthor';
[480] Fix | Delete
}
[481] Fix | Delete
}
[482] Fix | Delete
}
[483] Fix | Delete
[484] Fix | Delete
if ( empty( $comment_alt ) ) {
[485] Fix | Delete
$comment_alt = 0;
[486] Fix | Delete
}
[487] Fix | Delete
if ( empty( $comment_depth ) ) {
[488] Fix | Delete
$comment_depth = 1;
[489] Fix | Delete
}
[490] Fix | Delete
if ( empty( $comment_thread_alt ) ) {
[491] Fix | Delete
$comment_thread_alt = 0;
[492] Fix | Delete
}
[493] Fix | Delete
[494] Fix | Delete
if ( $comment_alt % 2 ) {
[495] Fix | Delete
$classes[] = 'odd';
[496] Fix | Delete
$classes[] = 'alt';
[497] Fix | Delete
} else {
[498] Fix | Delete
$classes[] = 'even';
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function