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=""></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=""></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=""><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 »', 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=""></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=""></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 »', 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=""></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=""></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 »', 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(); }
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=""></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=""></a> <?php if (!isset($first_image_src[0]) && has_post_thumbnail()) { ?> <a class="link-gallery" href="<?php echo $large_thumbnail[0]; ?> " data-icon="" rel="prettyPhoto"></a> <?php } elseif (isset($first_image_src[0])) { ?> <a class="link-gallery" href="<?php echo $first_full_image_src[0]; ?> " data-icon="" 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=""></a> <?php if (isset($video['url'])) { ?> <a class="link-gallery" href="<?php echo $video['url']; ?> " data-icon="" rel="<?php echo $enableLightbox == 'enable' ? 'prettyPhoto' : ''; ?> "></a> <?php } elseif (has_post_thumbnail()) { ?> <a class="link-gallery" href="<?php echo $large_thumbnail[0]; ?> " data-icon="" 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=""></a> <a class="link-gallery" href="<?php echo $large_thumbnail[0]; ?> " data-icon="" 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(', '); ?> </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="#"><</a> <a id="<?php echo $this->get_field_id('next-1'); ?> " class="carousel-next" href="#">></a> </div> </div> <?php wp_reset_postdata(); echo $after_widget; }
<?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-6'); // 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; } } }
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(); }
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; }
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; }
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(); } } } } }
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=""></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="" 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="" 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 = ''; } elseif (get_post_format() == 'audio') { $data_icon = ''; } else { $data_icon = ''; } ?> <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="#"><</a> <a id="next-4" class="carousel-next" href="#">></a> </div><!--end:carousel-nav--> <?php } ?> </div> </div> <?php } wp_reset_postdata(); } } } } }