Example #1
0
    /**
     * Display navigation to next/previous comments when applicable.
     *
     * @since 1.0.0
     */
    function toivo_lite_comment_nav($class = '')
    {
        // Are there comments to navigate through?
        if (get_comment_pages_count() > 1 && get_option('page_comments')) {
            ?>
	<nav class="navigation comment-navigation <?php 
            echo esc_attr($class);
            ?>
" role="navigation">
		<h2 class="screen-reader-text"><?php 
            _e('Comment navigation', 'toivo-lite');
            ?>
</h2>
		<div class="nav-links">
			<?php 
            if ($prev_link = get_previous_comments_link(__('&larr; Older Comments', 'toivo-lite'))) {
                printf('<div class="nav-previous">%s</div>', $prev_link);
            }
            if ($next_link = get_next_comments_link(__('Newer Comments &rarr;', 'toivo-lite'))) {
                printf('<div class="nav-next">%s</div>', $next_link);
            }
            ?>
		</div><!-- .nav-links -->
	</nav><!-- .comment-navigation -->
	<?php 
        }
    }
Example #2
0
    /**
     * Display navigation to next/previous comments when applicable.
     *
     */
    function twentyfifteen_comment_nav()
    {
        // Are there comments to navigate through?
        if (get_comment_pages_count() > 1 && get_option('page_comments')) {
            ?>
            <nav class="navigation comment-navigation" role="navigation">
                <h2 class="screen-reader-text"><?php 
            _e('Comment navigation', 'myblog');
            ?>
</h2>

                <div class="nav-links">
                    <?php 
            if ($prev_link = get_previous_comments_link(__('Older Comments', 'myblog'))) {
                printf('<div class="nav-previous">%s</div>', $prev_link);
            }
            if ($next_link = get_next_comments_link(__('Newer Comments', 'myblog'))) {
                printf('<div class="nav-next">%s</div>', $next_link);
            }
            ?>
                </div>
                <!-- .nav-links -->
            </nav><!-- .comment-navigation -->
        <?php 
        }
    }
Example #3
0
function get_comment_nav()
{
    ?>

	<?php 
    if (get_comment_pages_count() > 1) {
        ?>
	<div class="comments-nav">
		<div class="prev">
			<?php 
        previous_comments_link(__('Prev Comments', 'rb'));
        ?>
		</div>
		<div class="next">
			<?php 
        next_comments_link(__('Next Comments', 'rb'));
        ?>
		</div>
	</div>
	<?php 
    }
    ?>

<?php 
}
Example #4
0
/**
 * Comments Nav
 * @since 0.1.0
 */
