function quadro_single_portfolio_item($item_id) { // Get a global post reference since get_adjacent_post() references it global $post, $quadro_options; // Get Item ID from ajax call if there is $item_id = isset($_POST['item_id']) ? esc_attr($_POST['item_id']) : $item_id; // Get the post object for the specified post and place it in the global variable $post = get_post($item_id); setup_postdata($post); // Get Portfolio Item Options $media_order = esc_attr(get_post_meta($item_id, 'quadro_portfolio_video_position', true)); $video_out = esc_attr(get_post_meta($item_id, 'quadro_portfolio_video_out', true)); $item_style = esc_attr(get_post_meta($item_id, 'quadro_portfolio_item_style', true)); $img_link = esc_attr(get_post_meta($item_id, 'quadro_portfolio_img_link', true)); $viewall_url = esc_url(get_post_meta($item_id, 'quadro_portfolio_viewall_url', true)); $viewall_text = esc_attr(get_post_meta($item_id, 'quadro_portfolio_viewall', true)); $media_order = $video_out != 'true' ? explode(',', $media_order) : array('gallery', 'video'); // Prepare Navigation $viewall_url = $viewall_url != '' ? $viewall_url : esc_url($quadro_options['portfolio_viewall_url']); $viewall_text = $viewall_text != '' ? $viewall_text : esc_attr($quadro_options['portfolio_viewall']); $prev_id = get_previous_post() ? get_previous_post($quadro_options['portfolio_keep_nav_in'], '', 'portfolio_tax')->ID : ''; $next_id = get_next_post() ? get_next_post($quadro_options['portfolio_keep_nav_in'], '', 'portfolio_tax')->ID : ''; $disabled_prev = $prev_id == '' ? 'disabled' : ''; $disabled_next = $next_id == '' ? 'disabled' : ''; ?> <article id="post-<?php the_ID(); ?> " <?php post_class('clear ' . $item_style); ?> > <header class="item-header"> <?php qi_before_portf_item_header(); ?> <?php // Show view all option if on single. We check for the AJAX $_POST variable if ($viewall_url != '' && !isset($_POST['item_id'])) { ?> <a href="<?php echo $viewall_url; ?> " class="view-all-portf"><span><?php echo $viewall_text; ?> </span></a> <?php } ?> <h1 class="item-title"><?php the_title(); ?> </h1> <div class="item-terms"> <?php echo get_the_term_list($item_id, 'portfolio_tax', '', '', ''); ?> </div> <div class="actions-header"> <a href="<?php echo esc_url(get_permalink($prev_id)); ?> " class="item-link prev-portf-item <?php echo $disabled_prev; ?> " title="<?php esc_html_e('Prev Item', 'quadro'); ?> " data-id="<?php echo $prev_id; ?> "><span class="prev-item"><i class="fa fa-angle-left"></i></span></a> <a href="<?php echo esc_url(get_permalink($next_id)); ?> " class="item-link next-portf-item <?php echo $disabled_next; ?> " title="<?php esc_html_e('Next Item', 'quadro'); ?> " data-id="<?php echo $next_id; ?> "><span class="next-item"><i class="fa fa-angle-right"></i></span></a> </div> <?php qi_after_portf_item_header(); ?> </header> <div class="item-body clear"> <?php // Try to retrieve Content Transient and set it later if nothing there $content_transient = get_transient('qi_portf_item_content_' . $item_id); // Try to retrieve Media Transient and set it later if nothing there $media_transient = get_transient('qi_portf_item_media_' . $item_id); if (false === $content_transient || false === $media_transient) { $content = get_the_content($item_id); } ?> <?php // Process Media Content if ($item_style != 'as-created') { // Opening Style Conditional if (false === $content_transient || false === $media_transient) { // Remove Galleries from content $content = quadro_strip_shortcode_gallery($content); // Filter through the_content filter $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]>', $content); $media_transient = ''; $media_transient .= '<div class="media-wrapper">'; $media_transient .= '<ul class="portfolio-gallery ' . $item_style . '-gallery slides">'; // Define image sizes if ($item_style == 'portf-layout1' || $item_style == 'portf-layout2') { $correct_thumb = 'large'; } else { if ($item_style == 'portf-layout5' || $item_style == 'portf-layout5b') { $correct_thumb = 'quadro-med-full-thumb'; } else { $correct_thumb = 'quadro-full-thumb'; } } // Prepare faux element for masonry style. Avoid it if empty content. if (($item_style == 'portf-layout5' || $item_style == 'portf-layout5b') && $content != '') { $media_transient .= '<li class="gallery-item faux-element"></li>'; } foreach ($media_order as $media) { switch ($media) { case 'gallery': if (get_post_gallery()) { $gallery = get_post_gallery(get_the_ID(), false); /* Loop through all images and output them one by one */ $gallery_ids = explode(',', $gallery['ids']); foreach ($gallery_ids as $pic_id) { $full_url = wp_get_attachment_image_src($pic_id, 'full'); $media_transient .= '<li class="gallery-item">'; $media_transient .= $img_link == 'true' ? '<a href="' . $full_url[0] . '" class="portf-lightbox" rel="lightbox">' : ''; $media_transient .= wp_get_attachment_image($pic_id, $correct_thumb); $media_transient .= get_post($pic_id) && get_post($pic_id)->post_excerpt != '' ? '<p class="gallery-caption">' . get_post($pic_id)->post_excerpt . '</p>' : ''; $media_transient .= $img_link == 'true' ? '</a>' : ''; $media_transient .= '</li>'; } } else { $media_transient .= '<li class="gallery-item">'; // Bring Item's Featured Image $media_transient .= get_the_post_thumbnail(get_the_ID(), $correct_thumb, array('alt' => '' . get_the_title() . '', 'title' => '')); $media_transient .= '</li>'; } break; case 'video': // Exit early if Video Out checked and layout is 'wide-slider-media' if ($video_out == 'true' && ($item_style == 'wide-slider-media' || $item_style == 'regular-slider-media')) { break; } // Bring videos and strip them out of $content $iframes_return = quadro_print_iframes($content, '<li class="gallery-item">', '</li>'); $content = $iframes_return['content']; $media_transient .= $iframes_return['media']; break; } // end switch operator } // end foreach $media_transient .= '</ul>'; $media_transient .= '</div>'; // Closing .media-wrapper // Bring videos and strip them out of $content if ($video_out == 'true' && ($item_style == 'portf-layout2' || $item_style == 'portf-layout4' || $item_style == 'portf-layout6')) { $iframes_return = quadro_print_iframes($content, '<div class="item-videos">', '</div>'); $content = $iframes_return['content']; $media_transient .= $iframes_return['media']; } } // End if empty media or content } else { if (false === $content_transient || false === $media_transient) { // Filter through the_content filter as it comes $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]>', $content); } } ?> <?php if (false === $content_transient || false === $media_transient) { // We save both here to make sure they both get stored on the same place. set_transient('qi_portf_item_content_' . get_the_ID(), $content, 750 * HOUR_IN_SECONDS); set_transient('qi_portf_item_media_' . get_the_ID(), $media_transient, 750 * HOUR_IN_SECONDS); } else { $content = $content_transient; } ?> <?php if ($content !== '') { ?> <div class="item-content clear"> <?php // Present Content Handler if Layout 6 Selected if ($item_style == 'portf-layout6') { echo '<span class="portf-content-handler"></span>'; } ?> <?php quadro_get_portfolio_fields($item_id); ?> <div class="item-description"> <?php echo apply_filters('qi_filter_portf_item_content', $content); ?> </div> </div><!-- .item-content --> <?php } ?> <?php if ($item_style != 'as-created') { // Opening Style Conditional ?> <div class="item-media"> <?php echo apply_filters('qi_filter_portf_item_media', $media_transient); ?> </div><!-- .item-media --> <?php } ?> </div><!-- .item-body --> </article><!-- #post-## --> <?php // Reset post data wp_reset_postdata(); }
the_permalink(); ?> " rel="bookmark"><?php the_post_thumbnail('full'); ?> </a> <?php } break; case 'gallery': if (get_post_gallery()) { // Retrieve first gallery $gallery = get_post_gallery(get_the_ID(), false); if (isset($gallery['ids'])) { // Remove Galleries from content $content = quadro_strip_shortcode_gallery(get_the_content('<span class="read-more">' . esc_html__('Read more', 'quadro') . '</span>')); echo '<div class="entry-gallery"><ul class="slides">'; /* Loop through all images and output them one by one */ $gallery_ids = explode(',', $gallery['ids']); foreach ($gallery_ids as $pic_id) { echo '<li class="gallery-item">'; echo wp_get_attachment_image($pic_id, 'quadro-med-thumb'); echo get_post($pic_id) && get_post($pic_id)->post_excerpt != '' ? '<p class="gallery-caption">' . get_post($pic_id)->post_excerpt . '</p>' : ''; echo '</li>'; } echo '</ul></div>'; } else { // Exit if gallery has no ids (old versions), // and leave content intact. $content = get_the_content('<span class="read-more">' . esc_html__('Read more', 'quadro') . '</span>'); }
$media_return = quadro_print_media(get_the_content(), array('video', 'iframe', 'embed'), 1, '', ''); echo $media_return['media']; break; case 'audio': $media_return = quadro_print_media(get_the_content(), array('audio', 'iframe', 'embed'), 1, '', ''); echo $media_return['media']; echo quadro_excerpt($media_return['content'], 40, '<span class="read-more">' . esc_html__('Read more', 'quadro') . '</span>'); break; case 'quote': echo quadro_just_quote(get_the_content(), '', ''); echo '<a href="' . esc_url(get_the_permalink()) . '" class="readmore-link"><span class="read-more">' . esc_html__('Read more', 'quadro') . '</span></a>'; break; case 'gallery': if (get_post_gallery()) { // Remove Galleries from content $content = quadro_strip_shortcode_gallery(get_the_content()); // Filter through the_content filter $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]>', $content); echo '<div class="entry-gallery">'; echo '<ul class="slides">'; $gallery = get_post_gallery(get_the_ID(), false); /* Loop through all images and output them one by one */ $gallery_ids = explode(',', $gallery['ids']); foreach ($gallery_ids as $pic_id) { echo '<li class="gallery-item">'; echo wp_get_attachment_image($pic_id, 'quadro-med-full-thumb'); echo get_post($pic_id) && get_post($pic_id)->post_excerpt != '' ? '<p class="gallery-caption">' . get_post($pic_id)->post_excerpt . '</p>' : ''; echo '</li>'; } echo '</ul></div>';