• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wp_list_comments函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中wp_list_comments函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_list_comments函数的具体用法?PHP wp_list_comments怎么用?PHP wp_list_comments使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了wp_list_comments函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: get_comments_tree

 protected static function get_comments_tree($comments)
 {
     $tree = array();
     if (!empty($comments)) {
         $comments_by_id = array();
         foreach ($comments as $comment) {
             $comments_by_id[$comment->comment_ID] = $comment;
         }
         ob_start();
         $wp_list_comments_args = array();
         wp_list_comments(apply_filters('wpak_comments_list_args', $wp_list_comments_args), $comments);
         $comments_list = ob_get_contents();
         ob_end_clean();
         //TODO : find another way to retrieve depths and ids than parsing the html (which can change!!!)
         $depths_found = preg_match_all('/depth-(\\d+)/', $comments_list, $matches_depths);
         $ids_found = preg_match_all('/id="comment-(\\d+)"/', $comments_list, $matches_ids);
         if (!empty($depths_found) && !empty($ids_found)) {
             foreach ($matches_depths[1] as $k => $depth) {
                 $comment_id = $matches_ids[1][$k];
                 $tree[$comment_id] = array('id' => $comment_id, 'depth' => (int) $depth, 'comment' => $comments_by_id[$comment_id]);
             }
         }
     }
     return $tree;
 }
开发者ID:hiddenpearls,项目名称:wp-appkit,代码行数:25,代码来源:comments.php


示例2: list_comments

 public function list_comments()
 {
     // Prepare wp_list_comments args
     //comment callback function
     if ('' === $this->options->get('cgb_comment_adjust') && function_exists($this->options->get('cgb_comment_adjust'))) {
         $args['callback'] = $this->options->get('cgb_comment_callback');
     } else {
         $args['callback'] = array(&$this, 'show_comment_html');
     }
     //correct order of top level comments
     if ('default' !== $this->options->get('cgb_clist_order')) {
         $args['reverse_top_level'] = false;
     }
     //correct order of child comments
     if ('desc' === $this->options->get('cgb_clist_child_order')) {
         $args['reverse_children'] = true;
     } elseif ('asc' === $this->options->get('cgb_clist_child_order')) {
         $args['reverse_children'] = false;
     }
     //change child order if top level order is desc due to array_reverse
     if ('desc' === $this->options->get('cgb_clist_order')) {
         $args['reverse_children'] = isset($args['reverse_children']) ? !$args['reverse_children'] : true;
     }
     // Print comments
     wp_list_comments($args);
 }
开发者ID:andreasylivainio,项目名称:kangos.com,代码行数:26,代码来源:comments-functions.php


示例3: wpc_heartbeat_response

function wpc_heartbeat_response($response, $data)
{
    if (isset($data['wpc_comment_update'])) {
        global $wpdb;
        //get the newest comment-timestamp:
        // (we don't have to go to the DB for this every time, post_meta gets cached and updated only when the records get updated)
        $last_commented = get_post_meta($data['wpc_comment_update']['post_id'], '_wpc_comment_timestamp', true);
        //check the timestamp of our last known version versus the one in the heartbeat:
        if ($data['wpc_comment_update']['timestamp'] != $last_commented) {
            // We have data with our handle and a new comment! lets respond with something...
            // Get comments from the old timestamp up and post_id = $data['post_id'];
            $time = date('Y-m-d H:i:s', $last_commented);
            $post_id = $data['wpc_comment_update']['post_id'];
            //Query the new comments for this post that have been posted since:
            $_comments = $wpdb->get_results($wpdb->prepare("\n\t \t\t\t\t\tSELECT * \n\t \t\t\t\t\tFROM {$wpdb->comments} \n\t \t\t\t\t\tWHERE comment_post_ID = {$post_id} \n\t \t\t\t\t\tAND comment_date >= '{$time}' \n\n\t \t\t\t\t "));
            //Now, output the newest comments in html:
            ob_start();
            wp_list_comments(array('style' => 'ol', 'short_ping' => true, 'avatar_size' => 74), $_comments);
            //get the output buffer and clean it:
            $html = ob_get_clean();
            //then add it to the response object we're sending back
            //including the updated timestamp.
            $response['wpc_comment_update'] = array('timestamp' => $last_commented, 'html' => $html);
        }
    }
    return $response;
}
开发者ID:chefduweb,项目名称:auto-comments-websockets,代码行数:27,代码来源:auto-comments.php