function tamatebako_comments_nav()
{
    if (get_option('page_comments') && 1 < get_comment_pages_count()) {
        // Check for paged comments.
        ?>

	<div class="comments-nav">

		<?php 
        previous_comments_link('<span class="prev-comments"><span class="screen-reader-text">' . tamatebako_string('previous_comment') . '</span></span>');
        ?>

		<span class="page-numbers"><?php 
        printf('%1$s / %2$s', get_query_var('cpage') ? absint(get_query_var('cpage')) : 1, get_comment_pages_count());
        ?>
</span>

		<?php 
        next_comments_link('<span class="next-comments"><span class="screen-reader-text">' . tamatebako_string('next_comment') . '</span></span>');
        ?>

	</div><!-- .comments-nav -->

<?php 
    }
    // End check for paged comments.
}
 /**
  * Pagination based on options/args
  */
 function paginate($args = false)
 {
     if ($this->type === 'comments' && !get_option('page_comments')) {
         return;
     }
     $r = wp_parse_args($args, $this->options);
     extract($r, EXTR_SKIP);
     if (!isset($page) && !isset($pages)) {
         global $wp_query;
         if ($this->type === 'posts') {
             $page = get_query_var('paged');
             $posts_per_page = intval(get_query_var('posts_per_page'));
             $pages = intval(ceil($wp_query->found_posts / $posts_per_page));
         } else {
             $page = get_query_var('cpage');
             $comments_per_page = get_option('comments_per_page');
             $pages = get_comment_pages_count();
         }
         $page = !empty($page) ? intval($page) : 1;
     }
     $prevlink = $this->type === 'posts' ? esc_url(get_pagenum_link($page - 1)) : get_comments_pagenum_link($page - 1);
     $nextlink = $this->type === 'posts' ? esc_url(get_pagenum_link($page + 1)) : get_comments_pagenum_link($page + 1);
     $output = stripslashes($before);
     if ($pages > 1) {
         $output .= sprintf('<ol class="wp-paginate%s">', $this->type === 'posts' ? '' : ' wp-paginate-comments');
         if (strlen(stripslashes($title)) > 0) {
             $output .= sprintf('<li><span class="title">%s</span></li>', stripslashes($title));
         }
         $ellipsis = "<li><span class='gap'>...</span></li>";
         if ($page > 1 && !empty($previouspage)) {
             $output .= sprintf('<li><a href="%s" class="prev">%s</a></li>', $prevlink, stripslashes($previouspage));
         }
         $min_links = $range * 2 + 1;
         $block_min = min($page - $range, $pages - $min_links);
         $block_high = max($page + $range, $min_links);
         $left_gap = $block_min - $anchor - $gap > 0 ? true : false;
         $right_gap = $block_high + $anchor + $gap < $pages ? true : false;
         if ($left_gap && !$right_gap) {
             $output .= sprintf('%s%s%s', $this->paginate_loop(1, $anchor), $ellipsis, $this->paginate_loop($block_min, $pages, $page));
         } else {
             if ($left_gap && $right_gap) {
                 $output .= sprintf('%s%s%s%s%s', $this->paginate_loop(1, $anchor), $ellipsis, $this->paginate_loop($block_min, $block_high, $page), $ellipsis, $this->paginate_loop($pages - $anchor + 1, $pages));
             } else {
                 if ($right_gap && !$left_gap) {
                     $output .= sprintf('%s%s%s', $this->paginate_loop(1, $block_high, $page), $ellipsis, $this->paginate_loop($pages - $anchor + 1, $pages));
                 } else {
                     $output .= $this->paginate_loop(1, $pages, $page);
                 }
             }
         }
         if ($page < $pages && !empty($nextpage)) {
             $output .= sprintf('<li><a href="%s" class="next">%s</a></li>', $nextlink, stripslashes($nextpage));
         }
         $output .= "</ol>";
     }
     $output .= stripslashes($after);
     if ($pages > 1 || $empty) {
         echo $output;
     }
 }
 function thb_comments_navigation()
 {
     global $post;
     if (get_comment_pages_count() > 1 && get_option('page_comments')) {
         previous_comments_link(__('Older comments', 'thb_text_domain'));
         next_comments_link(__('Newer comments', 'thb_text_domain'));
     }
 }
Example #7
0
 public static function getPagesCount($comments)
 {
     if (class_exists(InnThemeComment::class) && method_exists(InnThemeComment::class, 'getPagesCount')) {
         return InnThemeComment::getPagesCount($comments);
     }
     static $count = null;
     if ($count === null) {
         $count = \get_comment_pages_count($comments, Other::getOption('comments_per_page'), Other::getOption('thread_comments'));
     }
     return $count;
 }
 /**
  * Retrieve the total number of comment pages.
  *
  * @return int $total Total number of comment pages.
  */
 public function get_total_comment_pages()
 {
     global $wp_query;
     // get max page from query
     if (!empty($wp_query->max_num_comment_pages)) {
         $max_page = $wp_query->max_num_comment_pages;
     }
     // if there is no max page in the query, calculate it
     if (empty($max_page)) {
         $max_page = get_comment_pages_count();
     }
     return intval(max($max_page, 1));
 }
Example #9
0
 function comments_title()
 {
     global $wp_query;
     $ppage = get_query_var('comments_per_page');
     $num = get_comments_number();
     // Subtract pings from this number
     $num -= count($wp_query->comments_by_type['pings']);
     if ($num > $ppage) {
         echo sprintf(__('Comments (page %d of %d)', 'guangzhou'), get_query_var('cpage'), get_comment_pages_count());
     } else {
         if ($num > 0) {
             echo sprintf(_n('%d Comment', '%d Comments', $num, 'guangzhou'), $num);
         } else {
             _e('No comments', 'guangzhou');
         }
     }
 }
Example #10
0
    /**
     * Display navigation to next/previous comments when applicable.
     */
    function bootplate_comment_nav()
    {
        // Are there comments to navigate through?
        if (get_comment_pages_count() > 1 && get_option('page_comments')) {
            ?>
	<ul class="pager comment-navigation" role="navigation">
		<?php 
            if ($prev_link = get_previous_comments_link('Older Comments')) {
                printf('<div class="pager-prev">%s</div>', $prev_link);
            }
            if ($next_link = get_next_comments_link('Newer Comments')) {
                printf('<div class="pager-next">%s</div>', $next_link);
            }
            ?>
	</ul><!-- .comment-navigation -->
	<?php 
        }
    }
