: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* @param string $comments_number_text A translatable string formatted based on whether the count
* is equal to 0, 1, or 1+.
* @param int $comments_number The number of post comments.
return apply_filters( 'comments_number', $comments_number_text, $comments_number );
* Retrieves the text of the current comment.
* @since 4.4.0 Added the ability for `$comment_id` to also accept a WP_Comment object.
* @since 5.4.0 Added 'In reply to %s.' prefix to child comments in comments feed.
* @see Walker_Comment::comment()
* @param int|WP_Comment $comment_id Optional. WP_Comment or ID of the comment for which to get the text.
* Default current comment.
* @param array $args Optional. An array of arguments. Default empty array.
* @return string The comment content.
function get_comment_text( $comment_id = 0, $args = array() ) {
$comment = get_comment( $comment_id );
$comment_text = $comment->comment_content;
if ( is_comment_feed() && $comment->comment_parent ) {
$parent = get_comment( $comment->comment_parent );
$parent_link = esc_url( get_comment_link( $parent ) );
$name = get_comment_author( $parent );
/* translators: %s: Comment link. */
ent2ncr( __( 'In reply to %s.' ) ),
'<a href="' . $parent_link . '">' . $name . '</a>'
) . "\n\n" . $comment_text;
* Filters the text of a comment.
* @see Walker_Comment::comment()
* @param string $comment_text Text of the comment.
* @param WP_Comment $comment The comment object.
* @param array $args An array of arguments.
return apply_filters( 'get_comment_text', $comment_text, $comment, $args );
* Displays the text of the current comment.
* @since 4.4.0 Added the ability for `$comment_id` to also accept a WP_Comment object.
* @see Walker_Comment::comment()
* @param int|WP_Comment $comment_id Optional. WP_Comment or ID of the comment for which to print the text.
* Default current comment.
* @param array $args Optional. An array of arguments. Default empty array.
function comment_text( $comment_id = 0, $args = array() ) {
$comment = get_comment( $comment_id );
$comment_text = get_comment_text( $comment, $args );
* Filters the text of a comment to be displayed.
* @see Walker_Comment::comment()
* @param string $comment_text Text of the comment.
* @param WP_Comment|null $comment The comment object. Null if not found.
* @param array $args An array of arguments.
echo apply_filters( 'comment_text', $comment_text, $comment, $args );
* Retrieves the comment time of the current comment.
* @since 6.2.0 Added the `$comment_id` parameter.
* @param string $format Optional. PHP date format. Defaults to the 'time_format' option.
* @param bool $gmt Optional. Whether to use the GMT date. Default false.
* @param bool $translate Optional. Whether to translate the time (for use in feeds).
* @param int|WP_Comment $comment_id Optional. WP_Comment or ID of the comment for which to get the time.
* Default current comment.
* @return string The formatted time.
function get_comment_time( $format = '', $gmt = false, $translate = true, $comment_id = 0 ) {
$comment = get_comment( $comment_id );
if ( null === $comment ) {
$comment_date = $gmt ? $comment->comment_date_gmt : $comment->comment_date;
$_format = ! empty( $format ) ? $format : get_option( 'time_format' );
$comment_time = mysql2date( $_format, $comment_date, $translate );
* Filters the returned comment time.
* @param string|int $comment_time The comment time, formatted as a date string or Unix timestamp.
* @param string $format PHP date format.
* @param bool $gmt Whether the GMT date is in use.
* @param bool $translate Whether the time is translated.
* @param WP_Comment $comment The comment object.
return apply_filters( 'get_comment_time', $comment_time, $format, $gmt, $translate, $comment );
* Displays the comment time of the current comment.
* @since 6.2.0 Added the `$comment_id` parameter.
* @param string $format Optional. PHP time format. Defaults to the 'time_format' option.
* @param int|WP_Comment $comment_id Optional. WP_Comment or ID of the comment for which to print the time.
* Default current comment.
function comment_time( $format = '', $comment_id = 0 ) {
echo get_comment_time( $format, false, true, $comment_id );
* Retrieves the comment type of the current comment.
* @since 4.4.0 Added the ability for `$comment_id` to also accept a WP_Comment object.
* @param int|WP_Comment $comment_id Optional. WP_Comment or ID of the comment for which to get the type.
* Default current comment.
* @return string The comment type.
function get_comment_type( $comment_id = 0 ) {
$comment = get_comment( $comment_id );
if ( '' === $comment->comment_type ) {
$comment->comment_type = 'comment';
* Filters the returned comment type.
* @since 4.1.0 The `$comment_id` and `$comment` parameters were added.
* @param string $comment_type The type of comment, such as 'comment', 'pingback', or 'trackback'.
* @param string $comment_id The comment ID as a numeric string.
* @param WP_Comment $comment The comment object.
return apply_filters( 'get_comment_type', $comment->comment_type, $comment->comment_ID, $comment );
* Displays the comment type of the current comment.
* @param string|false $commenttxt Optional. String to display for comment type. Default false.
* @param string|false $trackbacktxt Optional. String to display for trackback type. Default false.
* @param string|false $pingbacktxt Optional. String to display for pingback type. Default false.
function comment_type( $commenttxt = false, $trackbacktxt = false, $pingbacktxt = false ) {
if ( false === $commenttxt ) {
$commenttxt = _x( 'Comment', 'noun' );
if ( false === $trackbacktxt ) {
$trackbacktxt = __( 'Trackback' );
if ( false === $pingbacktxt ) {
$pingbacktxt = __( 'Pingback' );
$type = get_comment_type();
* Retrieves the current post's trackback URL.
* There is a check to see if permalink's have been enabled and if so, will
* retrieve the pretty path. If permalinks weren't enabled, the ID of the
* current post is used and appended to the correct page to go to.
* @return string The trackback URL after being filtered.
function get_trackback_url() {
if ( get_option( 'permalink_structure' ) ) {
$trackback_url = trailingslashit( get_permalink() ) . user_trailingslashit( 'trackback', 'single_trackback' );
$trackback_url = get_option( 'siteurl' ) . '/wp-trackback.php?p=' . get_the_ID();
* Filters the returned trackback URL.
* @param string $trackback_url The trackback URL.
return apply_filters( 'trackback_url', $trackback_url );
* Displays the current post's trackback URL.
* @param bool $deprecated_echo Not used.
* @return void|string Should only be used to echo the trackback URL, use get_trackback_url()
* for the result instead.
function trackback_url( $deprecated_echo = true ) {
if ( true !== $deprecated_echo ) {
/* translators: %s: get_trackback_url() */
__( 'Use %s instead if you do not want the value echoed.' ),
'<code>get_trackback_url()</code>'
if ( $deprecated_echo ) {
echo get_trackback_url();
return get_trackback_url();
* Generates and displays the RDF for the trackback information of current post.
* Deprecated in 3.0.0, and restored in 3.0.1.
* @param int|string $deprecated Not used (Was $timezone = 0).
function trackback_rdf( $deprecated = '' ) {
if ( ! empty( $deprecated ) ) {
_deprecated_argument( __FUNCTION__, '2.5.0' );
if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && false !== stripos( $_SERVER['HTTP_USER_AGENT'], 'W3C_Validator' ) ) {
echo '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
<rdf:Description rdf:about="';
echo ' dc:title="' . str_replace( '--', '--', wptexturize( strip_tags( get_the_title() ) ) ) . '"' . "\n";
echo ' trackback:ping="' . get_trackback_url() . '"' . " />\n";
* Determines whether the current post is open for comments.
* For more information on this and similar theme functions, check out
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
* Conditional Tags} article in the Theme Developer Handbook.
* @param int|WP_Post $post Optional. Post ID or WP_Post object. Default current post.
* @return bool True if the comments are open.
function comments_open( $post = null ) {
$_post = get_post( $post );
$post_id = $_post ? $_post->ID : 0;
$comments_open = ( $_post && ( 'open' === $_post->comment_status ) );
* Filters whether the current post is open for comments.
* @param bool $comments_open Whether the current post is open for comments.
* @param int $post_id The post ID.
return apply_filters( 'comments_open', $comments_open, $post_id );
* Determines whether the current post is open for pings.
* For more information on this and similar theme functions, check out
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
* Conditional Tags} article in the Theme Developer Handbook.
* @param int|WP_Post $post Optional. Post ID or WP_Post object. Default current post.
* @return bool True if pings are accepted
function pings_open( $post = null ) {
$_post = get_post( $post );
$post_id = $_post ? $_post->ID : 0;
$pings_open = ( $_post && ( 'open' === $_post->ping_status ) );
* Filters whether the current post is open for pings.
* @param bool $pings_open Whether the current post is open for pings.
* @param int $post_id The post ID.
return apply_filters( 'pings_open', $pings_open, $post_id );
* Displays form token for unfiltered comments.
* Will only display nonce token if the current user has permissions for
* unfiltered html. Won't display the token for other users.
* The function was backported to 2.0.10 and was added to versions 2.1.3 and
* above. Does not exist in versions prior to 2.0.10 in the 2.0 branch and in
* the 2.1 branch, prior to 2.1.3. Technically added in 2.2.0.
function wp_comment_form_unfiltered_html_nonce() {
$post_id = $post ? $post->ID : 0;
if ( current_user_can( 'unfiltered_html' ) ) {
wp_nonce_field( 'unfiltered-html-comment_' . $post_id, '_wp_unfiltered_html_comment_disabled', false );
wp_print_inline_script_tag( "(function(){if(window===window.parent){document.getElementById('_wp_unfiltered_html_comment_disabled').name='_wp_unfiltered_html_comment';}})();" );
* Loads the comment template specified in $file.
* Will not display the comments template if not on single post or page, or if
* the post does not have comments.
* Uses the WordPress database object to query for the comments. The comments
* are passed through the {@see 'comments_array'} filter hook with the list of comments
* and the post ID respectively.
* The `$file` path is passed through a filter hook called {@see 'comments_template'},
* which includes the template directory and $file combined. Tries the $filtered path
* first and if it fails it will require the default comment template from the
* default theme. If either does not exist, then the WordPress process will be
* halted. It is advised for that reason, that the default theme is not deleted.
* Will not try to get the comments if the post has none.
* @global WP_Query $wp_query WordPress Query object.
* @global WP_Post $post Global post object.
* @global wpdb $wpdb WordPress database abstraction object.
* @global WP_Comment $comment Global comment object.
* @global string $user_login
* @global string $user_identity
* @global bool $overridden_cpage
* @global bool $withcomments
* @global string $wp_stylesheet_path Path to current theme's stylesheet directory.
* @global string $wp_template_path Path to current theme's template directory.
* @param string $file Optional. The file to load. Default '/comments.php'.
* @param bool $separate_comments Optional. Whether to separate the comments by comment type.
function comments_template( $file = '/comments.php', $separate_comments = false ) {
global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_identity, $overridden_cpage, $wp_stylesheet_path, $wp_template_path;
if ( ! ( is_single() || is_page() || $withcomments ) || empty( $post ) ) {
$req = get_option( 'require_name_email' );
* Comment author information fetched from the comment cookies.
$commenter = wp_get_current_commenter();
* The name of the current comment author escaped for use in attributes.
* Escaped by sanitize_comment_cookies().
$comment_author = $commenter['comment_author'];
* The email address of the current comment author escaped for use in attributes.
* Escaped by sanitize_comment_cookies().
$comment_author_email = $commenter['comment_author_email'];
* The URL of the current comment author escaped for use in attributes.
$comment_author_url = esc_url( $commenter['comment_author_url'] );
'orderby' => 'comment_date_gmt',
'no_found_rows' => false,
if ( get_option( 'thread_comments' ) ) {
$comment_args['hierarchical'] = 'threaded';
$comment_args['hierarchical'] = false;
if ( is_user_logged_in() ) {
$comment_args['include_unapproved'] = array( get_current_user_id() );
$unapproved_email = wp_get_unapproved_comment_author_email();
if ( $unapproved_email ) {
$comment_args['include_unapproved'] = array( $unapproved_email );
if ( get_option( 'page_comments' ) ) {
$per_page = (int) get_query_var( 'comments_per_page' );
$per_page = (int) get_option( 'comments_per_page' );
$comment_args['number'] = $per_page;
$page = (int) get_query_var( 'cpage' );
$comment_args['offset'] = ( $page - 1 ) * $per_page;
} elseif ( 'oldest' === get_option( 'default_comments_page' ) ) {
$comment_args['offset'] = 0;
// If fetching the first page of 'newest', we need a top-level comment count.
$top_level_query = new WP_Comment_Query();
if ( $comment_args['hierarchical'] ) {
$top_level_args['parent'] = 0;