示例4: get_comments

 public function get_comments()
 {
     if (isset($_GET['post'])) {
         $comments = get_comments(array('post_id' => intval($_GET['post']), 'status' => 'approve'));
         wp_list_comments(array('style' => 'ol', 'callback' => 'dwqa_question_comment_callback'), $comments);
     }
     exit(0);
 }
开发者ID:layoutzweb,项目名称:dw-question-answer,代码行数:8,代码来源:Comment.php


示例5: show

 public function show()
 {
     global $post;
     if (post_password_required($post)) {
         return;
     }
     echo '<ul class="commentlist">';
     wp_list_comments(array("callback" => array(&$this, "format"), "walker" => new Walker_Comment_PE()));
     echo '</ul>';
 }
开发者ID:lukesmmr,项目名称:lowconstrutores,代码行数:10,代码来源:PeThemeComments.php


示例6: test_has_children

 /**
  * @ticket 14041
  */
 function test_has_children()
 {
     $comment_parent = self::factory()->comment->create(array('comment_post_ID' => $this->post_id));
     $comment_child = self::factory()->comment->create(array('comment_post_ID' => $this->post_id, 'comment_parent' => $comment_parent));
     $comment_parent = get_comment($comment_parent);
     $comment_child = get_comment($comment_child);
     $comment_walker = new Walker_Comment();
     $comment_callback = new Comment_Callback_Test($this, $comment_walker);
     wp_list_comments(array('callback' => array($comment_callback, 'comment'), 'walker' => $comment_walker, 'echo' => false), array($comment_parent, $comment_child));
     wp_list_comments(array('callback' => array($comment_callback, 'comment'), 'walker' => $comment_walker, 'echo' => false), array($comment_child, $comment_parent));
 }
开发者ID:boonebgorges,项目名称:develop.wordpress,代码行数:14,代码来源:walker.php


示例7: fruitframeLoadCommentsHook

 /**
  * Load Comments AJAX Hook
  */
 public function fruitframeLoadCommentsHook()
 {
     $id = (int) $_POST['id'];
     $query = new WP_Query(array('post_type' => 'post', 'p' => $id, 'post_status' => 'publish'));
     while ($query->have_posts()) {
         $query->the_post();
         $comments = get_comments(array('post_id' => get_the_ID(), 'orderby' => 'comment_date_gmt', 'order' => 'ASC', 'status' => 'approve'));
         wp_list_comments(array('callback' => 'fruitframe_comment'), $comments);
     }
     exit;
 }
开发者ID:slavic18,项目名称:cats,代码行数:14,代码来源:hooks_ajax.php


示例8: tc_comment_list

    /**
     * Comments Rendering
     *
     * @package Customizr
     * @since Customizr 3.0
     */
    function tc_comment_list()
    {
        ?>

      		<ul class="commentlist">
      			<?php 
        wp_list_comments(array('callback' => array($this, 'tc_comment_callback'), 'style' => 'ul'));
        ?>
      		</ul><!-- .commentlist -->

    		<?php 
    }
开发者ID:BackupTheBerlios,项目名称:vishwa-svn,代码行数:18,代码来源:class-content-comments.php


示例9: cherry_comments_default_list

/**
 * Dispaly the list of comments.
 *
 * @since 4.0.0
 */
function cherry_comments_default_list()
{
    $defaults = array('style' => 'ol', 'type' => 'all', 'avatar_size' => 48, 'short_ping' => true, 'callback' => 'cherry_rewrite_comment_item');
    /**
     * Filter the defaults list arguments of comments.
     *
     * @since 4.0.0
     * @param array $defaults Defaults arguments.
     */
    $args = apply_filters('cherry_comment_list_args', $defaults);
    // Set argument 'echo' to the function 'wp_list_comments' for return result.
    $args = array_merge($args, array('echo' => false));
    printf('<%1$s class="comment-list">%2$s</%1$s>', tag_escape($args['style']), wp_list_comments($args));
}
开发者ID:xav335,项目名称:sfnettoyage,代码行数:19,代码来源:template-comments.php


示例10: list_comments

/**
 * List Comments
 *
 * @param TimberPost $post
 * @global integer $cpage
 * @global boolean $overridden_cpage
 */