Example #11
0
    /**
     * Display navigation to next/previous comments when applicable.
     *
     * @since 1.0
     */
    function Radix_comment_nav()
    {
        // Are there comments to navigate through?
        if (get_comment_pages_count() > 1 && get_option('page_comments')) {
            ?>
	<nav class="comment-navigation" role="navigation">
		<ul class="pager">
			<?php 
            if ($prev_link = get_previous_comments_link(__('<i class="fa fa-chevron-left fa-fw" aria-hidden="true"></i> Older Comments', 'radix'))) {
                printf('<li class="nav-previous previous">%s</li>', $prev_link);
            }
            if ($next_link = get_next_comments_link(__('Newer Comments <i class="fa fa-chevron-right fa-fw" aria-hidden="true"></i>', 'radix'))) {
                printf('<li class="nav-next next">%s</li>', $next_link);
            }
            ?>
		</ul><!-- .nav-links -->
	</nav><!-- end .navigation -->
	<?php 
        }
    }
function cleansimplewhite_comment_nav()
{
    // Are there comments to navigate through?
    if (get_comment_pages_count() > 1 && get_option('page_comments')) {
        ?>
    <nav class="navigation comment-navigation">
        <div class="nav-links">
            <?php 
        if ($prev_link = get_previous_comments_link(__('Older Comments', 'clean-simple-white'))) {
            printf('<div class="nav-previous">%s</div>', $prev_link);
        }
        if ($next_link = get_next_comments_link(__('Newer Comments', 'clean-simple-white'))) {
            printf('<div class="nav-next">%s</div>', $next_link);
        }
        ?>
        </div><!-- .nav-links -->
    </nav><!-- .comment-navigation -->
    <?php 
    }
}
Example #13
0
function puma_comment_nav()
{
    // Are there comments to navigate through?
    if (get_comment_pages_count() > 1 && get_option('page_comments')) {
        ?>
        <nav class="navigation comment-navigation u-textAlignCenter" role="navigation">
            <div class="nav-links">
                <?php 
        if ($prev_link = get_previous_comments_link('上一页')) {
            printf('<div class="nav-previous">%s</div>', $prev_link);
        }
        if ($next_link = get_next_comments_link('下一页')) {
            printf('<div class="nav-next">%s</div>', $next_link);
        }
        ?>
            </div>
        </nav>
        <?php 
    }
}
Example #14
0
/**
 * Comments nav
 */
function scaffolder_comment_nav()
{
    if (get_comment_pages_count() > 1 && get_option('page_comments')) {
        ?>
        <nav id="comment-nav-above" class="navigation comment-navigation" role="navigation">
            <h1 class="screen-reader-text"><?php 
        _e('Comment navigation', 'scaffold');
        ?>
</h1>
            <div class="nav-previous"><?php 
        previous_comments_link(__('&larr; Older Comments', 'scaffold'));
        ?>
</div>
            <div class="nav-next"><?php 
        next_comments_link(__('Newer Comments &rarr;', 'scaffold'));
        ?>
</div>
        </nav>
    <?php 
    }
}
Example #15
0
    /**
     * Display navigation to next/previous comments pages when applicable
     *
     * @author	Konstantin Obenland
     * @since	1.5.0 - 19.05.2012
     *
     * @return	void
     */
    function the_bootstrap_comment_nav()
    {
        if (get_comment_pages_count() > 1 and get_option('page_comments')) {
            // are there comments to navigate through
            ?>
	<nav class="comment-nav well">
		<h1 class="assistive-text"><?php 
            _e('Comment navigation', 'the-bootstrap');
            ?>
</h1>
		<div class="nav-previous alignleft"><?php 
            next_comments_link(__('&larr; Newer Comments', 'the-bootstrap'));
            ?>
</div>
		<div class="nav-next alignright"><?php 
            previous_comments_link(__('Older Comments &rarr;', 'the-bootstrap'));
            ?>
</div>
	</nav>
	<?php 
        }
        // check for comment navigation
    }
    /**
     * Display navigation to next/previous comments when applicable.
     */
    function fortunato_comment_nav()
    {
        // Are there comments to navigate through?
        if (get_comment_pages_count() > 1 && get_option('page_comments')) {
            ?>
	<nav class="navigation comment-navigation" role="navigation">
		<h2 class="screen-reader-text"><?php 
            esc_html_e('Comment navigation', 'fortunato');
            ?>
</h2>
		<div class="nav-links">
			<?php 
            if ($prev_link = get_previous_comments_link('<i class="fa fa-lg fa-angle-double-left spaceRight"></i>' . esc_html__('Older Comments', 'fortunato'))) {
                printf('<div class="nav-previous">%s</div>', $prev_link);
            }
            if ($next_link = get_next_comments_link(esc_html__('Newer Comments', 'fortunato') . '<i class="fa fa-lg fa-angle-double-right spaceLeft"></i>')) {
                printf('<div class="nav-next">%s</div>', $next_link);
            }
            ?>
		</div><!-- .nav-links -->
	</nav><!-- .comment-navigation -->
	<?php 
        }
    }
Example #17
0
    /**
     * Display navigation to next/previous comments when applicable.
     *
     * @since Twenty Fifteen 1.0
     */
    function google_s_comment_nav()
    {
        // Are there comments to navigate through?
        if (get_comment_pages_count() > 1 && get_option('page_comments')) {
            ?>
<div class="container-medium gs-mrg-top">
<p class="large"><?php 
            _e('Comment navigation', 'google_s');
            ?>
</p>
	<nav class="article-nav gs-mrg-top" role="navigation">
			<?php 
            if ($prev_link = get_previous_comments_link(__('Older Comments', 'google_s'))) {
                printf('<div class="article-nav-link article-nav-link--prev">%s</div>', $prev_link);
            }
            if ($next_link = get_next_comments_link(__('Newer Comments', 'google_s'))) {
                printf('<div class="article-nav-link article-nav-link--next">%s</div>', $next_link);
            }
            ?>
	</nav><!-- .comment-navigation -->
</div>
	<?php 
        }
    }
Example #18
0
<?php if ( ! empty($comments_by_type['comment']) ) : ?>

				<div id="comments-list" class="comments">
					<h3><?php printf($comment_count > 1 ? __('<span>%d</span> Comments', 'uthili') : __('<span>One</span> Comment', 'uthili'), $comment_count) ?></h3>
					
<?php $total_pages = get_comment_pages_count(); if ( $total_pages > 1 ) : ?>					
					<div id="comments-nav-above" class="comments-navigation">
								<div class="paginated-comments-links"><?php paginate_comments_links(); ?></div>
					</div><!-- #comments-nav-above -->					
<?php endif; ?>					
				
					<ol>
<?php wp_list_comments('type=comment&callback=custom_comments'); ?>
					</ol>

<?php $total_pages = get_comment_pages_count(); if ( $total_pages > 1 ) : ?>					
	  			<div id="comments-nav-below" class="comments-navigation">
						<div class="paginated-comments-links"><?php paginate_comments_links(); ?></div>
	        </div><!-- #comments-nav-below -->
<?php endif; ?>					
					
				</div><!-- #comments-list .comments -->

<?php endif; /* if ( $comment_count ) */ ?>

<?php if ( ! empty($comments_by_type['pings']) ) : ?>

				<div id="trackbacks-list" class="comments">
					<h3><?php printf($ping_count > 1 ? __('<span>%d</span> Trackbacks', 'uthili') : __('<span>One</span> Trackback', 'uthili'), $ping_count) ?></h3>
					
					<ol>
Example #19
0
    /**
     * Display comments pagination
     *
     * @package Graphene
     * @since 1.9
     */
    function graphene_comments_nav()
    {
        global $graphene_settings, $is_paginated;
        if (get_comment_pages_count() > 1 && $is_paginated) {
            ?>
        <div class="comment-nav clearfix">
            <?php 
            if (function_exists('wp_commentnavi') && !$graphene_settings['inf_scroll_comments']) {
                wp_commentnavi();
                ?>
                <p class="commentnavi-view-all"><?php 
                wp_commentnavi_all_comments_link();
                ?>
</p>
            <?php 
            } else {
                ?>
 
                <p><?php 
                paginate_comments_links();
                ?>
</p>
            <?php 
            }
            do_action('graphene_comments_pagination');
            ?>
        </div>
        
        <?php 
            if ($graphene_settings['inf_scroll_comments']) {
                ?>
			<p class="fetch-more-wrapper"><a href="#" class="fetch-more"><?php 
                _e('Fetch more comments', 'graphene');
                ?>
</a></p>
		<?php 
            }
        }
    }
