本文整理汇总了PHP中separate_comments函数的典型用法代码示例。如果您正苦于以下问题:PHP separate_comments函数的具体用法?PHP separate_comments怎么用?PHP separate_comments使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了separate_comments函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: comments_evolved_get_wordpress_count
function comments_evolved_get_wordpress_count()
{
global $post, $comments, $wp_query, $comments_by_type, $id;
$get_comments = get_comments('post_id=' . $id);
$comments_by_type =& separate_comments($get_comments);
return count($comments_by_type['comment']);
}
示例2: comment_count
function comment_count($count)
{
global $id;
$get_comments = get_comments('post_id=' . $id);
$comments_by_type =& separate_comments($get_comments);
return count($comments_by_type['comment']);
}
示例3: miss_comment_tab
/**
*
*/
function miss_comment_tab()
{
global $post;
$get_comments = get_comments('post_id=' . $post->ID);
$separate_comments = separate_comments($get_comments);
$comments_by_type =& $separate_comments;
?>
<div class="blog_tabs_container">
<ul class="blog_tabs">
<li><a href="#" class="current"><?php
printf(_n('%1$s Comment', '%1$s Comments', count($comments_by_type['comment']), MISS_TEXTDOMAIN), number_format_i18n(count($comments_by_type['comment'])));
?>
</a></li>
<li><a href="#" class=""><?php
printf(_n('%1$s Trackback', '%1$s Trackback', count($comments_by_type['pings']), MISS_TEXTDOMAIN), number_format_i18n(count($comments_by_type['pings'])));
?>
</a></li>
<div class="clearboth"></div>
</ul><!-- .blog_tabs -->
<div class="blog_tabs_content">
<ol class="commentlist">
<?php
wp_list_comments(array('type' => 'comment', 'callback' => 'miss_comments_callback'));
?>
</ol>
<?php
if (get_option('page_comments')) {
?>
<div class="comment-navigation paged-navigation">
<?php
paginate_comments_links(miss_portfolio_comment_url($nav = true));
?>
</div><!-- .comment-navigation -->
<?php
}
?>
</div><!-- .blog_tabs_content -->
<div class="blog_tabs_content">
<ol class="commentlist trackbacks_pingbacks">
<!-- <?php
trackback_url();
?>
-->
<?php
wp_list_comments(array('type' => 'pings', 'callback' => 'miss_pings_callback'));
?>
</ol>
</div><!-- .blog_tabs_content -->
</div><!-- .blog_tabs_container -->
<?php
}
示例4: blankslate_comments_number
function blankslate_comments_number($count)
{
if (!is_admin()) {
global $id;
$comments_by_type =& separate_comments(get_comments('status=approve&post_id=' . $id));
return count($comments_by_type['comment']);
} else {
return $count;
}
}
示例5: responsive_comment_count
/**
* Filter 'get_comments_number'
*
* Filter 'get_comments_number' to display correct
* number of comments (count only comments, not
* trackbacks/pingbacks)
*
* Chip Bennett Contribution
*/
function responsive_comment_count($count)
{
if (!is_admin()) {
global $id;
$comments = get_comments('status=approve&post_id=' . $id);
$comments_by_type = separate_comments($comments);
return count($comments_by_type['comment']);
} else {
return $count;
}
}
示例6: comment_count
function comment_count($count)
{
if (!is_admin()) {
global $id;
$get_comments = get_comments('post_id=' . $id);
$comments_by_type =& separate_comments($get_comments);
return count($comments_by_type['comment']);
} else {
return $count;
}
}
示例7: blankslate_comments_number
function blankslate_comments_number($count)
{
if (!is_admin()) {
global $id;
$comments_by_type =& separate_comments(get_comments('status=approve&post_id=' . $id));
return count($comments_by_type['comment']);
} else {
return $count;
}
// Add to the admin_init hook of your theme functions.php file
// Add tag metabox to page
add_meta_box('tagsdiv-post_tag', __('Page Tags'), 'post_tags_meta_box', 'page', 'side', 'low');
register_taxonomy_for_object_type('post_tag', 'page');
// Add category metabox to page
add_meta_box('categorydiv', __('Categories'), 'post_categories_meta_box', 'page', 'side', 'core');
register_taxonomy_for_object_type('category', 'page');
register_taxonomy_for_object_type('post_tag', 'page');
register_taxonomy_for_object_type('category', 'page');
}
示例8: comment_count
function comment_count($commentcount)
{
global $id;
$_comments = get_comments('status=approve&post_id=' . $id);
$comments_by_type =& separate_comments($_comments);
return count($comments_by_type['comment']);
}
示例9: next_comments_link
next_comments_link(__('Newer Comments', APP_TD) . ' »', 0);
?>
</div>
<div class="clr"></div>
</div><!-- /navigation -->
<div class="clr"></div>
<?php
appthemes_before_blog_pings();
?>
<?php
$carray = separate_comments($comments);
// get the comments array to check for pings
?>
<?php
if (!empty($carray['pings'])) {
// pings include pingbacks & trackbacks
?>
<h2 class="dotted" id="pings"><?php
_e('Trackbacks/Pingbacks', APP_TD);
?>
</h2>
<ol class="pinglist">
示例10: thesis_list_comments
/**
* function thesis_list_comments()
*
* List comments — Warning: Here be dragons.
*
* @param string|array $args Formatting options
* @param array $comments Optional array of comment objects. Defaults to $wp_query->comments
* @since 1.5
* @usedby ../../comments.php
* @uses Thesis_Comment
*/
function thesis_list_comments()
{
global $wp_query, $comment_alt, $comment_depth, $comment_thread_alt, $overridden_cpage, $in_comment_loop;
$in_comment_loop = true;
$comment_alt = $comment_thread_alt = 0;
$comment_depth = 1;
$r = array('walker' => null, 'max_depth' => '', 'type' => 'comment', 'page' => '', 'per_page' => '', 'reverse_top_level' => null, 'reverse_children' => '');
// Get our comments.
$wp_query->comments_by_type =& separate_comments($wp_query->comments);
$_comments = $wp_query->comments_by_type['comment'];
// Are we paginating?
if (get_option('page_comments')) {
$r['per_page'] = get_query_var('comments_per_page');
}
if (empty($r['per_page'])) {
$r['per_page'] = 0;
$r['page'] = 0;
}
// How deep does our comments hole go?
if (get_option('thread_comments')) {
$r['max_depth'] = get_option('thread_comments_depth');
} else {
$r['max_depth'] = -1;
}
// Determine page number of comments.
if (empty($overridden_cpage)) {
$r['page'] = get_query_var('cpage');
} else {
$threaded = -1 == $r['max_depth'] ? false : true;
$r['page'] = 'newest' == get_option('default_comments_page') ? get_comment_pages_count($_comments, $r['per_page'], $threaded) : 1;
set_query_var('cpage', $r['page']);
}
// Validate our page number.
$r['page'] = intval($r['page']);
if (0 == $r['page'] && 0 != $r['per_page']) {
$r['page'] = 1;
}
// Which order should comments be displayed in?
$r['reverse_top_level'] = 'desc' == get_option('comment_order') ? TRUE : FALSE;
// Convert array into handy variables.
extract($r, EXTR_SKIP);
// Insantiate comments class.
if (empty($walker)) {
$walker = new Thesis_Comment();
}
$walker->paged_walk($_comments, $max_depth, $page, $per_page, $r);
$wp_query->max_num_comment_pages = $walker->max_pages;
$in_comment_loop = false;
}
示例11: 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';
}
}
示例12: get_comments_list_template
private function get_comments_list_template($comments, $post, $comments_count = null)
{
global $wp_query;
// we store unmodified wp_query as the same object is used again later
$original = clone $wp_query;
// Fakes have_comments() that uses $wp_query->current_comment + 1 < $wp_query->comment_count
if (!$comments_count) {
$comments_count = count($comments);
}
if ($comments_count == 0) {
$wp_query->current_comment = $comments_count;
}
$wp_query->comment_count = $comments_count;
// Fakes comments_number()
$post->comment_count = $comments_count;
$this->add_overridden_comments_count_filter($comments_count);
// Fakes wp_list_comments()
$wp_query->comments = $comments;
// Fakes $comments_by_type
$c_by_type = separate_comments($comments);
$wp_query->comments_by_type = $c_by_type;
$comments_by_type = $wp_query->comments_by_type;
// Hack for bad-written themes, which rely on globals instead of functions
$GLOBALS['comments'] =& $comments;
$GLOBALS['comment_count'] =& $comments_count;
// Prints the template buffered
ob_start();
include TEMPLATEPATH . '/comments.php';
$comments_template = ob_get_clean();
unset($GLOBALS['comments']);
unset($GLOBALS['comment_count']);
remove_filter('get_comments_number', 'overload_comments_number');
$wp_query = clone $original;
return $comments_template;
}
示例13: wp_list_comments
/**
* List comments
*
* Used in the comments.php template to list comments for a particular post
*
* @since 2.7.0
* @uses Walker_Comment
*
* @param string|array $args Formatting options
* @param array $comments Optional array of comment objects. Defaults to $wp_query->comments
*/
function wp_list_comments($args = array(), $comments = null)
{
global $wp_query, $comment_alt, $comment_depth, $comment_thread_alt, $overridden_cpage, $in_comment_loop;
$in_comment_loop = true;
$comment_alt = $comment_thread_alt = 0;
$comment_depth = 1;
$defaults = array('walker' => null, 'max_depth' => '', 'style' => 'ul', 'callback' => null, 'end-callback' => null, 'type' => 'all', 'page' => '', 'per_page' => '', 'avatar_size' => 32, 'reverse_top_level' => null, 'reverse_children' => '');
$r = wp_parse_args($args, $defaults);
// Figure out what comments we'll be looping through ($_comments)
if (null !== $comments) {
$comments = (array) $comments;
if (empty($comments)) {
return;
}
if ('all' != $r['type']) {
$comments_by_type =& separate_comments($comments);
if (empty($comments_by_type[$r['type']])) {
return;
}
$_comments = $comments_by_type[$r['type']];
} else {
$_comments = $comments;
}
} else {
if (empty($wp_query->comments)) {
return;
}
if ('all' != $r['type']) {
if (empty($wp_query->comments_by_type)) {
$wp_query->comments_by_type =& separate_comments($wp_query->comments);
}
if (empty($wp_query->comments_by_type[$r['type']])) {
return;
}
$_comments = $wp_query->comments_by_type[$r['type']];
} else {
$_comments = $wp_query->comments;
}
}
if ('' === $r['per_page'] && get_option('page_comments')) {
$r['per_page'] = get_query_var('comments_per_page');
}
if (empty($r['per_page'])) {
$r['per_page'] = 0;
$r['page'] = 0;
}
if ('' === $r['max_depth']) {
if (get_option('thread_comments')) {
$r['max_depth'] = get_option('thread_comments_depth');
} else {
$r['max_depth'] = -1;
}
}
if ('' === $r['page']) {
if (empty($overridden_cpage)) {
$r['page'] = get_query_var('cpage');
} else {
$threaded = -1 == $r['max_depth'] ? false : true;
$r['page'] = 'newest' == get_option('default_comments_page') ? get_comment_pages_count($_comments, $r['per_page'], $threaded) : 1;
set_query_var('cpage', $r['page']);
}
}
// Validation check
$r['page'] = intval($r['page']);
if (0 == $r['page'] && 0 != $r['per_page']) {
$r['page'] = 1;
}
if (null === $r['reverse_top_level']) {
$r['reverse_top_level'] = 'desc' == get_option('comment_order') ? TRUE : FALSE;
}
extract($r, EXTR_SKIP);
if (empty($walker)) {
$walker = new Walker_Comment();
}
$walker->paged_walk($_comments, $max_depth, $page, $per_page, $r);
$wp_query->max_num_comment_pages = $walker->max_pages;
$in_comment_loop = false;
}
示例14: separate_comments
*
* Lists comments and calls the comment form.
*
* @package deTube
* @subpackage Template
* @since deTube 1.0
*/
?>
<?php
/* If there are no comments are given and comments/pings are closed and viewing a page, return. */
if (!have_comments() && !comments_open() && !pings_open() && is_page()) {
return;
}
global $wp_query, $cpage;
$comments_by_type =& separate_comments($wp_query->comments);
$display_pings = false;
// set to true if you want to display trackbacks/pingbakcs
$cpage = $cpage > 1 ? $cpage : 1;
?>
<?php
dp_comment_form(array('comment_notes_after' => ''));
?>
<?php
if (!empty($comments_by_type['comment'])) {
?>
<div id="comments">
<div class="section-header"><h2 class="section-title" id="comments-title"><?php
comments_number(__('No Comments', 'dp'), __('1 Comment', 'dp'), __('% Comments', 'dp'));
示例15: hannover_get_comments_by_type
/**
* Gets the comments seperated by type
*
* @return array
*/
function hannover_get_comments_by_type()
{
global $wp_query, $post;
$comment_args = array('order' => 'ASC', 'orderby' => 'comment_date_gmt', 'status' => 'approve', 'post_id' => $post->ID);
$comments = get_comments($comment_args);
$wp_query->comments_by_type = separate_comments($comments);
$comments_by_type =& $wp_query->comments_by_type;
return $comments_by_type;
}