Exemplo n.º 1
0
        function widget($args, $instance)
        {
            extract($args);
            $title = apply_filters('widget_title', apply_filters('yit_recent_comments_widget_title', empty($instance['title']) ? __('Recent comments', 'yit') : $instance['title']));
            echo $before_widget;
            if ($title) {
                echo $before_title . $title . $after_title;
            }
            $defaults = array('title' => __('Recent Comments', 'yit'), 'number' => 5, 'show_avatar' => 'yes', 'show_author' => 'yes', 'show_content' => 'yes', 'excerpt_length' => 12);
            $instance = wp_parse_args((array) $instance, $defaults);
            $items = $instance['number'];
            $avatar = $instance['show_avatar'];
            $author = $instance['show_author'];
            $content = $instance['show_content'];
            $excerpt_length = $instance['excerpt_length'];
            $comments = get_comments(array('number' => $items, 'type' => 'comment', 'status' => 'approve'));
            ?>
<div class="recent-comments-list group"><?php 
            foreach ($comments as $comment) {
                $user = get_userdata($comment->user_id);
                $comment_author_gravatar_mail = is_object($user) ? $user->data->user_email : $comment->comment_author_email;
                ?>

            <div class="comment-container">
                <div class="the-post group">

                <?php 
                if ($avatar == 'yes') {
                    ?>
                    <div class="gravatar-wrapper">
                        <?php 
                    echo get_avatar($comment, 46);
                    ?>
                    </div>
                <?php 
                }
                ?>

                <div class="comments-info-wrapper">
                    <?php 
                if ($author == 'yes') {
                    ?>
                        <span class="author">
                            <?php 
                    if (!empty($comment->comment_author_url)) {
                        ?>
                                <a class="url" href="<?php 
                        echo $comment->comment_author_url;
                        ?>
">
                            <?php 
                    } elseif (!empty($comment_author_gravatar_mail)) {
                        ?>
                                <a class="email" href="mailto:<?php 
                        echo $comment_author_gravatar_mail;
                        ?>
">
                            <?php 
                    }
                    ?>

                            <?php 
                    echo $comment->comment_author;
                    ?>
                                <?php 
                    if (!empty($comment->comment_author_url) && $comment->comment_author_url != '' || !empty($comment_author_gravatar_mail) && $comment_author_gravatar_mail != '') {
                        ?>
                                </a>
                            <?php 
                    }
                    ?>
                            <?php 
                    _e('on', 'yit');
                    ?>
                        </span>
                    <?php 
                }
                ?>
                    <a class="title" href="<?php 
                echo get_permalink($comment->comment_post_ID) . '#comment-' . $comment->comment_ID;
                ?>
"><?php 
                echo get_the_title($comment->comment_post_ID);
                ?>
</a>
                </div>
            </div>

            <?php 
                if ($content == 'yes') {
                    ?>

                <p class="comment arrow">
                    <?php 
                    yit_excerpt_text(strip_tags($comment->comment_content), $excerpt_length, '...');
                    ?>
                </p>

            <?php 
                }
                ?>
        </div>
        <?php 
            }
            ?>
    </div>
        <?php 
            echo $after_widget;
        }