Example #20
0
			<?php 
if (have_comments()) {
    ?>

				<h3 id="comments-number" class="comments-header"><?php 
    comments_number(__('No Responses', 'my-life'), __('One Response', 'my-life'), __('% Responses', 'my-life'));
    ?>
</h3>

				<?php 
    if (get_option('page_comments')) {
        ?>
					<div class="comments-nav">
						<span class="page-numbers"><?php 
        printf(__('Page %1$s of %2$s', 'my-life'), get_query_var('cpage') ? absint(get_query_var('cpage')) : 1, get_comment_pages_count());
        ?>
</span>
						<?php 
        previous_comments_link();
        ?>
						<?php 
        next_comments_link();
        ?>
					</div><!-- .comments-nav -->
				<?php 
    }
    ?>

				<?php 
    do_atomic('before_comment_list');
Example #21
0
</div>
				<div class="post_nav_next"><?php 
        next_comments_link(__('Newer Comments &rarr;', 'bones'));
        ?>
</div>
			</div>
		<?php 
    }
    ?>

		<?php 
    wp_list_comments(array('style' => 'div', 'callback' => 'blockhead_comment'));
    ?>

		<?php 
    if (get_comment_pages_count() > 1) {
        ?>
			<div class="post_nav">
				<div class="post_nav_prev"><?php 
        previous_comments_link(__('&larr; Older Comments', 'bones'));
        ?>
</div>
				<div class="post_nav_next"><?php 
        next_comments_link(__('Newer Comments &rarr;', 'bones'));
        ?>
</div>
			</div>
		<?php 
    }
    ?>
Example #22
0
/**
 * Returns navigation to next/previous set of comments when applicable.
 *
 * @since 4.4.0
 *
 * @param array $args {
 *     Optional. Default comments navigation arguments.
 *
 *     @type string $prev_text          Anchor text to display in the previous comments link. Default 'Older comments'.
 *     @type string $next_text          Anchor text to display in the next comments link. Default 'Newer comments'.
 *     @type string $screen_reader_text Screen reader text for nav element. Default 'Comments navigation'.
 * }
 * @return string Markup for comments links.
 */
