get_comment [ WordPress Function ]
| Parameters: |
|
| Uses: |
|
| Returns: |
|
| Defined at: |
|
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.
If the comment is empty, then the global comment variable will be used, if it is set.
Source
<?php
function &get_comment(&$comment, $output = OBJECT) {
global $wpdb;
$null = null;
if ( empty($comment) ) {
if ( isset($GLOBALS['comment']) )
$_comment = & $GLOBALS['comment'];
else
$_comment = null;
} elseif ( is_object($comment) ) {
wp_cache_add($comment->comment_ID, $comment, 'comment');
$_comment = $comment;
} else {
if ( isset($GLOBALS['comment']) && ($GLOBALS['comment']->comment_ID == $comment) ) {
$_comment = & $GLOBALS['comment'];
} elseif ( ! $_comment = wp_cache_get($comment, 'comment') ) {
$_comment = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_ID = %d LIMIT 1", $comment));
if ( ! $_comment )
return $null;
wp_cache_add($_comment->comment_ID, $_comment, 'comment');
}
}
$_comment = apply_filters('get_comment', $_comment);
if ( $output == OBJECT ) {
return $_comment;
} elseif ( $output == ARRAY_A ) {
$__comment = get_object_vars($_comment);
return $__comment;
} elseif ( $output == ARRAY_N ) {
$__comment = array_values(get_object_vars($_comment));
return $__comment;
} else {
return $_comment;
}
}
?>
Examples [ wp-snippets.com ]
Google Arama Sonuçlarý
- Function Reference/get comment « WordPress Codex
Description. Takes a comment ID and returns the database record for that post. You can specify, by means of the $output parameter, how you would like the ...
codex.wordpress.org - get_comments - WordPress Codex
Description. Retrieve a list of comments. Usage. <?php get_comments( $args ); ? > Default Usage. <?php $defaults = array( 'author_email' => , 'ID' => , 'karma' ...
codex.wordpress.org - Manual Pages - Get_comment
The get_comment command extracts text fields from a variety of trace formats. Each comment is of the form Field-ID=comment, regardless of the file format.
staden.sourceforge.net - get_comment Wordpress hook details -- Adam Brown, BYU Political ...
Detailed information about every action hook and filter used in WordPress. Makes Plugin API easier to use. Lists appearance, file location, and deprecation data ...
adambrown.info