/**
  * Render 3D slider.
  *
  */
 function presscore_render_3d_slider_data()
 {
     global $post;
     $config = Presscore_Config::get_instance();
     $slider_id = $config->get('slideshow_sliders');
     $slideshows = presscore_query()->get_posts(array('post_type' => 'dt_slideshow', 'post__in' => $slider_id, 'has_password' => false));
     if (!$slideshows || !$slideshows->have_posts()) {
         return;
     }
     $slides = array();
     foreach ($slideshows->posts as $slideshow) {
         $media_items = get_post_meta($slideshow->ID, '_dt_slider_media_items', true);
         if (empty($media_items)) {
             continue;
         }
         $slides = array_merge($slides, $media_items);
     }
     $attachments_data = presscore_get_attachment_post_data($slides);
     $count = count($attachments_data);
     if ($count < 10) {
         $chunks = array($attachments_data, array(), array());
     } else {
         $length = ceil($count / 3);
         $chunks = array_chunk($attachments_data, $length);
     }
     $chunks = array_reverse($chunks);
     foreach ($chunks as $layer => $images) {
         printf('<div id="level%d" class="plane">' . "\n", $layer + 1);
         foreach ($images as $img) {
             printf('<img src="%s" alt="%s" />' . "\n", esc_url($img['full']), esc_attr($img['description']));
         }
         echo "</div>\n";
     }
 }
 /**
  * Display related projects.
  */
 function presscore_display_related_projects()
 {
     global $post;
     $html = '';
     $config = presscore_get_config();
     // if related projects turn on in theme options
     if ($config->get('post.related_posts.enabled')) {
         $terms = array();
         switch ($config->get('post.related_posts.query.mode')) {
             case 'custom':
                 $terms = $config->get('post.related_posts.query.terms');
                 break;
             default:
                 $terms = wp_get_object_terms($post->ID, 'dt_portfolio_category', array('fields' => 'ids'));
         }
         if ($terms && !is_wp_error($terms)) {
             $posts = presscore_query()->get_related_posts_by_terms(array('post_type' => 'dt_portfolio', 'taxonomy' => 'dt_portfolio_category', 'posts_per_page' => intval($config->get('post.related_posts.query.posts_per_page')), 'terms' => $terms));
             $portfolio_scroller = new Presscore_Portfolio_Posts_Scroller();
             $portfolio_scroller->setup($posts, array('class' => 'related-projects slider-wrapper', 'width' => $config->get('post.related_posts.width'), 'height' => $config->get('post.related_posts.height'), 'show_title' => $config->get('post.related_posts.show.title'), 'show_excerpt' => $config->get('post.related_posts.show.description'), 'appearance' => 'under_image', 'padding' => 20, 'bg_under_projects' => false, 'content_aligment' => 'center', 'hover_animation' => 'fade', 'hover_bg_color' => 'accent', 'hover_content_visibility' => 'on_hoover', 'show_link' => $config->get('post.related_posts.show.link'), 'show_details' => $config->get('post.related_posts.show.details_link'), 'show_zoom' => $config->get('post.related_posts.show.zoom'), 'show_date' => $config->get('post.related_posts.meta.fields.date'), 'show_categories' => $config->get('post.related_posts.meta.fields.categories'), 'show_comments' => $config->get('post.related_posts.meta.fields.comments'), 'show_author' => $config->get('post.related_posts.meta.fields.author'), 'arrows' => 'accent'));
             $html .= $portfolio_scroller->get_html();
             if ($html) {
                 $html = '<div class="full-width-wrap">' . $html . '</div>';
                 // fancy separator
                 $html = presscore_fancy_separator(array('title' => $config->get('post.related_posts.title'), 'class' => 'fancy-projects-title')) . $html;
                 if (!(post_password_required() || !comments_open() && 0 == get_comments_number())) {
                     // add gap after projects
                     $html .= do_shortcode('[dt_gap height="40"]');
                 }
             }
         }
     }
     echo (string) apply_filters('presscore_display_related_projects', $html);
 }
 public function do_header_slideshow($type)
 {
     global $post;
     $config = Presscore_Config::get_instance();
     switch ($type) {
         case 'porthole':
             $class = 'fixed' == $config->get('slideshow_layout') ? 'class="fixed" ' : '';
             $height = absint($config->get('slideshow_slider_height'));
             $width = absint($config->get('slideshow_slider_width'));
             if (!$height) {
                 $height = 500;
             }
             if (!$width) {
                 $width = 1200;
             }
             printf('<div id="main-slideshow" %sdata-width="%d" data-height="%d" data-autoslide="%d" data-scale="%s" data-paused="%s"></div>', $class, $width, $height, absint($config->get('slideshow_autoslide_interval')), 'fit' == $config->get('slideshow_slider_scaling') ? 'fit' : 'fill', 'paused' == $config->get('slideshow_autoplay') ? 'true' : 'false');
             add_action('wp_footer', 'presscore_render_porthole_slider_data', 15);
             break;
         case 'photo_scroller':
             $slides = array();
             $slider_id = $config->get('slideshow_sliders');
             $slideshow = presscore_query()->get_posts(array('post_type' => 'dt_slideshow', 'post__in' => $slider_id, 'has_password' => false));
             // prepare data
             if ($slideshow->have_posts()) {
                 while ($slideshow->have_posts()) {
                     $slideshow->the_post();
                     $media_items = get_post_meta($post->ID, '_dt_slider_media_items', true);
                     if (empty($media_items)) {
                         continue;
                     }
                     $slides = array_merge($slides, $media_items);
                 }
                 wp_reset_postdata();
             }
             $photo_scroller = new Presscore_PhotoScroller($slides, array('wrap_class' => 'fullscreen' == $config->get('slideshow.photo_scroller.layout') ? 'fullscreen-scroller' : '', 'background_color' => $config->get('slideshow.photo_scroller.background.color'), 'padding_top' => $config->get('slideshow.photo_scroller.padding.top'), 'padding_bottom' => $config->get('slideshow.photo_scroller.padding.bottom'), 'padding_side' => $config->get('slideshow.photo_scroller.padding.side'), 'autoplay' => 'play' == $config->get('slideshow.photo_scroller.autoplay.mode'), 'autoplay_speed' => $config->get('slideshow.photo_scroller.autoplay.speed'), 'thumbnails_visibility' => $config->get('slideshow.photo_scroller.thumbnails.visibility'), 'thumbnails_width' => $config->get('slideshow.photo_scroller.thumbnail.width'), 'thumbnails_height' => $config->get('slideshow.photo_scroller.thumbnail.height'), 'portrait_images_view' => array('max_width' => $config->get('slideshow.photo_scroller.behavior.portrait.width.max'), 'min_width' => $config->get('slideshow.photo_scroller.behavior.portrait.width.min'), 'fill_desktop' => $config->get('slideshow.photo_scroller.behavior.portrait.fill.desktop'), 'fill_mobile' => $config->get('slideshow.photo_scroller.behavior.portrait.fill.mobile')), 'landscape_images_view' => array('max_width' => $config->get('slideshow.photo_scroller.behavior.landscape.width.max'), 'min_width' => $config->get('slideshow.photo_scroller.behavior.landscape.width.min'), 'fill_desktop' => $config->get('slideshow.photo_scroller.behavior.landscape.fill.desktop'), 'fill_mobile' => $config->get('slideshow.photo_scroller.behavior.landscape.fill.mobile')), 'inactive_opacity' => $config->get('slideshow.photo_scroller.inactive.opacity'), 'show_overlay' => $config->get('slideshow.photo_scroller.overlay.enabled'), 'show_post_navigation' => false, 'show_share_buttons' => false));
             if ($photo_scroller->have_slides()) {
                 echo $photo_scroller->get_html();
             }
             break;
         case '3d':
             $class = '';
             $data_attr = '';
             $slider_layout = $config->get('slideshow_3d_layout');
             if (in_array($slider_layout, array('prop-fullwidth', 'prop-content-width'))) {
                 $class = 'prop-fullwidth' == $slider_layout ? 'class="fixed-height" ' : 'class="fixed" ';
                 $width = $config->get('slideshow_3d_slider_width');
                 $height = $config->get('slideshow_3d_slider_height');
                 $data_attr = sprintf(' data-width="%d" data-height="%d"', $width ? absint($width) : 2500, $height ? absint($height) : 1200);
             }
             printf('<div id="main-slideshow" %s><div class="three-d-slider"%s><span id="loading">0</span></div></div>', $class, $data_attr);
             add_action('wp_footer', 'presscore_render_3d_slider_data', 15);
             break;
     }
     // switch
 }
 /**
  * @return WP_Query Album photos query.
  */
 function presscore_mod_albums_get_photos()
 {
     $albums_query = presscore_get_filtered_posts(array('post_type' => 'dt_gallery', 'taxonomy' => 'dt_gallery_category', 'posts_per_page' => -1));
     $media_items = array(0);
     if ($albums_query->have_posts()) {
         $media_items = array();
         foreach ($albums_query->posts as $gallery) {
             $gallery_media = get_post_meta($gallery->ID, '_dt_album_media_items', true);
             if (is_array($gallery_media)) {
                 $media_items = array_merge($media_items, $gallery_media);
             }
         }
     }
     $media_items = array_unique($media_items);
     $attachments_args = array('post__in' => $media_items, 'orderby' => 'post__in', 'no_found_rows' => false, 'paged' => dt_get_paged_var());
     $posts_per_page = presscore_config()->get('posts_per_page');
     if ($posts_per_page) {
         $attachments_args['posts_per_page'] = $posts_per_page;
     }
     return presscore_query()->get_attachments($attachments_args);
 }
 function presscore_get_filtered_posts($args)
 {
     $config = presscore_config();
     // sanitize
     $request = $config->get('request_display');
     if ($request) {
         $request = wp_parse_args($request, array('terms_ids' => null));
     }
     $display = $config->get('display');
     if (!is_array($display)) {
         $display = array();
     }
     $display = wp_parse_args($display, array('terms_ids' => null, 'posts_ids' => null, 'type' => 'category', 'select' => 'all'));
     $is_posts_query = 'albums' == $display['type'];
     $terms = $request ? $request['terms_ids'] : ($is_posts_query ? null : $display['terms_ids']);
     $defaults = array('post_type' => 'post', 'taxonomy' => 'category', 'select' => $request ? 'only' : $display['select'], 'order' => $config->get('order'), 'orderby' => $config->get('orderby'), 'posts_per_page' => $config->get('posts_per_page'), 'terms' => $terms, 'post__in' => $is_posts_query && 'only' == $display['select'] ? $display['posts_ids'] : null, 'post__not_in' => $is_posts_query && 'except' == $display['select'] ? $display['posts_ids'] : null, 'query' => presscore_query());
     $args = wp_parse_args($args, $defaults);
     $query = $args['query'];
     unset($args['query']);
     $posts_query = $query->get_posts_by_terms($args);
     do_action('presscore_get_filtered_posts-' . $args['post_type'], $posts_query);
     do_action('presscore_get_filtered_posts', $posts_query);
     return $posts_query;
 }