function get_the_comments_navigation($args = array())
{
    $navigation = '';
    // Are there comments to navigate through?
    if (get_comment_pages_count() > 1) {
        $args = wp_parse_args($args, array('prev_text' => __('Older comments'), 'next_text' => __('Newer comments'), 'screen_reader_text' => __('Comments navigation')));
        $prev_link = get_previous_comments_link($args['prev_text']);
        $next_link = get_next_comments_link($args['next_text']);
        if ($prev_link) {
            $navigation .= '<div class="nav-previous">' . $prev_link . '</div>';
        }
        if ($next_link) {
            $navigation .= '<div class="nav-next">' . $next_link . '</div>';
        }
        $navigation = _navigation_markup($navigation, 'comment-navigation', $args['screen_reader_text']);
    }
    return $navigation;
}
/**
 * List comments.
 *
 * Used in the comments.php template to list comments for a particular post.
 *
 * @since 2.7.0
 *
 * @see WP_Query->comments
 *
 * @global WP_Query $wp_query
 * @global int $comment_alt
 * @global int $comment_depth
 * @global int $comment_thread_alt
 * @global bool $overridden_cpage
 * @global bool $in_comment_loop
 *
 * @param string|array $args {
 *     Optional. Formatting options.
 *
 * @type object $walker Instance of a Walker class to list comments. Default null.
 * @type int $max_depth The maximum comments depth. Default empty.
 * @type string $style The style of list ordering. Default 'ul'. Accepts 'ul', 'ol'.
 * @type string $callback Callback function to use. Default null.
 * @type string $end -callback      Callback function to use at the end. Default null.
 * @type string $type Type of comments to list.
 *                                     Default 'all'. Accepts 'all', 'comment', 'pingback', 'trackback', 'pings'.
 * @type int $page Page ID to list comments for. Default empty.
 * @type int $per_page Number of comments to list per page. Default empty.
 * @type int $avatar_size Height and width dimensions of the avatar size. Default 32.
 * @type string $reverse_top_level Ordering of the listed comments. Default null. Accepts 'desc', 'asc'.
 * @type bool $reverse_children Whether to reverse child comments in the list. Default null.
 * @type string $format How to format the comments list.
 *                                     Default 'html5' if the theme supports it. Accepts 'html5', 'xhtml'.
 * @type bool $short_ping Whether to output short pings. Default false.
 * @type bool $echo Whether to echo the output or return it. Default true.
 * }
 * @param array $comments Optional. Array of comment objects.
 */
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' => '', 'format' => current_theme_supports('html5', 'comment-list') ? 'html5' : 'xhtml', 'short_ping' => false, 'echo' => true);
    $r = wp_parse_args($args, $defaults);
    /**
     * Filter the arguments used in retrieving the comment list.
     *
     * @since 4.0.0
     *
     * @see wp_list_comments()
     *
     * @param array $r An array of arguments for displaying comments.
     */
    $r = apply_filters('wp_list_comments_args', $r);
    // 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'];
            $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');
    }
    if (empty($r['walker'])) {
        $walker = new Walker_Comment();
    } else {
        $walker = $r['walker'];
    }
    $output = $walker->paged_walk($_comments, $r['max_depth'], $r['page'], $r['per_page'], $r);
    $wp_query->max_num_comment_pages = $walker->max_pages;
    $in_comment_loop = false;
    if ($r['echo']) {
        echo $output;
    } else {
        return $output;
    }
}
Example #24
0
/**
 * List comments.
 *
 * Used in the comments.php template to list comments for a particular post.
 *
 * @since 2.7.0
 *
 * @see WP_Query->comments
 *
 * @global WP_Query $wp_query
 * @global int      $comment_alt
 * @global int      $comment_depth
 * @global int      $comment_thread_alt
 * @global bool     $overridden_cpage
 * @global bool     $in_comment_loop
 *
 * @param string|array $args {
 *     Optional. Formatting options.
 *
 *     @type object $walker            Instance of a Walker class to list comments. Default null.
 *     @type int    $max_depth         The maximum comments depth. Default empty.
 *     @type string $style             The style of list ordering. Default 'ul'. Accepts 'ul', 'ol'.
 *     @type string $callback          Callback function to use. Default null.
 *     @type string $end-callback      Callback function to use at the end. Default null.
 *     @type string $type              Type of comments to list.
 *                                     Default 'all'. Accepts 'all', 'comment', 'pingback', 'trackback', 'pings'.
 *     @type int    $page              Page ID to list comments for. Default empty.
 *     @type int    $per_page          Number of comments to list per page. Default empty.
 *     @type int    $avatar_size       Height and width dimensions of the avatar size. Default 32.
 *     @type string $reverse_top_level Ordering of the listed comments. Default null. Accepts 'desc', 'asc'.
 *     @type bool   $reverse_children  Whether to reverse child comments in the list. Default null.
 *     @type string $format            How to format the comments list.
 *                                     Default 'html5' if the theme supports it. Accepts 'html5', 'xhtml'.
 *     @type bool   $short_ping        Whether to output short pings. Default false.
 *     @type bool   $echo              Whether to echo the output or return it. Default true.
 * }
 * @param array $comments Optional. Array of WP_Comment objects.
 */
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' => '', 'format' => current_theme_supports('html5', 'comment-list') ? 'html5' : 'xhtml', 'short_ping' => false, 'echo' => true);
    $r = wp_parse_args($args, $defaults);
    /**
     * Filter the arguments used in retrieving the comment list.
     *
     * @since 4.0.0
     *
     * @see wp_list_comments()
     *
     * @param array $r An array of arguments for displaying comments.
     */
    $r = apply_filters('wp_list_comments_args', $r);
    // 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 'page' or 'per_page' has been passed, and does not match what's in $wp_query,
         * perform a separate comment query and allow Walker_Comment to paginate.
         */
        if ($r['page'] || $r['per_page']) {
            $current_cpage = get_query_var('cpage');
            if (!$current_cpage) {
                $current_cpage = 'newest' === get_option('default_comments_page') ? 1 : $wp_query->max_num_comment_pages;
            }
            $current_per_page = get_query_var('comments_per_page');
            if ($r['page'] != $current_cpage || $r['per_page'] != $current_per_page) {
                $comments = get_comments(array('post_id' => get_the_ID(), 'orderby' => 'comment_date_gmt', 'order' => 'ASC', 'status' => 'all'));
                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;
                }
            }
            // Otherwise, fall back on the comments from `$wp_query->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 ($wp_query->max_num_comment_pages) {
                $default_comments_page = get_option('default_comments_page');
                $cpage = get_query_var('cpage');
                if ('newest' === $default_comments_page) {
                    $r['cpage'] = $cpage;
                    /*
                     * When first page shows oldest comments, post permalink is the same as
                     * the comment permalink.
                     */
                } elseif ($cpage == 1) {
                    $r['cpage'] = '';
                } else {
                    $r['cpage'] = $cpage;
                }
                $r['page'] = 0;
                $r['per_page'] = 0;
            }
        }
    }
    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'];
            $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');
    }
    wp_queue_comments_for_comment_meta_lazyload($_comments);
    if (empty($r['walker'])) {
        $walker = new Walker_Comment();
    } else {
        $walker = $r['walker'];
    }
    $output = $walker->paged_walk($_comments, $r['max_depth'], $r['page'], $r['per_page'], $r);
    $in_comment_loop = false;
    if ($r['echo']) {
        echo $output;
    } else {
        return $output;
    }
}
Example #25
0
			?>
		</h2>

		<?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // are there comments to navigate through ?>
		<nav id="comment-nav-above">
			<h1 class="section-heading"><?php _e( 'Comment navigation', 'duster' ); ?></h1>
			<div class="nav-previous"><?php previous_comments_link( __( '&larr; Older Comments', 'duster' ) ); ?></div>
			<div class="nav-next"><?php next_comments_link( __( 'Newer Comments &rarr;', 'duster' ) ); ?></div>
		</nav>
		<?php endif; // check for comment navigation ?>

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

		<?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // are there comments to navigate through ?>
		<nav id="comment-nav-below">
			<h1 class="section-heading"><?php _e( 'Comment navigation', 'duster' ); ?></h1>
			<div class="nav-previous"><?php previous_comments_link( __( '&larr; Older Comments', 'duster' ) ); ?></div>
			<div class="nav-next"><?php next_comments_link( __( 'Newer Comments &rarr;', 'duster' ) ); ?></div>
		</nav>
		<?php endif; // check for comment navigation ?>

	<?php else : // this is displayed if there are no comments so far ?>

		<?php if ( comments_open() ) : // If comments are open, but there are no comments ?>

		<?php else : // or, if we don't have comments:

			/* If there are no comments and comments are closed,
			 * let's leave a little note, shall we?
function mobiler_comments($comment, $args, $depth)
{
    $GLOBALS['comment'] = $comment;
    extract($args, EXTR_SKIP);
    if ('div' == $args['style']) {
        $tag = 'div';
        $add_below = 'comment';
    } else {
        $tag = 'li';
        $add_below = 'div-comment';
    }
    ?>
	<<?php 
    echo $tag;
    ?>
 <?php 
    comment_class(empty($args['has_children']) ? '' : 'parent');
    ?>
 id="comment-<?php 
    comment_ID();
    ?>
">
	<?php 
    if ('div' != $args['style']) {
        ?>
	<div id="div-comment-<?php 
        comment_ID();
        ?>
" class="comment-body">
	<?php 
    }
    ?>
	<div class="row">
		<div class="col-xs-2">
			<?php 
    if ($args['avatar_size'] != 0) {
        echo get_avatar($comment, $args['avatar_size']);
    }
    ?>
		</div>
		<div class="col-xs-10">
			<div class="row">
				<div class="comment-author vcard col-xs-9">
				
				<?php 
    printf(__('<cite class="fn">%s</cite> <span class="says">pisze:</span>'), get_comment_author_link());
    ?>
				</div>

				<div class="comment-meta commentmetadata col-xs-3"><a href="<?php 
    echo htmlspecialchars(get_comment_link($comment->comment_ID));
    ?>
">
					<?php 
    /* translators: 1: date, 2: time */
    printf(__('%1$s o %2$s', 'mobiler'), get_comment_date(), get_comment_time());
    ?>
