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