Beispiel #1
0
function kopa_content_get_gallery_attachment_ids($content)
{
    $gallery = kopa_content_get_gallery($content);
    if (isset($gallery[0])) {
        $gallery = $gallery[0];
    } else {
        return '';
    }
    if (isset($gallery['shortcode'])) {
        $shortcode = $gallery['shortcode'];
    } else {
        return '';
    }
    // get gallery string ids
    preg_match_all('/ids=\\"(?:\\d+,*)+\\"/', $shortcode, $gallery_string_ids);
    if (isset($gallery_string_ids[0][0])) {
        $gallery_string_ids = $gallery_string_ids[0][0];
    } else {
        return '';
    }
    // get array of image id
    preg_match_all('/\\d+/', $gallery_string_ids, $gallery_ids);
    if (isset($gallery_ids[0])) {
        $gallery_ids = $gallery_ids[0];
    } else {
        return '';
    }
    return $gallery_ids;
}
Beispiel #2
0
function kopa_get_articles($query_args, $stored_month_year)
{
    global $post;
    $posts = kopa_widget_article_build_query($query_args);
    if ($posts->post_count > 0) {
        $previous_date = '';
        $month_year = json_decode(stripslashes($stored_month_year), true);
        $post_id_array = array();
        foreach ($query_args['post__not_in'] as $kopa_post_key => $kopa_post_id) {
            array_push($post_id_array, $kopa_post_id);
        }
        while ($posts->have_posts()) {
            $posts->the_post();
            $post_id = get_the_ID();
            array_push($post_id_array, $post_id);
            $post_url = get_permalink();
            $post_title = get_the_title();
            $current_date = get_the_date('M,Y');
            $_element = array('month' => get_the_date('m'), 'year' => get_the_date('Y'), 'month-year' => get_the_date('M') . '-' . get_the_date('Y'), 'month-text' => get_the_date('F'));
            array_push($month_year, $_element);
            $last_stored_month_year = json_decode(stripslashes($stored_month_year), true);
            $last_array_element = array_pop($last_stored_month_year);
            if ($_element['month-year'] !== $last_array_element['month-year']) {
                if ($current_date != $previous_date) {
                    $previous_date = $current_date;
                    $total_post_no = kopa_total_post_count_by_month(get_the_date('m'), get_the_date('Y'));
                    ?>
                    <div class="time-to-filter clearfix" id="<?php 
                    echo get_the_date('M') . '-' . get_the_date('Y');
                    ?>
">
                        <p class="timeline-filter"><span><?php 
                    echo $current_date;
                    ?>
</span></p>
                        <span class="post-quantity"><?php 
                    echo $total_post_no;
                    if ($total_post_no <= 1) {
                        _e(' Article', kopa_get_domain());
                    } else {
                        _e(' Articles', kopa_get_domain());
                    }
                    ?>
                        </span>
                        <span class="top-ring"></span>
                        <span class="bottom-ring"></span>
                    </div><!--time-to-filter-->
                    <?php 
                }
            }
            switch (get_post_format()) {
                case 'quote':
                    ?>
                    <article class="timeline-item quote-post clearfix">                                                    
                        <div class="timeline-icon">
                            <div><span class="post-type" data-icon="&#xe075;"></span></div>
                            <span class="dotted-horizon"></span>
                            <span class="vertical-line"></span>
                            <span class="circle-outer"></span>
                            <span class="circle-inner"></span>
                        </div>
                        <div class="entry-body clearfix">                                                    
                            <p><?php 
                    the_excerpt();
                    ?>
</p>
                            <center><span class="quote-name"><?php 
                    the_author();
                    ?>
</span></center>
                            <header>
                                <span class="entry-date"><span class="icon-clock-4 entry-icon" aria-hidden="true"></span><span><?php 
                    echo get_the_date();
                    ?>
</span></span></span>
                                <span class="entry-comment"><span class="icon-bubbles-4 entry-icon" aria-hidden="true"></span><?php 
                    comments_popup_link(__('No Comment', kopa_get_domain()), __('1 Comment', kopa_get_domain()), __('% Comments', kopa_get_domain()), '', __('Comments Off', kopa_get_domain()));
                    ?>
</span>
                            </header>
                        </div>
                    </article><!--timeline-item-->
                    <?php 
                    break;
                case 'video':
                    $video = kopa_content_get_video($post->post_content);
                    ?>
                    <article class="timeline-item video-post clearfix">                                                    
                        <div class="timeline-icon">
                            <div><span class="post-type" data-icon="&#xe023;"></span></div>
                            <span class="dotted-horizon"></span>
                            <span class="vertical-line"></span>
                            <span class="circle-outer"></span>
                            <span class="circle-inner"></span>
                        </div>
                        <div class="entry-body clearfix">
                            <div class="kp-thumb hover-effect">
                                <div class="mask">
                                    <a href="<?php 
                    echo $video[0]['url'];
                    ?>
" rel="prettyPhoto" class="link-detail" data-icon="&#xe022;"><span></span></a>
                                </div>
                                <?php 
                    if (has_post_thumbnail()) {
                        the_post_thumbnail('kopa-image-size-1');
                    } else {
                        printf('<img src="%1$s" alt="">', kopa_get_video_thumbnails_url($video[0]['type'], $video[0]['url']));
                    }
                    ?>
                            </div>
                            <header>
                                <h2 class="entry-title"><a href="<?php 
                    echo $post_url;
                    ?>
"><?php 
                    the_title();
                    ?>
</a></h2>
                                <span class="entry-date"><span class="icon-clock-4 entry-icon" aria-hidden="true"></span><span><?php 
                    echo get_the_date();
                    ?>
</span></span>
                                <span class="entry-comment"><span class="icon-bubbles-4 entry-icon" aria-hidden="true"></span><?php 
                    comments_popup_link(__('No Comment', kopa_get_domain()), __('1 Comment', kopa_get_domain()), __('% Comments', kopa_get_domain()), '', __('Comments Off', kopa_get_domain()));
                    ?>
</span>
                            </header>
                            <p><?php 
                    the_excerpt();
                    ?>
</p>
                            <a href="<?php 
                    echo $post_url;
                    ?>
" class="more-link"><?php 
                    _e('Continue Reading &raquo;', kopa_get_domain());
                    ?>
</a>
                        </div>

                    </article><!--timeline-item-->
                    <?php 
                    break;
                case 'gallery':
                    ?>
                    <article class="timeline-item gallery-post clearfix">                                                    
                        <div class="timeline-icon">
                            <div><span class="post-type" data-icon="&#xe01d;"></p></div>
                            <span class="dotted-horizon"></span>
                            <span class="vertical-line"></span>
                            <span class="circle-outer"></span>
                            <span class="circle-inner"></span>
                        </div>
                        <div class="entry-body clearfix"> 
                            <?php 
                    $gallery = kopa_content_get_gallery($post->post_content);
                    if ($gallery) {
                        $shortcode = substr_replace($gallery[0]['shortcode'], ' display_type = 1]', strlen($gallery[0]['shortcode']) - 1, strlen($gallery[0]['shortcode']));
                        echo do_shortcode($shortcode);
                    }
                    ?>
                            <header>
                                <h2 class="entry-title"><a href="<?php 
                    echo $post_url;
                    ?>
"><?php 
                    the_title();
                    ?>
</a></h2>
                                <span class="entry-date"><span class="icon-clock-4 entry-icon" aria-hidden="true"></span><span><?php 
                    echo get_the_date();
                    ?>
</span></span>
                                <span class="entry-comment"><span class="icon-bubbles-4 entry-icon" aria-hidden="true"></span><?php 
                    comments_popup_link(__('No Comment', kopa_get_domain()), __('1 Comment', kopa_get_domain()), __('% Comments', kopa_get_domain()), '', __('Comments Off', kopa_get_domain()));
                    ?>
</span>
                            </header>
                            <span class="load-more-gallery" onclick="more_gallery(jQuery(this));"><span></span></span>
                        </div>                                                    

                    </article><!--timeline-item-->
                    <?php 
                    break;
                case 'audio':
                    ?>
                    <article class="timeline-item audio-post clearfix">                                                    
                        <div class="timeline-icon">
                            <div><span class="post-type" data-icon="&#xe020;"></span></div>
                            <span class="dotted-horizon"></span>
                            <span class="vertical-line"></span>
                            <span class="circle-outer"></span>
                            <span class="circle-inner"></span>
                        </div>
                        <div class="entry-body clearfix">
                            <header>
                                <h2 class="entry-title"><a href="<?php 
                    echo $post_url;
                    ?>
"><?php 
                    the_title();
                    ?>
</a></h2>
                                <span class="entry-date"><span class="icon-clock-4 entry-icon" aria-hidden="true"></span><span><?php 
                    echo get_the_date();
                    ?>
</span></span>
                                <span class="entry-comment"><span class="icon-bubbles-4 entry-icon" aria-hidden="true"></span><?php 
                    comments_popup_link(__('No Comment', kopa_get_domain()), __('1 Comment', kopa_get_domain()), __('% Comments', kopa_get_domain()), '', __('Comments Off', kopa_get_domain()));
                    ?>
</span>
                            </header>
                            <?php 
                    $audio = kopa_content_get_audio($post->post_content);
                    if ($audio) {
                        echo do_shortcode($audio[0]['shortcode']);
                    }
                    ?>
                            <p><?php 
                    the_excerpt();
                    ?>
</p>
                            <a href="<?php 
                    echo $post_url;
                    ?>
" class="more-link"><?php 
                    _e('Continue Reading &raquo;', kopa_get_domain());
                    ?>
</a>
                        </div>

                    </article><!--timeline-item-->
                    <?php 
                    break;
                default:
                    ?>
                    <article class="timeline-item <?php 
                    if (has_post_thumbnail()) {
                        echo ' standard-post ';
                    } else {
                        echo 'link-post';
                    }
                    ?>
 clearfix">
                        <div class="timeline-icon">
                            <div><span class="post-type" data-icon="&#xe034;"></span></div>
                            <span class="dotted-horizon"></span>
                            <span class="vertical-line"></span>
                            <span class="circle-outer"></span>
                            <span class="circle-inner"></span>
                        </div>
                        <div class="entry-body clearfix">
                    <?php 
                    if (has_post_thumbnail()) {
                        ?>
                                <div class="kp-thumb hover-effect">
                                    <div class="mask">
                                        <a class="link-detail" href="<?php 
                        echo $post_url;
                        ?>
" data-icon="&#xe0c2;"></a>
                                    </div>
                                <?php 
                        the_post_thumbnail('kopa-image-size-1');
                        ?>
                                </div>
                    <?php 
                    }
                    ?>
                            <header>
                                <h2 class="entry-title"><a href="<?php 
                    echo $post_url;
                    ?>
"><?php 
                    the_title();
                    ?>
</a></h2>
                                <span class="entry-date"><span class="icon-clock-4 entry-icon" aria-hidden="true"></span><span><?php 
                    echo get_the_date();
                    ?>
</span></span>
                                <span class="entry-comment"><span class="icon-bubbles-4 entry-icon" aria-hidden="true"></span><?php 
                    comments_popup_link(__('No Comment', kopa_get_domain()), __('1 Comment', kopa_get_domain()), __('% Comments', kopa_get_domain()), '', __('Comments Off', kopa_get_domain()));
                    ?>
</span>
                            </header>
                            <p><?php 
                    the_excerpt();
                    ?>
</p>
                            <a href="<?php 
                    echo $post_url;
                    ?>
" class="more-link"><?php 
                    _e('Continue Reading &raquo;', kopa_get_domain());
                    ?>
</a>
                        </div>
                    </article><!--timeline-item-->
                    <?php 
                    break;
            }
            ?>
        <?php 
        }
        ?>
  

        <?php 
        $post_id_string = implode(",", $post_id_array);
        ?>
        <input type="hidden" id="post_id_array" value="<?php 
        echo $post_id_string;
        ?>
">
        <div class="kp-filter clearfix">
            <div onclick="kp_filter_click(jQuery(this))">
                <span>View by:</span><em>All</em>
                <a></a>                                    
                <ul id="ss-links" class="ss-links">
                    <?php 
        $current_month = '';
        $current_year = '';
        foreach ($month_year as $k => $v) {
            if ($v['year'] !== $current_year) {
                $current_year = $v['year'];
                echo '<li class="year"><span>' . $current_year . '</span></li>';
            }
            if ($v['month'] !== $current_month) {
                $current_month = $v['month'];
                echo '<li><a href="#' . $v['month-year'] . '" onclick="kp_filter_li_click(jQuery(this))">' . $v['month-text'] . '</a></li>';
            }
        }
        ?>
                </ul>
                <input type="hidden" id="stored_month_year" value='<?php 
        echo json_encode($month_year);
        ?>
'>
                <input type="hidden" id="no_post_found" value="0">
            </div>
        </div><!--kp-filter-->
        <?php 
    } else {
        ?>
        <input type="hidden" id="no_post_found" value="1">
    <?php 
    }
    wp_reset_postdata();
}
<?php

