[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/ -> comment-template.php (summary)

Comment template functions These functions are meant to live inside of the WordPress loop.

File Size: 2908 lines (103 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 1 file
 wp-includes/theme-compat/comments.php

Defines 54 functions

  get_comment_author()
  comment_author()
  get_comment_author_email()
  comment_author_email()
  comment_author_email_link()
  get_comment_author_email_link()
  get_comment_author_link()
  comment_author_link()
  get_comment_author_IP()
  comment_author_IP()
  get_comment_author_url()
  comment_author_url()
  get_comment_author_url_link()
  comment_author_url_link()
  comment_class()
  get_comment_class()
  get_comment_date()
  comment_date()
  get_comment_excerpt()
  comment_excerpt()
  get_comment_ID()
  comment_ID()
  get_comment_link()
  get_comments_link()
  comments_link()
  get_comments_number()
  comments_number()
  get_comments_number_text()
  get_comment_text()
  comment_text()
  get_comment_time()
  comment_time()
  get_comment_type()
  comment_type()
  get_trackback_url()
  trackback_url()
  trackback_rdf()
  comments_open()
  pings_open()
  wp_comment_form_unfiltered_html_nonce()
  comments_template()
  comments_popup_link()
  get_comment_reply_link()
  comment_reply_link()
  get_post_reply_link()
  post_reply_link()
  get_cancel_comment_reply_link()
  cancel_comment_reply_link()
  get_comment_id_fields()
  comment_id_fields()
  comment_form_title()
  _get_comment_reply_id()
  wp_list_comments()
  comment_form()

Functions
Functions that are not part of a class:

get_comment_author( $comment_id = 0 )   X-Ref
Retrieves the author of the current comment.

If the comment has an empty comment_author field, then 'Anonymous' person is
assumed.

return: string The comment author
param: int|WP_Comment $comment_id Optional. WP_Comment or the ID of the comment for which to retrieve the author.

comment_author( $comment_id = 0 )   X-Ref
Displays the author of the current comment.

param: int|WP_Comment $comment_id Optional. WP_Comment or the ID of the comment for which to print the author.

get_comment_author_email( $comment_id = 0 )   X-Ref
Retrieves the email of the author of the current comment.

return: string The current comment author's email
param: int|WP_Comment $comment_id Optional. WP_Comment or the ID of the comment for which to get the author's email.

comment_author_email( $comment_id = 0 )   X-Ref
Displays the email of the author of the current global $comment.

Care should be taken to protect the email address and assure that email
harvesters do not capture your commenter's email address. Most assume that
their email address will not appear in raw form on the site. Doing so will
enable anyone, including those that people don't want to get the email
address and use it for their own means good and bad.

param: int|WP_Comment $comment_id Optional. WP_Comment or the ID of the comment for which to print the author's email.

comment_author_email_link( $link_text = '', $before = '', $after = '', $comment = null )   X-Ref
Displays the HTML email link to the author of the current comment.

Care should be taken to protect the email address and assure that email
harvesters do not capture your commenter's email address. Most assume that
their email address will not appear in raw form on the site. Doing so will
enable anyone, including those that people don't want to get the email
address and use it for their own means good and bad.

param: string         $link_text Optional. Text to display instead of the comment author's email address.
param: string         $before    Optional. Text or HTML to display before the email link. Default empty.
param: string         $after     Optional. Text or HTML to display after the email link. Default empty.
param: int|WP_Comment $comment   Optional. Comment ID or WP_Comment object. Default is the current comment.

get_comment_author_email_link( $link_text = '', $before = '', $after = '', $comment = null )   X-Ref
Returns the HTML email link to the author of the current comment.

Care should be taken to protect the email address and assure that email
harvesters do not capture your commenter's email address. Most assume that
their email address will not appear in raw form on the site. Doing so will
enable anyone, including those that people don't want to get the email
address and use it for their own means good and bad.

return: string HTML markup for the comment author email link. By default, the email address is obfuscated
param: string         $link_text Optional. Text to display instead of the comment author's email address.
param: string         $before    Optional. Text or HTML to display before the email link. Default empty.
param: string         $after     Optional. Text or HTML to display after the email link. Default empty.
param: int|WP_Comment $comment   Optional. Comment ID or WP_Comment object. Default is the current comment.

get_comment_author_link( $comment_id = 0 )   X-Ref
Retrieves the HTML link to the URL of the author of the current comment.

Both get_comment_author_url() and get_comment_author() rely on get_comment(),
which falls back to the global comment variable if the $comment_id argument is empty.

return: string The comment author name or HTML link for author's URL.
param: int|WP_Comment $comment_id Optional. WP_Comment or the ID of the comment for which to get the author's link.

comment_author_link( $comment_id = 0 )   X-Ref
Displays the HTML link to the URL of the author of the current comment.

param: int|WP_Comment $comment_id Optional. WP_Comment or the ID of the comment for which to print the author's link.

get_comment_author_IP( $comment_id = 0 )   X-Ref
Retrieves the IP address of the author of the current comment.

return: string Comment author's IP address, or an empty string if it's not available.
param: int|WP_Comment $comment_id Optional. WP_Comment or the ID of the comment for which to get the author's IP address.

comment_author_IP( $comment_id = 0 )   X-Ref
Displays the IP address of the author of the current comment.

param: int|WP_Comment $comment_id Optional. WP_Comment or the ID of the comment for which to print the author's IP address.

get_comment_author_url( $comment_id = 0 )   X-Ref
Retrieves the URL of the author of the current comment, not linked.

return: string Comment author URL, if provided, an empty string otherwise.
param: int|WP_Comment $comment_id Optional. WP_Comment or the ID of the comment for which to get the author's URL.

comment_author_url( $comment_id = 0 )   X-Ref
Displays the URL of the author of the current comment, not linked.

param: int|WP_Comment $comment_id Optional. WP_Comment or the ID of the comment for which to print the author's URL.

get_comment_author_url_link( $link_text = '', $before = '', $after = '', $comment = 0 )   X-Ref
Retrieves the HTML link of the URL of the author of the current comment.

$link_text parameter is only used if the URL does not exist for the comment
author. If the URL does exist then the URL will be used and the $link_text
will be ignored.

Encapsulate the HTML link between the $before and $after. So it will appear
in the order of $before, link, and finally $after.

return: string The HTML link between the $before and $after parameters.
param: string         $link_text Optional. The text to display instead of the comment
param: string         $before    Optional. The text or HTML to display before the email link.
param: string         $after     Optional. The text or HTML to display after the email link.
param: int|WP_Comment $comment   Optional. Comment ID or WP_Comment object.

comment_author_url_link( $link_text = '', $before = '', $after = '', $comment = 0 )   X-Ref
Displays the HTML link of the URL of the author of the current comment.

param: string         $link_text Optional. Text to display instead of the comment author's
param: string         $before    Optional. Text or HTML to display before the email link.
param: string         $after     Optional. Text or HTML to display after the email link.
param: int|WP_Comment $comment   Optional. Comment ID or WP_Comment object.

comment_class( $css_class = '', $comment = null, $post = null, $display = true )   X-Ref
Generates semantic classes for each comment element.

return: void|string Void if `$display` argument is true, comment classes if `$display` is false.
param: string|string[] $css_class Optional. One or more classes to add to the class list.
param: int|WP_Comment  $comment   Optional. Comment ID or WP_Comment object. Default current comment.
param: int|WP_Post     $post      Optional. Post ID or WP_Post object. Default current post.
param: bool            $display   Optional. Whether to print or return the output.

get_comment_class( $css_class = '', $comment_id = null, $post = null )   X-Ref
Returns the classes for the comment div as an array.

return: string[] An array of classes.
param: string|string[] $css_class  Optional. One or more classes to add to the class list.
param: int|WP_Comment  $comment_id Optional. Comment ID or WP_Comment object. Default current comment.
param: int|WP_Post     $post       Optional. Post ID or WP_Post object. Default current post.

get_comment_date( $format = '', $comment_id = 0 )   X-Ref
Retrieves the comment date of the current comment.

return: string The comment's date.
param: string         $format     Optional. PHP date format. Defaults to the 'date_format' option.
param: int|WP_Comment $comment_id Optional. WP_Comment or ID of the comment for which to get the date.

comment_date( $format = '', $comment_id = 0 )   X-Ref
Displays the comment date of the current comment.

param: string         $format     Optional. PHP date format. Defaults to the 'date_format' option.
param: int|WP_Comment $comment_id WP_Comment or ID of the comment for which to print the date.

get_comment_excerpt( $comment_id = 0 )   X-Ref
Retrieves the excerpt of the given comment.

Returns a maximum of 20 words with an ellipsis appended if necessary.

return: string The possibly truncated comment excerpt.
param: int|WP_Comment $comment_id Optional. WP_Comment or ID of the comment for which to get the excerpt.

comment_excerpt( $comment_id = 0 )   X-Ref
Displays the excerpt of the current comment.

param: int|WP_Comment $comment_id Optional. WP_Comment or ID of the comment for which to print the excerpt.

get_comment_ID()   X-Ref
Retrieves the comment ID of the current comment.

return: string The comment ID as a numeric string.

comment_ID()   X-Ref
Displays the comment ID of the current comment.


get_comment_link( $comment = null, $args = array()   X-Ref
Retrieves the link to a given comment.

return: string The permalink to the given comment.
param: WP_Comment|int|null $comment Optional. Comment to retrieve. Default current comment.
param: array               $args {

get_comments_link( $post = 0 )   X-Ref
Retrieves the link to the current post comments.

return: string The link to the comments.
param: int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.

comments_link( $deprecated = '', $deprecated_2 = '' )   X-Ref
Displays the link to the current post comments.

param: string $deprecated   Not Used.
param: string $deprecated_2 Not Used.

get_comments_number( $post = 0 )   X-Ref
Retrieves the amount of comments a post has.

return: string|int If the post exists, a numeric string representing the number of comments
param: int|WP_Post $post Optional. Post ID or WP_Post object. Default is the global `$post`.

comments_number( $zero = false, $one = false, $more = false, $post = 0 )   X-Ref
Displays the language string for the number of comments the current post has.

param: string|false $zero Optional. Text for no comments. Default false.
param: string|false $one  Optional. Text for one comment. Default false.
param: string|false $more Optional. Text for more than one comment. Default false.
param: int|WP_Post  $post Optional. Post ID or WP_Post object. Default is the global `$post`.

get_comments_number_text( $zero = false, $one = false, $more = false, $post = 0 )   X-Ref
Displays the language string for the number of comments the current post has.

return: string Language string for the number of comments a post has.
param: string      $zero Optional. Text for no comments. Default false.
param: string      $one  Optional. Text for one comment. Default false.
param: string      $more Optional. Text for more than one comment. Default false.
param: int|WP_Post $post Optional. Post ID or WP_Post object. Default is the global `$post`.

get_comment_text( $comment_id = 0, $args = array()   X-Ref
Retrieves the text of the current comment.

return: string The comment content.
param: int|WP_Comment $comment_id Optional. WP_Comment or ID of the comment for which to get the text.
param: array          $args       Optional. An array of arguments. Default empty array.

comment_text( $comment_id = 0, $args = array()   X-Ref
Displays the text of the current comment.

param: int|WP_Comment $comment_id Optional. WP_Comment or ID of the comment for which to print the text.
param: array          $args       Optional. An array of arguments. Default empty array.

get_comment_time( $format = '', $gmt = false, $translate = true, $comment_id = 0 )   X-Ref
Retrieves the comment time of the current comment.

return: string The formatted time.
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.

comment_time( $format = '', $comment_id = 0 )   X-Ref
Displays the comment time of the current comment.

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.

get_comment_type( $comment_id = 0 )   X-Ref
Retrieves the comment type of the current comment.

return: string The comment type.
param: int|WP_Comment $comment_id Optional. WP_Comment or ID of the comment for which to get the type.

comment_type( $commenttxt = false, $trackbacktxt = false, $pingbacktxt = false )   X-Ref
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.

get_trackback_url()   X-Ref
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.

trackback_url( $deprecated_echo = true )   X-Ref
Displays the current post's trackback URL.

return: void|string Should only be used to echo the trackback URL, use get_trackback_url()
param: bool $deprecated_echo Not used.

trackback_rdf( $deprecated = '' )   X-Ref
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).

comments_open( $post = null )   X-Ref
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.

return: bool True if the comments are open.
param: int|WP_Post $post Optional. Post ID or WP_Post object. Default current post.

pings_open( $post = null )   X-Ref
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.

return: bool True if pings are accepted
param: int|WP_Post $post Optional. Post ID or WP_Post object. Default current post.

wp_comment_form_unfiltered_html_nonce()   X-Ref
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.

Backported to 2.0.10.


comments_template( $file = '/comments.php', $separate_comments = false )   X-Ref
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.

param: string $file              Optional. The file to load. Default '/comments.php'.
param: bool   $separate_comments Optional. Whether to separate the comments by comment type.

comments_popup_link( $zero = false, $one = false, $more = false, $css_class = '', $none = false )   X-Ref
Displays the link to the comments for the current post ID.

param: false|string $zero      Optional. String to display when no comments. Default false.
param: false|string $one       Optional. String to display when only one comment is available. Default false.
param: false|string $more      Optional. String to display when there are more than one comment. Default false.
param: string       $css_class Optional. CSS class to use for comments. Default empty.
param: false|string $none      Optional. String to display when comments have been turned off. Default false.

get_comment_reply_link( $args = array()   X-Ref
Retrieves HTML content for reply to comment link.

return: string|false|null Link to show comment form, if successful. False, if comments are closed.
param: array          $args {
param: int|WP_Comment $comment Optional. Comment being replied to. Default current comment.
param: int|WP_Post    $post    Optional. Post ID or WP_Post object the comment is going to be displayed on.

comment_reply_link( $args = array()   X-Ref
Displays the HTML content for reply to comment link.

param: array          $args    Optional. Override default options. Default empty array.
param: int|WP_Comment $comment Optional. Comment being replied to. Default current comment.
param: int|WP_Post    $post    Optional. Post ID or WP_Post object the comment is going to be displayed on.

get_post_reply_link( $args = array()   X-Ref
Retrieves HTML content for reply to post link.

return: string|false|null Link to show comment form, if successful. False, if comments are closed.
param: array       $args {
param: int|WP_Post $post    Optional. Post ID or WP_Post object the comment is going to be displayed on.

post_reply_link( $args = array()   X-Ref
Displays the HTML content for reply to post link.

param: array       $args Optional. Override default options. Default empty array.
param: int|WP_Post $post Optional. Post ID or WP_Post object the comment is going to be displayed on.

get_cancel_comment_reply_link( $link_text = '', $post = null )   X-Ref
Retrieves HTML content for cancel comment reply link.

return: string
param: string           $link_text Optional. Text to display for cancel reply link. If empty,
param: int|WP_Post|null $post      Optional. The post the comment thread is being

cancel_comment_reply_link( $link_text = '' )   X-Ref
Displays HTML content for cancel comment reply link.

param: string $link_text Optional. Text to display for cancel reply link. If empty,

get_comment_id_fields( $post = null )   X-Ref
Retrieves hidden input HTML for replying to comments.

return: string Hidden input HTML for replying to comments.
param: int|WP_Post|null $post Optional. The post the comment is being displayed for.

comment_id_fields( $post = null )   X-Ref
Outputs hidden input HTML for replying to comments.

Adds two hidden inputs to the comment form to identify the `comment_post_ID`
and `comment_parent` values for threaded comments.

This tag must be within the `<form>` section of the `comments.php` template.

param: int|WP_Post|null $post Optional. The post the comment is being displayed for.

comment_form_title( $no_reply_text = false, $reply_text = false, $link_to_parent = true, $post = null )   X-Ref
Displays text based on comment reply status.

Only affects users with JavaScript disabled.

param: string|false     $no_reply_text  Optional. Text to display when not replying to a comment.
param: string|false     $reply_text     Optional. Text to display when replying to a comment.
param: bool             $link_to_parent Optional. Boolean to control making the author's name a link
param: int|WP_Post|null $post           Optional. The post that the comment form is being displayed for.

_get_comment_reply_id( $post = null )   X-Ref
Gets the comment's reply to ID from the $_GET['replytocom'].

return: int Comment's reply to ID.
param: int|WP_Post $post The post the comment is being displayed for.

wp_list_comments( $args = array()   X-Ref
Displays a list of comments.

Used in the comments.php template to list comments for a particular post.

return: void|string Void if 'echo' argument is true, or no comments to list.
param: string|array $args {
param: WP_Comment[] $comments Optional. Array of WP_Comment objects. Default null.

comment_form( $args = array()   X-Ref
Outputs a complete commenting form for use within a template.

Most strings and form fields may be controlled through the `$args` array passed
into the function, while you may also choose to use the {@see 'comment_form_default_fields'}
filter to modify the array of default fields if you'd just like to add a new
one or remove a single field. All fields are also individually passed through
a filter of the {@see 'comment_form_field_$name'} where `$name` is the key used
in the array of fields.

param: array       $args {
param: int|WP_Post $post Optional. Post ID or WP_Post object to generate the form for. Default current post.



Generated : Sat Nov 23 08:20:01 2024 Cross-referenced by PHPXref