function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
        $gallery = $instance['kpgallery'];
        $animation = $instance['animation'];
        $direction = $instance['direction'];
        $slideshowSpeed = $instance['slideshowSpeed'];
        $animationSpeed = $instance['animationSpeed'];
        $is_Autoplay = $instance['isAutoplay'];
        $gal_content_post = get_post($gallery);
        $gal_content = $gal_content_post->post_content;
        $gal_ids = kopa_content_get_gallery_attachment_ids($gal_content);
        ?>

        <?php 
        echo $before_widget;
        if (!empty($title)) {
            echo $before_title . $title . $after_title;
        }
        ?>
        <div class="flexslider kp-gallery-slider loading" data-animation = "<?php 
        echo $animation;
        ?>
" data-direction = "<?php 
        echo $direction;
        ?>
" data-slideshow-speed = "<?php 
        echo $slideshowSpeed;
        ?>
" data-animation-speed = "<?php 
        echo $animationSpeed;
        ?>
" data-autoplay = "<?php 
        echo $is_Autoplay;
        ?>
">
            <ul class="slides">
                <?php 
        foreach ($gal_ids as $id) {
            if (wp_attachment_is_image($id)) {
                ?>
                        <li><?php 
                echo wp_get_attachment_image($id, 'kopa-image-size-2');
                if (get_post_field('post_excerpt', $id)) {
                    ?>
                                <div class="kp-gallery-caption " style="text-align: center" >
                                    <?php 
                    echo get_post_field('post_excerpt', $id);
                    ?>

                                </div>
                            <?php 
                }
                // endif
                ?>
                        </li>
                        <?php 
            }
            ?>

                <?php 
        }
        ?>
            </ul>
            <!--slides -->
        </div><!--flexslider -->
        <?php 
        echo $after_widget;
    }
Example #2
0
            // 496 x 346
            $kopa_has_printed_thumbnail = true;
        } elseif ('video' == get_post_format()) {
            $video = kopa_content_get_video(get_the_content());
            if (isset($video[0])) {
                $video = $video[0];
            } else {
                $video = '';
            }
            if (isset($video['type']) && isset($video['url'])) {
                $video_thumbnail_url = kopa_get_video_thumbnails_url($video['type'], $video['url']);
                echo '<img src="' . esc_url($video_thumbnail_url) . '" alt="' . get_the_title() . '">';
                $kopa_has_printed_thumbnail = true;
            }
        } elseif ('gallery' == get_post_format()) {
            $gallery_ids = kopa_content_get_gallery_attachment_ids(get_the_content());
            if (!empty($gallery_ids)) {
                foreach ($gallery_ids as $id) {
                    if (wp_attachment_is_image($id)) {
                        echo wp_get_attachment_image($id, 'kopa-image-size-6');
                        // 496 x 346
                        $kopa_has_printed_thumbnail = true;
                        break;
                    }
                }
            }
        }
        // endif has_post_thumbnail
        ?>

                <?php 
