/** * Slideshow controller. * */ function presscore_slideshow_controller() { global $post; $config = Presscore_Config::get_instance(); if ('slideshow' != $config->get('header_title')) { return; } $slider_id = $config->get('slideshow_sliders'); // turn off regular titles and breadcrumbs remove_action('presscore_before_main_container', 'presscore_page_title_controller', 16); if (dt_get_paged_var() > 1) { return; } switch ($config->get('slideshow_mode')) { 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(); $slideshow = Presscore_Inc_Slideshow_Post_Type::get_by_id($slider_id); // 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 'metro': $slideshow = Presscore_Inc_Slideshow_Post_Type::get_by_id( $slider_id ); // prepare data if ( $slideshow->have_posts() ) { $slideshow_objects = array(); while ( $slideshow->have_posts() ) { $slideshow->the_post(); $media_items = get_post_meta( $post->ID, '_dt_slider_media_items', true ); if ( empty($media_items) ) { continue; } $attachments_data = presscore_get_attachment_post_data( $media_items ); if ( count($attachments_data) > 1 ) { $object = array(); foreach ( $attachments_data as $array ) { $object[] = Presscoe_Inc_Classes_SwapperSlider::array_to_object( $array ); } } else { $object = Presscoe_Inc_Classes_SwapperSlider::array_to_object( current($attachments_data) ); } $slideshow_objects[] = $object; } wp_reset_postdata(); echo Presscoe_Inc_Classes_SwapperSlider::get_html( $slideshow_objects ); } break; */ /* case 'metro': $slideshow = Presscore_Inc_Slideshow_Post_Type::get_by_id( $slider_id ); // prepare data if ( $slideshow->have_posts() ) { $slideshow_objects = array(); while ( $slideshow->have_posts() ) { $slideshow->the_post(); $media_items = get_post_meta( $post->ID, '_dt_slider_media_items', true ); if ( empty($media_items) ) { continue; } $attachments_data = presscore_get_attachment_post_data( $media_items ); if ( count($attachments_data) > 1 ) { $object = array(); foreach ( $attachments_data as $array ) { $object[] = Presscoe_Inc_Classes_SwapperSlider::array_to_object( $array ); } } else { $object = Presscoe_Inc_Classes_SwapperSlider::array_to_object( current($attachments_data) ); } $slideshow_objects[] = $object; } wp_reset_postdata(); echo Presscoe_Inc_Classes_SwapperSlider::get_html( $slideshow_objects ); } 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; case 'revolution': $rev_slider = $config->get('slideshow_revolution_slider'); if ($rev_slider && function_exists('putRevSlider')) { echo '<div id="main-slideshow">'; putRevSlider($rev_slider); echo '</div>'; } break; case 'layer': $layer_slider = $config->get('slideshow_layer_slider'); $layer_bg_and_paddings = $config->get('slideshow_layer_bg_and_paddings'); if ($layer_slider && function_exists('layerslider')) { echo '<div id="main-slideshow"' . ($layer_bg_and_paddings ? ' class="layer-fixed"' : '') . '>'; layerslider($layer_slider); echo '</div>'; } } // switch }
/** * Render 3D slider. * */ function presscore_render_3d_slider_data() { global $post; $config = Presscore_Config::get_instance(); $slider_id = $config->get('slideshow_sliders'); $slideshows = Presscore_Inc_Slideshow_Post_Type::get_by_id($slider_id); 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"; } }