<?php
/**
 * Template part for displaying moments
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
 *
 * @package pix
 */
$author_id = get_the_author_meta( 'ID' ); 
$url = get_author_posts_url($author_id);
$avatar = get_u_avatar($author_id,$type = 'url');
$type = !empty($args) ? $args['type'] : false;
$badges = function_exists('ppo_user_badges_html') ? ppo_user_badges_html($author_id, 'moment') : '';
?>

<div id="post-<?php the_ID(); ?>" <?php post_class('post-item moment_item uk-animation-slide-bottom-small'); ?>>
    <div class="moment-single-inner">

    <div class="top-header">
        <div class="moment-avatar">           
                <a href="<?php echo $url; ?>" target="_blank">
                    <img class="mo-ava lazy" data-src="<?php echo $avatar; ?>" alt="" uk-img="loading: lazy">
                </a>
        </div><!-- .entry-header -->

        <div class="top-meta">
            <div class="mo-meta">
                <div lcass="left">
                    <div class="nickname"><a href="<?php echo $url; ?>" target="_blank"><?php the_author(); ?></a><?php echo $badges; ?></div>
                    <div class="lv-info"></div>
                </div>
                <div class="right">
                <?php if(is_sticky()){ ?>
                        <span class="sticky_m_icon"><i class="ri-upload-line"></i>置顶</span>
                    <?php } else {
                        echo get_moment_first_cat($post->ID);
                    } ?>
                    
                </div>
            </div>

            <div class="mosub-meta">
                <time class="timeago" itemprop="datePublished" datetime="<?php echo get_the_date('c');?>"><?php echo ''.get_gmt_from_date(get_the_time('Y-m-d G:i:s')); ?></time>
            </div>
        </div>
    </div>

        <div class="moment-content-right">

            <div class="post-content mos-content">
                <div class="momoent_title"><a href="<?php echo get_permalink();?>"><?php the_title();  ?></a></div>
                <div class="ppo-rich-text"><div class="ppo-rich-text-content" data-max-length="200"><p><?php echo ppo_moment_filter(); ?></p></div></div>
                <?php echo get_moment_type_content(); ?>
                <?php echo get_moment_tag_link($post->ID); ?>
            </div>

            
        </div><!-- .entry-content -->

    
    </div>


    <?php if($type != 'pending'){ ?>

        <div class="moment-footer">
                <div class="left">
                    <div class="post-like item"><?php echo post_like_btn($post->ID); ?></div>
                    <div class="post-collect item"><?php echo post_collect_btn($post->ID); ?></div>
                    <div class="moment-share item"><a class="moment-share-btn"><i class="ri-share-forward-box-line"></i></a></div>
                    <?php echo mo_edit_btn($post->ID); ?>
                </div>
                <div class="right">
                    <?php if(is_moment_hot($post->ID)){ ?>
                        <span class="hot_m_icon"><i class="ri-vip-diamond-line"></i>精华</span>
                    <?php } ?>
                    <a class="moment-comment-btn" pid="<?php echo get_the_ID(); ?>"><i class="ri-message-3-line"></i><span class="comment-count"><?php echo get_comments_number(); ?></span></a>
                </div>
            </div><!-- .entry-footer -->

    <div class="moment_comments_wrap t_com_<?php echo $post->ID; ?>" style="display:none">
				<?php
					global $withcomments;
					$withcomments = true;
					comments_template('inc/layouts/comment-tmp.php'); 				
				?>
			</div>

    <?php } else { ?>

    <div class="moment-footer pending-footer" pid="<?php echo $post->ID; ?>">
        <div class="left">
            <a href="<?php echo home_url('/moment-edit?pid='.$post->ID.''); ?>" target="_blank" class="mo-edit-page"><i class="ri-edit-line"></i>重新编辑</a>
        </div>

        <div class="btn-group right">
            <a class="mo-pending-allow" action="allow">批准</a>
            <a class="mo-pending-remove" action="remove">删除</a>
        </div>
    </div>

    <?php } ?>
    

</div><!-- #post-<?php the_ID(); ?> -->