function list_comments($post)
{
    global $cpage, $overridden_cpage;
    $cpage = $cpage ? $cpage : 1;
    $overridden_cpage = true;
    $commentsPerPage = (int) get_option('comments_per_page');
    $commentsOrder = get_option('comment_order');
    $defaultCommentsPage = get_option('default_comments_page');
    $commentPage = $cpage;
    $lastPage = ceil($post->comment_count / $commentsPerPage);
    if ($defaultCommentsPage == 'newest') {
        $commentPage = $lastPage - $cpage + 1;
    }
    wp_list_comments(array('callback' => 'render_comment'), get_comments(array('post_id' => $post->ID, 'number' => $commentsPerPage, 'offset' => (int) ($commentPage - 1) * $commentsPerPage, 'order' => $commentsOrder)));
}
开发者ID:mindgruve,项目名称:mg-press,代码行数:22,代码来源:comments.php


示例11: novusopress_comments_list

 function novusopress_comments_list(array $args = [], $echo = true)
 {
     $defaults = ['listEl' => 'ol', 'listId' => 'comment-list', 'listClass' => 'comment-list list-unstyled', 'callback' => 'novusopress_comment', 'endCallback' => 'novusopress_comment_end', 'indent' => 5, 'tab' => '    '];
     $args = wp_parse_args($args, $defaults);
     extract($args, EXTR_SKIP);
     $tabs = str_repeat($tab, $indent);
     $output = [];
     $output[] = sprintf('%s<%s id="%s" class="%s">%s', $tabs, $listEl, $listId, $listClass, PHP_EOL);
     $output[] = wp_list_comments(['callback' => $callback, 'end-callback' => $endCallback, 'walker' => new CommentWalker(), 'echo' => false]);
     $output[] = sprintf('%s</%s><!-- #%s -->%s', $tabs, $listEl, $listId, PHP_EOL);
     $output = apply_filters('novusopress_comments_list_output', implode('', $output));
     if ($echo) {
         echo $output;
     } else {
         return $output;
     }
 }
开发者ID:novuso,项目名称:novusopress,代码行数:17,代码来源:comments.php


示例12: tc_comment_list

 /**
  * Comment list Rendering
  *
  * @package Customizr
  * @since Customizr 3.0
  */
 function tc_comment_list()
 {
     $_args = apply_filters('tc_list_comments_args', array('callback' => array($this, 'tc_comment_callback'), 'style' => 'ul'));
     ob_start();
     ?>
       <ul class="commentlist">
         <?php 
     wp_list_comments($_args);
     ?>
       </ul><!-- .commentlist -->
     <?php 
     $html = ob_get_contents();
     if ($html) {
         ob_end_clean();
     }
     echo apply_filters('tc_comment_list', $html);
 }
开发者ID:lokenxo,项目名称:familygenerator,代码行数:23,代码来源:class-content-comments.php


示例13: test_should_respect_reverse_top_level_param

 /**
  * @ticket 35175
  */
 public function test_should_respect_reverse_top_level_param()
 {
     $p = self::factory()->post->create();
     $comments = array();
     $now = time();
     for ($i = 0; $i <= 5; $i++) {
         $comments[] = self::factory()->comment->create(array('comment_post_ID' => $p, 'comment_date_gmt' => date('Y-m-d H:i:s', $now - $i), 'comment_author' => 'Commenter ' . $i));
     }
     update_option('page_comments', true);
     update_option('comments_per_page', 2);
     $this->go_to(get_permalink($p));
     // comments_template() populates $wp_query->comments
     get_echo('comments_template');
     $found1 = wp_list_comments(array('reverse_top_level' => true, 'echo' => false));
     preg_match_all('|id="comment\\-([0-9]+)"|', $found1, $matches);
     $this->assertSame(array($comments[0], $comments[1]), array_map('intval', $matches[1]));
     $found2 = wp_list_comments(array('reverse_top_level' => false, 'echo' => false));
     preg_match_all('|id="comment\\-([0-9]+)"|', $found2, $matches);
     $this->assertSame(array($comments[1], $comments[0]), array_map('intval', $matches[1]));
 }
开发者ID:theukedge,项目名称:wordpress-develop,代码行数:23,代码来源:wpListComments.php


示例14: supernova_theme_setup

function supernova_theme_setup()
{
    global $background_defaults, $header_defaults, $wp_version;
    //Featured image for both page and post
    add_theme_support('post-thumbnails');
    //Adds automatic feed links
    add_theme_support('automatic-feed-links');
    //Adds Custom background
    add_theme_support('custom-background', $background_defaults);
    //Adds Custom Header
    add_theme_support('custom-header', $header_defaults);
    add_theme_support("title-tag");
    //Setting Avatar Size
    wp_list_comments('avatar_size=80');
    // Visual Editor Style
    add_editor_style();
    //Loading Language File
    load_theme_textdomain('Supernova', SUPERNOVA_DIR . '/languages');
    //Navigation Registration
    register_nav_menus(array('Header_Nav' => __('Header Navigation', 'Supernova'), 'Header_Cat' => __('Header Categories', 'Supernova'), 'Main_Nav' => __('Main Navigation', 'Supernova'), 'Footer_Nav' => __('Footer Navigation', 'Supernova')));
    do_action('supernova_after_theme_setup');
}
开发者ID:plusinterativa,项目名称:clientes,代码行数:22,代码来源:functions.php


示例15: miss_comment_list

    /**
     *
     */
    function miss_comment_list()
    {
        //echo apply_filters( 'miss_comments_title', '<h3 id="comments-title">' . sprintf( _n( '1 Comment', '%1$s Comments', get_comments_number(), MISS_TEXTDOMAIN ), number_format_i18n( get_comments_number() ), get_the_title() ) . '</h3>', array( 'comments_number' => get_comments_number(), 'title' =>  get_the_title() ) );
        ?>
<div class="comments">
		<?php 
        wp_list_comments(array('type' => 'all', 'walker' => new zipGun_walker_comment()));
        ?>
	</div>

	<?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 
        }
        ?>

<?php 
    }
开发者ID:schiz,项目名称:scrollax,代码行数:27,代码来源:function.php


示例16: wp_list_comments

</div>
			</nav><!-- #comment-nav-above -->
			<?php 
    }
    // check for comment navigation
    ?>

			<ol class="comment-list">
				<?php 
    /* Loop through and list the comments. Tell wp_list_comments()
     * to use sz_comment() to format the comments.
     * If you want to override this in a child theme, then you can
     * define sz_comment() and that will be used instead.
     * See sz_comment() in inc/template-tags.php for more.
     */
    wp_list_comments(array('callback' => 'sz_comment', 'avatar_size' => 98));
    ?>
			</ol><!-- .comment-list -->

	</div><!-- #comments -->