Example #3
0
 function kopa_ajax_load_quick_sort_articles()
 {
     if (!wp_verify_nonce($_POST['wpnonce'], 'kopa_load_quick_sort_articles')) {
         echo null;
         die;
     }
     $output = '';
     $offset = $_POST['offset'];
     $categories = $_POST['categories'];
     $categories = explode(',', $categories);
     $posts_per_page = $_POST['posts_per_page'];
     $orderby = $_POST['orderby'];
     $post__not_in = explode(',', $_POST['post__not_in']);
     $query_args = array('category__in' => $categories, 'posts_per_page' => $posts_per_page);
     if ($orderby != 'random') {
         $query_args['offset'] = $offset;
     }
     switch ($orderby) {
         case 'popular':
             $query_args['meta_key'] = 'kopa_' . kopa_get_domain() . '_total_view';
             $query_args['orderby'] = 'meta_value_num';
             break;
         case 'most_comment':
             $query_args['orderby'] = 'comment_count';
             break;
         case 'random':
             $query_args['orderby'] = 'rand';
             $query_args['post__not_in'] = $post__not_in;
             break;
         default:
             $query_args['orderby'] = 'date';
             break;
     }
     $posts = new WP_Query($query_args);
     if ($posts->have_posts()) {
         while ($posts->have_posts()) {
             $posts->the_post();
             array_push($post__not_in, get_the_ID());
             $post_terms = get_the_terms(get_the_ID(), 'category');
             $data_category = array();
             $has_printed_thumbnail = false;
             if ('video' == get_post_format()) {
                 $data_icon = 'video';
                 // icon-film-2
             } elseif ('gallery' == get_post_format()) {
                 $data_icon = 'images';
                 // icon-images
             } elseif ('audio' == get_post_format()) {
                 $data_icon = 'music';
                 // icon-music
             } else {
                 $data_icon = 'pencil';
                 // icon-pencil
             }
             foreach ($post_terms as $post_term) {
                 if (in_array($post_term->term_id, $categories)) {
                     array_push($data_category, $post_term->slug);
                 }
             }
             if (!empty($data_category)) {
                 $data_category = implode(' ', $data_category);
             } else {
                 $data_category = '';
             }
             $output .= '<article class="element ' . $data_category . '" data-category="' . $data_category . '">';
             $output .= '<div class=top-line>';
             $output .= '</div><div class=entry-thumb>';
             if (has_post_thumbnail()) {
                 $output .= wp_get_attachment_image(get_post_thumbnail_id(), 'kopa-image-size-6');
                 // 496 x 346
                 $has_printed_thumbnail = true;
             } elseif ('video' == get_post_format()) {
                 $video = kopa_content_get_video(get_the_content());
                 if (isset($video[0])) {
                     $video = $video[0];
                 } else {
                     $video = '';
                 }
                 if (isset($video['type']) && isset($video['url'])) {
                     $video_thumbnail_url = kopa_get_video_thumbnails_url($video['type'], $video['url']);
                     $output .= '<img src="' . esc_url($video_thumbnail_url) . '" alt="' . get_the_title() . '">';
                     $has_printed_thumbnail = true;
                 }
             } elseif ('gallery' == get_post_format()) {
                 $gallery_ids = kopa_content_get_gallery_attachment_ids(get_the_content());
                 if (!empty($gallery_ids)) {
                     foreach ($gallery_ids as $id) {
                         if (wp_attachment_is_image($id)) {
                             $output .= wp_get_attachment_image($id, 'kopa-image-size-6');
                             // 496 x 346
                             $has_printed_thumbnail = true;
                             break;
                         }
                     }
                 }
             }
             // endif has_post_thumbnail
             if ($has_printed_thumbnail) {
                 $output .= '<a href="' . get_permalink() . '">' . KopaIcon::getIcon('long-arrow-right') . '</a>';
             }
             $output .= '</div>';
             $output .= '<div class=entry-content><header>';
             $output .= '<h4 class="entry-title clearfix">' . KopaIcon::getIcon($data_icon, 'span') . '<a href="' . get_permalink() . '">' . get_the_title() . '</a></h4>';
             $output .= '<div class="meta-box">';
             $output .= '<span class="entry-date">' . get_the_time(get_option('date_format')) . '</span> ';
             $output .= '<span class="entry entry-author">' . __('By', kopa_get_domain()) . ' <a href="' . get_author_posts_url(get_the_author_meta('ID')) . '" title="' . __('Posts by', kopa_get_domain()) . ' ' . get_the_author() . '" rel="author">' . get_the_author() . '</a></span>';
             $output .= '</div></header>';
             $output .= '<p>' . get_the_excerpt() . '</p>';
             $output .= '<footer class=clearfix>';
             $output .= '<div class=meta-box>';
             $output .= '<span class=entry-comments>' . KopaIcon::getIcon('comment', 'span');
             if (comments_open()) {
                 $output .= '<a href="' . get_comments_link() . '" title="' . __('Comment on') . ' ' . get_the_title() . '">' . get_comments_number() . '</a>';
             } else {
                 $output .= '<span>' . __('Off', kopa_get_domain()) . '</span>';
             }
             $output .= '</span> ';
             if ('show' == get_option('kopa_theme_options_view_count_status', 'show') && true == get_post_meta(get_the_ID(), 'kopa_' . kopa_get_domain() . '_total_view', true)) {
                 $output .= '<span class=entry-view>' . KopaIcon::getIcon('view', 'span') . get_post_meta(get_the_ID(), 'kopa_' . kopa_get_domain() . '_total_view', true) . '</span>';
             }
             $output .= '</div> <!-- .meta-box -->';
             $post_rating = round(get_post_meta(get_the_ID(), 'kopa_editor_user_total_all_rating_' . kopa_get_domain(), true));
             if (!empty($post_rating)) {
                 $output .= '<ul class="kopa-rating clearfix">';
                 for ($i = 0; $i < $post_rating; $i++) {
                     $output .= '<li>' . KopaIcon::getIcon('star', 'span') . '</li>';
                 }
                 for ($i = 0; $i < 5 - $post_rating; $i++) {
                     $output .= '<li>' . KopaIcon::getIcon('star2', 'span') . '</li>';
                 }
                 $output .= '</ul>';
             }
             $output .= '</footer>';
             $output .= '</div> <!-- entry-content -->';
             $output .= '<div class=bottom-line></div>';
             $output .= '</article>';
         }
         wp_reset_postdata();
     } else {
         echo null;
         die;
     }
     $responses_data = array('output' => $output, 'post__not_in' => implode(',', $post__not_in));
     echo json_encode($responses_data);
     die;
 }