</a><?php 
    edit_comment_link(__('(Edytuj)', 'mobiler'), '  ', '');
    ?>
				</div>
			</div>
			<?php 
    comment_text();
    ?>
			<?php 
    if ($comment->comment_approved == '0') {
        ?>
				<br /><em class="comment-awaiting-moderation"><?php 
        _e('Twój komentarz czeka na moderację.', 'mobiler');
        ?>
</em><br />
				<?php 
    }
    ?>
			<div class="reply btn btn-sm btn-default pull-right">
			<?php 
    comment_reply_link(array_merge($args, array('add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth'])));
    ?>
			</div></div></div>
			<hr />
			<?php 
    if ('div' != $args['style']) {
        ?>
		</div>
		
	</div>
	<?php 
        if (get_comment_pages_count() > 1) {
            ?>
		<nav class="row" role="navigation">
			<div class="pull-left"><?php 
            previous_comments_link(__('&larr; Starsze komentarze', 'mobiler'));
            ?>
</div>
			<div class="pull-right"><?php 
            next_comments_link(__('Nowsze komentarze &rarr;', 'mobiler'));
            ?>
</div>
		</nav><!-- .comment-navigation -->
		<?php 
        }
        // Check for comment navigation
        ?>
	<?php 
    }
    ?>
	