</div><!-- .row -->
<hr class="comment-response" />
<div class="row">
	<div class="columns large-10 large-centered">

	<?php 
    if (get_comment_pages_count() > 1 && get_option('page_comments')) {
        // are there comments to navigate through
        ?>
			<nav id="comment-nav-below" class="comment-navigation" role="navigation">
				<h1 class="screen-reader-text"><?php 
开发者ID:sdh100shaun,项目名称:pantheon,代码行数:31,代码来源:comments.php


示例17: COUNT

    echo '<div id="comments">';
    $count = $wpdb->get_var("\n\t\tSELECT COUNT(meta_value) FROM {$wpdb->commentmeta} \n\t\tLEFT JOIN {$wpdb->comments} ON {$wpdb->commentmeta}.comment_id = {$wpdb->comments}.comment_ID\n\t\tWHERE meta_key = 'rating'\n\t\tAND comment_post_ID = {$post->ID}\n\t\tAND comment_approved = '1'\n\t\tAND meta_value > 0\n\t");
    $rating = $wpdb->get_var("\n\t\tSELECT SUM(meta_value) FROM {$wpdb->commentmeta} \n\t\tLEFT JOIN {$wpdb->comments} ON {$wpdb->commentmeta}.comment_id = {$wpdb->comments}.comment_ID\n\t\tWHERE meta_key = 'rating'\n\t\tAND comment_post_ID = {$post->ID}\n\t\tAND comment_approved = '1'\n\t");
    if ($count > 0) {
        $average = number_format($rating / $count, 2);
        echo '<div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">';
        echo '<div class="star-rating" title="' . sprintf(__('Rated %s out of 5', 'woocommerce'), $average) . '"><span style="width:' . $average * 10 . 'px"><span itemprop="ratingValue" class="rating">' . $average . '</span> ' . __('out of 5', 'woocommerce') . '</span></div>';
        echo '<h2>' . sprintf(_n('%s review for %s', '%s reviews for %s', $count, 'woocommerce'), '<span itemprop="ratingCount" class="count">' . $count . '</span>', wptexturize($post->post_title)) . '</h2>';
        echo '</div>';
    } else {
        echo '<h2>' . __('Reviews', 'woocommerce') . '</h2>';
    }
    $title_reply = '';
    if (have_comments()) {
        echo '<ol class="commentlist">';
        wp_list_comments(array('callback' => 'woocommerce_comments'));
        echo '</ol>';
        if (get_comment_pages_count() > 1 && get_option('page_comments')) {
            ?>
			<div class="navigation">
				<div class="nav-previous"><?php 
            previous_comments_link(__('<span class="meta-nav">&larr;</span> Previous', 'woocommerce'));
            ?>
</div>
				<div class="nav-next"><?php 
            next_comments_link(__('Next <span class="meta-nav">&rarr;</span>', 'woocommerce'));
            ?>
</div>
			</div>
		<?php 
        }
开发者ID:Nguyenkain,项目名称:hanghieusales,代码行数:31,代码来源:single-product-reviews.php


示例18: _e

<?php

// DISPLAY COMMENTS IF COMMENTS ARE OPENED
if (comments_open()) {
    echo '<div class="comments">', '<h2>';
    _e('Comentários', 'wikiwp');
    // alterado
    echo '</h2>';
    if (have_comments()) {
        // this is displayed if there are comments
        echo '<h3>';
        _e('Este post tem', 'wikiwp');
        echo '&nbsp;';
        comments_number(__('0 comentários', 'wikiwp'), __('um comentário', 'wikiwp'), __('% comentários', 'wikiwp'));
        echo '</h3>', '<ul class="commentlist">';
        wp_list_comments();
        echo '</ul>', '<div class="comment-nav">', '<div class="alignleft">';
        previous_comments_link();
        echo '</div>', '<div class="alignright">';
        next_comments_link();
        echo '</div>', '</div>';
    } else {
        // this is displayed if there are no comments so far
        _e('Nenhum comentário!', 'wikiwp');
    }
    // load comment form
    comment_form();
    echo '</div>';
    // end of .content
}
开发者ID:arildoosilva,项目名称:besm_restricted_area,代码行数:30,代码来源:comments.php


示例19: count

	<?php 
if (!empty($comments_by_type['pings'])) {
    // let's seperate pings/trackbacks from comments
    $count = count($comments_by_type['pings']);
    $count !== 1 ? $txt = __('Pings&#47;Trackbacks', 'responsive-mobile') : ($txt = __('Pings&#47;Trackbacks', 'responsive-mobile'));
    ?>

		<h2 id="pings"><?php 
    printf(__('%1$d %2$s for "%3$s"', 'responsive-mobile'), $count, $txt, get_the_title());
    ?>
</h2>

		<ol class="commentlist">
			<?php 
    wp_list_comments(array('max_depth' => '<em>', 'type' => 'pings'));
    ?>
		</ol>

	<?php 
}
?>

	<?php 
if (comments_open()) {
    ?>

		<?php 
    $fields = array('author' => '<p class="comment-form-author">' . '<label for="author">' . __('Name', 'responsive-mobile') . '</label> ' . ($req ? '<span class="required">*</span>' : '') . '<input id="author" name="author" type="text" value="' . esc_attr($commenter['comment_author']) . '" size="30" /></p>', 'email' => '<p class="comment-form-email"><label for="email">' . __('E-mail', 'responsive-mobile') . '</label> ' . ($req ? '<span class="required">*</span>' : '') . '<input id="email" name="email" type="text" value="' . esc_attr($commenter['comment_author_email']) . '" size="30" /></p>', 'url' => '<p class="comment-form-url"><label for="url">' . __('Website', 'responsive-mobile') . '</label>' . '<input id="url" name="url" type="text" value="' . esc_attr($commenter['comment_author_url']) . '" size="30" /></p>');
    comment_form();
    ?>
开发者ID:AhmeddSayed,项目名称:MM_Portal,代码行数:30,代码来源:comments.php


示例20: previous_comments_link

&#8221;</h2>

	<ul class="navigation">
		<li class="alignleft"><?php 
    previous_comments_link();
    ?>
</li>
		<li class="alignright"><?php 
    next_comments_link();
    ?>
</li>
	</ul>

	<ol class="commentlist">
<?php 
    wp_list_comments('callback=base_comment');
    ?>
	</ol>

	<ul class="navigation">
		<li class="alignleft"><?php 
    previous_comments_link();
    ?>
</li>
		<li class="alignright"><?php 
    next_comments_link();
    ?>
</li>
	</ul>
	
<?php 
开发者ID:jaredwilli,项目名称:3.0basics,代码行数:31,代码来源:comments.php



注:本文中的wp_list_comments函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wp_list_filter函数代码示例发布时间:2022-05-23
下一篇:
PHP wp_list_cats函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap