本文整理汇总了PHP中WP_Comment_Query类的典型用法代码示例。如果您正苦于以下问题:PHP WP_Comment_Query类的具体用法?PHP WP_Comment_Query怎么用?PHP WP_Comment_Query使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WP_Comment_Query类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: enp_popular_comments_save
function enp_popular_comments_save($btn_slug, $post_types, $args)
{
// all comments by btn slug (combines pages, posts, etc. anywhere the button is shown)
$comment_args = array('fields' => 'ids', 'status' => 'approve', 'number' => 20);
$args = array_merge($comment_args, $args);
$comments_query = new WP_Comment_Query();
$comments = $comments_query->query($args);
$popular_comments = enp_build_popular_array($btn_slug, $comments, 'comment');
update_option('enp_button_popular_' . $btn_slug . '_comments', $popular_comments);
// Loop through all the passed post_types and
// save all comments by post type
// ex: enp_button_popular_respect_page_comments
foreach ($post_types as $key => $value) {
// check if the button type is active
if ($value === '1' && $key !== 'comment') {
// build the arguments
$post_type_args = array('post_type' => $key);
$post_type_args = array_merge($args, $post_type_args);
// generate the query
$comments_query = new WP_Comment_Query();
$comments = $comments_query->query($post_type_args);
// build the array of popular ids and counts
$popular_comments = enp_build_popular_array($btn_slug, $comments, 'comment');
// save the array
update_option('enp_button_popular_' . $btn_slug . '_' . $key . '_comments', $popular_comments);
}
}
}
示例2: get_items
/**
* Get a list of comments.
*
* @param WP_REST_Request $request Full details about the request.
* @return WP_Error|WP_REST_Response
*/
public function get_items($request)
{
$prepared_args = array('comment__in' => $request['include'], 'comment__not_in' => $request['exclude'], 'number' => $request['per_page'], 'post_id' => $request['post'] ? $request['post'] : '', 'parent' => isset($request['parent']) ? $request['parent'] : '', 'search' => $request['search'], 'offset' => $request['offset'], 'orderby' => $this->normalize_query_param($request['orderby']), 'order' => $request['order'], 'status' => 'approve', 'type' => 'comment', 'no_found_rows' => false);
if (empty($request['offset'])) {
$prepared_args['offset'] = $prepared_args['number'] * (absint($request['page']) - 1);
}
if (current_user_can('edit_posts')) {
$protected_args = array('user_id' => $request['author'] ? $request['author'] : '', 'status' => $request['status'], 'type' => isset($request['type']) ? $request['type'] : '', 'author_email' => isset($request['author_email']) ? $request['author_email'] : '', 'karma' => isset($request['karma']) ? $request['karma'] : '', 'post_author' => isset($request['post_author']) ? $request['post_author'] : '', 'post_name' => isset($request['post_slug']) ? $request['post_slug'] : '', 'post_parent' => isset($request['post_parent']) ? $request['post_parent'] : '', 'post_status' => isset($request['post_status']) ? $request['post_status'] : '', 'post_type' => isset($request['post_type']) ? $request['post_type'] : '');
$prepared_args = array_merge($prepared_args, $protected_args);
}
/**
* Filter arguments, before passing to WP_Comment_Query, when querying comments via the REST API.
*
* @see https://developer.wordpress.org/reference/classes/wp_comment_query/
*
* @param array $prepared_args Array of arguments for WP_Comment_Query.
* @param WP_REST_Request $request The current request.
*/
$prepared_args = apply_filters('rest_comment_query', $prepared_args, $request);
$query = new WP_Comment_Query();
$query_result = $query->query($prepared_args);
$comments = array();
foreach ($query_result as $comment) {
$post = get_post($comment->comment_post_ID);
if (!$this->check_read_post_permission($post) || !$this->check_read_permission($comment)) {
continue;
}
$data = $this->prepare_item_for_response($comment, $request);
$comments[] = $this->prepare_response_for_collection($data);
}
$total_comments = (int) $query->found_comments;
$max_pages = (int) $query->max_num_pages;
if ($total_comments < 1) {
// Out-of-bounds, run the query again without LIMIT for total count
unset($prepared_args['number']);
unset($prepared_args['offset']);
$query = new WP_Comment_Query();
$prepared_args['count'] = true;
$total_comments = $query->query($prepared_args);
$max_pages = ceil($total_comments / $request['per_page']);
}
$response = rest_ensure_response($comments);
$response->header('X-WP-Total', $total_comments);
$response->header('X-WP-TotalPages', $max_pages);
$base = add_query_arg($request->get_query_params(), rest_url('/wp/v2/comments'));
if ($request['page'] > 1) {
$prev_page = $request['page'] - 1;
if ($prev_page > $max_pages) {
$prev_page = $max_pages;
}
$prev_link = add_query_arg('page', $prev_page, $base);
$response->link_header('prev', $prev_link);
}
if ($max_pages > $request['page']) {
$next_page = $request['page'] + 1;
$next_link = add_query_arg('page', $next_page, $base);
$response->link_header('next', $next_link);
}
return $response;
}
示例3: cases_display_todo_comments
function cases_display_todo_comments()
{
if (!is_singular('cases')) {
return;
}
if (!shortcode_exists('cp_todo_comments')) {
return;
}
global $post;
$args = array('post_id' => $post->ID, 'meta_query' => array(array('key' => 'cp_control', 'value' => 'yes')), 'meta_key' => 'cp_control_order', 'orderby' => 'meta_value_num', 'order' => 'ASC');
$comments_query = new WP_Comment_Query();
$comments = $comments_query->query($args);
if (empty($comments)) {
return;
}
?>
<section id="case_todo_comments_wrapper" class="cases-box">
<header class="cases-box-header">
<h1>Комментарии на контроле</h1>
<hr>
</header>
<article class="cases-box-content">
<?php
echo do_shortcode('[cp_todo_comments]');
?>
</article>
</section>
<?php
}
示例4: get_items
/**
* Get a list of reactions.
*
* @param WP_REST_Request $request Full details about the request.
* @return WP_Error|WP_REST_Response
*/
public function get_items($request)
{
$prepared_args = array('post__in' => $request['post'], 'type' => 'reaction');
/**
* Filter arguments, before passing to WP_Comment_Query, when querying reactions via the REST API.
*
* @see https://developer.wordpress.org/reference/classes/wp_comment_query/
*
* @param array $prepared_args Array of arguments for WP_Comment_Query.
* @param WP_REST_Request $request The current request.
*/
$prepared_args = apply_filters('rest_reaction_query', $prepared_args, $request);
$query = new WP_Comment_Query();
$query_result = $query->query($prepared_args);
$reactions_count = array();
foreach ($query_result as $reaction) {
if (empty($reactions_count[$reaction->comment_content])) {
$reactions_count[$reaction->comment_content] = array('count' => 0, 'post_id' => $reaction->comment_post_ID);
}
$reactions_count[$reaction->comment_content]++;
}
$reactions = array();
foreach ($reactions_count as $emoji => $data) {
$reaction = array('emoji' => $emoji, 'count' => $data['count'], 'post_id' => $data['post_id']);
$data = $this->prepare_item_for_response($reaction, $request);
$reactions[] = $this->prepare_response_for_collection($data);
}
$total_reactions = (int) $query->found_comments;
$reaction_groups = count($reactions);
$response = rest_ensure_response($reactions);
$response->header('X-WP-Total', $total_reactions);
$response->header('X-WP-TotalGroups', $reaction_groups);
return $response;
}
示例5: hackgov_get_comments
/**
* Get comment for all post by user
* @param string $user_id [description]
* @return [type] [description]
*/
function hackgov_get_comments($user_id = '')
{
if (empty($user_id)) {
$user_id = get_current_user_id();
}
$args = array('post_author__in' => $user_id, 'post_status' => 'publish');
$comments_query = new WP_Comment_Query();
$comments = $comments_query->query($args);
return $comments;
}
示例6: getTrackingObject
public static function getTrackingObject()
{
$hash = md5(network_site_url() . '-' . $_SERVER['REMOTE_ADDR']);
global $blog_id, $wpdb;
$pts = array();
foreach (get_post_types(array('public' => true)) as $pt) {
$count = wp_count_posts($pt);
$pts[$pt] = $count->publish;
}
$comments_count = wp_count_comments();
$theme_data = wp_get_theme();
$theme = array('version' => $theme_data->Version, 'name' => $theme_data->Name, 'author' => $theme_data->Author, 'template' => $theme_data->Template);
if (!function_exists('get_plugin_data')) {
require_once ABSPATH . 'wp-admin/includes/admin.php';
}
$plugins = array();
foreach (get_option('active_plugins', array()) as $plugin_path) {
$plugin_info = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin_path);
$slug = str_replace('/' . basename($plugin_path), '', $plugin_path);
$plugins[$slug] = array('version' => $plugin_info['Version'], 'name' => $plugin_info['Name'], 'plugin_uri' => $plugin_info['PluginURI'], 'author' => $plugin_info['AuthorName'], 'author_uri' => $plugin_info['AuthorURI']);
}
if (is_multisite()) {
foreach (get_option('active_sitewide_plugins', array()) as $plugin_path) {
$plugin_info = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin_path);
$slug = str_replace('/' . basename($plugin_path), '', $plugin_path);
$plugins[$slug] = array('version' => $plugin_info['Version'], 'name' => $plugin_info['Name'], 'plugin_uri' => $plugin_info['PluginURI'], 'author' => $plugin_info['AuthorName'], 'author_uri' => $plugin_info['AuthorURI']);
}
}
$version = explode('.', PHP_VERSION);
$version = array('major' => $version[0], 'minor' => $version[0] . '.' . $version[1], 'release' => PHP_VERSION);
$user_query = new WP_User_Query(array('blog_id' => $blog_id, 'count_total' => true));
$comments_query = new WP_Comment_Query();
$data = array('_id' => $hash, 'localhost' => $_SERVER['REMOTE_ADDR'] === '127.0.0.1' ? 1 : 0, 'php' => $version, 'site' => array('hash' => $hash, 'version' => get_bloginfo('version'), 'multisite' => is_multisite(), 'users' => $user_query->get_total(), 'lang' => get_locale(), 'wp_debug' => defined('WP_DEBUG') ? WP_DEBUG ? true : false : false, 'memory' => WP_MEMORY_LIMIT), 'pts' => $pts, 'comments' => array('total' => $comments_count->total_comments, 'approved' => $comments_count->approved, 'spam' => $comments_count->spam, 'pings' => $comments_query->query(array('count' => true, 'type' => 'pingback'))), 'options' => apply_filters('redux/tracking/options', array()), 'theme' => $theme, 'redux' => array('mode' => ReduxFramework::$_is_plugin ? 'plugin' : 'theme', 'version' => ReduxFramework::$_version, 'demo_mode' => get_option('ReduxFrameworkPlugin')), 'developer' => apply_filters('redux/tracking/developer', array()), 'plugins' => $plugins);
$parts = explode(' ', $_SERVER['SERVER_SOFTWARE']);
$software = array();
foreach ($parts as $part) {
if ($part[0] == "(") {
continue;
}
if (strpos($part, '/') !== false) {
$chunk = explode("/", $part);
$software[strtolower($chunk[0])] = $chunk[1];
}
}
$software['full'] = $_SERVER['SERVER_SOFTWARE'];
$data['environment'] = $software;
if (function_exists('mysql_get_server_info')) {
$data['environment']['mysql'] = mysql_get_server_info();
}
if (empty($data['developer'])) {
unset($data['developer']);
}
return $data;
}
示例7: widget
/** @see WP_Widget::widget -- do not rename this */
function widget($args, $instance)
{
extract($args);
//Our variables from the widget settings.
$title = apply_filters('widget_title', $instance['title']);
$width = $instance['width'];
$number = $instance['number'];
echo '<div class="' . $width . '">
<div class="dash-widget">' . $before_widget;
// Display the widget title
if ($title) {
echo $before_title . $title . $after_title;
}
$unit_comments = vibe_get_option('unit_comments');
if (isset($unit_comments) && is_numeric($unit_comments)) {
$link = get_permalink($unit_comments);
} else {
$link = '#';
}
echo '<div id="vibe-tabs-notes_discussion" class="tabs tabbable">
<a href="' . $link . '" class="view_all_notes">' . __('SEE ALL', 'wplms-dashboard') . '</a>
<ul class="nav nav-tabs clearfix">
<li><a href="#tab-notes" data-toggle="tab">' . __('My Notes', 'wplms-dashboard') . '</a></li>
<li><a href="#tab-discussion" data-toggle="tab">' . __('My Discussions', 'wplms-dashboard') . '</a></li>
</ul><div class="tab-content">';
echo '<div id="tab-notes" class="tab-pane">';
$user_id = get_current_user_id();
$args = apply_filters('wplms_notes_dicussion_dashboard_args', array('number' => $number, 'post_status' => 'publish', 'post_type' => 'unit', 'status' => 'approve', 'type' => 'note', 'user_id' => $user_id));
echo '<div id="notes_query">' . json_encode($args) . '</div>
<div id="notes_discussions">';
$comments_query = new WP_Comment_Query();
$comments = $comments_query->query($args);
// Comment Loop
$vibe_notes_discussions = new vibe_notes_discussions();
$vibe_notes_discussions->comments_loop($comments);
echo '</div></div>';
echo '<div id="tab-discussion" class="tab-pane">';
$args = apply_filters('wplms_notes_dicussion_dashboard_args', array('number' => $number, 'post_status' => 'publish', 'post_type' => 'unit', 'status' => 'approve', 'type' => 'public', 'user_id' => $user_id));
echo '<div id="notes_query">' . json_encode($args) . '</div>
<div id="notes_discussions">';
$comments_query = new WP_Comment_Query();
$comments = $comments_query->query($args);
// Comment Loop
$vibe_notes_discussions = new vibe_notes_discussions();
$vibe_notes_discussions->comments_loop($comments);
echo '</div></div>';
echo '</div></div>';
echo $after_widget . '
</div>
</div>';
}
示例8: custom_recent_comments
function custom_recent_comments($amount = 5, $avatar_size = 35)
{
$comments_query = new WP_Comment_Query();
$comments = $comments_query->query(array('number' => $amount));
$comm = '';
if ($comments) {
foreach ($comments as $comment) {
$comm .= '<li><div class="recent-avatar">' . get_avatar($comment->comment_author_email, $avatar_size);
$comm .= '</div><div class="recent-text"><p><a class="recent-author" href="' . get_permalink($comment->comment_post_ID) . '#comment-' . $comment->comment_ID . '">';
$comm .= get_comment_author($comment->comment_ID) . '</a> la:<br /> ';
$comm .= '<a href="' . get_permalink($comment->comment_post_ID) . '">' . get_the_title($comment->comment_post_ID) . '</a></p></div></li>';
}
} else {
$comm .= 'No comments.';
}
echo $comm;
}
示例9: find
public function find($args = array(), &$found = null)
{
//add filter for before/after handling, hopefully more complex date querying
//will exist by wp3.7
if (isset($args['before']) || isset($args['after'])) {
add_filter('comments_clauses', array(__CLASS__, '_filter_comments_clauses_handleDateRange'), 10, 2);
}
//setup paging
if (empty($args['per_page'])) {
$number = get_option('comments_per_page');
if ($number < 1) {
$number = \Voce\Thermal\v1\MAX_COMMENTS_PER_PAGE;
}
}
if (isset($args['offset'])) {
$offset = $args['offset'];
} elseif (isset($args['paged'])) {
$offset = (absint($args['paged']) - 1) * $number;
} else {
$offset = 0;
}
//normalize search arg
if (isset($args['s'])) {
$args['search'] = $args['s'];
unset($args['s']);
}
//allow 'in' arg
if (!empty($args['in'])) {
add_filter('comments_clauses', array(__CLASS__, '_filter_comments_clauses_handleInArg'), 10, 2);
}
//status handling
if (empty($args['status'])) {
$args['status'] = 'approve';
}
//make sure count isn't set to true
$args['count'] = false;
$wp_comments = new \WP_Comment_Query();
$comments = $wp_comments->query($args);
if (!empty($args['include_found'])) {
$args['count'] = true;
//@todo - counts don't cache in core
$found = $wp_comments->query($args);
}
return $comments;
}
示例10: init
public function init(&$existing_meta_keys = array())
{
if (!self::$is_active) {
return;
}
global $wp_version;
if (version_compare($wp_version, '4.2.0', '>=')) {
$commentsQuery = new WP_Comment_Query(array('orderby' => 'comment_ID', 'order' => 'ASC', 'number' => 10, 'count' => true));
$comments = $commentsQuery->get_comments();
} else {
$comments = get_comments(array('orderby' => 'comment_ID', 'order' => 'ASC', 'number' => 10, 'count' => true));
}
if (!empty($comments)) {
foreach ($comments as $comment) {
$comment_meta = get_comment_meta($comment->comment_ID, '');
if (!empty($comment_meta)) {
foreach ($comment_meta as $record_meta_key => $record_meta_value) {
if (!in_array($record_meta_key, $existing_meta_keys)) {
$to_add = true;
foreach ($this->default_fields as $default_value) {
if ($record_meta_key == $default_value['name'] || $record_meta_key == $default_value['type']) {
$to_add = false;
break;
}
}
if ($to_add) {
foreach ($this->advanced_fields as $advanced_value) {
if ($record_meta_key == $advanced_value['name'] || $record_meta_key == $advanced_value['type']) {
$to_add = false;
break;
}
}
}
if ($to_add) {
$existing_meta_keys[] = $record_meta_key;
}
}
}
}
}
}
}
示例11: widget
/**
* Outputs the content of the widget.
*
* @param array args The array of form elements
* @param array instance The current instance of the widget
*/
public function widget($args, $instance)
{
$cache = wp_cache_get('featured_comments_widget', 'widget');
if (!is_array($cache)) {
$cache = array();
}
if (!isset($args['widget_id'])) {
$args['widget_id'] = $this->id;
}
if (isset($cache[$args['widget_id']])) {
echo $cache[$args['widget_id']];
return;
}
$title = apply_filters('widget_title', $instance['title']);
$output = '';
if (empty($instance['number']) || $instance['number'] < 1) {
$intance['number'] = 5;
}
$query_args = apply_filters('featured_comments_query', array('number' => $instance['number'], 'status' => 'approve', 'post_status' => 'publish', 'meta_query' => array(array('key' => 'featured', 'value' => '1'))));
$query = new WP_Comment_Query();
$comments = $query->query($query_args);
if ($comments) {
$output = $args['before_widget'];
if ($title) {
$output .= $args['before_title'] . $title . $args['after_title'];
}
$output .= '<ul id="featured-comments">';
if ($comments) {
foreach ((array) $comments as $comment) {
$output .= '<li class="featured-comments">';
$output .= sprintf(_x('%1$s on %2$s', 'widgets'), get_comment_author_link($comment->comment_ID), '<a href="' . esc_url(get_comment_link($comment->comment_ID)) . '">' . get_the_title($comment->comment_post_ID) . '</a>');
$output .= '</li>';
}
}
$output .= '</ul>';
}
$output .= $args['after_widget'];
echo $output;
$cache[$args['widget_id']] = $output;
wp_cache_set('featured_comments_widget', $cache, 'widget');
}
示例12: get_items
/**
* Get a list of comments.
*
* @param WP_REST_Request $request Full details about the request.
* @return WP_Error|WP_REST_Response
*/
public function get_items($request)
{
$prepared_args = $this->prepare_items_query($request);
$query = new WP_Comment_Query();
$query_result = $query->query($prepared_args);
$comments = array();
foreach ($query_result as $comment) {
$post = get_post($comment->comment_post_ID);
if (!$this->check_read_post_permission($post) || !$this->check_read_permission($comment)) {
continue;
}
$data = $this->prepare_item_for_response($comment, $request);
$comments[] = $this->prepare_response_for_collection($data);
}
$response = rest_ensure_response($comments);
unset($prepared_args['number']);
unset($prepared_args['offset']);
$query = new WP_Comment_Query();
$prepared_args['count'] = true;
$total_comments = $query->query($prepared_args);
$response->header('X-WP-Total', (int) $total_comments);
$max_pages = ceil($total_comments / $request['per_page']);
$response->header('X-WP-TotalPages', (int) $max_pages);
$base = add_query_arg($request->get_query_params(), rest_url('/wp/v2/comments'));
if ($request['page'] > 1) {
$prev_page = $request['page'] - 1;
if ($prev_page > $max_pages) {
$prev_page = $max_pages;
}
$prev_link = add_query_arg('page', $prev_page, $base);
$response->link_header('prev', $prev_link);
}
if ($max_pages > $request['page']) {
$next_page = $request['page'] + 1;
$next_link = add_query_arg('page', $next_page, $base);
$response->link_header('next', $next_link);
}
return $response;
}
示例13: 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.
*
* Will not try to get the comments if the post has none.
*
* @since 1.5.0
*
* @global WP_Query $wp_query
* @global WP_Post $post
* @global wpdb $wpdb
* @global int $id
* @global WP_Comment $comment
* @global string $user_login
* @global int $user_ID
* @global string $user_identity
* @global bool $overridden_cpage
* @global bool $withcomments
*
* @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.
*/
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.
*/
$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']);
$comment_args = array('orderby' => 'comment_date_gmt', 'order' => 'ASC', 'status' => 'approve', 'post_id' => $post->ID, 'no_found_rows' => false, 'update_comment_meta_cache' => false);
if (get_option('thread_comments')) {
$comment_args['hierarchical'] = 'threaded';
} else {
$comment_args['hierarchical'] = false;
}
if ($user_ID) {
$comment_args['include_unapproved'] = array($user_ID);
} elseif (!empty($comment_author_email)) {
$comment_args['include_unapproved'] = array($comment_author_email);
}
$per_page = 0;
if (get_option('page_comments')) {
$per_page = (int) get_query_var('comments_per_page');
if (0 === $per_page) {
$per_page = (int) get_option('comments_per_page');
}
$comment_args['number'] = $per_page;
$page = (int) get_query_var('cpage');
if ($page) {
$comment_args['offset'] = ($page - 1) * $per_page;
} elseif ('oldest' === get_option('default_comments_page')) {
$comment_args['offset'] = 0;
} else {
// If fetching the first page of 'newest', we need a top-level comment count.
$top_level_query = new WP_Comment_Query();
$top_level_args = array('count' => true, 'orderby' => false, 'post_id' => $post->ID, 'status' => 'approve');
if ($comment_args['hierarchical']) {
$top_level_args['parent'] = 0;
}
if (isset($comment_args['include_unapproved'])) {
$top_level_args['include_unapproved'] = $comment_args['include_unapproved'];
}
$top_level_count = $top_level_query->query($top_level_args);
$comment_args['offset'] = (ceil($top_level_count / $per_page) - 1) * $per_page;
}
}
//.........这里部分代码省略.........
示例14: ajax_wpt_widget_content
//.........这里部分代码省略.........
</li>
<?php
}
wp_reset_query();
?>
</ul>
<div class="clear"></div>
<?php
if ($allow_pagination) {
?>
<?php
$this->tab_pagination($page, $last_page);
?>
<?php
}
?>
<?php
break;
/* ---------- Latest Comments ---------- */
/* ---------- Latest Comments ---------- */
case "comments":
?>
<ul>
<?php
$no_comments = false;
$avatar_size = 65;
$comment_length = 90;
// max length for comments
$comments_total = new WP_Comment_Query();
$comments_total_number = $comments_total->query(array('count' => 1));
$last_page = ceil($comments_total_number / $comment_num);
$comments_query = new WP_Comment_Query();
$offset = ($page - 1) * $comment_num;
$comments = $comments_query->query(array('number' => $comment_num, 'offset' => $offset, 'status' => 'approve'));
if ($comments) {
foreach ($comments as $comment) {
?>
<li>
<?php
if ($show_avatar) {
?>
<div class="wpt_avatar">
<a href="<?php
echo get_comment_link($comment->comment_ID);
?>
">
<?php
echo get_avatar($comment->comment_author_email, $avatar_size);
?>
</a>
</div>
<?php
}
?>
<div class="wpt_comment_meta">
<a href="<?php
echo get_comment_link($comment->comment_ID);
示例15: independent_publisher_pings
/**
* Creates a custom query for pingbacks/trackbacks (i.e., 'pings')
* and displays them. Using this custom query instead of
* wp_list_comments() allows us to always show all pings,
* even when we're showing paginated comments.
*
* @since Independent Publisher 1.0
*/
function independent_publisher_pings()
{
$args = array('post_id' => get_the_ID(), 'type' => 'pings');
$pings_query = new WP_Comment_Query();
$pings = $pings_query->query($args);
if ($pings) {
foreach ($pings as $ping) {
?>
<li <?php
comment_class('', $ping->comment_ID);
?>
id="li-comment-<?php
echo $ping->comment_ID;
?>
">
<?php
printf('<cite class="fn">%s</cite>', get_comment_author_link($ping->comment_ID));
?>
<span> <?php
edit_comment_link(__('(Edit)', 'independent-publisher'), ' ', '');
?>
</span>
</li>
<?php
}
}
}