$gallery = kopa_content_get_gallery(get_the_content());
if (isset($gallery[0])) {
    $gallery = $gallery[0];
} else {
    $gallery = '';
}
?>
<div id="post-<?php 
the_ID();
?>
" <?php 
post_class();
?>
>
                        
    <?php 
if (isset($gallery['shortcode'])) {
    ?>
                
        <div class="entry-thumb">
            <?php 
    echo do_shortcode($gallery['shortcode']);
    ?>
               
        </div>
    <?php 
}
// endif
?>
Beispiel #4
0
    function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
        $max_items = $instance['max_items'];
        $scroll_items = $instance['scroll_items'];
        $query_args['post_type'] = 'post';
        $query_args['cat_name'] = 'category';
        $query_args['tag_name'] = 'post_tag';
        $query_args['categories'] = $instance['categories'];
        $query_args['relation'] = esc_attr($instance['relation']);
        $query_args['tags'] = $instance['tags'];
        $query_args['posts_per_page'] = (int) $instance['posts_per_page'];
        $query_args['orderby'] = $instance['orderby'];
        $posts = kopa_widget_posttype_build_query($query_args);
        if ($posts->post_count == 0) {
            return;
        }
        echo $before_widget;
        if (!empty($title)) {
            echo $before_title . '<span data-icon="&#xf040;"></span>' . $title . $after_title;
        }
        ?>
        
        <div class="list-carousel responsive" >
            <ul class="kopa-latest-work-carousel" data-max-items="<?php 
        echo $max_items;
        ?>
" data-scroll-items="<?php 
        echo $scroll_items;
        ?>
" data-prev-id="#<?php 
        echo $this->get_field_id('prev-1');
        ?>
" data-next-id="#<?php 
        echo $this->get_field_id('next-1');
        ?>
">

        <?php 
        while ($posts->have_posts()) {
            $posts->the_post();
            $thumbnail_id = get_post_thumbnail_id();
            $large_thumbnail = wp_get_attachment_image_src($thumbnail_id, 'large');
            $thumbnail = wp_get_attachment_image_src($thumbnail_id, 'kopa-image-size-3');
            ?>
            <li style="width: 252px;">
                <article class="entry-item clearfix">
                    <?php 
            if (get_post_format() == 'gallery') {
                $gallery = kopa_content_get_gallery(get_the_content());
                $slug = $this->get_field_id('gallery') . '-' . get_the_ID();
                if (!empty($gallery)) {
                    $gallery = $gallery[0];
                    $shortcode = $gallery['shortcode'];
                    // get gallery string ids
                    preg_match_all('/ids=\\"(?:\\d+,*)+\\"/', $shortcode, $gallery_string_ids);
                    $gallery_string_ids = $gallery_string_ids[0][0];
                    // get array of image id
                    preg_match_all('/\\d+/', $gallery_string_ids, $gallery_ids);
                    $gallery_ids = $gallery_ids[0];
                    $first_image_id = array_shift($gallery_ids);
                    $first_image_src = wp_get_attachment_image_src($first_image_id, 'kopa-image-size-1');
                    $first_full_image_src = wp_get_attachment_image_src($first_image_id, 'full');
                }
                ?>
                        <div class="entry-thumb hover-effect">
                            <div class="mask">
                                <a class="link-detail" href="<?php 
                the_permalink();
                ?>
" data-icon="&#xf0c1;"></a>
                                
                                <?php 
                if (!isset($first_image_src[0]) && has_post_thumbnail()) {
                    ?>
                                    <a class="link-gallery" href="<?php 
                    echo $large_thumbnail[0];
                    ?>
" data-icon="&#xf002;" rel="prettyPhoto"></a>
                                <?php 
                } elseif (isset($first_image_src[0])) {
                    ?>
                                    <a class="link-gallery" href="<?php 
                    echo $first_full_image_src[0];
                    ?>
" data-icon="&#xf03e;" rel="prettyPhoto[<?php 
                    echo $slug;
                    ?>
]"></a>
                                <?php 
                }
                ?>

                                <?php 
                if (isset($gallery_ids) && !empty($gallery_ids)) {
                    foreach ($gallery_ids as $gallery_id) {
                        $gallery_image_src = wp_get_attachment_image_src($gallery_id, 'full');
                        echo '<a style="display: none;" href="' . $gallery_image_src[0] . '" rel="prettyPhoto[' . $slug . ']"></a>';
                    }
                }
                ?>
                            </div>
                            <?php 
                if (has_post_thumbnail()) {
                    ?>
                                <img src="<?php 
                    echo $thumbnail[0];
                    ?>
" alt="<?php 
                    the_title();
                    ?>
">
                            <?php 
                } elseif (isset($first_image_src[0])) {
                    ?>
                                <img src="<?php 
                    echo $first_image_src[0];
                    ?>
" alt="<?php 
                    the_title();
                    ?>
">
                            <?php 
                }
                ?>
                        </div>

                    <?php 
            } elseif (get_post_format() == 'video') {
                $video = kopa_content_get_video(get_the_content());
                if (!empty($video)) {
                    $video = $video[0];
                    if (isset($video['type']) && isset($video['url'])) {
                        $video_thumbnail = kopa_get_video_thumbnails_url($video['type'], $video['url']);
                    }
                }
                $enableLightbox = get_option('kopa_theme_options_play_video_in_lightbox', 'enable');
                ?>
                        <div class="entry-thumb hover-effect">
                            <div class="mask">
                                <a class="link-detail" href="<?php 
                the_permalink();
                ?>
" data-icon="&#xf0c1;"></a>
                                <?php 
                if (isset($video['url'])) {
                    ?>
                                    <a class="link-gallery" href="<?php 
                    echo $video['url'];
                    ?>
" data-icon="&#xf04b;" rel="<?php 
                    echo $enableLightbox == 'enable' ? 'prettyPhoto' : '';
                    ?>
"></a>
                                <?php 
                } elseif (has_post_thumbnail()) {
                    ?>
                                    <a class="link-gallery" href="<?php 
                    echo $large_thumbnail[0];
                    ?>
" data-icon="&#xf002;" rel="<?php 
                    echo $enableLightbox == 'enable' ? 'prettyPhoto' : '';
                    ?>
"></a>
                                <?php 
                }
                ?>
                            </div>
                            <?php 
                if (has_post_thumbnail()) {
                    ?>
                                <img src="<?php 
                    echo $thumbnail[0];
                    ?>
" alt="<?php 
                    the_title();
                    ?>
">
                            <?php 
                } elseif (isset($video_thumbnail)) {
                    ?>
                                <img width="252" src="<?php 
                    echo $video_thumbnail;
                    ?>
" alt="<?php 
                    the_title();
                    ?>
">
                            <?php 
                }
                ?>
                        </div>

                    <?php 
            } else {
                ?>
                        <div class="entry-thumb hover-effect">
                            <div class="mask">
                                <a class="link-detail" href="<?php 
                the_permalink();
                ?>
" data-icon="&#xf0c1;"></a>
                                <a class="link-gallery" href="<?php 
                echo $large_thumbnail[0];
                ?>
" data-icon="&#xf002;" rel="prettyPhoto"></a>
                            </div>
                            <?php 
                if (has_post_thumbnail()) {
                    ?>
                                <img src="<?php 
                    echo $thumbnail[0];
                    ?>
" alt="<?php 
                    the_title();
                    ?>
">
                            <?php 
                }
                ?>
                        </div>
                    <?php 
            }
            ?>
                    <div class="entry-content">
                        <h6 class="entry-title"><a href="<?php 
            the_permalink();
            ?>
