Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Portfolio Single Item Main
- *
- * Laborator.co
- * www.laborator.co
- */
- global $post;
- the_post();
- wp_enqueue_script(array('laborator_basicslider', 'scrollpane_custom'));
- wp_enqueue_style('scrollpane');
- # Post
- $post_id = $post->ID;
- # Fetch images for this item
- $item_gallery = gb_field('portfolio_images');
- # Image Crop Mode
- $crop_by_width_and_height = 'Crop by width and height';
- $image_cropping_method = get_data('portfolio_image_cropping_method');
- $image_max_height = get_data('portfolio_image_max_height');
- # Autoswitch Pictures
- $portfolio_autoswitch = get_data('portfolio_autoswitch_interval');
- if( ! is_numeric($portfolio_autoswitch))
- {
- $portfolio_autoswitch = 0;
- }
- # Categories
- $portfolio_terms = wp_get_object_terms($post->ID, 'portfolio-category');
- # Meta
- $launch_url = $post->launch_url;
- $client_name = $post->client_name;
- $client_web = $post->client_web;
- $album_date = $post->album_date;
- # Show Available Information
- $show_meta_info = get_data('portfolio_show_meta_info');
- $show_category_info = is_array($portfolio_terms) && count($portfolio_terms);
- $show_client_name = ! empty($client_name);
- $show_album_date = $album_date ? TRUE : FALSE;
- $show_launch_url = $launch_url ? TRUE : FALSE;
- $show_project_details = $show_category_info || $show_client_name || $show_album_date || $show_launch_url;
- # Share
- $porftolio_share_networks = get_data('porftolio_share_networks');
- if($porftolio_share_networks instanceof WP_Error)
- $porftolio_share_networks = array();
- $sn_count = 0;
- if(isset($porftolio_share_networks['facebook'])) $sn_count++;
- if(isset($porftolio_share_networks['twitter'])) $sn_count++;
- if(isset($porftolio_share_networks['google'])) $sn_count++;
- # Likes
- $portfolio_likes = get_data('portfolio_likes');
- $likes = laborator_get_likes();
- $show_share_block = $portfolio_likes || count($porftolio_share_networks);
- # Next and Previous Links
- $prev_post = get_adjacent_post(false, null, 0);
- $next_post = get_adjacent_post(false, null, 1);
- # Layout Type to use
- $layout_type = apply_filters('laborator_portfolio_layout_type', get_data('portfolio_default_layout_type'));
- $is_left_side = false;
- if($layout_type == 3)
- {
- $layout_type = 2;
- $is_left_side = true;
- }
- if( ! count($item_gallery) && has_post_thumbnail())
- {
- $item_gallery = array( get_post( get_post_thumbnail_id() ) );
- }
- ?>
- <section class="portfolio single">
- <div class="container">
- <div class="sixteen columns">
- <?php if(count($categories) && is_array($categories) && $category_browsing_mode != 'nocategories'): ?>
- <div class="portfolio_categories<?php echo $category_browsing_mode == 'normal' ? ' normal_link' : ''; ?>" id="portfolio_filter">
- <a href="<?php echo $is_single ? ($permalink . "?showall=1") : get_post_type_archive_link('portfolio'); ?>"<?php echo ! isset($filter['portfolio-category']) ? ' class="active"' : ''; ?> data-category="*"><?php _e('All', TD); ?></a>
- <?php
- foreach($categories as $category):
- $link = $is_single ? ($permalink . "?cat={$category->slug}") : get_term_link($category, 'portfolio-category');
- $is_current = isset($filter['portfolio-category']) && $filter['portfolio-category'] == $category->slug;
- ?>
- <a href="<?php echo $link; ?>"<?php echo $is_current ? ' class="active"' : ''; ?> data-category="<?php echo $category->slug; ?>"><?php echo $category->name; ?></a>
- <?php
- if(count($category->children))
- {
- ?>
- <div class="nested-category-items">
- <?php
- foreach($category->children as $child_category):
- $link = $is_single ? ($permalink . "?cat={$child_category->slug}") : get_term_link($child_category, 'portfolio-category');
- $is_current = isset($filter['portfolio-category']) && $filter['portfolio-category'] == $child_category->slug;
- ?>
- <a href="<?php echo $link; ?>"<?php echo $is_current ? ' class="active"' : ''; ?> data-category="<?php echo $child_category->slug; ?>"><?php echo $child_category->name; ?></a>
- <?php
- endforeach;
- ?>
- </div>
- <?php
- }
- endforeach;
- ?>
- </div>
- <?php endif; ?>
- <div class="portfolio_item_details<?php echo $layout_type == 2 ? (' layout_2' . ($is_left_side ? ' left_side' : '')) : ''; ?>">
- <!-- item images / videos -->
- <div class="images" data-autoswitch="<?php echo $portfolio_autoswitch * 1000; ?>">
- <?php
- foreach($item_gallery as $attachment):
- $attachment_id = $attachment->ID;
- $is_video = false;
- # Use for videos
- $alt_text = get_post_meta($attachment_id, '_wp_attachment_image_alt', TRUE);
- $guid = $attachment->guid;
- $original_file = str_replace(site_url('/'), ABSPATH, $guid);
- # Failsafe - Skip images that doesn't exists
- if( ! file_exists($original_file))
- {
- continue;
- }
- $big_image = wp_get_attachment_image_src($attachment_id, 'original');
- # crop by width and height
- if($image_max_height && $image_cropping_method == $crop_by_width_and_height)
- {
- $big_image = laborator_show_img($big_image[0], ($layout_type == 2 ? 630 : 940), $image_max_height, 1);
- }
- else
- {
- $big_image = laborator_show_img($big_image[0], ($layout_type == 2 ? 'portfolio-large-img-2' : 'portfolio-large-img'));
- }
- $rel = 'shadowbox[portfolio_gallery];';
- # Detect Video Link
- if($alt_text_video_link = get_video_frames_links($alt_text))
- {
- $guid = $alt_text_video_link;
- $rel .= 'width=700;height=450';
- $is_video = true;
- }
- ?>
- <a href="<?php echo $guid; ?>" class="<?php echo $is_video ? 'video' : ''; ?>" rel="<?php echo $rel; ?>" target="_blank"><?php echo $big_image; ?></a>
- <?php endforeach; ?>
- <div class="prev_next_nav"></div>
- </div>
- <!-- item info -->
- <div class="item_info">
- <h1><?php the_title(); ?></h1>
- <div class="blocks">
- <!-- description -->
- <div class="description<?php echo ! $show_project_details || ! $show_meta_info ? (! $show_share_block ? ' full_c' : ' full') : ( ! $show_share_block ? ' full' : ''); ?>">
- <div class="scroll-pane">
- <?php the_content(); ?>
- </div>
- </div>
- <?php if($show_meta_info && $show_project_details): ?>
- <!-- more info -->
- <div class="meta_info<?php echo ! $show_share_block ? ' right' : ''; ?>">
- <ul>
- <?php if($show_client_name): ?>
- <li>
- <strong><?php _e('Client', TD); ?>:</strong>
- <?php if($client_web): ?>
- <a href="<?php echo $client_web; ?>" target="_blank" class="active"><?php echo $client_name; ?></a>
- <?php else: echo $client_name; endif; ?>
- </li>
- <?php endif; ?>
- <?php if($show_category_info): ?>
- <li>
- <strong><?php _e('Category', TD); ?>:</strong>
- <?php the_terms($post_id, 'portfolio-category'); ?>
- </li>
- <?php endif; ?>
- <?php if($show_album_date): ?>
- <li>
- <strong><?php _e('Date', TD); ?>:</strong>
- <span><?php echo date_i18n(get_option('date_format'), strtotime($album_date)); ?></span>
- </li>
- <?php endif; ?>
- </ul>
- <?php if($show_launch_url): ?>
- <a href="<?php echo $launch_url; ?>" target="_blank" class="launch"><?php _e('Launch Project', TD); ?></a>
- <?php endif; ?>
- </div>
- <?php endif; ?>
- <?php if($show_share_block): ?>
- <!-- share & like -->
- <div class="share_like<?php echo ! $portfolio_likes ? ' left' : ''; ?>">
- <!-- share buttons -->
- <div class="share_networks<?php echo " sn_count_{$sn_count}"; ?>">
- <?php if(isset($porftolio_share_networks['twitter'])): ?>
- <!-- tweet -->
- <div class="share_btn tweet">
- <a href="https://twitter.com/share" class="twitter-share-button" data-lang="en">Tweet</a>
- <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="https://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
- </div>
- <!-- end: tweet -->
- <?php endif; ?>
- <?php if(isset($porftolio_share_networks['google'])): ?>
- <!-- google plus -->
- <div class="share_btn google">
- <div class="g-plusone" data-size="medium"></div>
- <!-- Place this tag after the last +1 button tag. -->
- <script type="text/javascript">
- (function() {
- var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
- po.src = 'https://apis.google.com/js/plusone.js';
- var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
- })();
- </script>
- </div>
- <!-- end: google plus -->
- <?php endif; ?>
- <?php if(isset($porftolio_share_networks['facebook'])): ?>
- <!-- facebook -->
- <script>(function(d, s, id) {
- var js, fjs = d.getElementsByTagName(s)[0];
- if (d.getElementById(id)) return;
- js = d.createElement(s); js.id = id;
- js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=343445865761187";
- fjs.parentNode.insertBefore(js, fjs);
- }(document, 'script', 'facebook-jssdk'));</script>
- <div class="share_btn">
- <div class="fb-like" data-send="false" data-layout="button_count" data-width="" data-show-faces="false" data-font="lucida grande"></div>
- </div>
- <!-- end: facebook -->
- <?php endif; ?>
- <div id="fb-root"></div>
- <span class="arrow"></span>
- </div>
- <?php if(count($porftolio_share_networks)): ?>
- <!-- share -->
- <a href="#" class="share"><?php _e('Share', TD); ?></a>
- <?php endif; ?>
- <?php if($portfolio_likes): ?>
- <!-- like -->
- <a href="#" class="like<?php echo laborator_item_is_liked() ? ' liked' : ''; ?>" data-verify="<?php echo laborator_likes_nonce(); ?>" data-id="<?php echo $post_id; ?>"><span><?php echo $likes; ?></span></a>
- <?php endif; ?>
- </div>
- <?php endif; ?>
- </div>
- </div>
- </div>
- <?php if(get_data('portfolio_prev_next_nav') && ($prev_post || $next_post)): ?>
- <!-- prev / next project -->
- <div class="prev_next_project">
- <?php if($prev_post): ?>
- <a href="<?php echo get_permalink($prev_post->ID); ?>" class="prev">
- <i></i>
- <span><?php _e('Previous', TD); ?></span>
- </a>
- <?php endif; ?>
- <?php if($next_post): ?>
- <a href="<?php echo get_permalink($next_post->ID); ?>" class="next">
- <span><?php _e('Next', TD); ?></span>
- <i></i>
- </a>
- <?php endif; ?>
- </div>
- <?php endif; ?>
- </div>
- <?php
- if(get_data('portfolio_related_projects')):
- # Related Projects
- get_template_part('tpls/portfolio', 'related');
- endif;
- ?>
- </div>
- </section>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement