[ Index ]

WordPress Cross Reference

title

Body

[close]

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

Manages WordPress comments

File Size: 2479 lines (79 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 2 files
 wp-includes/class-IXR.php
 wp-includes/class-wp-http-ixr-client.php

Defines 1 class

WP_Comment_Query:: (49 methods):
  query()
  get_search_sql()
  get_comment_statuses()
  get_lastcommentmodified()
  get_comment_count()
  add_comment_meta()
  delete_comment_meta()
  get_comment_meta()
  update_comment_meta()
  wp_set_comment_cookies()
  sanitize_comment_cookies()
  wp_allow_comment()
  check_comment_flood_db()
  separate_comments()
  get_comment_pages_count()
  get_page_of_comment()
  wp_blacklist_check()
  wp_count_comments()
  wp_delete_comment()
  wp_trash_comment()
  wp_untrash_comment()
  wp_spam_comment()
  wp_unspam_comment()
  wp_get_comment_status()
  wp_transition_comment_status()
  wp_get_current_commenter()
  wp_insert_comment()
  wp_filter_comment()
  wp_throttle_comment_flood()
  wp_new_comment()
  wp_set_comment_status()
  wp_update_comment()
  wp_defer_comment_counting()
  wp_update_comment_count()
  wp_update_comment_count_now()
  discover_pingback_server_uri()
  do_all_pings()
  do_trackbacks()
  generic_ping()
  pingback()
  privacy_ping_filter()
  trackback()
  weblog_ping()
  pingback_ping_source_uri()
  xmlrpc_pingback_error()
  clean_comment_cache()
  update_comment_cache()
  _close_comments_for_old_posts()
  _close_comments_for_old_post()

Defines 49 functions

  check_comment()
  get_approved_comments()
  get_comment()
  get_comments()

Class: WP_Comment_Query  - X-Ref

WordPress Comment Query class.

query( $query_vars )   X-Ref
Execute the query

param: string|array $query_vars
return: int|array

get_search_sql( $string, $cols )   X-Ref
Used internally to generate an SQL string for searching across multiple columns

param: string $string
param: array $cols
return: string

get_comment_statuses()   X-Ref
Retrieve all of the WordPress supported comment statuses.

Comments have a limited set of valid status values, this provides the comment
status values and descriptions.

return: array List of comment statuses.

get_lastcommentmodified($timezone = 'server')   X-Ref
The date the last comment was modified.

param: string $timezone Which timezone to use in reference to 'gmt', 'blog',
return: string Last comment modified date.

get_comment_count( $post_id = 0 )   X-Ref
The amount of comments in a post or total comments.

A lot like {@link wp_count_comments()}, in that they both return comment
stats (albeit with different types). The {@link wp_count_comments()} actual
caches, but this function does not.

param: int $post_id Optional. Comment amount in post if > 0, else total comments blog wide.
return: array The amount of spam, approved, awaiting moderation, and total comments.

add_comment_meta($comment_id, $meta_key, $meta_value, $unique = false)   X-Ref
Add meta data field to a comment.

param: int $comment_id Comment ID.
param: string $meta_key Metadata name.
param: mixed $meta_value Metadata value.
param: bool $unique Optional, default is false. Whether the same key should not be added.
return: int|bool Meta ID on success, false on failure.

delete_comment_meta($comment_id, $meta_key, $meta_value = '')   X-Ref
Remove metadata matching criteria from a comment.

You can match based on the key, or key and value. Removing based on key and
value, will keep from removing duplicate metadata with the same key. It also
allows removing all metadata matching key, if needed.

param: int $comment_id comment ID
param: string $meta_key Metadata name.
param: mixed $meta_value Optional. Metadata value.
return: bool True on success, false on failure.

get_comment_meta($comment_id, $key = '', $single = false)   X-Ref
Retrieve comment meta field for a comment.

param: int $comment_id Comment ID.
param: string $key Optional. The meta key to retrieve. By default, returns data for all keys.
param: bool $single Whether to return a single value.
return: mixed Will be an array if $single is false. Will be value of meta data field if $single

update_comment_meta($comment_id, $meta_key, $meta_value, $prev_value = '')   X-Ref
Update comment meta field based on comment ID.

Use the $prev_value parameter to differentiate between meta fields with the
same key and comment ID.

If the meta field for the comment does not exist, it will be added.

param: int $comment_id Comment ID.
param: string $meta_key Metadata key.
param: mixed $meta_value Metadata value.
param: mixed $prev_value Optional. Previous value to check before removing.
return: bool True on success, false on failure.

wp_set_comment_cookies($comment, $user)   X-Ref
Sets the cookies used to store an unauthenticated commentator's identity. Typically used
to recall previous comments by this commentator that are still held in moderation.

param: object $comment Comment object.
param: object $user Comment author's object.

sanitize_comment_cookies()   X-Ref
Sanitizes the cookies sent to the user already.

Will only do anything if the cookies have already been created for the user.
Mostly used after cookies had been sent to use elsewhere.


wp_allow_comment($commentdata)   X-Ref
Validates whether this comment is allowed to be made.

param: array $commentdata Contains information on the comment
return: mixed Signifies the approval status (0|1|'spam')

check_comment_flood_db( $ip, $email, $date )   X-Ref
Check whether comment flooding is occurring.

Won't run, if current user can manage options, so to not block
administrators.

param: string $ip Comment IP.
param: string $email Comment author email address.
param: string $date MySQL time string.

separate_comments(&$comments)   X-Ref
Separates an array of comments into an array keyed by comment_type.

param: array $comments Array of comments
return: array Array of comments keyed by comment_type.

get_comment_pages_count( $comments = null, $per_page = null, $threaded = null )   X-Ref
Calculate the total number of comment pages.

param: array $comments Optional array of comment objects. Defaults to $wp_query->comments
param: int $per_page Optional comments per page.
param: boolean $threaded Optional control over flat or threaded comments.
return: int Number of comment pages.

get_page_of_comment( $comment_ID, $args = array()   X-Ref
Calculate what page number a comment will appear on for comment paging.

param: int $comment_ID Comment ID.
param: array $args Optional args.
return: int|null Comment page number or null on error.

wp_blacklist_check($author, $email, $url, $comment, $user_ip, $user_agent)   X-Ref
Does comment contain blacklisted characters or words.

param: string $author The author of the comment
param: string $email The email of the comment
param: string $url The url used in the comment
param: string $comment The comment content
param: string $user_ip The comment author IP address
param: string $user_agent The author's browser user agent
return: bool True if comment contains blacklisted content, false if comment does not

wp_count_comments( $post_id = 0 )   X-Ref
Retrieve total comments for blog or single post.

The properties of the returned object contain the 'moderated', 'approved',
and spam comments for either the entire blog or single post. Those properties
contain the amount of comments that match the status. The 'total_comments'
property contains the integer of total comments.

The comment stats are cached and then retrieved, if they already exist in the
cache.

param: int $post_id Optional. Post ID.
return: object Comment stats.

wp_delete_comment($comment_id, $force_delete = false)   X-Ref
Trashes or deletes a comment.

The comment is moved to trash instead of permanently deleted unless trash is
disabled, item is already in the trash, or $force_delete is true.

The post comment count will be updated if the comment was approved and has a
post ID available.

param: int $comment_id Comment ID
param: bool $force_delete Whether to bypass trash and force deletion. Default is false.
return: bool True on success, false on failure.

wp_trash_comment($comment_id)   X-Ref
Moves a comment to the Trash

If trash is disabled, comment is permanently deleted.

param: int $comment_id Comment ID.
return: bool True on success, false on failure.

wp_untrash_comment($comment_id)   X-Ref
Removes a comment from the Trash

param: int $comment_id Comment ID.
return: bool True on success, false on failure.

wp_spam_comment($comment_id)   X-Ref
Marks a comment as Spam

param: int $comment_id Comment ID.
return: bool True on success, false on failure.

wp_unspam_comment($comment_id)   X-Ref
Removes a comment from the Spam

param: int $comment_id Comment ID.
return: bool True on success, false on failure.

wp_get_comment_status($comment_id)   X-Ref
The status of a comment by ID.

param: int $comment_id Comment ID
return: string|bool Status might be 'trash', 'approved', 'unapproved', 'spam'. False on failure.

wp_transition_comment_status($new_status, $old_status, $comment)   X-Ref
Call hooks for when a comment status transition occurs.

Calls hooks for comment status transitions. If the new comment status is not the same
as the previous comment status, then two hooks will be ran, the first is
'transition_comment_status' with new status, old status, and comment data. The
next action called is 'comment_OLDSTATUS_to_NEWSTATUS' the NEWSTATUS is the
$new_status parameter and the OLDSTATUS is $old_status parameter; it has the
comment data.

The final action will run whether or not the comment statuses are the same. The
action is named 'comment_NEWSTATUS_COMMENTTYPE', NEWSTATUS is from the $new_status
parameter and COMMENTTYPE is comment_type comment data.

param: string $new_status New comment status.
param: string $old_status Previous comment status.
param: object $comment Comment data.

wp_get_current_commenter()   X-Ref
Get current commenter's name, email, and URL.

Expects cookies content to already be sanitized. User of this function might
wish to recheck the returned array for validity.

return: array Comment author, email, url respectively.

wp_insert_comment($commentdata)   X-Ref
Inserts a comment to the database.

The available comment data key names are 'comment_author_IP', 'comment_date',
'comment_date_gmt', 'comment_parent', 'comment_approved', and 'user_id'.

param: array $commentdata Contains information on the comment.
return: int The new comment's ID.

wp_filter_comment($commentdata)   X-Ref
Filters and sanitizes comment data.

Sets the comment data 'filtered' field to true when finished. This can be
checked as to whether the comment should be filtered and to keep from
filtering the same comment more than once.

param: array $commentdata Contains information on the comment.
return: array Parsed comment information.

wp_throttle_comment_flood($block, $time_lastcomment, $time_newcomment)   X-Ref
Whether a comment should be blocked because of comment flood.

param: bool $block Whether plugin has already blocked comment.
param: int $time_lastcomment Timestamp for last comment.
param: int $time_newcomment Timestamp for new comment.
return: bool Whether comment should be blocked.

wp_new_comment( $commentdata )   X-Ref
Adds a new comment to the database.

Filters new comment to ensure that the fields are sanitized and valid before
inserting comment into database. Calls 'comment_post' action with comment ID
and whether comment is approved by WordPress. Also has 'preprocess_comment'
filter for processing the comment data before the function handles it.

We use REMOTE_ADDR here directly. If you are behind a proxy, you should ensure
that it is properly set, such as in wp-config.php, for your environment.
See {@link http://core.trac.wordpress.org/ticket/9235}

param: array $commentdata Contains information on the comment.
return: int The ID of the comment after adding.

wp_set_comment_status($comment_id, $comment_status, $wp_error = false)   X-Ref
Sets the status of a comment.

The 'wp_set_comment_status' action is called after the comment is handled.
If the comment status is not in the list, then false is returned.

param: int $comment_id Comment ID.
param: string $comment_status New comment status, either 'hold', 'approve', 'spam', or 'trash'.
param: bool $wp_error Whether to return a WP_Error object if there is a failure. Default is false.
return: bool|WP_Error True on success, false or WP_Error on failure.

wp_update_comment($commentarr)   X-Ref
Updates an existing comment in the database.

Filters the comment and makes sure certain fields are valid before updating.

param: array $commentarr Contains information on the comment.
return: int Comment was updated if value is 1, or was not updated if value is 0.

wp_defer_comment_counting($defer=null)   X-Ref
Whether to defer comment counting.

When setting $defer to true, all post comment counts will not be updated
until $defer is set to false. When $defer is set to false, then all
previously deferred updated post comment counts will then be automatically
updated without having to call wp_update_comment_count() after.

param: bool $defer
return: unknown

wp_update_comment_count($post_id, $do_deferred=false)   X-Ref
Updates the comment count for post(s).

When $do_deferred is false (is by default) and the comments have been set to
be deferred, the post_id will be added to a queue, which will be updated at a
later date and only updated once per post ID.

If the comments have not be set up to be deferred, then the post will be
updated. When $do_deferred is set to true, then all previous deferred post
IDs will be updated along with the current $post_id.

param: int $post_id Post ID
param: bool $do_deferred Whether to process previously deferred post comment counts
return: bool True on success, false on failure

wp_update_comment_count_now($post_id)   X-Ref
Updates the comment count for the post.

param: int $post_id Post ID
return: bool True on success, false on '0' $post_id or if post with ID does not exist.

discover_pingback_server_uri( $url, $deprecated = '' )   X-Ref
Finds a pingback server URI based on the given URL.

Checks the HTML for the rel="pingback" link and x-pingback headers. It does
a check for the x-pingback headers first and returns that, if available. The
check for the rel="pingback" has more overhead than just the header.

param: string $url URL to ping.
param: int $deprecated Not Used.
return: bool|string False on failure, string containing URI on success.

do_all_pings()   X-Ref
Perform all pingbacks, enclosures, trackbacks, and send to pingback services.


do_trackbacks($post_id)   X-Ref
Perform trackbacks.

param: int $post_id Post ID to do trackbacks on.

generic_ping($post_id = 0)   X-Ref
Sends pings to all of the ping site services.

param: int $post_id Post ID. Not actually used.
return: int Same as Post ID from parameter

pingback($content, $post_ID)   X-Ref
Pings back the links found in a post.

param: string $content Post content to check for links.
param: int $post_ID Post ID.

privacy_ping_filter($sites)   X-Ref
Check whether blog is public before returning sites.

param: mixed $sites Will return if blog is public, will not return if not public.
return: mixed Empty string if blog is not public, returns $sites, if site is public.

trackback($trackback_url, $title, $excerpt, $ID)   X-Ref
Send a Trackback.

Updates database when sending trackback to prevent duplicates.

param: string $trackback_url URL to send trackbacks.
param: string $title Title of post.
param: string $excerpt Excerpt of post.
param: int $ID Post ID.
return: mixed Database query from update.

weblog_ping($server = '', $path = '')   X-Ref
Send a pingback.

param: string $server Host of blog to connect to.
param: string $path Path to send the ping.

pingback_ping_source_uri( $source_uri )   X-Ref
Default filter attached to pingback_ping_source_uri to validate the pingback's Source URI

param: string $source_uri
return: string

xmlrpc_pingback_error( $ixr_error )   X-Ref
Default filter attached to xmlrpc_pingback_error.

Returns a generic pingback error code unless the error code is 48,
which reports that the pingback is already registered.

param: IXR_Error $ixr_error
return: IXR_Error

clean_comment_cache($ids)   X-Ref
Removes comment ID from the comment cache.

param: int|array $ids Comment ID or array of comment IDs to remove from cache

update_comment_cache($comments)   X-Ref
Updates the comment cache of given comments.

Will add the comments in $comments to the cache. If comment ID already exists
in the comment cache then it will not be updated. The comment is added to the
cache using the comment group with the key using the ID of the comments.

param: array $comments Array of comment row objects

_close_comments_for_old_posts( $posts, $query )   X-Ref
Close comments on old posts on the fly, without any extra DB queries. Hooked to the_posts.

param: object $posts Post data object.
param: object $query Query object.
return: object

_close_comments_for_old_post( $open, $post_id )   X-Ref
Close comments on an old post. Hooked to comments_open and pings_open.

param: bool $open Comments open or closed
param: int $post_id Post ID
return: bool $open

Functions
Functions that are not part of a class:

check_comment($author, $email, $url, $comment, $user_ip, $user_agent, $comment_type)   X-Ref
Checks whether a comment passes internal checks to be allowed to add.

If comment moderation is set in the administration, then all comments,
regardless of their type and whitelist will be set to false. If the number of
links exceeds the amount in the administration, then the check fails. If any
of the parameter contents match the blacklist of words, then the check fails.

If the number of links exceeds the amount in the administration, then the
check fails. If any of the parameter contents match the blacklist of words,
then the check fails.

If the comment author was approved before, then the comment is
automatically whitelisted.

If none of the checks fail, then the failback is to set the check to pass
(return true).

param: string $author Comment Author's name
param: string $email Comment Author's email
param: string $url Comment Author's URL
param: string $comment Comment contents
param: string $user_ip Comment Author's IP address
param: string $user_agent Comment Author's User Agent
param: string $comment_type Comment type, either user submitted comment,
return: bool Whether the checks passed (true) and the comments should be

get_approved_comments($post_id)   X-Ref
Retrieve the approved comments for post $post_id.

param: int $post_id The ID of the post
return: array $comments The approved comments

get_comment(&$comment, $output = OBJECT)   X-Ref
Retrieves comment data given a comment ID or comment object.

If an object is passed then the comment data will be cached and then returned
after being passed through a filter. If the comment is empty, then the global
comment variable will be used, if it is set.

param: object|string|int $comment Comment to retrieve.
param: string $output Optional. OBJECT or ARRAY_A or ARRAY_N constants.
return: object|array|null Depends on $output value.

get_comments( $args = '' )   X-Ref
Retrieve a list of comments.

The comment list can be for the blog as a whole or for an individual post.

The list of comment arguments are 'status', 'orderby', 'comment_date_gmt',
'order', 'number', 'offset', and 'post_id'.

param: mixed $args Optional. Array or string of options to override defaults.
return: array List of comments.



Generated: Tue Mar 25 01:41:18 2014 WordPress honlapkészítés: online1.hu