<?php 
}
Example #27
0
 /**
  * @return int
  */
 function number_of_comment_pages()
 {
     if (!$this->uses_paged_comments()) {
         $number = 1;
     } else {
         $this->_push_wp_query('initialize');
         get_comment_pages_count($this->comments(), $this->comments_per_page(), $this->uses_threaded_comments());
         $this->_pop_wp_query();
     }
     return $number;
 }
Example #28
0
     * 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 
        _e('Comment navigation', 'sennzaversion3');
        ?>
</h1>
				<div class="nav-previous"><?php 
        previous_comments_link(__('&larr; Older Comments', 'sennzaversion3'));
        ?>
</div>
				<div class="nav-next"><?php 
        next_comments_link(__('Newer Comments &rarr;', 'sennzaversion3'));
        ?>
</div>
Example #29
0
/**
 * Create pagination links for the comments on the current post.
 *
 * @see paginate_links()
 * @since 2.7.0
 *
 * @global WP_Rewrite $wp_rewrite
 *
 * @param string|array $args Optional args. See paginate_links().
 * @return string|void Markup for pagination links.
*/
function paginate_comments_links($args = array())
{
    global $wp_rewrite;
    if (!is_singular() || !get_option('page_comments')) {
        return;
    }
    $page = get_query_var('cpage');
    if (!$page) {
        $page = 1;
    }
    $max_page = get_comment_pages_count();
    $defaults = array('base' => add_query_arg('cpage', '%#%'), 'format' => '', 'total' => $max_page, 'current' => $page, 'echo' => true, 'add_fragment' => '#comments');
    if ($wp_rewrite->using_permalinks()) {
        $defaults['base'] = user_trailingslashit(trailingslashit(get_permalink()) . $wp_rewrite->comments_pagination_base . '-%#%', 'commentpaged');
    }
    $args = wp_parse_args($args, $defaults);
    $page_links = paginate_links($args);
    if ($args['echo']) {
        echo $page_links;
    } else {
        return $page_links;
    }
}
    public function sfw_comment_form_header()
    {
        global $comment;
        // Comment form header start
        if (post_password_required()) {
            ?>
			<p class="sfw-no-password">This post is password protected. Enter the password to view comments.</p>
			<?php 
            return;
        }
        // if comments are open
        if (have_comments()) {
            ?>
			<h2 id="sfw-comments-title">
			<?php 
            printf(_n('One comment on &ldquo;%2$s&rdquo;', '%1$s comments on &ldquo;%2$s&rdquo;', get_comments_number()), number_format_i18n(get_comments_number()), '<span>' . get_the_title() . '</span>');
            ?>
			</h2>
			<?php 
            // Generates the list of comments
            ?>
			<ol class="sfw-commentlist">
			<?php 
            wp_list_comments(array('callback' => array($this, 'SFWlist_comments')));
            ?>
			</ol>
			<?php 
            // if comments are paginated (broken into pages) provides link to next and previous page
            if (get_comment_pages_count() > 1 && get_option('page_comments')) {
                // are there comments to navigate through
                ?>
				<div id="sfw-comment-nav-above">
					<div class="sfw-nav-previous">
					<?php 
                previous_comments_link('&larr; Older Comments');
                ?>
					</div>
					<div class="sfw-nav-next">
					<?php 
                next_comments_link('Newer Comments &rarr;');
                ?>
					</div>
				</div>
				<?php 
            }
        } elseif (!comments_open() && !is_page() && post_type_supports(get_post_type(), 'comments')) {
            ?>
			<p class="sfw-nocomments">Comments are closed.</p>
			<?php 
        }
        // Comment form header end
        // Call the comment form template
        $this->sfw_comment_form();
    }