Exemplo n.º 2
0
    function widget( $args, $instance )
    {
        extract( $args );

        $title = apply_filters('widget_title', empty( $instance['title'] ) ? __( 'Recent comments', 'yit' ) : $instance['title'] );
        
        echo $before_widget;                   

        if ( $title ) echo $before_title . $title . $after_title;    
        
        $defaults = array( 
            'title' => __( 'Recent Comments', 'yit' ),
            'number' => 5,
            'show_avatar' => 'yes',
            'show_author' => 'yes',
            'show_content' => 'yes',
            'excerpt_length' => 12
        );
        
        $instance = wp_parse_args( (array) $instance, $defaults );  
        
        $items  = $instance['number'];
        $avatar = $instance['show_avatar'];
        $author = $instance['show_author'];
        $content = $instance['show_content'];
        $excerpt_length = $instance['excerpt_length'];
        
        $comments = get_comments( array( 'number' => $items, 'type' => 'comment' ) ); 
        
        ?><div class="recent-post recent-comments group"><?php
    
        foreach( $comments as $comment ) : 
                
            $ncomments = get_comments_number( $comment->comment_post_ID ); ?>  
                  
            <div class="the-post group">  
            
                <?php if ( $avatar == 'yes' ) : ?>
                <div class="avatar">
                    <?php echo get_avatar( $comment, 55 ); ?>   
                </div> 
                <?php endif ?>     
                                     
                <?php if ( $author == 'yes' ) : ?>
                <span class="author"><strong>
                    <?php if ( ! empty( $comment->comment_author_url ) ) : ?>
                    <a href="<?php echo $comment->comment_author_url ?>">
                    <?php elseif ( ! empty( $comment->comment_author_email ) ) : ?>    
                    <a href="mailto:<?php echo $comment->comment_author_email ?>">
                    <?php endif; ?>
                    <?php echo $comment->comment_author ?>
                    <?php if ( (! empty( $comment->comment_author_url ) && $comment->comment_author_url != '') || (! empty( $comment->comment_author_email ) && $comment->comment_author_email != '') ) : ?>
                    </a>
                    <?php endif; ?>
                    </strong> <?php _e( 'in', 'yit' ) ?></span>
                <?php endif ?>               
                
                <a class="title" href="<?php echo get_permalink( $comment->comment_post_ID ) . '#comment-' . $comment->comment_ID ?>"><?php echo get_the_title( $comment->comment_post_ID ) ?></a>
                
                <?php if ( $content == 'yes' ) : ?>
                <p class="comment">
                    <?php yit_excerpt_text( strip_tags( $comment->comment_content ), $excerpt_length, '...' ) ?>
                    <a class="goto" href="<?php echo get_permalink( $comment->comment_post_ID ) . '#comment-' . $comment->comment_ID ?>">&#187;</a>
                </p>
                <?php endif ?>
            </div>
        
        <?php endforeach;  
        
        ?></div><?php
        
        echo $after_widget;
    }                     
Exemplo n.º 3
0
    function widget( $args, $instance ) {

        extract( $args );

        wp_enqueue_script( 'owl-carousel' );

        $title = apply_filters( 'yit_recent_reviews_widget_title', empty( $instance['title'] ) ? __( 'Recent reviews', 'yit' ) : $instance['title'] );

        echo $before_widget;

        if ( $title ) {
            echo $before_title . $title . $after_title;
        }

        $id = ( isset( $instance['product'] ) && ($instance['product'] != '' || $instance['product'] != 'all' ) ) ? (int) $instance['product'] : 0;

        $attribute = array(
            'number' => $instance['number'],
            'type'   => 'comment',
            'status' => 'approve',
            'orderby' => 'date',
            'order' => 'DESC',
        );
        if ( $id != 0 ) {
            $attribute['post_id'] = $id;
        }
        else {
            $attribute['post_type'] = 'product';
        }

        $autoplay = ($instance['autoplay'] == 'yes' || $instance['autoplay']===true) ? 'true' : 'false';

        $reviews = get_comments( $attribute );

        ?>
        <div class="reviews_container_widget">

            <ul class="slides-reviews-widget" data-slidespeed="<?php echo $instance['slidespeed'] ?>" data-autoplay="<?php echo $autoplay ?>">
                <?php foreach ( $reviews as $review ) : ?>
                    <li class="clearfix">

                        <div class="review-content arrow-down">
                            <p itemprop="description" class="description"><?php yit_excerpt_text( strip_tags( $review->comment_content ), $instance['excerpt_length'], '...' ) ?></p>
                        </div>

                        <div class="review-meta-avatar">

                            <?php if ( $instance['show_avatar'] == 'yes' ) : ?>
                            <div class="avatar-thumb">
                                <?php echo get_avatar( $review->comment_author_email, $size = '58' ); ?>
                            </div>
                            <?php endif ?>

                            <div class="clearfix meta">
                                <div class="author" itemprop="author"><?php echo $review->comment_author; ?></div>
                                <div class="product-review-link">
                                    <a href="<?php echo get_permalink( $review->ID ) ?>"><?php _e( 'on ', 'yit' ); echo $review->post_title; ?></a>
                                </div>
                                <?php if ( $instance['show_rating'] == 'yes' ) :
                                    $rating = esc_attr( get_comment_meta( $review->comment_ID, 'rating', true ) ); ?>
                                    <div class="star-rating"><span style="width:<?php echo ( $rating / 5 ) * 100 ?>%"></span></div>
                                <?php endif; ?>
                            </div>

                        </div>

                    </li>
                <?php endforeach; ?>
            </ul>

        </div>

        <div class="clearfix"></div>
        <?php

        echo $after_widget;

    }