"><?php 
            the_title();
            ?>
</a></h6>
                        <span class="entry-categories"><?php 
            the_category(',&nbsp;');
            ?>
</span>
                    </div><!--entry-content-->
                </article><!--entry-item-->
            </li>
        <?php 
        }
        ?>

            </ul>
            <div class="clearfix"></div>
            <div class="carousel-nav clearfix">
                <a id="<?php 
        echo $this->get_field_id('prev-1');
        ?>
" class="carousel-prev" href="#">&lt;</a>
                <a id="<?php 
        echo $this->get_field_id('next-1');
        ?>
" class="carousel-next" href="#">&gt;</a>
            </div>
        </div>
        <?php 
        wp_reset_postdata();
        echo $after_widget;
    }
Beispiel #5
0
    function show_entry_list_style_1($query_args)
    {
        $posts = kopa_widget_posttype_build_query($query_args);
        if ($posts->have_posts()) {
            $post_index = 1;
            while ($posts->have_posts()) {
                $posts->the_post();
                if ($post_index == 1) {
                    // show the thumbnail of the first post
                    ?>
                    <article class="entry-item">
                        <div class="entry-thumb">
                            <?php 
                    if (get_post_format() == 'gallery') {
                        ?>

                                <div class="entry-thumb-slider flexslider">
                                    <ul class="slides">
                                        <?php 
                        if (has_post_thumbnail()) {
                            ?>
                                            <li><img src="<?php 
                            echo kopa_get_image_src(get_the_ID(), 'kopa-image-size-4');
                            ?>
" alt="<?php 
                            echo get_the_title();
                            ?>
"></li>
                                        <?php 
                        }
                        $gallery = kopa_content_get_gallery(get_the_content());
                        if (isset($gallery[0])) {
                            $gallery = $gallery[0];
                        } else {
                            $gallery = '';
                        }
                        if (isset($gallery['shortcode'])) {
                            $shortcode = $gallery['shortcode'];
                        } else {
                            $shortcode = '';
                        }
                        // get gallery string ids
                        preg_match_all('/ids=\\"(?:\\d+,*)+\\"/', $shortcode, $gallery_string_ids);
                        if (isset($gallery_string_ids[0][0])) {
                            $gallery_string_ids = $gallery_string_ids[0][0];
                        } else {
                            $gallery_string_ids = '';
                        }
                        // get array of image id
                        preg_match_all('/\\d+/', $gallery_string_ids, $gallery_ids);
                        if (isset($gallery_ids[0])) {
                            $gallery_ids = $gallery_ids[0];
                        } else {
                            $gallery_ids = '';
                        }
                        if (!empty($gallery_ids)) {
                            foreach ($gallery_ids as $gallery_id) {
                                if (wp_attachment_is_image($gallery_id)) {
                                    echo '<li>' . wp_get_attachment_image($gallery_id, 'kopa-image-size-4') . '</li>';
                                }
                            }
                        }
                        ?>
                                    </ul><!--slides-->
                                </div><!--entry-thumb-slider-->

                            <?php 
                    } elseif (get_post_format() == 'video') {
                        $video = kopa_content_get_video(get_the_content());
                        if (isset($video[0])) {
                            $video = $video[0];
                            if (isset($video['url']) && !empty($video['url'])) {
                                ?>
                                            <a class="play-icon" href="<?php 
                                echo esc_url($video['url']);
                                ?>
" rel="prettyPhoto[<?php 
                                echo $this->get_field_id('video');
                                ?>
]"></a>
                            <?php 
                            }
                            // endif isset( $video['url']
                        }
                        // endif isset( $video[0] )
                        ?>
                                    <a href="<?php 
                        the_permalink();
                        ?>
"><?php 
                        if (has_post_thumbnail()) {
                            ?>
                                        <img src="<?php 
                            echo kopa_get_image_src(get_the_ID(), 'kopa-image-size-4');
                            // 53x53
                            ?>
" alt="<?php 
                            echo get_the_title();
                            ?>
">
                                    <?php 
                        } elseif (isset($video['url']) && isset($video['type'])) {
                            echo '<img src="' . kopa_get_video_thumbnails_url($video['type'], $video['url']) . '">';
                        }
                        ?>
</a>
                            <?php 
                    } else {
                        ?>
                                <?php 
                        if (has_post_thumbnail()) {
                            ?>
 
                                    <a href="<?php 
                            the_permalink();
                            ?>
">
                                        <img src="<?php 
                            echo kopa_get_image_src(get_the_ID(), 'kopa-image-size-4');
                            // 53x53
                            ?>
" alt="<?php 
                            echo get_the_title();
                            ?>
">
                                    </a>
                                <?php 
                        }
                        ?>
                            <?php 
                    }
                    ?>
                        </div>
                        <div class="entry-content">
                            <header>
                                <h4 class="entry-title"><a href="<?php 
                    the_permalink();
                    ?>
"><?php 
                    echo get_the_title();
                    ?>
</a></h4>
                                <span class="entry-date"><span class="kopa-minus"></span><?php 
                    the_time(get_option('date_format'));
                    ?>
</span>
                            </header>
                            <?php 
                    the_excerpt();
                    ?>
                        </div>
                    </article><!--entry-item-->

        <?php 
                    echo $posts->post_count > 1 ? '<ul class="older-post">' : '';
                } else {
                    // $post_index != 1 ( the rest posts )
                    ?>
                    <li>
                        <a href="<?php 
                    the_permalink();
                    ?>
"><?php 
                    echo get_the_title();
                    ?>
</a>
                        <?php 
                    the_excerpt();
                    ?>
                    </li>
        <?php 
                }
                // endif $post_index == 1
                $post_index++;
                // increase post index by 1
            }
            // endwhile $posts->have_posts()
            echo $posts->post_count > 1 ? '</ul><!-- .older-post -->' : '';
        } else {
            // if ! $posts->have_posts()
            _e('No Posts Found', kopa_get_domain());
        }
        wp_reset_postdata();
    }
