本文整理汇总了PHP中update_comment_cache函数的典型用法代码示例。如果您正苦于以下问题:PHP update_comment_cache函数的具体用法?PHP update_comment_cache怎么用?PHP update_comment_cache使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了update_comment_cache函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: prepare_items
function prepare_items()
{
global $post_id, $comment_status, $search, $comment_type;
$comment_status = isset($_REQUEST['comment_status']) ? $_REQUEST['comment_status'] : 'all';
if (!in_array($comment_status, array('all', 'moderated', 'approved', 'spam', 'trash'))) {
$comment_status = 'all';
}
$comment_type = !empty($_REQUEST['comment_type']) ? $_REQUEST['comment_type'] : '';
$search = isset($_REQUEST['s']) ? $_REQUEST['s'] : '';
$post_type = isset($_REQUEST['post_type']) ? sanitize_key($_REQUEST['post_type']) : '';
$user_id = isset($_REQUEST['user_id']) ? $_REQUEST['user_id'] : '';
$orderby = isset($_REQUEST['orderby']) ? $_REQUEST['orderby'] : '';
$order = isset($_REQUEST['order']) ? $_REQUEST['order'] : '';
$comments_per_page = $this->get_per_page($comment_status);
$doing_ajax = defined('DOING_AJAX') && DOING_AJAX;
if (isset($_REQUEST['number'])) {
$number = (int) $_REQUEST['number'];
} else {
$number = $comments_per_page + min(8, $comments_per_page);
// Grab a few extra
}
$page = $this->get_pagenum();
if (isset($_REQUEST['start'])) {
$start = $_REQUEST['start'];
} else {
$start = ($page - 1) * $comments_per_page;
}
if ($doing_ajax && isset($_REQUEST['offset'])) {
$start += $_REQUEST['offset'];
}
$status_map = array('moderated' => 'hold', 'approved' => 'approve', 'all' => '');
$args = array('status' => isset($status_map[$comment_status]) ? $status_map[$comment_status] : $comment_status, 'search' => $search, 'user_id' => $user_id, 'offset' => $start, 'number' => $number, 'post_id' => $post_id, 'type' => $comment_type, 'orderby' => $orderby, 'order' => $order, 'post_type' => $post_type);
$_comments = get_comments($args);
update_comment_cache($_comments);
$this->items = array_slice($_comments, 0, $comments_per_page);
$this->extra_items = array_slice($_comments, $comments_per_page);
$total_comments = get_comments(array_merge($args, array('count' => true, 'offset' => 0, 'number' => 0)));
$_comment_post_ids = array();
foreach ($_comments as $_c) {
$_comment_post_ids[] = $_c->comment_post_ID;
}
$_comment_post_ids = array_unique($_comment_post_ids);
$this->pending_count = get_pending_comments_num($_comment_post_ids);
$this->set_pagination_args(array('total_items' => $total_comments, 'per_page' => $comments_per_page));
}
开发者ID:Nancers,项目名称:Snancy-Website-Files,代码行数:45,代码来源:class-wp-comments-list-table.php
示例2: _wp_get_comment_list
/**
* {@internal Missing Short Description}}
*
* @since unknown
*
* @param unknown_type $status
* @param unknown_type $s
* @param unknown_type $start
* @param unknown_type $num
* @param unknown_type $post
* @param unknown_type $type
* @return unknown
*/
function _wp_get_comment_list( $status = '', $s = false, $start, $num, $post = 0, $type = '' ) {
global $wpdb;
$start = abs( (int) $start );
$num = (int) $num;
$post = (int) $post;
if ( 'moderated' == $status )
$approved = "comment_approved = '0'";
elseif ( 'approved' == $status )
$approved = "comment_approved = '1'";
elseif ( 'spam' == $status )
$approved = "comment_approved = 'spam'";
else
$approved = "( comment_approved = '0' OR comment_approved = '1' )";
if ( $post ) {
$post = " AND comment_post_ID = '$post'";
$orderby = "ORDER BY comment_date_gmt ASC LIMIT $start, $num";
} else {
$post = '';
$orderby = "ORDER BY comment_date_gmt DESC LIMIT $start, $num";
}
if ( 'comment' == $type )
$typesql = "AND comment_type = ''";
elseif ( 'pingback' == $type )
$typesql = "AND comment_type = 'pingback'";
elseif ( 'trackback' == $type )
$typesql = "AND comment_type = 'trackback'";
elseif ( 'pings' == $type )
$typesql = "AND ( comment_type = 'pingback' OR comment_type = 'trackback' )";
else
$typesql = '';
if ( $s ) {
$s = $wpdb->escape($s);
$comments = $wpdb->get_results("SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments WHERE
(comment_author LIKE '%$s%' OR
comment_author_email LIKE '%$s%' OR
comment_author_url LIKE ('%$s%') OR
comment_author_IP LIKE ('%$s%') OR
comment_content LIKE ('%$s%') ) AND
$approved
$typesql
$orderby");
} else {
$comments = $wpdb->get_results( "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments WHERE $approved $post $typesql $orderby" );
}
update_comment_cache($comments);
$total = $wpdb->get_var( "SELECT FOUND_ROWS()" );
return array($comments, $total);
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:69,代码来源:template.php
示例3: comments_template
/**
* 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 'comments_array' filter hook with the list of comments
* and the post ID respectively.
*
* The $file path is passed through a filter hook called, 'comments_template'
* which includes the TEMPLATEPATH and $file combined. Tries the $filtered path
* first and if it fails it will require the default comment themplate 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.
*
* @since 1.5.0
* @global array $comment List of comment objects for the current post
* @uses $wpdb
* @uses $id
* @uses $post
* @uses $withcomments Will not try to get the comments if the post has none.
*
* @param string $file Optional, default '/comments.php'. The file to load
* @param bool $separate_comments Optional, whether to separate the comments by comment type. Default is false.
* @return null Returns null if no comments appear
*/
function comments_template($file = '/comments.php', $separate_comments = false)
{
global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity, $overridden_cpage;
if (!(is_single() || is_page() || $withcomments)) {
return;
}
if (empty($file)) {
$file = '/comments.php';
}
$req = get_option('require_name_email');
$commenter = wp_get_current_commenter();
extract($commenter, EXTR_SKIP);
/** @todo Use API instead of SELECTs. */
if ($user_ID) {
$comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->comments} WHERE comment_post_ID = %d AND (comment_approved = '1' OR ( user_id = %d AND comment_approved = '0' ) ) ORDER BY comment_date_gmt", $post->ID, $user_ID));
} else {
if (empty($comment_author)) {
$comments = get_comments(array('post_id' => $post->ID, 'status' => 'approve', 'order' => 'ASC'));
} else {
$comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->comments} WHERE comment_post_ID = %d AND ( comment_approved = '1' OR ( comment_author = %s AND comment_author_email = %s AND comment_approved = '0' ) ) ORDER BY comment_date_gmt", $post->ID, $comment_author, $comment_author_email));
}
}
// keep $comments for legacy's sake
$wp_query->comments = apply_filters('comments_array', $comments, $post->ID);
$comments =& $wp_query->comments;
$wp_query->comment_count = count($wp_query->comments);
update_comment_cache($wp_query->comments);
if ($separate_comments) {
$wp_query->comments_by_type =& separate_comments($comments);
$comments_by_type =& $wp_query->comments_by_type;
}
$overridden_cpage = FALSE;
if ('' == get_query_var('cpage') && get_option('page_comments')) {
set_query_var('cpage', 'newest' == get_option('default_comments_page') ? get_comment_pages_count() : 1);
$overridden_cpage = TRUE;
}
define('COMMENTS_TEMPLATE', true);
$include = apply_filters('comments_template', STYLESHEETPATH . $file);
if (file_exists($include)) {
require $include;
} elseif (file_exists(TEMPLATEPATH . $file)) {
require TEMPLATEPATH . $file;
} else {
require get_theme_root() . '/default/comments.php';
}
}
开发者ID:schr,项目名称:wordpress,代码行数:73,代码来源:comment-template.php
示例4: callback
//.........这里部分代码省略.........
if ($count) {
$found = $count->approved;
}
break;
default:
if (!current_user_can('moderate_comments')) {
return new WP_Error('unauthorized', 'User cannot read non-approved comments', 403);
}
if ('unapproved' === $args['status']) {
$status = 'hold';
$count_status = 'moderated';
} elseif ('all' === $args['status']) {
$status = 'all';
$count_status = 'total_comments';
} else {
$status = $count_status = $args['status'];
}
if ($count) {
$found = $count->{$count_status};
}
}
$query = array('order' => $args['order'], 'type' => 'any' === $args['type'] ? false : $args['type'], 'status' => $status);
if (isset($args['page'])) {
if ($args['page'] < 1) {
$args['page'] = 1;
}
} else {
if ($args['offset'] < 0) {
$args['offset'] = 0;
}
}
if (!$args['hierarchical']) {
$query['number'] = $args['number'];
if (isset($args['page'])) {
$query['offset'] = ($args['page'] - 1) * $args['number'];
} else {
$query['offset'] = $args['offset'];
}
$is_before = isset($args['before_gmt']);
$is_after = isset($args['after_gmt']);
if ($is_before || $is_after) {
$query['date_query'] = array('column' => 'comment_date_gmt', 'inclusive' => true);
if ($is_before) {
$query['date_query']['before'] = $args['before_gmt'];
}
if ($is_after) {
$query['date_query']['after'] = $args['after_gmt'];
}
}
}
if ($post_id) {
$post = get_post($post_id);
if (!$post || is_wp_error($post)) {
return new WP_Error('unknown_post', 'Unknown post', 404);
}
$query['post_id'] = $post->ID;
if ($this->api->ends_with($this->path, '/replies')) {
$query['parent'] = 0;
}
} elseif ($comment_id) {
$comment = get_comment($comment_id);
if (!$comment || is_wp_error($comment)) {
return new WP_Error('unknown_comment', 'Unknown comment', 404);
}
$query['parent'] = $comment_id;
}
$comments = get_comments($query);
update_comment_cache($comments);
if ($args['hierarchical']) {
$walker = new WPCOM_JSON_API_List_Comments_Walker();
$comment_ids = $walker->paged_walk($comments, get_option('thread_comments_depth', -1), isset($args['page']) ? $args['page'] : 1, $args['number']);
$comments = array_map('get_comment', $comment_ids);
}
$return = array();
foreach (array_keys($this->response_format) as $key) {
switch ($key) {
case 'found':
$return[$key] = (int) $found;
break;
case 'site_ID':
$return[$key] = (int) $blog_id;
break;
case 'comments':
$return_comments = array();
foreach ($comments as $comment) {
$the_comment = $this->get_comment($comment->comment_ID, $args['context']);
if ($the_comment && !is_wp_error($the_comment)) {
$return_comments[] = $the_comment;
}
}
if ($return_comments) {
/** This action is documented in json-endpoints/class.wpcom-json-api-site-settings-endpoint.php */
do_action('wpcom_json_api_objects', 'comments', count($return_comments));
}
$return[$key] = $return_comments;
break;
}
}
return $return;
}
开发者ID:StefanBonilla,项目名称:CoupSoup,代码行数:101,代码来源:class.wpcom-json-api-list-comments-endpoint.php
示例5: ddl_load_comments_array
function ddl_load_comments_array()
{
global $wpddlayout, $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity, $overridden_cpage;
$commenter = wp_get_current_commenter();
$comment_author = $commenter['comment_author'];
$comment_author_email = $commenter['comment_author_email'];
$comment_author_url = esc_url($commenter['comment_author_url']);
if ($user_ID) {
$comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->comments} WHERE comment_post_ID = %d AND (comment_approved = '1' OR ( user_id = %d AND comment_approved = '0' ) ) ORDER BY comment_date_gmt", $post->ID, $user_ID));
} else {
if (empty($comment_author)) {
$comments = get_comments(array('post_id' => $post->ID, 'status' => 'approve', 'order' => 'ASC'));
} else {
$comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->comments} WHERE comment_post_ID = %d AND ( comment_approved = '1' OR ( comment_author = %s AND comment_author_email = %s AND comment_approved = '0' ) ) ORDER BY comment_date_gmt", $post->ID, wp_specialchars_decode($comment_author, ENT_QUOTES), $comment_author_email));
}
}
$wp_query->comments = apply_filters('comments_array', $comments, $post->ID);
$comments =& $wp_query->comments;
$wp_query->comment_count = count($wp_query->comments);
update_comment_cache($wp_query->comments);
return $comments;
}
开发者ID:javierdlahoz,项目名称:paella-development,代码行数:22,代码来源:wpddl.cell_comments.class.php
示例6: get_comments
//.........这里部分代码省略.........
// Strip leading 'AND'.
$where[] = preg_replace('/^\\s*AND\\s*/', '', $search_sql);
}
// If any post-related query vars are passed, join the posts table.
$join_posts_table = false;
$plucked = hq_array_slice_assoc($this->query_vars, array('post_author', 'post_name', 'post_parent', 'post_status', 'post_type'));
$post_fields = array_filter($plucked);
if (!empty($post_fields)) {
$join_posts_table = true;
foreach ($post_fields as $field_name => $field_value) {
// $field_value may be an array.
$esses = array_fill(0, count((array) $field_value), '%s');
$where[] = $hqdb->prepare(" {$hqdb->posts}.{$field_name} IN (" . implode(',', $esses) . ')', $field_value);
}
}
// Comment author IDs for an IN clause.
if (!empty($this->query_vars['author__in'])) {
$where[] = 'user_id IN ( ' . implode(',', hq_parse_id_list($this->query_vars['author__in'])) . ' )';
}
// Comment author IDs for a NOT IN clause.
if (!empty($this->query_vars['author__not_in'])) {
$where[] = 'user_id NOT IN ( ' . implode(',', hq_parse_id_list($this->query_vars['author__not_in'])) . ' )';
}
// Post author IDs for an IN clause.
if (!empty($this->query_vars['post_author__in'])) {
$join_posts_table = true;
$where[] = 'post_author IN ( ' . implode(',', hq_parse_id_list($this->query_vars['post_author__in'])) . ' )';
}
// Post author IDs for a NOT IN clause.
if (!empty($this->query_vars['post_author__not_in'])) {
$join_posts_table = true;
$where[] = 'post_author NOT IN ( ' . implode(',', hq_parse_id_list($this->query_vars['post_author__not_in'])) . ' )';
}
if ($join_posts_table) {
$join = "JOIN {$hqdb->posts} ON {$hqdb->posts}.ID = {$hqdb->comments}.comment_post_ID";
}
if (!empty($meta_query_clauses)) {
$join .= $meta_query_clauses['join'];
// Strip leading 'AND'.
$where[] = preg_replace('/^\\s*AND\\s*/', '', $meta_query_clauses['where']);
if (!$this->query_vars['count']) {
$groupby = "{$hqdb->comments}.comment_ID";
}
}
$date_query = $this->query_vars['date_query'];
if (!empty($date_query) && is_array($date_query)) {
$date_query_object = new HQ_Date_Query($date_query, 'comment_date');
$where[] = preg_replace('/^\\s*AND\\s*/', '', $date_query_object->get_sql());
}
$where = implode(' AND ', $where);
$pieces = array('fields', 'join', 'where', 'orderby', 'limits', 'groupby');
/**
* Filter the comment query clauses.
*
* @since 0.0.1
*
* @param array $pieces A compacted array of comment query clauses.
* @param HQ_Comment_Query &$this Current instance of HQ_Comment_Query, passed by reference.
*/
$clauses = apply_filters_ref_array('comments_clauses', array(compact($pieces), &$this));
$fields = isset($clauses['fields']) ? $clauses['fields'] : '';
$join = isset($clauses['join']) ? $clauses['join'] : '';
$where = isset($clauses['where']) ? $clauses['where'] : '';
$orderby = isset($clauses['orderby']) ? $clauses['orderby'] : '';
$limits = isset($clauses['limits']) ? $clauses['limits'] : '';
$groupby = isset($clauses['groupby']) ? $clauses['groupby'] : '';
if ($where) {
$where = 'WHERE ' . $where;
}
if ($groupby) {
$groupby = 'GROUP BY ' . $groupby;
}
if ($orderby) {
$orderby = "ORDER BY {$orderby}";
}
$this->request = "SELECT {$fields} FROM {$hqdb->comments} {$join} {$where} {$groupby} {$orderby} {$limits}";
if ($this->query_vars['count']) {
return $hqdb->get_var($this->request);
}
if ('ids' == $this->query_vars['fields']) {
$this->comments = $hqdb->get_col($this->request);
return array_map('intval', $this->comments);
}
$results = $hqdb->get_results($this->request);
/**
* Filter the comment query results.
*
* @since 0.0.1
*
* @param array $results An array of comments.
* @param HQ_Comment_Query &$this Current instance of HQ_Comment_Query, passed by reference.
*/
$comments = apply_filters_ref_array('the_comments', array($results, &$this));
hq_cache_add($cache_key, $comments, 'comment');
if ('*' === $fields) {
update_comment_cache($comments);
}
$this->comments = $comments;
return $this->comments;
}
开发者ID:gcorral,项目名称:hivequeen,代码行数:101,代码来源:comment.php
示例7: comments_template
/**
* 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 'comments_array' filter hook with the list of comments
* and the post ID respectively.
*
* The $file path is passed through a filter hook called, 'comments_template'
* which includes the TEMPLATEPATH and $file combined. Tries the $filtered path
* first and if it fails it will require the default comment themplate 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.
*
* @since 1.5.0
* @global array $comment List of comment objects for the current post
* @uses $wpdb
* @uses $id
* @uses $post
* @uses $withcomments Will not try to get the comments if the post has none.
*
* @param string $file Optional, default '/comments.php'. The file to load
* @param bool $separate_comments Optional, whether to separate the comments by comment type. Default is false.
* @return null Returns null if no comments appear
*/
function comments_template($file = '/comments.php', $separate_comments = false)
{
global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity, $overridden_cpage;
if (!(is_single() || is_page() || $withcomments)) {
return;
}
if (empty($file)) {
$file = '/comments.php';
}
$req = get_option('require_name_email');
/**
* Comment author information fetched from the comment cookies.
*
* @uses wp_get_current_commenter()
*/
$commenter = wp_get_current_commenter();
/**
* The name of the current comment author escaped for use in attributes.
*/
$comment_author = $commenter['comment_author'];
// Escaped by sanitize_comment_cookies()
/**
* The email address of the current comment author escaped for use in attributes.
*/
$comment_author_email = $commenter['comment_author_email'];
// Escaped by sanitize_comment_cookies()
/**
* The url of the current comment author escaped for use in attributes.
*/
$comment_author_url = esc_url($commenter['comment_author_url']);
/** @todo Use API instead of SELECTs. */
if ($user_ID) {
$comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->comments} WHERE comment_post_ID = %d AND (comment_approved = '1' OR ( user_id = %d AND comment_approved = '0' ) ) ORDER BY comment_date_gmt", $post->ID, $user_ID));
} else {
if (empty($comment_author)) {
$comments = get_comments(array('post_id' => $post->ID, 'status' => 'approve', 'order' => 'ASC'));
} else {
$comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->comments} WHERE comment_post_ID = %d AND ( comment_approved = '1' OR ( comment_author = %s AND comment_author_email = %s AND comment_approved = '0' ) ) ORDER BY comment_date_gmt", $post->ID, wp_specialchars_decode($comment_author, ENT_QUOTES), $comment_author_email));
}
}
// keep $comments for legacy's sake
$wp_query->comments = apply_filters('comments_array', $comments, $post->ID);
$comments =& $wp_query->comments;
$wp_query->comment_count = count($wp_query->comments);
update_comment_cache($wp_query->comments);
if ($separate_comments) {
$wp_query->comments_by_type =& separate_comments($comments);
$comments_by_type =& $wp_query->comments_by_type;
}
$overridden_cpage = FALSE;
if ('' == get_query_var('cpage') && get_option('page_comments')) {
set_query_var('cpage', 'newest' == get_option('default_comments_page') ? get_comment_pages_count() : 1);
$overridden_cpage = TRUE;
}
if (!defined('COMMENTS_TEMPLATE') || !COMMENTS_TEMPLATE) {
define('COMMENTS_TEMPLATE', true);
}
$include = apply_filters('comments_template', STYLESHEETPATH . $file);
if (file_exists($include)) {
require $include;
} elseif (file_exists(TEMPLATEPATH . $file)) {
require TEMPLATEPATH . $file;
} else {
require get_theme_root() . '/default/comments.php';
}
}
开发者ID:klr2003,项目名称:sourceread,代码行数:93,代码来源:comment-template.php
示例8: _wap_get_comment_list
function _wap_get_comment_list($s = false, $start, $num, $view_all = false)
{
global $wpdb;
$start = abs((int) $start);
$num = (int) $num;
if ($view_all) {
$comments = $wpdb->get_results("SELECT SQL_CALC_FOUND_ROWS * FROM {$wpdb->comments} WHERE comment_approved = '0' OR comment_approved = '1' ORDER BY comment_date DESC LIMIT {$start}, {$num}");
} else {
$comments = $wpdb->get_results("SELECT SQL_CALC_FOUND_ROWS * FROM {$wpdb->comments} WHERE comment_approved = '0' ORDER BY comment_date DESC LIMIT {$start}, {$num}");
}
update_comment_cache($comments);
$total = $wpdb->get_var("SELECT FOUND_ROWS()");
return array($comments, $total);
}
开发者ID:rfyiamcool,项目名称:solrex,代码行数:14,代码来源:functions.php
示例9: comments_template
/**
* Load 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 'comments_array' filter hook with the list of comments
* and the post ID respectively.
*
* The $file path is passed through a filter hook called, 'comments_template'
* which includes the TEMPLATEPATH 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.
*
* @todo Document globals
* @uses $withcomments Will not try to get the comments if the post has none.
*
* @since 1.5.0
*
* @param string $file Optional. The file to load. Default '/comments.php'.
* @param bool $separate_comments Optional. Whether to separate the comments by comment type. Default false.
* @return null Returns null if no comments appear.
*/
function comments_template($file = '/comments.php', $separate_comments = false)
{
global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity, $overridden_cpage;
if (!(is_single() || is_page() || $withcomments) || empty($post)) {
return;
}
if (empty($file)) {
$file = '/comments.php';
}
$req = get_option('require_name_email');
/**
* Comment author information fetched from the comment cookies.
*
* @uses wp_get_current_commenter()
*/
$commenter = wp_get_current_commenter();
/**
* The name of the current comment author escaped for use in attributes.
*/
$comment_author = $commenter['comment_author'];
// Escaped by sanitize_comment_cookies()
/**
* The email address of the current comment author escaped for use in attributes.
*/
$comment_author_email = $commenter['comment_author_email'];
// Escaped by sanitize_comment_cookies()
/**
* The url of the current comment author escaped for use in attributes.
*/
$comment_author_url = esc_url($commenter['comment_author_url']);
/** @todo Use API instead of SELECTs. */
if ($user_ID) {
$comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->comments} WHERE comment_post_ID = %d AND (comment_approved = '1' OR ( user_id = %d AND comment_approved = '0' ) ) ORDER BY comment_date_gmt", $post->ID, $user_ID));
} else {
if (empty($comment_author)) {
$comments = get_comments(array('post_id' => $post->ID, 'status' => 'approve', 'order' => 'ASC'));
} else {
$comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->comments} WHERE comment_post_ID = %d AND ( comment_approved = '1' OR ( comment_author = %s AND comment_author_email = %s AND comment_approved = '0' ) ) ORDER BY comment_date_gmt", $post->ID, wp_specialchars_decode($comment_author, ENT_QUOTES), $comment_author_email));
}
}
// keep $comments for legacy's sake
/**
* Filter the comments array.
*
* @since 2.1.0
*
* @param array $comments The array of comments supplied to the comments template.
* @param int $post->ID The post ID.
*/
$wp_query->comments = apply_filters('comments_array', $comments, $post->ID);
$comments =& $wp_query->comments;
$wp_query->comment_count = count($wp_query->comments);
update_comment_cache($wp_query->comments);
if ($separate_comments) {
$wp_query->comments_by_type = separate_comments($comments);
$comments_by_type =& $wp_query->comments_by_type;
}
$overridden_cpage = false;
if ('' == get_query_var('cpage') && get_option('page_comments')) {
set_query_var('cpage', 'newest' == get_option('default_comments_page') ? get_comment_pages_count() : 1);
$overridden_cpage = true;
}
if (!defined('COMMENTS_TEMPLATE')) {
define('COMMENTS_TEMPLATE', true);
}
$theme_template = STYLESHEETPATH . $file;
/**
* Filter the path to the theme template file used for the comments template.
*
* @since 1.5.2
*
* @param string $theme_template The path to the theme template file.
*/
$include = apply_filters('comments_template', $theme_template);
if (file_exists($include)) {
//.........这里部分代码省略.........
开发者ID:palimadra,项目名称:bubblegraphics-wpsite,代码行数:101,代码来源:comment-template.php
示例10: _wp_get_comment_list
/**
* {@internal Missing Short Description}}
*
* @since unknown
*
* @param unknown_type $status
* @param unknown_type $s
* @param unknown_type $start
* @param unknown_type $num
* @param unknown_type $post
* @param unknown_type $type
* @return unknown
*/
function _wp_get_comment_list( $status = '', $s = false, $start, $num, $post = 0, $type = '' ) {
global $wpdb;
$start = abs( (int) $start );
$num = (int) $num;
$post = (int) $post;
$count = wp_count_comments();
$index = '';
if ( 'moderated' == $status ) {
$approved = "comment_approved = '0'";
$total = $count->moderated;
} elseif ( 'approved' == $status ) {
$approved = "comment_approved = '1'";
$total = $count->approved;
} elseif ( 'spam' == $status ) {
$approved = "comment_approved = 'spam'";
$total = $count->spam;
} else {
$approved = "( comment_approved = '0' OR comment_approved = '1' )";
$total = $count->moderated + $count->approved;
$index = 'USE INDEX (comment_date_gmt)';
}
if ( $post ) {
$total = '';
$post = " AND comment_post_ID = '$post'";
$orderby = "ORDER BY comment_date_gmt ASC LIMIT $start, $num";
} else {
$post = '';
$orderby = "ORDER BY comment_date_gmt DESC LIMIT $start, $num";
}
if ( 'comment' == $type )
$typesql = "AND comment_type = ''";
elseif ( 'pingback' == $type )
$typesql = "AND comment_type = 'pingback'";
elseif ( 'trackback' == $type )
$typesql = "AND comment_type = 'trackback'";
elseif ( 'pings' == $type )
$typesql = "AND ( comment_type = 'pingback' OR comment_type = 'trackback' )";
else
$typesql = '';
if ( !empty($type) )
$total = '';
if ( $s ) {
$total = '';
$s = $wpdb->escape($s);
$query = "FROM $wpdb->comments WHERE
(comment_author LIKE '%$s%' OR
comment_author_email LIKE '%$s%' OR
comment_author_url LIKE ('%$s%') OR
comment_author_IP LIKE ('%$s%') OR
comment_content LIKE ('%$s%') ) AND
$approved
$typesql";
} else {
$query = "FROM $wpdb->comments $index WHERE $approved $post $typesql";
}
$comments = $wpdb->get_results("SELECT * $query $orderby");
if ( '' === $total )
$total = $wpdb->get_var("SELECT COUNT(comment_ID) $query");
update_comment_cache($comments);
return array($comments, $total);
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:83,代码来源:template.php
示例11: edit_comments
/**
* LazyestCommentor::edit_comments()
*
* @param mixed $filevar
* @return void
*/
function edit_comments($filevar)
{
global $lg_gallery;
switch ($this->comments_from) {
case 'folder':
$folder = new LazyestFolder($filevar);
$folder->open();
$comments = $this->get_comments($folder->id);
$caption = $folder->caption;
break;
case 'image':
$folder = new LazyestFolder(dirname($filevar));
$folder->load('images');
$image = $folder->single_image(basename($filevar));
$comments = $this->get_comments($image->id);
$caption = $image->caption;
break;
case 'gallery':
$comments = $this->get_root_comments();
$page_id = $lg_gallery->get_option('gallery_id');
$gallery_page = get_post($page_id);
$caption = $gallery_page->post_title;
break;
case 'all':
default:
$page_id = (int) $lg_gallery->get_option('gallery_id');
$comments = $this->get_approved_comments($page_id);
$gallery_page = get_post($page_id);
$caption = $gallery_page->post_title;
break;
}
$do_pagination = false;
if ($comments) {
update_comment_cache($comments);
$comments = array_reverse($comments);
$comments_table = new LazyestCommentsTable($comments);
$perpage = 20;
$total_pages = ceil(count($comments) / $perpage);
$query_var = 'lg_paged';
if (isset($paged)) {
$current = $paged;
} else {
$current = isset($_REQUEST[$query_var]) ? absint($_REQUEST[$query_var]) : 0;
$current = min(max(1, $current), $total_pages);
}
$start = ($current - 1) * $perpage + 1;
$end = min(count($comments), $current * $perpage);
$do_pagination = 1 < $total_pages;
if ($do_pagination) {
$pagination = $lg_gallery->pagination('comments', $comments);
?>
<div class="tablenav"><?php
echo $pagination;
?>
</div>
<?php
}
?>
<br class="clear" />
<?php
$comments_table->display();
?>
<?php
}
if ($do_pagination) {
?>
<div class="tablenav"><?php
echo $pagination;
?>
</div>
<?php
}
if (isset($folder)) {
unset($folder);
}
unset($comments_table);
}
开发者ID:slavam,项目名称:adult-childhood,代码行数:87,代码来源:comments.php
示例12: bbl_comments_template
/**
* Replicates the core comments_template function, but uses the API
* to fetch the comments and includes more filters.
*
* 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 'comments_array' filter hook with the list of comments
* and the post ID respectively.
*
* The $file path is passed through a filter hook called, 'comments_template'
* which includes the TEMPLATEPATH 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.
*
* @since 1.5.0
* @global array $comment List of comment objects for the current post
* @uses $wpdb
* @uses $post
* @uses $withcomments Will not try to get the comments if the post has none.
*
* @see comments_template()
*
* @param string $file Optional, default '/comments.php'. The file to load
* @param bool $separate_comments Optional, whether to separate the comments by comment type. Default is false.
* @return null Returns null if no comments appear
*/
function bbl_comments_template($file = '/comments.php', $separate_comments = false)
{
global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity, $overridden_cpage;
if (!(is_single() || is_page() || $withcomments) || empty($post)) {
return;
}
if (empty($file)) {
$file = '/comments.php';
}
$req = get_option('require_name_email');
/**
* Comment author information fetched from the comment cookies.
*
* @uses wp_get_current_commenter()
*/
$commenter = wp_get_current_commenter();
/**
* The name of the current comment author escaped for use in attributes.
*/
$comment_author = $commenter['comment_author'];
// Escaped by sanitize_comment_cookies()
/**
* The email address of the current comment author escaped for use in attributes.
*/
$comment_author_email = $commenter['comment_author_email'];
// Escaped by sanitize_comment_cookies()
/**
* The url of the current comment author escaped for use in attributes.
*/
$comment_author_url = esc_url($commenter['comment_author_url']);
$query = new Bbl_Comment_Query();
$args = array('order' => 'ASC', 'post_id' => $post->ID, 'status' => 'approve', 'status' => 'approve');
if ($user_ID) {
$args['unapproved_user_id'] = $user_ID;
} else {
if (!empty($comment_author)) {
$args['unapproved_author'] = wp_specialchars_decode($comment_author, ENT_QUOTES);
$args['unapproved_author_email'] = $comment_author_email;
}
}
$args = apply_filters('comments_template_args', $args);
$comments = $query->query($args);
// keep $comments for legacy's sake
$wp_query->comments = apply_filters('comments_array', $comments, $post->ID);
$comments =& $wp_query->comments;
$wp_query->comment_count = count($wp_query->comments);
update_comment_cache($wp_query->comments);
if ($separate_comments) {
$wp_query->comments_by_type =& separate_comments($comments);
$comments_by_type =& $wp_query->comments_by_type;
}
$overridden_cpage = FALSE;
if ('' == get_query_var('cpage') && get_option('page_comments')) {
set_query_var('cpage', 'newest' == get_option('default_comments_page') ? get_comment_pages_count() : 1);
$overridden_cpage = TRUE;
}
if (!defined('COMMENTS_TEMPLATE') || !COMMENTS_TEMPLATE) {
define('COMMENTS_TEMPLATE', true);
}
$include = apply_filters('comments_template', trailingslashit(get_stylesheet_directory()) . sanitize_file_name($file));
if (file_exists($include)) {
require $include;
} elseif (file_exists(trailingslashit(get_template_directory()) . sanitize_file_name($file))) {
require trailingslashit(get_template_directory()) . sanitize_file_name($file);
} else {
// Backward compat code will be removed in a future release
require ABSPATH . WPINC . '/theme-compat/comments.php';
}
}
开发者ID:gopinathshiva,项目名称:wordpress-vip-plugins,代码行数:100,代码来源:miscellaneous.php
示例13: prepare_items
function prepare_items()
{
global $post_id, $comment_status, $search;
$post_id = isset($_REQUEST['p']) ? absint($_REQUEST['p']) : 0;
$comment_status = isset($_REQUEST['comment_status']) ? $_REQUEST['comment_status'] : 'all';
if (!in_array($comment_status, array('all', 'moderated', 'approved', 'spam', 'trash'))) {
$comment_status = 'all';
}
$comment_type = !empty($_REQUEST['comment_type']) ? $_REQUEST['comment_type'] : '';
$search = isset($_REQUEST['s']) ? $_REQUEST['s'] : '';
if (isset($_POST['per_page'])) {
$comments_per_page = $_POST['per_page'];
} else {
$comments_per_page = (int) get_user_option('edit_comments_per_page');
}
if (empty($comments_per_page) || $comments_per_page < 1) {
$comments_per_page = 20;
}
$comments_per_page = apply_filters('comments_per_page', $comments_per_page, $comment_status);
if (isset($_POST['number'])) {
$number = (int) $_POST['number'];
} else {
$number = $comments_per_page + min(8, $comments_per_page);
}
// Grab a few extra
$page = $this->get_pagenum();
$start = $offset = ($page - 1) * $comments_per_page;
$args = array('status' => 'moderated' == $comment_status ? 'hold' : $comment_status, 'search' => $search, 'offset' => $start, 'number' => $number, 'post_id' => $post_id, 'type' => $comment_type, 'orderby' => @$_REQUEST['orderby'], 'order' => @$_REQUEST['order']);
$_comments = get_comments($args);
update_comment_cache($_comments);
$this->items = array_slice($_comments, 0, $comments_per_page);
$this->extra_items = array_slice($_comments, $comments_per_page);
$total_comments = get_comments(array_merge($args, array('count' => true, 'offset' => 0, 'number' => 0)));
$_comment_post_ids = array();
foreach ($_comments as $_c) {
$_comment_post_ids[] = $_c->comment_post_ID;
}
$_comment_pending_count = get_pending_comments_num($_comment_post_ids);
$this->set_pagination_args(array('total_items' => $total_comments, 'per_page' => $comments_per_page));
}
开发者ID:junxuan,项目名称:wordpress,代码行数:40,代码来源:default-list-tables.php
示例14: _wp_get_comment_list
function _wp_get_comment_list($s = false, $start, $num)
{
global $wpdb;
$start = abs((int) $start);
$num = (int) $num;
if ($s) {
$s = $wpdb->escape($s);
$comments = $wpdb->get_results("SELECT SQL_CALC_FOUND_ROWS * FROM {$wpdb->comments} WHERE\n\t\t\t(comment_author LIKE '%{$s}%' OR\n\t\t\tcomment_author_email LIKE '%{$s}%' OR\n\t\t\tcomment_author_url LIKE ('%{$s}%') OR\n\t\t\tcomment_author_IP LIKE ('%{$s}%') OR\n\t\t\tcomment_content LIKE ('%{$s}%') ) AND\n\t\t\tcomment_approved != 'spam'\n\t\t\tORDER BY comment_date DESC LIMIT {$start}, {$num}");
} else {
$comments = $wpdb->get_results("SELECT SQL_CALC_FOUND_ROWS * FROM {$wpdb->comments} WHERE comment_approved = '0' OR comment_approved = '1' ORDER BY comment_date DESC LIMIT {$start}, {$num}");
}
update_comment_cache($comments);
$total = $wpdb->get_var("SELECT FOUND_ROWS()");
return array($comments, $total);
}
开发者ID:64kbytes,项目名称:stayinba,代码行数:15,代码来源:template.php
示例15: comments_template
//.........这里部分代码省略.........
* @param bool $separate_comments Optional, whether to separate the comments by comment type. Default is false.
* @return null Returns null if no comments appear
*/
function comments_template($file = '/comments.php', $separate_comments = false)
{
global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity, $overridden_cpage;
if (!(is_single() || is_page() || $withcomments) || empty($post)) {
return;
}
if (empty($file)) {
$file = '/comments.php';
}
$req = get_option('require_name_email');
/**
* Comment author information fetched from the comment cookies.
*
* @uses wp_get_current_commenter()
*/
$commenter = wp_get_current_commenter();
/**
* The name of the current comment author escaped for use in attributes.
*/
$comment_author = $commenter['comment_author'];
// Escaped by sanitize_comment_cookies()
/**
* The email address of the current comment author escaped for use in attributes.
*/
$comment_author_email = $commenter['comment_author_email'];
// Escaped by sanitize_comment_cookies()
/**
* The url of the current comment author escaped for use in attributes.
*/
$comment_author_url = esc_url($commenter['comment_author_url']);
/** @todo Use API instead of SELECTs. */
#echo "HERE!! - UID: $user_ID ";
if ($user_ID or $user_ID == 0) {
// show only one language if logged in (ToDo: allow selection of languages instead)
// or if not logged in (important for search engine localization
#echo "DONE!";
// comment_id FROM $wpdb->comment
|
请发表评论