Example #4
0
    function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
        $query_args['posts_per_page'] = $instance['number_of_article'];
        $orderbys = array('lastest', 'popular', 'most_comment');
        echo $before_widget;
        if (!empty($title)) {
            echo $before_title . $title . $after_title;
        }
        ?>

        <div class="list-container-2">
            <ul class="tabs-2 clearfix">
                <li class="active"><a href="#<?php 
        echo $this->get_field_id('tab') . '-lastest';
        ?>
"><?php 
        _e('Latest', kopa_get_domain());
        ?>
</a></li>
                <li><a href="#<?php 
        echo $this->get_field_id('tab') . '-popular';
        ?>
"><?php 
        _e('Popular', kopa_get_domain());
        ?>
</a></li>
                <li><a href="#<?php 
        echo $this->get_field_id('tab') . '-most_comment';
        ?>
"><?php 
        _e('Comments', kopa_get_domain());
        ?>
</a></li>
            </ul><!--tabs-2-->
        </div>

        <div class="tab-container-2">

        <?php 
        foreach ($orderbys as $orderby) {
            $query_args['orderby'] = $orderby;
            $posts = kopa_widget_posttype_build_query($query_args);
            ?>

            <div class="tab-content-2" id="<?php 
            echo $this->get_field_id('tab') . '-' . $orderby;
            ?>
">                        
                <ul>
                <?php 
            if ($posts->have_posts()) {
                while ($posts->have_posts()) {
                    $posts->the_post();
                    ?>

                        <li>
                            <article class="entry-item clearfix">
                                <div class="entry-thumb">
                                    <?php 
                    if (has_post_thumbnail()) {
                        the_post_thumbnail('kopa-image-size-4');
                        // 81 x 81
                    } elseif ('video' == get_post_format()) {
                        $video = kopa_content_get_video(get_the_content());
                        if (isset($video[0])) {
                            $video = $video[0];
                        } else {
                            $video = '';
                        }
                        if (isset($video['type']) && isset($video['url'])) {
                            $video_thumbnail_url = kopa_get_video_thumbnails_url($video['type'], $video['url']);
                            echo '<img src="' . esc_url($video_thumbnail_url) . '" alt="' . get_the_title() . '">';
                        }
                    } elseif ('gallery' == get_post_format()) {
                        $gallery_ids = kopa_content_get_gallery_attachment_ids(get_the_content());
                        if (!empty($gallery_ids)) {
                            foreach ($gallery_ids as $id) {
                                if (wp_attachment_is_image($id)) {
                                    echo wp_get_attachment_image($id, 'kopa-image-size-4');
                                    // 81 x 81
                                    break;
                                }
                            }
                        }
                    }
                    // endif has_post_thumbnail
                    ?>
                                </div>
                                <div class="entry-content">
                                    <h4 class="entry-title"><a href="<?php 
                    the_permalink();
                    ?>
"><?php 
                    the_title();
                    ?>
</a></h4>
                                    <div class="meta-box">
                                        <span class="entry-date"><?php 
                    the_time(get_option('date_format'));
                    ?>
</span>
                                        <span class="entry-author"><?php 
                    _e('By', kopa_get_domain());
                    ?>
 <?php 
                    the_author_posts_link();
                    ?>
</span>
                                    </div>
                                </div>
                            </article>
                        </li>

                        <?php 
                }
                // endwhile
            }
            // endif
            ?>
                </ul>
            </div>

            <?php 
            wp_reset_postdata();
        }
        // endforeach
        ?>

        </div>

        <?php 
        echo $after_widget;
    }