Beispiel #6
0
function kopa_get_related_articles()
{
    if (is_single()) {
        $get_by = get_option('kopa_theme_options_post_related_get_by', 'hide');
        if ('hide' != $get_by) {
            $limit = (int) get_option('kopa_theme_options_post_related_limit', 5);
            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);
                    $carousel_id = $related_posts->post_count > 3 ? 'related-widget' : 'related-widget-no-carousel';
                    if ($related_posts->have_posts()) {
                        ?>
                        <div class="kopa-related-post">
                            <h3><span data-icon="&#xf040;"></span><?php 
                        _e('Related Posts', kopa_get_domain());
                        ?>
</h3>
                            <div class="list-carousel responsive">
                                <ul class="kopa-related-post-carousel" id="<?php 
                        echo $carousel_id;
                        ?>
">
                                    <?php 
                        while ($related_posts->have_posts()) {
                            $related_posts->the_post();
                            $post_url = get_permalink();
                            $post_title = get_the_title();
                            ?>
       
                                        <li style="width: 390px;">
                                            <article class="entry-item clearfix">
                                                <div class="entry-thumb hover-effect">
                                                    <?php 
                            switch (get_post_format()) {
                                // video post format
                                case 'video':
                                    $video = kopa_content_get_video(get_the_content());
                                    if (!empty($video)) {
                                        $video = $video[0];
                                        ?>
                                                                <div class="mask">
                                                                    <a class="link-detail" rel="prettyPhoto" data-icon="&#xf04b;" href="<?php 
                                        echo $video['url'];
                                        ?>
"></a>
                                                                </div>
                                                                <?php 
                                        if (has_post_thumbnail()) {
                                            the_post_thumbnail('kopa-image-size-1');
                                        } else {
                                            echo '<img src="' . kopa_get_video_thumbnails_url($video['type'], $video['url']) . '">';
                                        }
                                    }
                                    // endif ! empty( $video )
                                    break;
                                    // gallery post format
                                // gallery post format
                                case 'gallery':
                                    $gallery = kopa_content_get_gallery(get_the_content());
                                    if (!empty($gallery)) {
                                        $shortcode = $gallery[0]['shortcode'];
                                        // get gallery string ids
                                        preg_match_all('/ids=\\"(?:\\d+,*)+\\"/', $shortcode, $gallery_string_ids);
                                        $gallery_string_ids = $gallery_string_ids[0][0];
                                        // get array of image id
                                        preg_match_all('/\\d+/', $gallery_string_ids, $gallery_ids);
                                        $gallery_ids = $gallery_ids[0];
                                        $first_image_id = array_shift($gallery_ids);
                                        $first_image_src = wp_get_attachment_image_src($first_image_id, 'kopa-image-size-1');
                                        $first_full_image_src = wp_get_attachment_image_src($first_image_id, 'full');
                                        $slug = 'gallery-' . get_the_ID();
                                        ?>
                                                                <div class="mask">
                                                                    <a class="link-detail" rel="prettyPhoto[<?php 
                                        echo $slug;
                                        ?>
]" data-icon="&#xf03e;" href="<?php 
                                        echo $first_full_image_src[0];
                                        ?>
"></a>
                                                                </div>
                                                                <?php 
                                        foreach ($gallery_ids as $gallery_id) {
                                            $image_src = wp_get_attachment_image_src($gallery_id, 'full');
                                            ?>
                                                                    <a style="display: none" href="<?php 
                                            echo $image_src[0];
                                            ?>
" rel="prettyPhoto[<?php 
                                            echo $slug;
                                            ?>
]"></a>
                                                                    <?php 
                                        }
                                        if (has_post_thumbnail()) {
                                            the_post_thumbnail('kopa-image-size-1');
                                        } else {
                                            echo '<img src="' . $first_image_src[0] . '">';
                                        }
                                    }
                                    // endif ! empty ( $gallery )
                                    break;
                                    // default post format
                                // default post format
                                default:
                                    if (get_post_format() == 'quote') {
                                        $data_icon = '&#xf10d;';
                                    } elseif (get_post_format() == 'audio') {
                                        $data_icon = '&#xf001;';
                                    } else {
                                        $data_icon = '&#xf0c1;';
                                    }
                                    ?>
                                                            <div class="mask">
                                                                <a class="link-detail" data-icon="<?php 
                                    echo $data_icon;
                                    ?>
" href="<?php 
                                    the_permalink();
                                    ?>
"></a>
                                                            </div>
                                                            <?php 
                                    if (has_post_thumbnail()) {
                                        the_post_thumbnail('kopa-image-size-1');
                                    }
                                    break;
                            }
                            ?>
                                                </div>
                                                <div class="entry-content">
                                                    <h6 class="entry-title"><a href="<?php 
                            echo $post_url;
                            ?>
"><?php 
                            echo $post_title;
                            ?>
</a><span></span></h6>
                                                    <span class="entry-date clearfix"><span class="fa fa-clock-o"></span><span><?php 
                            echo get_the_date();
                            ?>
</span></span>
                                                    <?php 
                            the_excerpt();
                            ?>
                                                </div><!--entry-content-->
                                            </article><!--entry-item-->
                                        </li>
                                        <?php 
                        }
                        ?>
                                </ul>
                                <div class="clearfix"></div>
                                <?php 
                        if ($related_posts->post_count > 3) {
                            ?>
                                    <div class="carousel-nav clearfix">
                                        <a id="prev-4" class="carousel-prev" href="#">&lt;</a>
                                        <a id="next-4" class="carousel-next" href="#">&gt;</a>
                                    </div><!--end:carousel-nav-->
                                <?php 
                        }
                        ?>
                            </div>
                        </div>
                        <?php 
                    }
                    wp_reset_postdata();
                }
            }
        }
    }
}