Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../public_h.../wp-inclu...
File: comment-template.php
* @since 2.7.0
[500] Fix | Delete
* @since 4.4.0 Added the ability for `$comment_id` to also accept a WP_Comment object.
[501] Fix | Delete
*
[502] Fix | Delete
* @global int $comment_alt
[503] Fix | Delete
* @global int $comment_depth
[504] Fix | Delete
* @global int $comment_thread_alt
[505] Fix | Delete
*
[506] Fix | Delete
* @param string|string[] $css_class Optional. One or more classes to add to the class list.
[507] Fix | Delete
* Default empty.
[508] Fix | Delete
* @param int|WP_Comment $comment_id Optional. Comment ID or WP_Comment object. Default current comment.
[509] Fix | Delete
* @param int|WP_Post $post Optional. Post ID or WP_Post object. Default current post.
[510] Fix | Delete
* @return string[] An array of classes.
[511] Fix | Delete
*/
[512] Fix | Delete
function get_comment_class( $css_class = '', $comment_id = null, $post = null ) {
[513] Fix | Delete
global $comment_alt, $comment_depth, $comment_thread_alt;
[514] Fix | Delete
[515] Fix | Delete
$classes = array();
[516] Fix | Delete
[517] Fix | Delete
$comment = get_comment( $comment_id );
[518] Fix | Delete
if ( ! $comment ) {
[519] Fix | Delete
return $classes;
[520] Fix | Delete
}
[521] Fix | Delete
[522] Fix | Delete
// Get the comment type (comment, trackback).
[523] Fix | Delete
$classes[] = ( empty( $comment->comment_type ) ) ? 'comment' : $comment->comment_type;
[524] Fix | Delete
[525] Fix | Delete
// Add classes for comment authors that are registered users.
[526] Fix | Delete
$user = $comment->user_id ? get_userdata( $comment->user_id ) : false;
[527] Fix | Delete
if ( $user ) {
[528] Fix | Delete
$classes[] = 'byuser';
[529] Fix | Delete
$classes[] = 'comment-author-' . sanitize_html_class( $user->user_nicename, $comment->user_id );
[530] Fix | Delete
// For comment authors who are the author of the post.
[531] Fix | Delete
$_post = get_post( $post );
[532] Fix | Delete
if ( $_post ) {
[533] Fix | Delete
if ( $comment->user_id === $_post->post_author ) {
[534] Fix | Delete
$classes[] = 'bypostauthor';
[535] Fix | Delete
}
[536] Fix | Delete
}
[537] Fix | Delete
}
[538] Fix | Delete
[539] Fix | Delete
if ( empty( $comment_alt ) ) {
[540] Fix | Delete
$comment_alt = 0;
[541] Fix | Delete
}
[542] Fix | Delete
if ( empty( $comment_depth ) ) {
[543] Fix | Delete
$comment_depth = 1;
[544] Fix | Delete
}
[545] Fix | Delete
if ( empty( $comment_thread_alt ) ) {
[546] Fix | Delete
$comment_thread_alt = 0;
[547] Fix | Delete
}
[548] Fix | Delete
[549] Fix | Delete
if ( $comment_alt % 2 ) {
[550] Fix | Delete
$classes[] = 'odd';
[551] Fix | Delete
$classes[] = 'alt';
[552] Fix | Delete
} else {
[553] Fix | Delete
$classes[] = 'even';
[554] Fix | Delete
}
[555] Fix | Delete
[556] Fix | Delete
++$comment_alt;
[557] Fix | Delete
[558] Fix | Delete
// Alt for top-level comments.
[559] Fix | Delete
if ( 1 == $comment_depth ) {
[560] Fix | Delete
if ( $comment_thread_alt % 2 ) {
[561] Fix | Delete
$classes[] = 'thread-odd';
[562] Fix | Delete
$classes[] = 'thread-alt';
[563] Fix | Delete
} else {
[564] Fix | Delete
$classes[] = 'thread-even';
[565] Fix | Delete
}
[566] Fix | Delete
++$comment_thread_alt;
[567] Fix | Delete
}
[568] Fix | Delete
[569] Fix | Delete
$classes[] = "depth-$comment_depth";
[570] Fix | Delete
[571] Fix | Delete
if ( ! empty( $css_class ) ) {
[572] Fix | Delete
if ( ! is_array( $css_class ) ) {
[573] Fix | Delete
$css_class = preg_split( '#\s+#', $css_class );
[574] Fix | Delete
}
[575] Fix | Delete
$classes = array_merge( $classes, $css_class );
[576] Fix | Delete
}
[577] Fix | Delete
[578] Fix | Delete
$classes = array_map( 'esc_attr', $classes );
[579] Fix | Delete
[580] Fix | Delete
/**
[581] Fix | Delete
* Filters the returned CSS classes for the current comment.
[582] Fix | Delete
*
[583] Fix | Delete
* @since 2.7.0
[584] Fix | Delete
*
[585] Fix | Delete
* @param string[] $classes An array of comment classes.
[586] Fix | Delete
* @param string[] $css_class An array of additional classes added to the list.
[587] Fix | Delete
* @param string $comment_id The comment ID as a numeric string.
[588] Fix | Delete
* @param WP_Comment $comment The comment object.
[589] Fix | Delete
* @param int|WP_Post $post The post ID or WP_Post object.
[590] Fix | Delete
*/
[591] Fix | Delete
return apply_filters( 'comment_class', $classes, $css_class, $comment->comment_ID, $comment, $post );
[592] Fix | Delete
}
[593] Fix | Delete
[594] Fix | Delete
/**
[595] Fix | Delete
* Retrieves the comment date of the current comment.
[596] Fix | Delete
*
[597] Fix | Delete
* @since 1.5.0
[598] Fix | Delete
* @since 4.4.0 Added the ability for `$comment_id` to also accept a WP_Comment object.
[599] Fix | Delete
*
[600] Fix | Delete
* @param string $format Optional. PHP date format. Defaults to the 'date_format' option.
[601] Fix | Delete
* @param int|WP_Comment $comment_id Optional. WP_Comment or ID of the comment for which to get the date.
[602] Fix | Delete
* Default current comment.
[603] Fix | Delete
* @return string The comment's date.
[604] Fix | Delete
*/
[605] Fix | Delete
function get_comment_date( $format = '', $comment_id = 0 ) {
[606] Fix | Delete
$comment = get_comment( $comment_id );
[607] Fix | Delete
[608] Fix | Delete
$_format = ! empty( $format ) ? $format : get_option( 'date_format' );
[609] Fix | Delete
[610] Fix | Delete
$comment_date = mysql2date( $_format, $comment->comment_date );
[611] Fix | Delete
[612] Fix | Delete
/**
[613] Fix | Delete
* Filters the returned comment date.
[614] Fix | Delete
*
[615] Fix | Delete
* @since 1.5.0
[616] Fix | Delete
*
[617] Fix | Delete
* @param string|int $comment_date Formatted date string or Unix timestamp.
[618] Fix | Delete
* @param string $format PHP date format.
[619] Fix | Delete
* @param WP_Comment $comment The comment object.
[620] Fix | Delete
*/
[621] Fix | Delete
return apply_filters( 'get_comment_date', $comment_date, $format, $comment );
[622] Fix | Delete
}
[623] Fix | Delete
[624] Fix | Delete
/**
[625] Fix | Delete
* Displays the comment date of the current comment.
[626] Fix | Delete
*
[627] Fix | Delete
* @since 0.71
[628] Fix | Delete
* @since 4.4.0 Added the ability for `$comment_id` to also accept a WP_Comment object.
[629] Fix | Delete
*
[630] Fix | Delete
* @param string $format Optional. PHP date format. Defaults to the 'date_format' option.
[631] Fix | Delete
* @param int|WP_Comment $comment_id WP_Comment or ID of the comment for which to print the date.
[632] Fix | Delete
* Default current comment.
[633] Fix | Delete
*/
[634] Fix | Delete
function comment_date( $format = '', $comment_id = 0 ) {
[635] Fix | Delete
echo get_comment_date( $format, $comment_id );
[636] Fix | Delete
}
[637] Fix | Delete
[638] Fix | Delete
/**
[639] Fix | Delete
* Retrieves the excerpt of the given comment.
[640] Fix | Delete
*
[641] Fix | Delete
* Returns a maximum of 20 words with an ellipsis appended if necessary.
[642] Fix | Delete
*
[643] Fix | Delete
* @since 1.5.0
[644] Fix | Delete
* @since 4.4.0 Added the ability for `$comment_id` to also accept a WP_Comment object.
[645] Fix | Delete
*
[646] Fix | Delete
* @param int|WP_Comment $comment_id Optional. WP_Comment or ID of the comment for which to get the excerpt.
[647] Fix | Delete
* Default current comment.
[648] Fix | Delete
* @return string The possibly truncated comment excerpt.
[649] Fix | Delete
*/
[650] Fix | Delete
function get_comment_excerpt( $comment_id = 0 ) {
[651] Fix | Delete
$comment = get_comment( $comment_id );
[652] Fix | Delete
[653] Fix | Delete
if ( ! post_password_required( $comment->comment_post_ID ) ) {
[654] Fix | Delete
$comment_text = strip_tags( str_replace( array( "\n", "\r" ), ' ', $comment->comment_content ) );
[655] Fix | Delete
} else {
[656] Fix | Delete
$comment_text = __( 'Password protected' );
[657] Fix | Delete
}
[658] Fix | Delete
[659] Fix | Delete
/* translators: Maximum number of words used in a comment excerpt. */
[660] Fix | Delete
$comment_excerpt_length = (int) _x( '20', 'comment_excerpt_length' );
[661] Fix | Delete
[662] Fix | Delete
/**
[663] Fix | Delete
* Filters the maximum number of words used in the comment excerpt.
[664] Fix | Delete
*
[665] Fix | Delete
* @since 4.4.0
[666] Fix | Delete
*
[667] Fix | Delete
* @param int $comment_excerpt_length The amount of words you want to display in the comment excerpt.
[668] Fix | Delete
*/
[669] Fix | Delete
$comment_excerpt_length = apply_filters( 'comment_excerpt_length', $comment_excerpt_length );
[670] Fix | Delete
[671] Fix | Delete
$comment_excerpt = wp_trim_words( $comment_text, $comment_excerpt_length, '…' );
[672] Fix | Delete
[673] Fix | Delete
/**
[674] Fix | Delete
* Filters the retrieved comment excerpt.
[675] Fix | Delete
*
[676] Fix | Delete
* @since 1.5.0
[677] Fix | Delete
* @since 4.1.0 The `$comment_id` and `$comment` parameters were added.
[678] Fix | Delete
*
[679] Fix | Delete
* @param string $comment_excerpt The comment excerpt text.
[680] Fix | Delete
* @param string $comment_id The comment ID as a numeric string.
[681] Fix | Delete
* @param WP_Comment $comment The comment object.
[682] Fix | Delete
*/
[683] Fix | Delete
return apply_filters( 'get_comment_excerpt', $comment_excerpt, $comment->comment_ID, $comment );
[684] Fix | Delete
}
[685] Fix | Delete
[686] Fix | Delete
/**
[687] Fix | Delete
* Displays the excerpt of the current comment.
[688] Fix | Delete
*
[689] Fix | Delete
* @since 1.2.0
[690] Fix | Delete
* @since 4.4.0 Added the ability for `$comment_id` to also accept a WP_Comment object.
[691] Fix | Delete
*
[692] Fix | Delete
* @param int|WP_Comment $comment_id Optional. WP_Comment or ID of the comment for which to print the excerpt.
[693] Fix | Delete
* Default current comment.
[694] Fix | Delete
*/
[695] Fix | Delete
function comment_excerpt( $comment_id = 0 ) {
[696] Fix | Delete
$comment = get_comment( $comment_id );
[697] Fix | Delete
[698] Fix | Delete
$comment_excerpt = get_comment_excerpt( $comment );
[699] Fix | Delete
[700] Fix | Delete
/**
[701] Fix | Delete
* Filters the comment excerpt for display.
[702] Fix | Delete
*
[703] Fix | Delete
* @since 1.2.0
[704] Fix | Delete
* @since 4.1.0 The `$comment_id` parameter was added.
[705] Fix | Delete
*
[706] Fix | Delete
* @param string $comment_excerpt The comment excerpt text.
[707] Fix | Delete
* @param string $comment_id The comment ID as a numeric string.
[708] Fix | Delete
*/
[709] Fix | Delete
echo apply_filters( 'comment_excerpt', $comment_excerpt, $comment->comment_ID );
[710] Fix | Delete
}
[711] Fix | Delete
[712] Fix | Delete
/**
[713] Fix | Delete
* Retrieves the comment ID of the current comment.
[714] Fix | Delete
*
[715] Fix | Delete
* @since 1.5.0
[716] Fix | Delete
*
[717] Fix | Delete
* @return string The comment ID as a numeric string.
[718] Fix | Delete
*/
[719] Fix | Delete
function get_comment_ID() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
[720] Fix | Delete
$comment = get_comment();
[721] Fix | Delete
[722] Fix | Delete
$comment_id = ! empty( $comment->comment_ID ) ? $comment->comment_ID : '0';
[723] Fix | Delete
[724] Fix | Delete
/**
[725] Fix | Delete
* Filters the returned comment ID.
[726] Fix | Delete
*
[727] Fix | Delete
* @since 1.5.0
[728] Fix | Delete
* @since 4.1.0 The `$comment` parameter was added.
[729] Fix | Delete
*
[730] Fix | Delete
* @param string $comment_id The current comment ID as a numeric string.
[731] Fix | Delete
* @param WP_Comment $comment The comment object.
[732] Fix | Delete
*/
[733] Fix | Delete
return apply_filters( 'get_comment_ID', $comment_id, $comment ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
[734] Fix | Delete
}
[735] Fix | Delete
[736] Fix | Delete
/**
[737] Fix | Delete
* Displays the comment ID of the current comment.
[738] Fix | Delete
*
[739] Fix | Delete
* @since 0.71
[740] Fix | Delete
*/
[741] Fix | Delete
function comment_ID() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
[742] Fix | Delete
echo get_comment_ID();
[743] Fix | Delete
}
[744] Fix | Delete
[745] Fix | Delete
/**
[746] Fix | Delete
* Retrieves the link to a given comment.
[747] Fix | Delete
*
[748] Fix | Delete
* @since 1.5.0
[749] Fix | Delete
* @since 4.4.0 Added the ability for `$comment` to also accept a WP_Comment object. Added `$cpage` argument.
[750] Fix | Delete
*
[751] Fix | Delete
* @see get_page_of_comment()
[752] Fix | Delete
*
[753] Fix | Delete
* @global WP_Rewrite $wp_rewrite WordPress rewrite component.
[754] Fix | Delete
* @global bool $in_comment_loop
[755] Fix | Delete
*
[756] Fix | Delete
* @param WP_Comment|int|null $comment Optional. Comment to retrieve. Default current comment.
[757] Fix | Delete
* @param array $args {
[758] Fix | Delete
* An array of optional arguments to override the defaults.
[759] Fix | Delete
*
[760] Fix | Delete
* @type string $type Passed to get_page_of_comment().
[761] Fix | Delete
* @type int $page Current page of comments, for calculating comment pagination.
[762] Fix | Delete
* @type int $per_page Per-page value for comment pagination.
[763] Fix | Delete
* @type int $max_depth Passed to get_page_of_comment().
[764] Fix | Delete
* @type int|string $cpage Value to use for the comment's "comment-page" or "cpage" value.
[765] Fix | Delete
* If provided, this value overrides any value calculated from `$page`
[766] Fix | Delete
* and `$per_page`.
[767] Fix | Delete
* }
[768] Fix | Delete
* @return string The permalink to the given comment.
[769] Fix | Delete
*/
[770] Fix | Delete
function get_comment_link( $comment = null, $args = array() ) {
[771] Fix | Delete
global $wp_rewrite, $in_comment_loop;
[772] Fix | Delete
[773] Fix | Delete
$comment = get_comment( $comment );
[774] Fix | Delete
[775] Fix | Delete
// Back-compat.
[776] Fix | Delete
if ( ! is_array( $args ) ) {
[777] Fix | Delete
$args = array( 'page' => $args );
[778] Fix | Delete
}
[779] Fix | Delete
[780] Fix | Delete
$defaults = array(
[781] Fix | Delete
'type' => 'all',
[782] Fix | Delete
'page' => '',
[783] Fix | Delete
'per_page' => '',
[784] Fix | Delete
'max_depth' => '',
[785] Fix | Delete
'cpage' => null,
[786] Fix | Delete
);
[787] Fix | Delete
[788] Fix | Delete
$args = wp_parse_args( $args, $defaults );
[789] Fix | Delete
[790] Fix | Delete
$comment_link = get_permalink( $comment->comment_post_ID );
[791] Fix | Delete
[792] Fix | Delete
// The 'cpage' param takes precedence.
[793] Fix | Delete
if ( ! is_null( $args['cpage'] ) ) {
[794] Fix | Delete
$cpage = $args['cpage'];
[795] Fix | Delete
[796] Fix | Delete
// No 'cpage' is provided, so we calculate one.
[797] Fix | Delete
} else {
[798] Fix | Delete
if ( '' === $args['per_page'] && get_option( 'page_comments' ) ) {
[799] Fix | Delete
$args['per_page'] = get_option( 'comments_per_page' );
[800] Fix | Delete
}
[801] Fix | Delete
[802] Fix | Delete
if ( empty( $args['per_page'] ) ) {
[803] Fix | Delete
$args['per_page'] = 0;
[804] Fix | Delete
$args['page'] = 0;
[805] Fix | Delete
}
[806] Fix | Delete
[807] Fix | Delete
$cpage = $args['page'];
[808] Fix | Delete
[809] Fix | Delete
if ( '' == $cpage ) {
[810] Fix | Delete
if ( ! empty( $in_comment_loop ) ) {
[811] Fix | Delete
$cpage = get_query_var( 'cpage' );
[812] Fix | Delete
} else {
[813] Fix | Delete
// Requires a database hit, so we only do it when we can't figure out from context.
[814] Fix | Delete
$cpage = get_page_of_comment( $comment->comment_ID, $args );
[815] Fix | Delete
}
[816] Fix | Delete
}
[817] Fix | Delete
[818] Fix | Delete
/*
[819] Fix | Delete
* If the default page displays the oldest comments, the permalinks for comments on the default page
[820] Fix | Delete
* do not need a 'cpage' query var.
[821] Fix | Delete
*/
[822] Fix | Delete
if ( 'oldest' === get_option( 'default_comments_page' ) && 1 === $cpage ) {
[823] Fix | Delete
$cpage = '';
[824] Fix | Delete
}
[825] Fix | Delete
}
[826] Fix | Delete
[827] Fix | Delete
if ( $cpage && get_option( 'page_comments' ) ) {
[828] Fix | Delete
if ( $wp_rewrite->using_permalinks() ) {
[829] Fix | Delete
if ( $cpage ) {
[830] Fix | Delete
$comment_link = trailingslashit( $comment_link ) . $wp_rewrite->comments_pagination_base . '-' . $cpage;
[831] Fix | Delete
}
[832] Fix | Delete
[833] Fix | Delete
$comment_link = user_trailingslashit( $comment_link, 'comment' );
[834] Fix | Delete
} elseif ( $cpage ) {
[835] Fix | Delete
$comment_link = add_query_arg( 'cpage', $cpage, $comment_link );
[836] Fix | Delete
}
[837] Fix | Delete
}
[838] Fix | Delete
[839] Fix | Delete
if ( $wp_rewrite->using_permalinks() ) {
[840] Fix | Delete
$comment_link = user_trailingslashit( $comment_link, 'comment' );
[841] Fix | Delete
}
[842] Fix | Delete
[843] Fix | Delete
$comment_link = $comment_link . '#comment-' . $comment->comment_ID;
[844] Fix | Delete
[845] Fix | Delete
/**
[846] Fix | Delete
* Filters the returned single comment permalink.
[847] Fix | Delete
*
[848] Fix | Delete
* @since 2.8.0
[849] Fix | Delete
* @since 4.4.0 Added the `$cpage` parameter.
[850] Fix | Delete
*
[851] Fix | Delete
* @see get_page_of_comment()
[852] Fix | Delete
*
[853] Fix | Delete
* @param string $comment_link The comment permalink with '#comment-$id' appended.
[854] Fix | Delete
* @param WP_Comment $comment The current comment object.
[855] Fix | Delete
* @param array $args An array of arguments to override the defaults.
[856] Fix | Delete
* @param int $cpage The calculated 'cpage' value.
[857] Fix | Delete
*/
[858] Fix | Delete
return apply_filters( 'get_comment_link', $comment_link, $comment, $args, $cpage );
[859] Fix | Delete
}
[860] Fix | Delete
[861] Fix | Delete
/**
[862] Fix | Delete
* Retrieves the link to the current post comments.
[863] Fix | Delete
*
[864] Fix | Delete
* @since 1.5.0
[865] Fix | Delete
*
[866] Fix | Delete
* @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
[867] Fix | Delete
* @return string The link to the comments.
[868] Fix | Delete
*/
[869] Fix | Delete
function get_comments_link( $post = 0 ) {
[870] Fix | Delete
$hash = get_comments_number( $post ) ? '#comments' : '#respond';
[871] Fix | Delete
$comments_link = get_permalink( $post ) . $hash;
[872] Fix | Delete
[873] Fix | Delete
/**
[874] Fix | Delete
* Filters the returned post comments permalink.
[875] Fix | Delete
*
[876] Fix | Delete
* @since 3.6.0
[877] Fix | Delete
*
[878] Fix | Delete
* @param string $comments_link Post comments permalink with '#comments' appended.
[879] Fix | Delete
* @param int|WP_Post $post Post ID or WP_Post object.
[880] Fix | Delete
*/
[881] Fix | Delete
return apply_filters( 'get_comments_link', $comments_link, $post );
[882] Fix | Delete
}
[883] Fix | Delete
[884] Fix | Delete
/**
[885] Fix | Delete
* Displays the link to the current post comments.
[886] Fix | Delete
*
[887] Fix | Delete
* @since 0.71
[888] Fix | Delete
*
[889] Fix | Delete
* @param string $deprecated Not Used.
[890] Fix | Delete
* @param string $deprecated_2 Not Used.
[891] Fix | Delete
*/
[892] Fix | Delete
function comments_link( $deprecated = '', $deprecated_2 = '' ) {
[893] Fix | Delete
if ( ! empty( $deprecated ) ) {
[894] Fix | Delete
_deprecated_argument( __FUNCTION__, '0.72' );
[895] Fix | Delete
}
[896] Fix | Delete
if ( ! empty( $deprecated_2 ) ) {
[897] Fix | Delete
_deprecated_argument( __FUNCTION__, '1.3.0' );
[898] Fix | Delete
}
[899] Fix | Delete
echo esc_url( get_comments_link() );
[900] Fix | Delete
}
[901] Fix | Delete
[902] Fix | Delete
/**
[903] Fix | Delete
* Retrieves the amount of comments a post has.
[904] Fix | Delete
*
[905] Fix | Delete
* @since 1.5.0
[906] Fix | Delete
*
[907] Fix | Delete
* @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is the global `$post`.
[908] Fix | Delete
* @return string|int If the post exists, a numeric string representing the number of comments
[909] Fix | Delete
* the post has, otherwise 0.
[910] Fix | Delete
*/
[911] Fix | Delete
function get_comments_number( $post = 0 ) {
[912] Fix | Delete
$post = get_post( $post );
[913] Fix | Delete
[914] Fix | Delete
$comments_number = $post ? $post->comment_count : 0;
[915] Fix | Delete
$post_id = $post ? $post->ID : 0;
[916] Fix | Delete
[917] Fix | Delete
/**
[918] Fix | Delete
* Filters the returned comment count for a post.
[919] Fix | Delete
*
[920] Fix | Delete
* @since 1.5.0
[921] Fix | Delete
*
[922] Fix | Delete
* @param string|int $comments_number A string representing the number of comments a post has, otherwise 0.
[923] Fix | Delete
* @param int $post_id Post ID.
[924] Fix | Delete
*/
[925] Fix | Delete
return apply_filters( 'get_comments_number', $comments_number, $post_id );
[926] Fix | Delete
}
[927] Fix | Delete
[928] Fix | Delete
/**
[929] Fix | Delete
* Displays the language string for the number of comments the current post has.
[930] Fix | Delete
*
[931] Fix | Delete
* @since 0.71
[932] Fix | Delete
* @since 5.4.0 The `$deprecated` parameter was changed to `$post`.
[933] Fix | Delete
*
[934] Fix | Delete
* @param string|false $zero Optional. Text for no comments. Default false.
[935] Fix | Delete
* @param string|false $one Optional. Text for one comment. Default false.
[936] Fix | Delete
* @param string|false $more Optional. Text for more than one comment. Default false.
[937] Fix | Delete
* @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is the global `$post`.
[938] Fix | Delete
*/
[939] Fix | Delete
function comments_number( $zero = false, $one = false, $more = false, $post = 0 ) {
[940] Fix | Delete
echo get_comments_number_text( $zero, $one, $more, $post );
[941] Fix | Delete
}
[942] Fix | Delete
[943] Fix | Delete
/**
[944] Fix | Delete
* Displays the language string for the number of comments the current post has.
[945] Fix | Delete
*
[946] Fix | Delete
* @since 4.0.0
[947] Fix | Delete
* @since 5.4.0 Added the `$post` parameter to allow using the function outside of the loop.
[948] Fix | Delete
*
[949] Fix | Delete
* @param string $zero Optional. Text for no comments. Default false.
[950] Fix | Delete
* @param string $one Optional. Text for one comment. Default false.
[951] Fix | Delete
* @param string $more Optional. Text for more than one comment. Default false.
[952] Fix | Delete
* @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is the global `$post`.
[953] Fix | Delete
* @return string Language string for the number of comments a post has.
[954] Fix | Delete
*/
[955] Fix | Delete
function get_comments_number_text( $zero = false, $one = false, $more = false, $post = 0 ) {
[956] Fix | Delete
$comments_number = get_comments_number( $post );
[957] Fix | Delete
[958] Fix | Delete
if ( $comments_number > 1 ) {
[959] Fix | Delete
if ( false === $more ) {
[960] Fix | Delete
$comments_number_text = sprintf(
[961] Fix | Delete
/* translators: %s: Number of comments. */
[962] Fix | Delete
_n( '%s Comment', '%s Comments', $comments_number ),
[963] Fix | Delete
number_format_i18n( $comments_number )
[964] Fix | Delete
);
[965] Fix | Delete
} else {
[966] Fix | Delete
// % Comments
[967] Fix | Delete
/*
[968] Fix | Delete
* translators: If comment number in your language requires declension,
[969] Fix | Delete
* translate this to 'on'. Do not translate into your own language.
[970] Fix | Delete
*/
[971] Fix | Delete
if ( 'on' === _x( 'off', 'Comment number declension: on or off' ) ) {
[972] Fix | Delete
$text = preg_replace( '#<span class="screen-reader-text">.+?</span>#', '', $more );
[973] Fix | Delete
$text = preg_replace( '/&.+?;/', '', $text ); // Remove HTML entities.
[974] Fix | Delete
$text = trim( strip_tags( $text ), '% ' );
[975] Fix | Delete
[976] Fix | Delete
// Replace '% Comments' with a proper plural form.
[977] Fix | Delete
if ( $text && ! preg_match( '/[0-9]+/', $text ) && str_contains( $more, '%' ) ) {
[978] Fix | Delete
/* translators: %s: Number of comments. */
[979] Fix | Delete
$new_text = _n( '%s Comment', '%s Comments', $comments_number );
[980] Fix | Delete
$new_text = trim( sprintf( $new_text, '' ) );
[981] Fix | Delete
[982] Fix | Delete
$more = str_replace( $text, $new_text, $more );
[983] Fix | Delete
if ( ! str_contains( $more, '%' ) ) {
[984] Fix | Delete
$more = '% ' . $more;
[985] Fix | Delete
}
[986] Fix | Delete
}
[987] Fix | Delete
}
[988] Fix | Delete
[989] Fix | Delete
$comments_number_text = str_replace( '%', number_format_i18n( $comments_number ), $more );
[990] Fix | Delete
}
[991] Fix | Delete
} elseif ( 0 == $comments_number ) {
[992] Fix | Delete
$comments_number_text = ( false === $zero ) ? __( 'No Comments' ) : $zero;
[993] Fix | Delete
} else { // Must be one.
[994] Fix | Delete
$comments_number_text = ( false === $one ) ? __( '1 Comment' ) : $one;
[995] Fix | Delete
}
[996] Fix | Delete
[997] Fix | Delete
/**
[998] Fix | Delete
* Filters the comments count for display.
[999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function