function output($options) { global $dslc_active; if ($dslc_active && is_user_logged_in() && current_user_can(DS_LIVE_COMPOSER_CAPABILITY)) { $dslc_is_admin = true; } else { $dslc_is_admin = false; } $this->module_start($options); /* CUSTOM START */ if (!isset($options['excerpt_length'])) { $options['excerpt_length'] = 20; } /** * Query */ // Fix for pagination if (is_front_page()) { $paged = get_query_var('page') ? get_query_var('page') : 1; } else { $paged = get_query_var('paged') ? get_query_var('paged') : 1; } // General args $args = array('paged' => $paged, 'post_type' => $options['post_type'], 'posts_per_page' => $options['amount'], 'order' => $options['order'], 'orderby' => $options['orderby'], 'offset' => $options['offset']); // Category args if (isset($options['categories']) && $options['categories'] != '') { $cats_array = explode(' ', $options['categories']); $args['category__in'] = $cats_array; } // Exlcude and Include arrays $exclude = array(); $include = array(); // Exclude current post if (is_singular(get_post_type())) { $exclude[] = get_the_ID(); } // Exclude posts ( option ) if ($options['query_post_not_in']) { $exclude = array_merge($exclude, explode(' ', $options['query_post_not_in'])); } // Include posts ( option ) if ($options['query_post_in']) { $include = array_merge($include, explode(' ', $options['query_post_in'])); } // Include query parameter if (!empty($include)) { $args['post__in'] = $include; } // Exclude query parameter if (!empty($exclude)) { $args['post__not_in'] = $exclude; } // Author archive page if (is_author()) { global $authordata; $args['author__in'] = array($authordata->data->ID); } // No paging if ($options['pagination_type'] == 'disabled') { $args['no_found_rows'] = true; } // Do the query if (is_category() || is_tax() || is_search()) { global $wp_query; $dslc_query = $wp_query; } else { $dslc_query = new WP_Query($args); } /** * Duration when hover link */ $duration_hover = ''; $value_duration = $options['as_duration_hover']; if ($value_duration != '') { $duration_hover = ' <style> #dslc-module-' . $options['module_instance_id'] . ' .dslc-cpt-post-title h2 a, #dslc-module-' . $options['module_instance_id'] . ' .dslc-cpt-post-meta a, #dslc-module-' . $options['module_instance_id'] . ' .dslc-cpt-post-read-more a, #dslc-module-' . $options['module_instance_id'] . ' a.as-post-like .dslc-icon{ -webkit-transition: all ' . $value_duration . 'ms ease; -moz-transition: all ' . $value_duration . 'ms ease; -ms-transition: all ' . $value_duration . 'ms ease; -o-transition: all ' . $value_duration . 'ms ease; transition: all ' . $value_duration . 'ms ease; </style> '; } /** * Unnamed */ $columns_class = 'dslc-col dslc-' . $options['columns'] . '-col '; $count = 0; $real_count = 0; $increment = $options['columns']; $max_count = 12; /** * Elements to show */ // Main Elements $elements = $options['elements']; if (!empty($elements)) { $elements = explode(' ', trim($elements)); } else { $elements = array(); } // Post Elements $post_elements = $options['post_elements']; if (!empty($post_elements)) { $post_elements = explode(' ', trim($post_elements)); } else { $post_elements = 'all'; } // Carousel Elements $carousel_elements = $options['carousel_elements']; if (!empty($carousel_elements)) { $carousel_elements = explode(' ', trim($carousel_elements)); } else { $carousel_elements = array(); } /** * Classes generation */ // Posts container $container_class = 'dslc-posts dslc-cpt-posts dslc-clearfix dslc-cpt-posts-type-' . $options['type'] . ' dslc-posts-orientation-' . $options['orientation'] . ' '; if ($options['type'] == 'masonry') { $container_class .= 'dslc-init-masonry '; } elseif ($options['type'] == 'grid') { $container_class .= 'dslc-init-grid '; } // Post $element_class = 'dslc-post dslc-cpt-post '; if ($options['type'] == 'masonry') { $element_class .= 'dslc-masonry-item '; } elseif ($options['type'] == 'carousel') { $element_class .= 'dslc-carousel-item '; } /** * What is shown */ $show_header = false; $show_heading = false; $show_filters = false; $show_carousel_arrows = false; $show_view_all_link = false; if (in_array('main_heading', $elements)) { $show_heading = true; } if (($elements == 'all' || in_array('filters', $elements)) && $options['type'] !== 'carousel') { $show_filters = true; } if ($options['type'] == 'carousel' && in_array('arrows', $carousel_elements)) { $show_carousel_arrows = true; } if ($show_heading || $show_filters || $show_carousel_arrows) { $show_header = true; } /** * Carousel Items */ switch ($options['columns']) { case 12: $carousel_items = 1; break; case 6: $carousel_items = 2; break; case 4: $carousel_items = 3; break; case 3: $carousel_items = 4; break; case 2: $carousel_items = 6; break; default: $carousel_items = 6; break; } /** * Heading ( output ) */ if ($show_header) { ?> <div class="dslc-module-heading"> <!-- Heading --> <?php if ($show_heading) { ?> <h2 class="dslca-editable-content" data-id="main_heading_title" data-type="simple" <?php if ($dslc_is_admin) { echo 'contenteditable'; } ?> ><?php echo $options['main_heading_title']; ?> </h2> <!-- View all --> <?php if (isset($options['view_all_link']) && $options['view_all_link'] !== '') { ?> <span class="dslc-module-heading-view-all"><a href="<?php echo $options['view_all_link']; ?> " class="dslca-editable-content" data-id="main_heading_link_title" data-type="simple" <?php if ($dslc_is_admin) { echo 'contenteditable'; } ?> ><?php echo $options['main_heading_link_title']; ?> </a></span> <?php } ?> <?php } ?> <!-- Filters --> <?php if ($show_filters) { $cats_array = array(); if ($dslc_query->have_posts()) { while ($dslc_query->have_posts()) { $dslc_query->the_post(); $post_cats = get_the_category(get_the_ID()); if (!empty($post_cats)) { foreach ($post_cats as $post_cat) { $cats_array[$post_cat->slug] = $post_cat->name; } } } } ?> <div class="dslc-post-filters"> <span class="dslc-post-filter dslc-active" data-id=" "><?php _e('All', 'Post Filter', 'dslc_string'); ?> </span> <?php foreach ($cats_array as $cat_slug => $cat_name) { ?> <span class="dslc-post-filter dslc-inactive" data-id="<?php echo $cat_slug; ?> "><?php echo $cat_name; ?> </span> <?php } ?> </div><!-- .dslc-post-filters --> <?php } ?> <!-- Carousel --> <?php if ($show_carousel_arrows) { ?> <span class="dslc-carousel-nav fr"> <span class="dslc-carousel-nav-inner"> <a href="#" class="dslc-carousel-nav-prev"><span class="dslc-icon-chevron-left dslc-init-center"></span></a> <a href="#" class="dslc-carousel-nav-next"><span class="dslc-icon-chevron-right dslc-init-center"></span></a> </span> </span><!-- .carousel-nav --> <?php } ?> </div><!-- .dslc-module-heading --> <?php } /** * Posts ( output ) */ global $post; if ($dslc_query->have_posts()) { ?> <?php echo $duration_hover; ?> <div class="as-custom-post-class <?php echo $container_class; ?> "><?php ?> <div class="dslc-posts-inner"><?php if ($options['type'] == 'carousel') { ?> <div class="dslc-loader"></div><div class="dslc-carousel" data-stop-on-hover="<?php echo $options['carousel_autoplay_hover']; ?> " data-autoplay="<?php echo $options['carousel_autoplay']; ?> " data-columns="<?php echo $carousel_items; ?> " data-pagination="<?php if (in_array('circles', $carousel_elements)) { echo 'true'; } else { echo 'false'; } ?> " data-slide-speed="<?php echo $options['arrows_slide_speed']; ?> " data-pagination-speed="<?php echo $options['circles_slide_speed']; ?> "><?php } while ($dslc_query->have_posts()) { $dslc_query->the_post(); $count += $increment; $real_count++; if ($count == $max_count) { $count = 0; $extra_class = ' dslc-last-col'; } elseif ($count == $increment) { $extra_class = ' dslc-first-col'; } else { $extra_class = ''; } if (!has_post_thumbnail()) { $extra_class .= ' dslc-post-no-thumb'; } $post_cats = get_the_category(get_the_ID()); $post_cats_data = ''; if (!empty($post_cats)) { foreach ($post_cats as $post_cat) { $post_cats_data .= $post_cat->slug . ' '; } } ?> <div class="<?php echo $element_class . $columns_class . $extra_class; ?> " data-cats="<?php echo $post_cats_data; ?> "> <?php if ($post_elements == 'all' || in_array('thumbnail', $post_elements)) { ?> <?php /** * Manual Resize */ $manual_resize = false; if (isset($options['thumb_resize_height']) && !empty($options['thumb_resize_height']) || isset($options['thumb_resize_width_manual']) && !empty($options['thumb_resize_width_manual'])) { $manual_resize = true; $thumb_url = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full'); $thumb_url = $thumb_url[0]; $thumb_alt = get_post_meta(get_post_thumbnail_id(), '_wp_attachment_image_alt', true); if (!$thumb_alt) { $thumb_alt = ''; } $resize_width = false; $resize_height = false; if (isset($options['thumb_resize_width_manual']) && !empty($options['thumb_resize_width_manual'])) { $resize_width = $options['thumb_resize_width_manual']; } if (isset($options['thumb_resize_height']) && !empty($options['thumb_resize_height'])) { $resize_height = $options['thumb_resize_height']; } } ?> <!-- post format --> <?php define('AS_LIVE_COMPOSER_ABS', dirname(__FILE__)); $format = get_post_format(); get_template_part('plugins/ds-live-composer/as_custom/modules/as-posts-2/format/content', $format); ?> <!-- post format --> <?php } ?> <?php if ($options['main_location'] == 'bellow' && ($post_elements == 'all' || in_array('title', $post_elements) || in_array('meta', $post_elements) || in_array('excerpt', $post_elements) || in_array('button', $post_elements))) { ?> <div class="dslc-post-main dslc-cpt-post-main"> <?php if ($post_elements == 'all' || in_array('title', $post_elements)) { ?> <div class="dslc-cpt-post-title"> <h2><a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h2> </div><!-- .dslc-cpt-post-title --> <?php } ?> <?php if ($post_elements == 'all' || in_array('meta', $post_elements)) { ?> <div class="dslc-cpt-post-meta"> <div class="dslc-cpt-post-meta-date"> <?php the_time(get_option('date_format')); ?> </div><!-- .dslc-cpt-post-meta-date --> <span class="as-circle-line-post"></span> <div class="dslc-cpt-post-meta-author"> <?php _e('by', 'dslc_string'); ?> <?php the_author_posts_link(); ?> </div><!-- .dslc-cpt-post-meta-author --> <span class="as-circle-line-post"></span> <div class="dslc-cpt-post-meta-category"> <?php _e('in', 'dslc_string'); ?> <?php the_category(', '); ?> </div><!-- .dslc-cpt-post-meta-category --> </div><!-- .dslc-cpt-post-meta --> <?php } ?> <?php if ($post_elements == 'all' || in_array('excerpt', $post_elements)) { ?> <div class="dslc-cpt-post-excerpt"> <?php if (isset($format) && empty($format)) { ?> <?php if ($options['excerpt_or_content'] == 'content') { ?> <?php the_content(); ?> <?php } else { ?> <?php if (has_excerpt()) { echo do_shortcode(wp_trim_words(get_the_excerpt(), $options['excerpt_length'])); } else { echo do_shortcode(wp_trim_words(get_the_content(), $options['excerpt_length'])); } ?> <?php } ?> <?php } ?> </div><!-- .dslc-cpt-post-excerpt --> <?php } ?> <?php if ($post_elements == 'all' || in_array('button', $post_elements)) { ?> <div class="dslc-cpt-post-read-more"> <a href="<?php the_permalink(); ?> " class="as-btn-read-more"> <?php if ($options['as_button_position_icon'] == 'left') { ?> <?php if (isset($options['button_icon_id']) && $options['button_icon_id'] != '') { ?> <span class="dslc-icon dslc-icon-<?php echo $options['button_icon_id']; ?> "></span> <?php } ?> <?php } ?> <?php echo $options['button_text']; ?> <?php if ($options['as_button_position_icon'] == 'right') { ?> <?php if (isset($options['button_icon_id']) && $options['button_icon_id'] != '') { ?> <span class="dslc-icon dslc-icon-<?php echo $options['button_icon_id']; ?> "></span> <?php } ?> <?php } ?> </a> <div class="as-post-like-share"> <div class="as-btn-heart-blog"> <a href="#" class="as-post-like <?php echo as_is_like_post($post->ID); ?> " data-id="<?php echo $post->ID; ?> "> <span class="dslc-icon dslc-icon-heart"></span> <span class="number-like-heart"> <?php echo get_post_meta($post->ID, 'as_like_count', true) ? get_post_meta($post->ID, 'as_like_count', true) : 0; ?> </span> </a> </div> <!-- <div class="as-btn-share-social-blog"> <span class="dslc-icon dslc-icon-share"></span> <ul class="as-list-icon-share"> <li> <a class="as-share-blog-twitter" href="http://twitter.com/share?url=<?php the_permalink(); ?> &lang=en&text=Check out this awesome project:&" onclick="javascript:window.open(this.href,'', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=400,width=620');return false;" data-count="none" data-via=" "> <span class="dslc-icon dslc-icon-twitter"></span> </a> <a class="sb-facebook" href="http://www.facebook.com/sharer/sharer.php?u=<?php the_permalink(); ?> " onclick="javascript:window.open(this.href,'', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=400,width=660');return false;" target="_blank"> <span class="dslc-icon dslc-icon-facebook"></span> </a> <a class="sb-google" href="https://plus.google.com/share?url=<?php the_permalink(); ?> &title=<?php wp_title(''); ?> " onclick="javascript:window.open(this.href,'', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=400,width=500');return false;"> <span class="dslc-icon dslc-icon-google-plus"></span> </a> </li> </ul> </div> --> </div> </div><!-- .dslc-cpt-post-read-more --> <?php } ?> </div><!-- .dslc-cpt-post-main --> <?php } ?> </div><!-- .dslc-cpt-post --> <?php // Row Separator if ($options['type'] == 'grid' && $count == 0 && $real_count != $dslc_query->found_posts && $real_count != $options['amount'] && $options['separator_enabled'] == 'enabled') { echo '<div class="dslc-post-separator"></div>'; } } if ($options['type'] == 'carousel') { ?> </div><?php } ?> </div><!--.dslc-posts-inner --><?php ?> </div><!-- .dslc-cpt-posts --><?php } else { if ($dslc_is_admin) { ?> <div class="dslc-notification dslc-red"><?php _e('You do not have any posts of that post type at the moment.', 'dslc_string'); ?> <span class="dslca-refresh-module-hook dslc-icon dslc-icon-refresh"></span></span></div><?php } } /** * Pagination */ if (isset($options['pagination_type']) && $options['pagination_type'] != 'disabled') { $num_pages = $dslc_query->max_num_pages; dslc_post_pagination(array('pages' => $num_pages, 'type' => $options['pagination_type'])); } wp_reset_query(); $this->module_end($options); }
<div class="as-post-btn-group"> <a href="<?php echo esc_url($the_project_url); ?> " class="as-btn-readmore as-btn-single-project" target="_blank"> <?php _e('Visit Project', AS_DOMAIN); ?> </a> <div class="as-post-social-group"> <?php if (as_option('as_port_btn_like_heart', '1')) { ?> <div class="as-btn-heart-blog"> <a href="#" class="as-post-like <?php echo as_is_like_post($post->ID); ?> " data-id="<?php echo esc_attr($post->ID); ?> "> <span class="dslc-icon dslc-icon-heart"></span> <span class="number-like-heart"> <?php echo get_post_meta($post->ID, 'as_like_count', true) ? get_post_meta($post->ID, 'as_like_count', true) : 0; ?> </span> </a> </div> <?php }