Example #1
0
/**
 * Theme comment walker
 *
 * @param $comment
 * @param $args
 * @param $depth
 */
function mutheme_comment($comment, $args, $depth)
{
    $GLOBALS['comment'] = $comment;
    global $commentcount;
    if (!$commentcount) {
        $page = !empty($in_comment_loop) ? get_query_var('cpage') - 1 : get_page_of_comment($comment->comment_ID, $args) - 1;
        $cpp = get_option('comments_per_page');
        $commentcount = $cpp * $page;
    }
    if (!$comment->comment_parent) {
        //$email  = $comment->comment_author_email;
        $avatar = get_avatar($comment, $size = '50');
        ?>
		<li <?php 
        comment_class();
        ?>
 id="li-comment-<?php 
        comment_ID();
        ?>
">
		<div id="comment-<?php 
        comment_ID();
        ?>
" class="comment-body">
			<div class="comment-avatar"><?php 
        echo $avatar;
        ?>
</div>
					<span class="comment-floor"><?php 
        ++$commentcount;
        switch ($commentcount) {
            case 1:
                print_r("沙发");
                break;
            case 2:
                print_r("板凳");
                break;
            case 3:
                print_r("地板");
                break;
            default:
                printf(__('%s楼'), $commentcount);
        }
        ?>
</span>

			<div class="comment-data">
				<span class="comment-span <?php 
        if ($comment->user_id == 1) {
            echo "comment-author";
        }
        ?>
"><?php 
        printf(__('%s'), get_comment_author_link());
        ?>
</span>
				<span
					class="comment-span comment-date"><?php 
        echo mutheme_time_since(abs(strtotime($comment->comment_date_gmt . "GMT")), true);
        ?>
</span>
			</div>
			<div class="comment-text"><?php 
        comment_text();
        ?>
</div>
			<div class="comment-reply"><?php 
        comment_reply_link(array_merge($args, array('depth' => $depth, 'max_depth' => $args['max_depth'], 'reply_text' => __('回复'))));
        ?>
</div>
		</div>
	<?php 
    } else {
        ?>
	<li <?php 
        comment_class();
        ?>
 id="li-comment-<?php 
        comment_ID();
        ?>
">
		<div id="comment-<?php 
        comment_ID();
        ?>
" class="comment-body comment-children-body">
			<div class="comment-avatar"><?php 
        echo get_avatar($comment, $size = '30');
        ?>
</div>
			<span
				class="comment-floor"><?php 
        comment_reply_link(array_merge($args, array('depth' => $depth, 'max_depth' => $args['max_depth'], 'reply_text' => __('回复'))));
        ?>
</span>

			<div class="comment-data">
				<span class="comment-span <?php 
        if ($comment->user_id == 1) {
            echo "comment-author";
        }
        ?>
">
					<?php 
        $parent_id = $comment->comment_parent;
        $comment_parent = get_comment($parent_id);
        printf(__('%s'), get_comment_author_link());
        ?>
				</span>
				<span
					class="comment-span comment-date"><?php 
        echo mutheme_time_since(abs(strtotime($comment->comment_date_gmt . "GMT")), true);
        ?>
</span>
			</div>
			<div class="comment-text">
				<span class="comment-to"><a href="<?php 
        echo "#comment-" . $parent_id;
        ?>
"
				                            title="<?php 
        echo mb_strimwidth(strip_tags(apply_filters('the_content', $comment_parent->comment_content)), 0, 100, "...");
        ?>
">@<?php 
        echo $comment_parent->comment_author;
        ?>
</a>:</span>
				<?php 
        echo get_comment_text();
        ?>
			</div>
		</div>
	<?php 
    }
}
Example #2
0
    function widget($args, $instance)
    {
        extract($args);
        $limit = strip_tags($instance['limit']);
        $limit = $limit ? $limit : 5;
        ?>
		<div class="widget widget-comment">
			<h3><?php 
        _e('Latest comments', MUTHEME_NAME);
        ?>
</h3>
			<ul>
				<?php 
        $comments = get_comments("user_id=0&number={$limit}&status=approve&type=comment");
        foreach ($comments as $comment) {
            ?>
					<li>
						<p>
							<a href="<?php 
            echo get_permalink($comment->comment_post_ID);
            ?>
#comment-<?php 
            echo $comment->comment_ID;
            ?>
">
								<?php 
            echo $comment->comment_content;
            ?>
							</a>
						</p>

						<p>
							<?php 
            echo get_avatar($comment->comment_author_email, 32);
            ?>
							<?php 
            echo $comment->comment_author;
            ?>
							<span><?php 
            echo mutheme_time_since(strtotime($comment->comment_date_gmt));
            ?>
</span>
						</p>
					</li>
				<?php 
        }
        ?>
			</ul>
		</div>
	<?php 
    }
Example #3
0
        if (is_sticky()) {
            ?>
								<span class="post-sticky"><?php 
            _e('Stick', MUTHEME_NAME);
            ?>
</span>
							<?php 
        }
        ?>
						</h2>
					</div>
					<div class="post-meta">
						<ul class="inline-ul">
							<li class="inline-li">
								<?php 
        echo mutheme_time_since(strtotime($post->post_date_gmt));
        ?>
							</li>
							<li class="inline-li">
								<span class="post-span">·</span>
							</li>
							<li class="inline-li">
								<?php 
        the_category(' , ');
        ?>
							</li>
							<?php 
        mutheme_views();
        ?>
							<li class="inline-li">
								<span class="post-span">·</span>
Example #4
0
    function widget($args, $instance)
    {
        extract($args);
        $limit = strip_tags($instance['limit']);
        $limit = $limit ? $limit : 8;
        ?>
		<div class="widget widget-modified">
			<h3>最近更新的文章</h3>
			<ul class="list">
				<?php 
        $args = array('orderby' => 'modified', 'ignore_sticky_posts' => 1, 'post_type' => 'post', 'post_status' => 'publish', 'showposts' => $limit);
        $index = 0;
        $posts = query_posts($args);
        ?>
				<?php 
        while (have_posts()) {
            the_post();
            ?>
					<li>
						<p>
							<a href="<?php 
            the_permalink();
            ?>
" rel="bookmark"
							   title="<?php 
            the_title();
            ?>
"><?php 
            the_title();
            ?>
</a>
						</p>

						<p>
							更新时间:<span><?php 
            echo mutheme_time_since(abs(strtotime($posts[$index]->post_modified_gmt)));
            ?>
</span>
						</p>
					</li>
					<?php 
            $index++;
        }
        wp_reset_query();
        $posts = null;
        ?>
			</ul>
		</div>
	<?php 
    }