Example #5
0
function kopa_get_related_articles()
{
    if (is_single()) {
        $get_by = kopa_get_option('kopa_theme_options_post_related_get_by');
        if ('hide' != $get_by) {
            $limit = (int) kopa_get_option('kopa_theme_options_post_related_limit');
            if ($limit > 0) {
                global $post;
                $taxs = array();
                if ('category' == $get_by) {
                    $cats = get_the_category($post->ID);
                    if ($cats) {
                        $ids = array();
                        foreach ($cats as $cat) {
                            $ids[] = $cat->term_id;
                        }
                        $taxs[] = array('taxonomy' => 'category', 'field' => 'id', 'terms' => $ids);
                    }
                } else {
                    $tags = get_the_tags($post->ID);
                    if ($tags) {
                        $ids = array();
                        foreach ($tags as $tag) {
                            $ids[] = $tag->term_id;
                        }
                        $taxs[] = array('taxonomy' => 'post_tag', 'field' => 'id', 'terms' => $ids);
                    }
                }
                if ($taxs) {
                    $related_args = array('tax_query' => $taxs, 'post__not_in' => array($post->ID), 'posts_per_page' => $limit);
                    $related_posts = new WP_Query($related_args);
                    if ($related_posts->have_posts()) {
                        ?>
                        <div class="kopa-related-post">
                            <h4><?php 
                        _e('Related Posts', kopa_get_domain());
                        ?>
</h4>
                            <div class="list-carousel responsive" >
                                <ul class="kopa-featured-news-carousel" data-pagination-id="#single_related_posts_pager" data-scroll-items="1">
                        <?php 
                        $post_index = 1;
                        while ($related_posts->have_posts()) {
                            $related_posts->the_post();
                            if ('video' == get_post_format()) {
                                $kopa_data_icon = 'film';
                                // icon-film-2
                            } elseif ('gallery' == get_post_format()) {
                                $kopa_data_icon = 'images';
                                // icon-images
                            } elseif ('audio' == get_post_format()) {
                                $kopa_data_icon = 'music';
                                // icon-music
                            } else {
                                $kopa_data_icon = 'pencil';
                                // icon-pencil
                            }
                            ?>
                                        <li>
                                            <article class="entry-item clearfix">
                                                <div class="entry-thumb">
                                        <?php 
                            // flag to determine whether or not display arrow button
                            $kopa_has_printed_thumbnail = false;
                            if (has_post_thumbnail()) {
                                the_post_thumbnail('kopa-image-size-1');
                                // 247 x 146
                                $kopa_has_printed_thumbnail = true;
                            } elseif ('video' == get_post_format()) {
                                $video = kopa_content_get_video(get_the_content());
                                if (isset($video[0])) {
                                    $video = $video[0];
                                } else {
                                    $video = '';
                                }
                                if (isset($video['type']) && isset($video['url'])) {
                                    $video_thumbnail_url = kopa_get_video_thumbnails_url($video['type'], $video['url']);
                                    echo '<img src="' . esc_url($video_thumbnail_url) . '" alt="' . get_the_title() . '">';
                                    $kopa_has_printed_thumbnail = true;
                                }
                            } elseif ('gallery' == get_post_format()) {
                                $gallery_ids = kopa_content_get_gallery_attachment_ids(get_the_content());
                                if (!empty($gallery_ids)) {
                                    foreach ($gallery_ids as $id) {
                                        if (wp_attachment_is_image($id)) {
                                            echo wp_get_attachment_image($id, 'kopa-image-size-1');
                                            // 247 x 146
                                            $kopa_has_printed_thumbnail = true;
                                            break;
                                        }
                                    }
                                }
                            }
                            // endif has_post_thumbnail
                            ?>

                                                    <?php 
                            if ($kopa_has_printed_thumbnail) {
                                ?>
                                                        <a href="<?php 
                                the_permalink();
                                ?>
"><?php 
                                echo KopaIcon::getIcon('exit');
                                ?>
</a>
                                                    <?php 
                            }
                            // endif
                            ?>
                                                </div>
                                                <div class="entry-content">
                                                    <header class="clearfix">                                               
                                                        <span class="entry-date"><?php 
                            the_time(get_option('date_format'));
                            ?>
</span>
                            <?php 
                            $post_rating = round(get_post_meta(get_the_ID(), 'kopa_editor_user_total_all_rating_' . kopa_get_domain(), true));
                            if (!empty($post_rating)) {
                                ?>
                                                            <ul class="kopa-rating clearfix">
                                                            <?php 
                                for ($i = 0; $i < $post_rating; $i++) {
                                    echo '<li>' . KopaIcon::getIcon('star', 'span') . '</li>';
                                }
                                for ($i = 0; $i < 5 - $post_rating; $i++) {
                                    echo '<li>' . KopaIcon::getIcon('star2', 'span') . '</li>';
                                }
                                ?>
                                                            </ul>
                                                            <?php 
                            }
                            ?>
                                                    </header>
                                                    <h4 class="entry-title clearfix"><?php 
                            echo KopaIcon::getIcon($kopa_data_icon, 'span');
                            ?>
<a href="<?php 
                            the_permalink();
                            ?>
"><?php 
                            the_title();
                            ?>
</a></h4>
                                                </div><!--entry-content-->
                                            </article><!--entry-item-->
                                        </li>
                        <?php 
                        }
                        // endwhile
                        ?>
                                </ul>
                                <div class="clearfix"></div>
                                <div id="single_related_posts_pager" class="pager"></div>
                            </div> <!-- list-carousel -->                            
                        </div>
                        <?php 
                    }
                    // endif
                    wp_reset_postdata();
                }
            }
        }
    }
}