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; } $options['module_id'] = $this->module_id; $this->module_start($options); /* Module output stars here */ if (!isset($options['excerpt_length'])) { $options['excerpt_length'] = 20; } if (!isset($options['type'])) { $options['type'] = 'grid'; } 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; } // Fix for pagination from other modules affecting this one when pag disabled if ($options['pagination_type'] == 'disabled') { $paged = 1; } // Fix for offset braking pagination $query_offset = $options['offset']; if ($query_offset > 0 && $paged > 1) { $query_offset = ($paged - 1) * $options['amount'] + $options['offset']; } $args = array('paged' => $paged, 'post_type' => 'dslc_projects', 'posts_per_page' => $options['amount'], 'order' => $options['order'], 'orderby' => $options['orderby'], 'offset' => $query_offset); if (isset($options['categories']) && $options['categories'] != '') { $cats_array = explode(' ', trim($options['categories'])); $args['tax_query'] = array(array('taxonomy' => 'dslc_projects_cats', 'field' => 'slug', 'terms' => $cats_array, 'operator' => $options['categories_operator'])); } // 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); } $wrapper_class = ''; $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(); } /* Container Class */ $container_class = 'dslc-posts dslc-projects dslc-clearfix dslc-posts-orientation-' . $options['orientation'] . ' '; if ($options['type'] == 'masonry') { $container_class .= 'dslc-init-masonry '; } elseif ($options['type'] == 'grid') { $container_class .= 'dslc-init-grid '; } /* Element Class */ $element_class = 'dslc-post dslc-project '; 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_terms(get_the_ID(), 'dslc_projects_cats'); 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 _ex('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 ) */ if ($dslc_query->have_posts()) { ?> <div class="<?php echo $container_class; ?> "><?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'; } $project_cats_count = 0; $project_cats = get_the_terms(get_the_ID(), 'dslc_projects_cats'); $project_cats_data = ''; if (!empty($project_cats)) { foreach ($project_cats as $project_cat) { $project_cats_data .= $project_cat->slug . ' '; } } // Project URL $the_project_url = get_permalink(); if ($options['link'] == 'custom') { if (get_post_meta(get_the_ID(), 'dslc_project_url', true)) { $the_project_url = get_post_meta(get_the_ID(), 'dslc_project_url', true); } else { $the_project_url = '#'; } } // Project URL target $the_project_url_target = $options['link_target']; ?> <div class="<?php echo $element_class . $columns_class . $extra_class; ?> " data-cats="<?php echo $project_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']; } } ?> <?php if (has_post_thumbnail()) { ?> <div class="dslc-post-thumb dslc-project-thumb dslc-on-hover-anim"> <div class="dslc-project-thumb-inner dslca-post-thumb"> <?php if ($manual_resize) { ?> <a href="<?php echo $the_project_url; ?> " target="<?php echo $the_project_url_target; ?> "><img src="<?php $res_img = dslc_aq_resize($thumb_url, $resize_width, $resize_height, true); echo $res_img; ?> " alt="<?php echo $thumb_alt; ?> " /></a> <?php } else { ?> <a href="<?php echo $the_project_url; ?> " target="<?php echo $the_project_url_target; ?> "><?php the_post_thumbnail('full'); ?> </a> <?php } ?> </div><!-- .dslc-project-thumb-inner --> <?php if (($options['main_location'] == 'inside' || $options['main_location'] == 'inside_visible') && ($post_elements == 'all' || in_array('title', $post_elements) || in_array('categories', $post_elements) || in_array('excerpt', $post_elements) || in_array('button', $post_elements))) { ?> <div class="dslc-project-main <?php if ($options['main_location'] == 'inside_visible') { echo 'dslc-project-main-visible'; } ?> dslc-on-hover-anim-target dslc-anim-<?php echo $options['css_anim_hover']; ?> " data-dslc-anim="<?php echo $options['css_anim_hover']; ?> " data-dslc-anim-speed="<?php echo $options['css_anim_speed']; ?> "> <div class="dslc-project-main-inner dslc-init-<?php echo $options['main_position']; ?> "> <?php if ($post_elements == 'all' || in_array('title', $post_elements)) { ?> <div class="dslc-project-title"> <h2><a href="<?php echo $the_project_url; ?> " target="<?php echo $the_project_url_target; ?> "><?php the_title(); ?> </a></h2> </div><!-- .dslc-project-title --> <?php } ?> <?php if ($post_elements == 'all' || in_array('categories', $post_elements)) { ?> <?php if (!empty($project_cats)) { ?> <div class="dslc-project-cats"> <?php foreach ($project_cats as $project_cat) { $project_cats_count++; if ($project_cats_count > 1) { echo ', '; } echo $project_cat->name; } ?> </div><!-- .dslc-project-cats --> <?php } ?> <?php } ?> <?php if ($post_elements == 'all' || in_array('excerpt', $post_elements)) { ?> <div class="dslc-project-excerpt"> <?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 } ?> </div><!-- .dslc-project-excerpt --> <?php } ?> <?php if ($post_elements == 'all' || in_array('button', $post_elements)) { ?> <div class="dslc-project-read-more"> <a href="<?php echo $the_project_url; ?> " target="<?php echo $the_project_url_target; ?> "> <?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 echo $options['button_text']; ?> </a> </div><!-- .dslc-project-read-more --> <?php } ?> </div><!-- .dslc-init-center --> </div><!-- .dslc-project-main --> <?php } ?> </div><!-- .dslc-project-thumb --> <?php } ?> <?php } ?> <?php if ($options['main_location'] == 'bellow' && ($post_elements == 'all' || in_array('title', $post_elements) || in_array('categories', $post_elements) || in_array('excerpt', $post_elements) || in_array('button', $post_elements))) { ?> <div class="dslc-post-main dslc-project-main"> <?php if ($post_elements == 'all' || in_array('title', $post_elements)) { ?> <div class="dslc-project-title"> <h2><a href="<?php echo $the_project_url; ?> " target="<?php echo $the_project_url_target; ?> "><?php the_title(); ?> </a></h2> </div><!-- .dslc-project-title --> <?php } ?> <?php if ($post_elements == 'all' || in_array('categories', $post_elements)) { ?> <?php if (!empty($project_cats)) { ?> <div class="dslc-project-cats"> <?php foreach ($project_cats as $project_cat) { $project_cats_count++; if ($project_cats_count > 1) { echo ', '; } echo $project_cat->name; } ?> </div><!-- .dslc-project-cats --> <?php } ?> <?php } ?> <?php if ($post_elements == 'all' || in_array('excerpt', $post_elements)) { ?> <div class="dslc-project-excerpt"> <?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 } ?> </div><!-- .dslc-project-excerpt --> <?php } ?> <?php if ($post_elements == 'all' || in_array('button', $post_elements)) { ?> <div class="dslc-project-read-more"> <a href="<?php echo $the_project_url; ?> " target="<?php echo $the_project_url_target; ?> "> <?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 echo $options['button_text']; ?> </a> </div><!-- .dslc-project-read-more --> <?php } ?> </div><!-- .dslc-project-main --> <?php } ?> </div><!-- .dslc-project --> <?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-projects --> <?php } else { if ($dslc_is_admin) { ?> <div class="dslc-notification dslc-red"><?php _e('You do not have any projects at the moment. Go to <strong>WP Admin → Projects</strong> to add some.', '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; if ($options['offset'] > 0) { $num_pages = ceil(($dslc_query->found_posts - $options['offset']) / $options['amount']); } dslc_post_pagination(array('pages' => $num_pages, 'type' => $options['pagination_type'])); } wp_reset_postdata(); /* Module output ends here */ $this->module_end($options); }
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; } $options['module_id'] = $this->module_id; $this->module_start($options); /* Module output stars here */ if (!isset($options['excerpt_length'])) { $options['excerpt_length'] = 20; } if (!isset($options['type'])) { $options['type'] = 'grid'; } 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; } $args = array('paged' => $paged, 'post_type' => 'dslc_projects', 'posts_per_page' => $options['amount'], 'order' => $options['order'], 'orderby' => $options['orderby'], 'offset' => $options['offset']); if (isset($options['categories']) && $options['categories'] != '') { $cats_array = explode(' ', trim($options['categories'])); $args['tax_query'] = array(array('taxonomy' => 'dslc_projects_cats', 'field' => 'slug', 'terms' => $cats_array, 'operator' => $options['categories_operator'])); } // 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); } $wrapper_class = ''; $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(); } /* Container Class */ $container_class = 'dslc-posts dslc-projects dslc-clearfix '; if ($options['type'] == 'masonry') { $container_class .= 'dslc-init-masonry '; } elseif ($options['type'] == 'grid') { $container_class .= 'dslc-init-grid '; } $container_class .= " as-isotope-posts"; /* Element Class */ $element_class = 'dslc-post dslc-project '; 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; } ?> <?php if ($options['as_ajax_projects'] == 1 && $options['as_ajax_projects_position'] == 'top') { ?> <!-- PRINT PROJECTS DATA --> <div id="as_portfolio_content" style="display:none;"> <div class="as-wrapper clearfix"> <div class="as-portfolio-ajax-wrapper"> <div class="as-port-control dslc-col dslc-12-col dslc-last-col"> <a href="javascript:void(0);" class="prev" data-ajax="1" data-id="59"> <span class="dslc-icon dslc-icon-angle-left"></span><span class="as-btn-text-ajax-prj"><?php _e('Prev', 'as'); ?> </span> </a> <a href="javascript:void(0);" class="close-port"> <span class="dslc-icon dslc-icon-remove"></span> </a> <a href="javascript:void(0);" class="next" data-ajax="1" data-id="57"> <span class="as-btn-text-ajax-prj"><?php _e('Next', 'as'); ?> </span><span class="dslc-icon dslc-icon-angle-right"></span> </a> </div> </div> <div class="as-port-content"> </div> </div> </div> <div class="clearfix"></div> <!-- PRINT PROJECTS DATA / END --> <?php } ?> <?php /** * 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_terms(get_the_ID(), 'dslc_projects_cats'); 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 as-isotope-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 as-isotope-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 ) */ if ($dslc_query->have_posts()) { ?> <div class="<?php echo $container_class; ?> "> <?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'; } $project_cats_count = 0; $project_cats = get_the_terms(get_the_ID(), 'dslc_projects_cats'); $project_cats_data = ''; if (!empty($project_cats)) { foreach ($project_cats as $project_cat) { $project_cats_data .= $project_cat->slug . ' '; } } // Project URL $the_project_url = get_permalink(); if ($options['link'] == 'custom') { if (get_post_meta(get_the_ID(), 'dslc_project_url', true)) { $the_project_url = get_post_meta(get_the_ID(), 'dslc_project_url', true); } else { $the_project_url = '#'; } } // Project URL target $the_project_url_target = $options['link_target']; ?> <div class="<?php echo $element_class . $columns_class . $extra_class; ?> <?php echo $project_cats_data; ?> " data-cats="<?php echo $project_cats_data; ?> "> <?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']; } } ?> <?php if (has_post_thumbnail()) { ?> <?php $anchor_class = 'dslc-lightbox-image'; $duration_hover = ''; $value_duration = $options['css_main_bg_color_duration_hover']; if ($value_duration != '') { $duration_hover = 'style="-webkit-transition: all ' . $value_duration . 'ms ease-out;-moz-transition: all ' . $value_duration . 'ms ease-out;-ms-transition: all ' . $value_duration . 'ms ease-out;-o-transition: all ' . $value_duration . 'ms ease-out;transition: all ' . $value_duration . 'ms ease-out;"'; } ?> <div class="dslc-post-thumb dslc-project-thumb dslc-on-hover-anim as-project-custom"> <div class="dslc-project-thumb-inner dslca-post-thumb"> <?php if ($manual_resize) { ?> <a data-id="<?php echo get_the_ID(); ?> " data-ajax="<?php echo isset($options['as_ajax_projects']) && $options['as_ajax_projects'] ? '1' : '0'; ?> " href="<?php echo $the_project_url; ?> " target="<?php echo $the_project_url_target; ?> "><img src="<?php $res_img = dslc_aq_resize($thumb_url, $resize_width, $resize_height, true); echo $res_img; ?> " alt="<?php echo $thumb_alt; ?> " /></a> <?php } else { ?> <a data-id="<?php echo get_the_ID(); ?> " data-ajax="<?php echo isset($options['as_ajax_projects']) && $options['as_ajax_projects'] ? '1' : '0'; ?> " href="<?php echo $the_project_url; ?> " target="<?php echo $the_project_url_target; ?> "><?php the_post_thumbnail('full'); ?> </a> <?php } ?> </div><!-- .dslc-project-thumb-inner --> <?php if ($post_elements == 'all' || in_array('title', $post_elements) || in_array('categories', $post_elements) || in_array('excerpt', $post_elements) || in_array('button', $post_elements)) { ?> <div class="dslc-project-main dslc-on-hover-anim-target" <?php echo $duration_hover; ?> > <div class="dslc-project-main-inner"> <?php if ($post_elements == 'all' || in_array('title', $post_elements)) { ?> <div class="dslc-project-title"> <h2><a data-ajax="<?php echo isset($options['as_ajax_projects']) && $options['as_ajax_projects'] ? '1' : '0'; ?> " data-id="<?php echo get_the_ID(); ?> " href="<?php echo $the_project_url; ?> " target="<?php echo $the_project_url_target; ?> "><?php the_title(); ?> </a></h2> </div><!-- .dslc-project-title --> <?php } ?> <?php if ($post_elements == 'all' || in_array('categories', $post_elements)) { ?> <?php if (!empty($project_cats)) { ?> <div class="dslc-project-cats"> <?php foreach ($project_cats as $project_cat) { $project_cats_count++; if ($project_cats_count > 1) { echo ', '; } echo $project_cat->name; } ?> </div><!-- .dslc-project-cats --> <?php } ?> <?php } ?> <div class="as-project-line"></div> <?php if ($post_elements == 'all' || in_array('icon_link', $post_elements)) { ?> <div class="as-group-icon-project"> <?php $img_link_url = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full'); $img_link_url = $img_link_url[0]; ?> <a class="as-zoom-img-project as-lightbox-gallery" href="<?php echo esc_url($img_link_url); ?> "><span class="dslc-icon dslc-icon-search"></span></a> <a class="as-link-to-project" data-ajax="<?php echo isset($options['as_ajax_projects']) && $options['as_ajax_projects'] ? '1' : '0'; ?> " data-id="<?php echo get_the_ID(); ?> " href="<?php echo $the_project_url; ?> " target="<?php echo $the_project_url_target; ?> "><span class="dslc-icon dslc-icon-link"></span></a> </div> <?php } ?> </div><!-- .dslc-init-center --> </div><!-- .dslc-project-main --> <?php } ?> </div><!-- .dslc-project-thumb --> <?php } ?> </div><!-- .dslc-project --> <?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-projects --> <?php } else { if ($dslc_is_admin) { ?> <div class="dslc-notification dslc-red"><?php _e('You do not have any projects at the moment. Go to <strong>WP Admin → Projects</strong> to add some.', '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(); ?> <?php if ($options['as_ajax_projects'] == 1 && $options['as_ajax_projects_position'] == 'bottom') { ?> <!-- PRINT PROJECTS DATA --> <div id="as_portfolio_content" style="display:none;"> <div class="as-wrapper clearfix"> <div class="as-portfolio-ajax-wrapper"> <div class="as-port-control dslc-col dslc-12-col dslc-last-col"> <a href="javascript:void(0);" class="prev" data-ajax="1" data-id="59"> <span class="dslc-icon dslc-icon-angle-left"></span><span class="as-btn-text-ajax-prj"><?php _e('Prev', 'as'); ?> </span> </a> <a href="javascript:void(0);" class="close-port"> <span class="dslc-icon dslc-icon-remove"></span> </a> <a href="javascript:void(0);" class="next" data-ajax="1" data-id="57"> <span class="as-btn-text-ajax-prj"><?php _e('Next', 'as'); ?> </span><span class="dslc-icon dslc-icon-angle-right"></span> </a> </div> </div> <div class="as-port-content"> </div> </div> </div> <div class="clearfix"></div> <!-- PRINT PROJECTS DATA / END --> <?php } ?> <?php /* Module output ends here */ $this->module_end($options); }
function output($options) { global $dslc_active; $post_id = $options['post_id']; $this->module_start($options); if (is_singular()) { $post_id = get_the_ID(); } /* Module output starts here */ $manual_resize = false; if (!empty($options['resize_width']) || !empty($options['resize_height'])) { $manual_resize = true; $thumb_url = wp_get_attachment_image_src(get_post_thumbnail_id($post_id), 'full'); $thumb_url = $thumb_url[0]; $resize_width = false; $resize_height = false; if (isset($options['resize_width']) && !empty($options['resize_width'])) { $resize_width = $options['resize_width']; } if (isset($options['resize_height']) && !empty($options['resize_height'])) { $resize_height = $options['resize_height']; } } if (get_post_type($post_id) == 'dslc_templates' || defined('DOING_AJAX') && DOING_AJAX) { if (has_post_thumbnail($post_id)) { ?> <div class="dslc-tp-thumbnail"><?php if ($manual_resize) { ?> <img src="<?php $res_img = dslc_aq_resize($thumb_url, $resize_width, $resize_height, true); echo $res_img; ?> " /> <?php } else { ?> <?php echo get_the_post_thumbnail($post_id, 'full'); ?> <?php } ?> </div><?php } else { ?> <div class="dslc-tp-thumbnail dslc-tp-thumbnail-fake"><img src="<?php echo DS_LIVE_COMPOSER_URL; ?> /images/placeholders/tpl-thumb-placeholder.png" /></div><?php } } else { ?> <div class="dslc-tp-thumbnail"> <?php if (isset($options['lightbox_state']) && $options['lightbox_state'] == 'enabled') { ?> <a href="<?php $thumb = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), 'full'); echo $thumb[0]; ?> " class="dslc-lightbox-image"> <?php } ?> <?php if ($manual_resize) { ?> <img src="<?php $res_img = dslc_aq_resize($thumb_url, $resize_width, $resize_height, true); echo $res_img; ?> " /> <?php } else { ?> <?php the_post_thumbnail('full'); ?> <?php } ?> <?php if (isset($options['lightbox_state']) && $options['lightbox_state'] == 'enabled') { ?> </a> <?php } ?> </div><?php } /* Module output ends here */ $this->module_end($options); }
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; } // Fix slashes on apostrophes if (isset($options['button_text'])) { $options['button_text'] = stripslashes($options['button_text']); } $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; } // Fix for pagination from other modules affecting this one when pag disabled if ($options['pagination_type'] == 'disabled') { $paged = 1; } // Fix for offset braking pagination $query_offset = $options['offset']; if ($query_offset > 0 && $paged > 1) { $query_offset = ($paged - 1) * $options['amount'] + $options['offset']; } // General args $args = array('paged' => $paged, 'post_type' => 'post', 'posts_per_page' => $options['amount'], 'order' => $options['order'], 'orderby' => $options['orderby'], 'offset' => $query_offset); if (defined('DOING_AJAX') && DOING_AJAX) { $args['post_status'] = array('publish', 'private'); } // Category args if (isset($options['categories']) && $options['categories'] != '') { $cats_array = explode(' ', trim($options['categories'])); $args['tax_query'] = array(array('taxonomy' => 'category', 'field' => 'term_id', 'terms' => $cats_array, 'operator' => $options['categories_operator'])); } // 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_tag() || is_tax() || is_search()) { global $wp_query; $dslc_query = $wp_query; } else { $dslc_query = new WP_Query($args); } /** * 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-blog-posts dslc-clearfix dslc-blog-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-blog-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 stripslashes($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 _ex('All', 'Post Filter', 'live-composer-page-builder'); ?> </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 ) */ if ($dslc_query->have_posts()) { ?> <div 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; if (!is_sticky()) { $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 Format Class $post_format = get_post_format(); if (false === $post_format) { $post_format = 'standard'; } $extra_class .= ' dslc-post-format-' . $post_format; $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']; } } ?> <?php if (has_post_thumbnail()) { ?> <div class="dslc-blog-post-thumb dslc-post-thumb dslc-on-hover-anim"> <div class="dslc-blog-post-thumb-inner dslca-post-thumb"> <?php if ($manual_resize) { ?> <a href="<?php the_permalink(); ?> "><img src="<?php $res_img = dslc_aq_resize($thumb_url, $resize_width, $resize_height, true); echo $res_img; ?> " alt="<?php echo $thumb_alt; ?> " /></a> <?php } else { ?> <a href="<?php the_permalink(); ?> "><?php the_post_thumbnail('full'); ?> </a> <?php } ?> </div><!-- .dslc-blog-post-thumb-inner --> <?php if (($options['main_location'] == 'inside' || $options['main_location'] == 'inside_visible') && ($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-blog-post-main <?php if ($options['main_location'] == 'inside_visible') { echo 'dslc-blog-post-main-visible'; } ?> dslc-on-hover-anim-target dslc-anim-<?php echo $options['css_anim_hover']; ?> " data-dslc-anim="<?php echo $options['css_anim_hover']; ?> " data-dslc-anim-speed="<?php echo $options['css_anim_speed']; ?> "> <div class="dslc-blog-post-main-inner dslc-init-<?php echo $options['main_position']; ?> "> <?php if ($post_elements == 'all' || in_array('title', $post_elements)) { ?> <div class="dslc-blog-post-title"> <h2><a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h2> </div><!-- .dslc-blog-post-title --> <?php } ?> <?php if ($post_elements == 'all' || in_array('meta', $post_elements)) { ?> <?php // Meta Elements $meta_elements = $options['meta_elements']; $meta_elements = explode(' ', trim($meta_elements)); ?> <div class="dslc-blog-post-meta"> <?php if (in_array('author', $meta_elements)) { ?> <div class="dslc-blog-post-meta-author"> <?php _e('By', 'live-composer-page-builder'); ?> <?php the_author_posts_link(); ?> </div><!-- .dslc-blog-post-meta-author --> <?php } ?> <?php if (in_array('author', $meta_elements)) { ?> <div class="dslc-blog-post-meta-date"> <?php the_time(get_option('date_format')); ?> </div><!-- .dslc-blog-post-meta-date --> <?php } ?> </div><!-- .dslc-blog-post-meta --> <?php } ?> <?php if ($post_elements == 'all' || in_array('excerpt', $post_elements)) { ?> <div class="dslc-blog-post-excerpt"> <?php if ($options['excerpt_or_content'] == 'content') { ?> <?php the_content(); ?> <?php } else { ?> <?php if ($options['excerpt_length'] > 0) { 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'])); } } else { if (has_excerpt()) { echo do_shortcode(get_the_excerpt()); } else { echo do_shortcode(get_the_content()); } } ?> <?php } ?> </div><!-- .dslc-blog-post-excerpt --> <?php } ?> <?php if ($post_elements == 'all' || in_array('button', $post_elements)) { ?> <div class="dslc-blog-post-read-more"> <a href="<?php the_permalink(); ?> "> <?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 echo $options['button_text']; ?> </a> </div><!-- .dslc-blog-post-read-more --> <?php } ?> </div><!-- .blog-post-main-inner --> <a href="<?php the_permalink(); ?> " class="dslc-post-main-inner-link-cover"></a> </div><!-- .blog-post-main --> <?php } ?> </div><!-- .dslc-blog-post-thumb --> <?php } ?> <?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-blog-post-main"> <?php if ($post_elements == 'all' || in_array('title', $post_elements)) { ?> <div class="dslc-blog-post-title"> <h2><a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h2> </div><!-- .dslc-blog-post-title --> <?php } ?> <?php if ($post_elements == 'all' || in_array('meta', $post_elements)) { ?> <?php // Meta Elements $meta_elements = $options['meta_elements']; $meta_elements = explode(' ', trim($meta_elements)); ?> <div class="dslc-blog-post-meta"> <?php if (in_array('author', $meta_elements)) { ?> <div class="dslc-blog-post-meta-author"> <span class="dslc-blog-post-meta-avatar"> <?php echo get_avatar(get_the_author_meta('ID'), 100); ?> </span> <?php _e('By', 'live-composer-page-builder'); ?> <?php the_author_posts_link(); ?> </div><!-- .dslc-blog-post-meta-author --> <?php } ?> <?php if (in_array('date', $meta_elements)) { ?> <div class="dslc-blog-post-meta-date"> <?php the_time(get_option('date_format')); ?> </div><!-- .dslc-blog-post-meta-date --> <?php } ?> </div><!-- .dslc-blog-post-meta --> <?php } ?> <?php if ($post_elements == 'all' || in_array('excerpt', $post_elements)) { ?> <div class="dslc-blog-post-excerpt"> <?php if ($options['excerpt_or_content'] == 'content') { ?> <?php the_content(); ?> <?php } else { ?> <?php if ($options['excerpt_length'] > 0) { 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'])); } } else { if (has_excerpt()) { echo do_shortcode(get_the_excerpt()); } else { echo do_shortcode(get_the_content()); } } ?> <?php } ?> </div><!-- .dslc-blog-post-excerpt --> <?php } ?> <?php if ($post_elements == 'all' || in_array('button', $post_elements)) { ?> <div class="dslc-blog-post-read-more"> <a href="<?php the_permalink(); ?> "> <?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 echo $options['button_text']; ?> </a> </div><!-- .dslc-blog-post-read-more --> <?php } ?> </div><!-- .blog-post-main --> <?php if ($post_elements == 'all' || in_array('social', $post_elements)) { ?> <?php $share_info = dslc_get_social_count(); ?> <div class="dslc-posts-social-share"> <?php $post_img = wp_get_attachment_url(get_post_thumbnail_id(get_the_ID())); ?> <?php $share_status = esc_attr(get_the_title(get_the_ID()) . ' ' . get_permalink(get_the_ID())); ?> <a href="#" target="_blank" onClick="return dslc_social_share(400, 300, 'http://www.facebook.com/share.php?u=<?php echo get_permalink(get_the_ID()); ?> ')"><span class="dslc-icon dslc-icon-facebook"></span><span class="dslc-posts-social-share-count"><?php if ($share_info) { echo esc_html($share_info['fb']); } ?> </span></a> <a href="#" onClick="return dslc_social_share(400, 300, 'https://twitter.com/home?status=<?php echo $share_status; ?> ')" ><span class="dslc-icon dslc-icon-twitter"></span><span class="dslc-posts-social-share-count"><?php if ($share_info) { echo esc_html($share_info['twitter']); } ?> </span></a> <a href="#" onClick="return dslc_social_share(400, 300, 'https://pinterest.com/pin/create/button/?url=<?php the_permalink(); ?> &media=<?php echo esc_html($post_img); ?> &description=<?php echo esc_attr(get_the_excerpt()); ?> ')"><span class="dslc-icon dslc-icon-pinterest"></span><span class="dslc-posts-social-share-count"><?php if ($share_info) { echo esc_html($share_info['pinterest']); } ?> </span></a> </div><!-- .dslc-posts-social-share --> <?php } ?> <?php } ?> </div><!-- .dslc-blog-post --> <?php do_action('dslc_blog_module_after_post', $real_count); ?> <?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-blog-posts --><?php } else { if ($dslc_is_admin) { ?> <div class="dslc-notification dslc-red"><?php _e('You do not have any blog posts at the moment. Go to <strong>WP Admin → Posts</strong> to add some.', 'live-composer-page-builder'); ?> <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; if ($options['offset'] > 0) { $num_pages = ceil(($dslc_query->found_posts - $options['offset']) / $options['amount']); } dslc_post_pagination(array('pages' => $num_pages, 'type' => $options['pagination_type'])); } wp_reset_postdata(); $this->module_end($options); }
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; } $post_id = get_the_ID(); if (isset($options["number_posts"]) && !empty($options["number_posts"]) && is_numeric($options["number_posts"]) && $options["number_posts"] > 0) { $number_post = $options["number_posts"]; } else { $number_post = 1; } $categories = get_the_category($post_id); $category_get = array(); foreach ($categories as $category) { $category_get[] = $category->cat_ID; } $args = array("posts_per_page" => $number_post, "category__in" => $category_get, "post__not_in" => array($post_id)); $dslc_query = new WP_Query($args); /** * 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 ) */ if ($dslc_query->have_posts()) { ?> <div 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-columns="<?php echo $carousel_items; ?> " data-pagination="<?php if (in_array('circles', $carousel_elements)) { echo 'true'; } else { echo 'false'; } ?> "><?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]; $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']; } } ?> <?php if (has_post_thumbnail()) { ?> <div class="dslc-post-thumb dslc-cpt-post-thumb dslc-on-hover-anim"> <div class="dslc-cpt-post-thumb-inner dslca-post-thumb"> <?php if ($manual_resize) { ?> <a href="<?php the_permalink(); ?> "><img src="<?php $res_img = dslc_aq_resize($thumb_url, $resize_width, $resize_height, true); echo $res_img; ?> " /></a> <?php } else { ?> <a href="<?php the_permalink(); ?> "><?php the_post_thumbnail('full'); ?> </a> <?php } ?> </div><!-- .dslc-cpt-post-thumb-inner --> <?php if (($options['main_location'] == 'inside' || $options['main_location'] == 'inside_visible') && ($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 ($options['main_location'] == 'inside_visible') { echo 'dslc-cpt-post-main-visible'; } ?> dslc-on-hover-anim-target dslc-anim-<?php echo $options['css_anim_hover']; ?> " data-dslc-anim="<?php echo $options['css_anim_hover']; ?> "> <div class="dslc-cpt-post-main-inner dslc-init-<?php echo $options['main_position']; ?> "> <?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-author"> <?php _e('By', 'dslc_string'); ?> <?php the_author_posts_link(); ?> </div><!-- .dslc-cpt-post-meta-author --> <div class="dslc-cpt-post-meta-date"> <?php the_time(get_option('date_format')); ?> </div><!-- .dslc-cpt-post-meta-date --> </div><!-- .dslc-cpt-post-meta --> <?php } ?> <?php if ($post_elements == 'all' || in_array('excerpt', $post_elements)) { ?> <div class="dslc-cpt-post-excerpt"> <?php if ($options['excerpt_or_content'] == 'content') { ?> <?php the_content(); ?> <?php } else { ?> <?php echo do_shortcode(wp_trim_words(get_the_excerpt(), $options['excerpt_length'])); ?> <?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(); ?> "> <?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 echo $options['button_text']; ?> </a> </div><!-- .dslc-cpt-post-read-more --> <?php } ?> </div><!-- .dslc-cpt-post-main-inner --> </div><!-- .dslc-cpt-post-main --> <?php } ?> </div><!-- .dslc-cpt-post-thumb --> <?php } ?> <?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-author"> <?php _e('By', 'dslc_string'); ?> <?php the_author_posts_link(); ?> </div><!-- .dslc-cpt-post-meta-author --> <div class="dslc-cpt-post-meta-date"> <?php the_time(get_option('date_format')); ?> </div><!-- .dslc-cpt-post-meta-date --> </div><!-- .dslc-cpt-post-meta --> <?php } ?> <?php if ($post_elements == 'all' || in_array('excerpt', $post_elements)) { ?> <div class="dslc-cpt-post-excerpt"> <?php if ($options['excerpt_or_content'] == 'content') { ?> <?php the_content(); ?> <?php } else { ?> <?php echo do_shortcode(wp_trim_words(get_the_excerpt(), $options['excerpt_length'])); ?> <?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(); ?> "> <?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 echo $options['button_text']; ?> </a> </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 } } wp_reset_query(); $this->module_end($options); }
function output($options) { $this->module_start($options); /* Module output starts here */ 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; } $anchor_class = ''; $anchor_target = '_self'; $anchor_href = '#'; if ($options['link_type'] == 'url_new') { $anchor_target = '_blank'; } if ($options['link_url'] !== '') { $anchor_href = do_shortcode($options['link_url']); } if ($options['link_type'] == 'lightbox' && $options['link_lb_image'] !== '') { $anchor_class .= 'dslc-lightbox-image '; $anchor_href = $options['link_lb_image']; } ?> <div class="dslc-image"> <?php if (empty($options['image']) && empty($options['image_url'])) { ?> <div class="dslc-notification dslc-red"><?php _e('No image has been set yet, edit the module to set one.', 'dslc_string'); ?> </div> <?php } else { ?> <?php $resize = false; $the_image = $options['image']; if (empty($options['image'])) { $the_image = do_shortcode($options['image_url']); } else { if ($options['resize_width'] != '' || $options['resize_height'] != '') { $resize = true; $resize_width = false; $resize_height = false; if ($options['resize_width'] != '') { $resize_width = $options['resize_width']; } if ($options['resize_height'] != '') { $resize_height = $options['resize_height']; } $the_image = dslc_aq_resize($options['image'], $resize_width, $resize_height, true); } } ?> <?php if ($options['link_type'] !== 'none') { ?> <a class="<?php echo $anchor_class; ?> " href="<?php echo $anchor_href; ?> " target="<?php echo $anchor_target; ?> "> <?php } ?> <img src="<?php echo $the_image; ?> " alt="<?php echo $options['image_alt']; ?> " title="<?php echo $options['image_title']; ?> " /> <?php if ($options['link_type'] !== 'none') { ?> </a> <?php } ?> <?php if ($options['custom_text_state'] == 'enabled') { ?> <div class="dslc-image-caption"> <?php if ($dslc_is_admin) { ?> <div class="dslca-editable-content" data-id="custom_text" data-type="simple" <?php if ($dslc_is_admin) { echo 'contenteditable'; } ?> ><?php echo stripslashes($options['custom_text']); ?> </div> <?php } else { ?> <?php echo stripslashes($options['custom_text']); ?> <?php } ?> </div> <?php } ?> <?php } ?> </div><!-- .dslc-image --> <?php /* Module output ends here */ $this->module_end($options); }
function widget($args, $instance) { $cache = array(); if (!$this->is_preview()) { $cache = wp_cache_get('widget_cocktail_recent_posts', 'widget'); } if (!is_array($cache)) { $cache = array(); } if (!isset($args['widget_id'])) { $args['widget_id'] = $this->id; } if (isset($cache[$args['widget_id']])) { echo $cache[$args['widget_id']]; return; } ob_start(); extract($args); $title = !empty($instance['title']) ? $instance['title'] : __('Recent Posts', AS_DOMAIN); /** This filter is documented in wp-includes/default-widgets.php */ $title = apply_filters('widget_title', $title, $instance, $this->id_base); $number = !empty($instance['number']) ? absint($instance['number']) : 5; if (!$number) { $number = 5; } $show_date = isset($instance['show_date']) ? $instance['show_date'] : false; $show_thumb = isset($instance['show_thumb']) ? $instance['show_thumb'] : false; /** * Filter the arguments for the Recent Posts widget. * * @since 3.4.0 * * @see WP_Query::get_posts() * * @param array $args An array of arguments used to retrieve the recent posts. */ $r = new WP_Query(apply_filters('widget_posts_args', array('posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true))); if ($r->have_posts()) { echo $args['before_widget']; if (!empty($title)) { echo $args['before_title'] . $title . $args['after_title']; } ?> <ul class="recent-post-widget-wrapper"> <?php while ($r->have_posts()) { $r->the_post(); ?> <li> <div class="recent-post-widget"> <?php if (has_post_thumbnail()) { ?> <?php $thumbnail_src = wp_get_attachment_url(get_post_thumbnail_id()); $website_url = site_url(); $thumbnail_src = str_replace($website_url, '', $thumbnail_src); $thumbnail = wp_get_attachment_url(get_post_thumbnail_id()); ?> <?php if ($show_thumb) { ?> <a href="<?php the_permalink(); ?> " title="<?php the_title(); ?> " class="as-img-thumb"> <img src="<?php echo dslc_aq_resize($thumbnail, 70, 50, true); ?> " alt="<?php the_title(); ?> "/> </a> <?php } ?> <?php } ?> <div class="recent-post-widget-content"> <h5><a href="<?php the_permalink(); ?> " class="sidebar-item-title"><?php the_title(); ?> </a></h5> <?php if ($show_date) { ?> <p class="recent-post-widget-date"><?php _e('Posted:', AS_DOMAIN); ?> <?php echo human_time_diff(get_the_time('U'), current_time('timestamp')) . __(' ago', AS_DOMAIN); ?> </p> <?php } ?> </div> <div class="clearfix"></div> </div> </li> <?php } ?> </ul> <?php echo $args['after_widget']; ?> <?php // Reset the global $the_post as this query will have stomped on it wp_reset_postdata(); } if (!$this->is_preview()) { $cache[$args['widget_id']] = ob_get_flush(); wp_cache_set('widget_cocktail_recent_posts', $cache, 'widget'); } else { ob_end_flush(); } }
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() && get_option('page_on_front', 0) != 0) { $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' => explode(' ', trim($options['post_type'])), 'order' => $options['order'], 'orderby' => $options['orderby'], 'offset' => $options['offset']); /** * ---------------------------------------------------------------------- * Lumberman Extension START */ // Prepare WP_Query argument for search listing if (is_search()) { $args['s'] = get_query_var('s'); global $posttypes_to_search; $posttypes_to_search = $args['post_type']; } // Prepare WP_Query argument for archive listing if (is_archive()) { if (is_category()) { $args['cat'] = get_query_var('cat'); } elseif (is_tag()) { $args['tag_id'] = get_query_var('tag_id'); } elseif (is_author()) { $args['author'] = get_query_var('author'); } elseif (is_date()) { $args['m'] = get_query_var('m'); } } // Custom posts per page doesn't work outofthebox, // so use global settings $args['posts_per_page'] = $options['amount'] = get_option('posts_per_page'); // Time based archive pages are available only for standard posts if (is_date() || is_front_page()) { $args['post_type'] = array('post'); } // else { // Get all registered (not searchable content types) // $registered_post_types = get_post_types( array('public' => true, 'publicly_queryable' => true, 'exclude_from_search' => false )); // Remove some custom types to not display // unset($registered_post_types['dslc_templates']); // Add WP_Query argument to search across all the post types // $args['post_type'] = array_values( $registered_post_types ); // } /** * ---------------------------------------------------------------------- */ // Category args if (isset($options['categories']) && $options['categories'] != '') { $cats_array = explode(' ', $options['categories']); $args['category__in'] = $cats_array; } // Debug: // lbmn_debug_console( $args ); // Do the query $dslc_query = new WP_Query($args); // Debug: // echo $GLOBALS['wp_query']->request; // $customPosts = new WP_Query($yourArgs); // echo "Last SQL-Query: {$dslc_query->request}"; /** * 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 if ($dslc_is_admin) { echo __('This heading will be automatically generated by a theme', 'lbmn'); } elseif (is_category()) { printf(__('Category Archives: %s', 'lbmn'), '<span>' . single_cat_title('', false) . '</span>'); } elseif (is_tag()) { printf(__('Tag Archives: %s', 'lbmn'), '<span>' . single_tag_title('', false) . '</span>'); } elseif (is_author()) { /* Queue the first post, that way we know * what author we're dealing with (if that is the case). */ the_post(); printf(__('Author Archives: %s', 'lbmn'), '<span class="vcard"><a class="url fn n" href="' . esc_url(get_author_posts_url(get_the_author_meta('ID'))) . '" title="' . esc_attr(get_the_author()) . '" rel="me">' . get_the_author() . '</a></span>'); /* Since we called the_post() above, we need to * rewind the loop back to the beginning that way * we can run the loop properly, in full. */ rewind_posts(); } elseif (is_day()) { printf(__('Daily Archives: %s', 'lbmn'), '<span>' . get_the_date() . '</span>'); } elseif (is_month()) { printf(__('Monthly Archives: %s', 'lbmn'), '<span>' . get_the_date('F Y') . '</span>'); } elseif (is_year()) { printf(__('Yearly Archives: %s', 'lbmn'), '<span>' . get_the_date('Y') . '</span>'); } elseif (is_tax('post_format', 'post-format-aside')) { _e('Asides', 'lbmn'); } elseif (is_tax('post_format', 'post-format-image')) { _e('Images', 'lbmn'); } elseif (is_tax('post_format', 'post-format-video')) { _e('Videos', 'lbmn'); } elseif (is_tax('post_format', 'post-format-quote')) { _e('Quotes', 'lbmn'); } elseif (is_tax('post_format', 'post-format-link')) { _e('Links', 'lbmn'); } elseif (is_search()) { // special title for search result page // get number of posts found for search query // $newSearch = new WP_Query("s=$s & showposts=-1"); $search_results_count = $dslc_query->found_posts; _e('You are searching for: ', 'lbmn'); echo '<strong>' . get_query_var('s') . '</strong>. <br />'; if (1 == $search_results_count) { _e('There is one post that match your criteria...', 'lbmn'); } elseif (1 < $search_results_count) { printf(__('Here are %s posts that match your criteria...', 'lbmn'), '<span>' . $search_results_count . '</span>'); } else { _e('Looks like nothing was found. Sorry.', 'lbmn') . $search_results_count; } } elseif (is_front_page()) { echo get_bloginfo('description'); } else { _e('Archives', 'lbmn'); } // 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 ) */ if ($dslc_query->have_posts()) { ?> <div 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-columns="<?php echo $carousel_items; ?> " data-pagination="<?php if (in_array('circles', $carousel_elements)) { echo 'true'; } else { echo 'false'; } ?> "><?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]; $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']; } } ?> <div class="dslc-post-thumb dslc-cpt-post-thumb dslc-on-hover-anim"> <div class="dslc-cpt-post-thumb-inner dslca-post-thumb"> <?php if ($manual_resize) { ?> <a href="<?php the_permalink(); ?> "><img src="<?php $res_img = dslc_aq_resize($thumb_url, $resize_width, $resize_height, true); echo $res_img; ?> " /></a> <?php } else { ?> <a href="<?php the_permalink(); ?> "><?php the_post_thumbnail('full'); ?> </a> <?php } ?> </div><!-- .dslc-cpt-post-thumb-inner --> <?php if (($options['main_location'] == 'inside' || $options['main_location'] == 'inside_visible') && ($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 ($options['main_location'] == 'inside_visible') { echo 'dslc-cpt-post-main-visible'; } ?> dslc-on-hover-anim-target dslc-anim-<?php echo $options['css_anim_hover']; ?> " data-dslc-anim="<?php echo $options['css_anim_hover']; ?> "> <div class="dslc-cpt-post-main-inner dslc-init-<?php echo $options['main_position']; ?> "> <?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-author"> <?php _e('By', 'dslc_string'); ?> <?php the_author_posts_link(); ?> </div><!-- .dslc-cpt-post-meta-author --> <div class="dslc-cpt-post-meta-date"> <?php the_time(get_option('date_format')); ?> </div><!-- .dslc-cpt-post-meta-date --> </div><!-- .dslc-cpt-post-meta --> <?php } ?> <?php if ($post_elements == 'all' || in_array('excerpt', $post_elements)) { ?> <div class="dslc-cpt-post-excerpt"> <?php if ($options['excerpt_or_content'] == 'content') { ?> <?php the_content(); ?> <?php } else { ?> <?php echo do_shortcode(wp_trim_words(get_the_excerpt(), $options['excerpt_length'])); ?> <?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(); ?> "> <?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 echo $options['button_text']; ?> </a> </div><!-- .dslc-cpt-post-read-more --> <?php } ?> </div><!-- .dslc-cpt-post-main-inner --> </div><!-- .dslc-cpt-post-main --> <?php } ?> </div><!-- .dslc-cpt-post-thumb --> <?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-author"> <?php _e('By', 'dslc_string'); ?> <?php the_author_posts_link(); ?> </div><!-- .dslc-cpt-post-meta-author --> <div class="dslc-cpt-post-meta-date"> <?php the_time(get_option('date_format')); ?> </div><!-- .dslc-cpt-post-meta-date --> </div><!-- .dslc-cpt-post-meta --> <?php } ?> <?php if ($post_elements == 'all' || in_array('excerpt', $post_elements)) { ?> <div class="dslc-cpt-post-excerpt"> <?php if ($options['excerpt_or_content'] == 'content') { ?> <?php the_content(); ?> <?php } else { ?> <?php // Lumberman edit start if (post_type_supports(get_post_type(), 'excerpt')) { echo do_shortcode(wp_trim_words(get_the_excerpt(), $options['excerpt_length'])); } else { // show 'dslc_search_content' metabox as excerpt for the content types // that have no 'excerpt' feature enabled echo do_shortcode(wp_trim_words(get_post_meta(get_the_ID(), 'dslc_search_content', true), $options['excerpt_length'])); } // Lumberman edit end ?> <?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(); ?> "> <?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 echo $options['button_text']; ?> </a> </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 && $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">You do not have any posts of that post type at the moment. <span class="dslca-refresh-module-hook dslc-icon dslc-icon-refresh"></span></span></div><?php } } /** * Pagination */ // if ( isset( $options['pagination_type'] ) && $options['pagination_type'] == 'numbered' ) { // Always show pagination for archive listings $num_pages = $dslc_query->max_num_pages; dslc_post_pagination(array('pages' => $num_pages)); // } wp_reset_query(); $this->module_end($options); }
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; } // Fix for pagination from other modules affecting this one when pag disabled if ($options['pagination_type'] == 'disabled') { $paged = 1; } // Fix for offset braking pagination $query_offset = $options['offset']; if ($query_offset > 0 && $paged > 1) { $query_offset = ($paged - 1) * $options['amount'] + $options['offset']; } // General args $args = array('paged' => $paged, 'post_type' => $options['post_type'], 'posts_per_page' => $options['amount'], 'order' => $options['order'], 'orderby' => $options['orderby'], 'offset' => $query_offset); if (defined('DOING_AJAX') && DOING_AJAX) { $args['post_status'] = array('publish', 'private'); } // 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 stripslashes($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 $taxonomy_name = ''; if ($show_filters) { $cats_array = array(); $cats_count = 0; if ($dslc_query->have_posts()) { while ($dslc_query->have_posts()) { $dslc_query->the_post(); $cats_count++; if ($cats_count == 1) { $post_type_taxonomies = get_object_taxonomies(get_post_type(), 'objects'); foreach ($post_type_taxonomies as $taxonomy) { if ($taxonomy->hierarchical == true) { $taxonomy_name = $taxonomy->name; } } } $post_cats = get_the_terms(get_the_ID(), $taxonomy_name); 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 _ex('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_data = ''; if (isset($taxonomy_name)) { $post_cats = get_the_terms(get_the_ID(), $taxonomy_name); 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']; } } ?> <?php if (has_post_thumbnail()) { ?> <div class="dslc-post-thumb dslc-cpt-post-thumb dslc-on-hover-anim"> <div class="dslc-cpt-post-thumb-inner dslca-post-thumb"> <?php if ($manual_resize) { ?> <a href="<?php the_permalink(); ?> "><img src="<?php $res_img = dslc_aq_resize($thumb_url, $resize_width, $resize_height, true); echo $res_img; ?> " alt="<?php echo $thumb_alt; ?> " /></a> <?php } else { ?> <a href="<?php the_permalink(); ?> "><?php the_post_thumbnail('full'); ?> </a> <?php } ?> </div><!-- .dslc-cpt-post-thumb-inner --> <?php if (($options['main_location'] == 'inside' || $options['main_location'] == 'inside_visible') && ($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 ($options['main_location'] == 'inside_visible') { echo 'dslc-cpt-post-main-visible'; } ?> dslc-on-hover-anim-target dslc-anim-<?php echo $options['css_anim_hover']; ?> " data-dslc-anim="<?php echo $options['css_anim_hover']; ?> " data-dslc-anim-speed="<?php echo $options['css_anim_speed']; ?> "> <div class="dslc-cpt-post-main-inner dslc-init-<?php echo $options['main_position']; ?> "> <?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 --> <div class="dslc-cpt-post-meta-author"> <?php _e('By', 'dslc_string'); ?> <?php the_author_posts_link(); ?> </div><!-- .dslc-cpt-post-meta-author --> </div><!-- .dslc-cpt-post-meta --> <?php } ?> <?php if ($post_elements == 'all' || in_array('excerpt', $post_elements)) { ?> <div class="dslc-cpt-post-excerpt"> <?php if ($options['excerpt_or_content'] == 'content') { ?> <?php the_content(); ?> <?php } else { ?> <?php if ($options['excerpt_length'] > 0) { 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'])); } } else { if (has_excerpt()) { echo do_shortcode(get_the_excerpt()); } else { echo do_shortcode(get_the_content()); } } ?> <?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(); ?> "> <?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><!-- .dslc-cpt-post-read-more --> <?php } ?> </div><!-- .dslc-cpt-post-main-inner --> </div><!-- .dslc-cpt-post-main --> <?php } ?> </div><!-- .dslc-cpt-post-thumb --> <?php } ?> <?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-author"> <?php _e('By', 'dslc_string'); ?> <?php the_author_posts_link(); ?> </div><!-- .dslc-cpt-post-meta-author --> <span class="as-line-post"></span> <div class="dslc-cpt-post-meta-category"> <span class="dslc-icon dslc-icon-folder-open-alt"></span> <?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 ($options['excerpt_or_content'] == 'content') { ?> <?php the_content(); ?> <?php } else { ?> <?php if ($options['excerpt_length'] > 0) { 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'])); } } else { if (has_excerpt()) { echo do_shortcode(get_the_excerpt()); } else { echo do_shortcode(get_the_content()); } } ?> <?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 get_the_ID(); ?> "> <span class="dslc-icon dslc-icon-heart-empty"></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; if ($options['offset'] > 0) { $num_pages = ceil(($dslc_query->found_posts - $options['offset']) / $options['amount']); } dslc_post_pagination(array('pages' => $num_pages, 'type' => $options['pagination_type'])); } wp_reset_postdata(); $this->module_end($options); }
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); /* Module output stars here */ if (!isset($options['excerpt_length'])) { $options['excerpt_length'] = 20; } 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; } // Fix for pagination from other modules affecting this one when pag disabled if ($options['pagination_type'] == 'disabled') { $paged = 1; } // Fix for offset braking pagination $query_offset = $options['offset']; if ($query_offset > 0 && $paged > 1) { $query_offset = ($paged - 1) * $options['amount'] + $options['offset']; } $args = array('paged' => $paged, 'post_type' => 'dslc_staff', 'posts_per_page' => $options['amount'], 'order' => $options['order'], 'orderby' => $options['orderby'], 'offset' => $query_offset); if (isset($options['categories']) && $options['categories'] != '') { $cats_array = explode(' ', trim($options['categories'])); $args['tax_query'] = array(array('taxonomy' => 'dslc_staff_cats', 'field' => 'slug', 'terms' => $cats_array, 'operator' => $options['categories_operator'])); } // 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; } // 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); } $columns_class = 'dslc-col dslc-' . $options['columns'] . '-col '; $count = 0; $real_count = 0; $increment = $options['columns']; $max_count = 12; /** * Elements to show */ // 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(); } /* Container Class */ $container_class = 'dslc-posts dslc-staff dslc-clearfix '; if ($options['type'] == 'masonry') { $container_class .= 'dslc-init-masonry '; } elseif ($options['type'] == 'carousel') { $container_class .= 'dslc-init-carousel '; } elseif ($options['type'] == 'grid') { $container_class .= 'dslc-init-grid '; } /* Element Class */ $element_class = 'dslc-post dslc-staff-member '; if ($options['type'] == 'masonry') { $element_class .= 'dslc-masonry-item '; } elseif ($options['type'] == 'carousel') { $element_class .= 'dslc-carousel-item '; } /** * 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; } /** * Posts ( output ) */ if ($dslc_query->have_posts()) { ?> <div class="<?php echo $container_class; ?> "><?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_terms(get_the_ID(), 'dslc_staff_cats'); $post_cats_data = ''; if (!empty($post_cats)) { foreach ($post_cats as $post_cat) { $post_cats_data .= $post_cat->slug . ' '; } } ?> <?php $social = $socials = array(); $position = get_post_meta(get_the_ID(), 'dslc_staff_position', true); $social['twitter'] = get_post_meta(get_the_ID(), 'dslc_staff_social_twitter', true); $social['facebook'] = get_post_meta(get_the_ID(), 'dslc_staff_social_facebook', true); $social['google-plus'] = get_post_meta(get_the_ID(), 'dslc_staff_social_googleplus', true); $social['linkedin'] = get_post_meta(get_the_ID(), 'dslc_staff_social_linkedin', true); $social['dribbble'] = get_post_meta(get_the_ID(), 'dslc_staff_social_dribbble', true); $social['github'] = get_post_meta(get_the_ID(), 'dslc_staff_social_github', true); $social['stackexchange'] = get_post_meta(get_the_ID(), 'dslc_staff_social_stackexchange', true); $social['vk'] = get_post_meta(get_the_ID(), 'dslc_staff_social_vk', true); $social['weibo'] = get_post_meta(get_the_ID(), 'dslc_staff_social_weibo', true); $social['xing'] = get_post_meta(get_the_ID(), 'dslc_staff_social_xing', true); $social['renren'] = get_post_meta(get_the_ID(), 'dslc_staff_social_renren', true); $social['foursquare'] = get_post_meta(get_the_ID(), 'dslc_staff_social_foursquare', true); $social['instagram'] = get_post_meta(get_the_ID(), 'dslc_staff_social_instagram', true); $social['pinterest'] = get_post_meta(get_the_ID(), 'dslc_staff_social_pinterest', true); $social['skype'] = get_post_meta(get_the_ID(), 'dslc_staff_social_skype', true); $social['tumblr'] = get_post_meta(get_the_ID(), 'dslc_staff_social_tumblr', true); $social['pagelines'] = get_post_meta(get_the_ID(), 'dslc_staff_social_pagelines', true); $social['youtube'] = get_post_meta(get_the_ID(), 'dslc_staff_social_youtube', true); $social['flickr'] = get_post_meta(get_the_ID(), 'dslc_staff_social_flickr', true); $social['vimeo-square'] = get_post_meta(get_the_ID(), 'dslc_staff_social_vimeo', true); $social['envelope'] = get_post_meta(get_the_ID(), 'dslc_staff_social_envelope', true); foreach ($social as $k => $v) { if (!empty($v)) { $socials[$k] = $v; } } ?> <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']; } } ?> <?php if (has_post_thumbnail()) { ?> <?php $black_white = ''; if ($options['effect_hover_img'] == 'black_white') { $black_white = ' as-grayscale'; } ?> <div class="dslc-post-thumb dslc-staff-member-thumb dslc-on-hover-anim <?php echo $black_white; ?> "> <div class="dslc-staff-member-thumb-inner dslca-post-thumb"> <?php if ($manual_resize) { ?> <img src="<?php $res_img = dslc_aq_resize($thumb_url, $resize_width, $resize_height, true); echo $res_img; ?> " alt="<?php echo $thumb_alt; ?> " /> <?php } else { ?> <?php the_post_thumbnail('full'); ?> <?php } ?> </div> </div><!-- .dslc-staff-member-thumb --> <?php } ?> <?php } ?> <?php if ($post_elements == 'all' || in_array('title', $post_elements) || in_array('position', $post_elements) || in_array('excerpt', $post_elements)) { ?> <div class="dslc-staff-member-main"> <?php if ($post_elements == 'all' || in_array('title', $post_elements)) { ?> <div class="dslc-staff-member-title"> <h2><?php the_title(); ?> </h2> </div><!-- .dslc-staff-member-title --> <?php } ?> <?php if ($post_elements == 'all' || in_array('position', $post_elements)) { ?> <div class="dslc-staff-member-position"> <?php echo $position; ?> </div><!-- .dslc-staff-member-position --> <?php } ?> <?php if ($post_elements == 'all' || in_array('excerpt', $post_elements)) { ?> <div class="dslc-staff-member-excerpt"> <?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 } ?> </div><!-- .dslc-staff-member-excerpt --> <?php } ?> <?php if ($post_elements == 'all' || in_array('social', $post_elements)) { ?> <div class="as-staff-social-wrapper"> <div class="as-staff-list-social"> <?php foreach ($socials as $k => $v) { if (!empty($v)) { ?> <a href="<?php echo $v; ?> " target="<?php echo $options['social_link_target']; ?> "><span class="dslc-icon dslc-icon-<?php echo $k; ?> "></span></a> <?php } } ?> </div> </div> <?php } ?> <!-- .dslc-staff-social --> </div><!-- .dslc-staff-member-main --> <?php } ?> </div><!-- .dslc-staff-member --> <?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><?php } else { if ($dslc_is_admin) { ?> <div class="dslc-notification dslc-red"><?php _e('You do not have staff at the moment. Go to <strong>WP Admin → Staff</strong> to add some.', '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; if ($options['offset'] > 0) { $num_pages = ceil(($dslc_query->found_posts - $options['offset']) / $options['amount']); } dslc_post_pagination(array('pages' => $num_pages, 'type' => $options['pagination_type'])); } wp_reset_postdata(); /* Module output ends here */ $this->module_end($options); }