Advertisement
Guest User

Untitled

a guest
Sep 5th, 2014
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.49 KB | None | 0 0
  1. <?php
  2. /**
  3. * Portfolio Single Item Main
  4. *
  5. * Laborator.co
  6. * www.laborator.co
  7. */
  8.  
  9. global $post;
  10.  
  11. the_post();
  12.  
  13. wp_enqueue_script(array('laborator_basicslider', 'scrollpane_custom'));
  14. wp_enqueue_style('scrollpane');
  15.  
  16. # Post
  17. $post_id = $post->ID;
  18.  
  19. # Fetch images for this item
  20. $item_gallery = gb_field('portfolio_images');
  21.  
  22. # Image Crop Mode
  23. $crop_by_width_and_height = 'Crop by width and height';
  24.  
  25. $image_cropping_method = get_data('portfolio_image_cropping_method');
  26. $image_max_height = get_data('portfolio_image_max_height');
  27.  
  28. # Autoswitch Pictures
  29. $portfolio_autoswitch = get_data('portfolio_autoswitch_interval');
  30.  
  31. if( ! is_numeric($portfolio_autoswitch))
  32. {
  33. $portfolio_autoswitch = 0;
  34. }
  35.  
  36.  
  37. # Categories
  38. $portfolio_terms = wp_get_object_terms($post->ID, 'portfolio-category');
  39.  
  40.  
  41. # Meta
  42. $launch_url = $post->launch_url;
  43. $client_name = $post->client_name;
  44. $client_web = $post->client_web;
  45. $album_date = $post->album_date;
  46.  
  47.  
  48. # Show Available Information
  49. $show_meta_info = get_data('portfolio_show_meta_info');
  50.  
  51. $show_category_info = is_array($portfolio_terms) && count($portfolio_terms);
  52. $show_client_name = ! empty($client_name);
  53. $show_album_date = $album_date ? TRUE : FALSE;
  54. $show_launch_url = $launch_url ? TRUE : FALSE;
  55.  
  56. $show_project_details = $show_category_info || $show_client_name || $show_album_date || $show_launch_url;
  57.  
  58.  
  59. # Share
  60. $porftolio_share_networks = get_data('porftolio_share_networks');
  61.  
  62. if($porftolio_share_networks instanceof WP_Error)
  63. $porftolio_share_networks = array();
  64.  
  65. $sn_count = 0;
  66.  
  67. if(isset($porftolio_share_networks['facebook'])) $sn_count++;
  68. if(isset($porftolio_share_networks['twitter'])) $sn_count++;
  69. if(isset($porftolio_share_networks['google'])) $sn_count++;
  70.  
  71. # Likes
  72. $portfolio_likes = get_data('portfolio_likes');
  73.  
  74. $likes = laborator_get_likes();
  75.  
  76. $show_share_block = $portfolio_likes || count($porftolio_share_networks);
  77.  
  78. # Next and Previous Links
  79. $prev_post = get_adjacent_post(false, null, 0);
  80. $next_post = get_adjacent_post(false, null, 1);
  81.  
  82. # Layout Type to use
  83. $layout_type = apply_filters('laborator_portfolio_layout_type', get_data('portfolio_default_layout_type'));
  84. $is_left_side = false;
  85.  
  86. if($layout_type == 3)
  87. {
  88. $layout_type = 2;
  89. $is_left_side = true;
  90. }
  91.  
  92. if( ! count($item_gallery) && has_post_thumbnail())
  93. {
  94. $item_gallery = array( get_post( get_post_thumbnail_id() ) );
  95. }
  96. ?>
  97. <section class="portfolio single">
  98.  
  99. <div class="container">
  100.  
  101. <div class="sixteen columns">
  102. <?php if(count($categories) && is_array($categories) && $category_browsing_mode != 'nocategories'): ?>
  103. <div class="portfolio_categories<?php echo $category_browsing_mode == 'normal' ? ' normal_link' : ''; ?>" id="portfolio_filter">
  104. <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>
  105. <?php
  106. foreach($categories as $category):
  107. $link = $is_single ? ($permalink . "?cat={$category->slug}") : get_term_link($category, 'portfolio-category');
  108. $is_current = isset($filter['portfolio-category']) && $filter['portfolio-category'] == $category->slug;
  109.  
  110. ?>
  111. <a href="<?php echo $link; ?>"<?php echo $is_current ? ' class="active"' : ''; ?> data-category="<?php echo $category->slug; ?>"><?php echo $category->name; ?></a>
  112. <?php
  113. if(count($category->children))
  114. {
  115. ?>
  116. <div class="nested-category-items">
  117. <?php
  118. foreach($category->children as $child_category):
  119. $link = $is_single ? ($permalink . "?cat={$child_category->slug}") : get_term_link($child_category, 'portfolio-category');
  120. $is_current = isset($filter['portfolio-category']) && $filter['portfolio-category'] == $child_category->slug;
  121.  
  122. ?>
  123. <a href="<?php echo $link; ?>"<?php echo $is_current ? ' class="active"' : ''; ?> data-category="<?php echo $child_category->slug; ?>"><?php echo $child_category->name; ?></a>
  124. <?php
  125. endforeach;
  126. ?>
  127. </div>
  128. <?php
  129. }
  130. endforeach;
  131. ?>
  132. </div>
  133. <?php endif; ?>
  134. <div class="portfolio_item_details<?php echo $layout_type == 2 ? (' layout_2' . ($is_left_side ? ' left_side' : '')) : ''; ?>">
  135.  
  136. <!-- item images / videos -->
  137. <div class="images" data-autoswitch="<?php echo $portfolio_autoswitch * 1000; ?>">
  138. <?php
  139. foreach($item_gallery as $attachment):
  140.  
  141. $attachment_id = $attachment->ID;
  142. $is_video = false;
  143.  
  144. # Use for videos
  145. $alt_text = get_post_meta($attachment_id, '_wp_attachment_image_alt', TRUE);
  146.  
  147. $guid = $attachment->guid;
  148. $original_file = str_replace(site_url('/'), ABSPATH, $guid);
  149.  
  150. # Failsafe - Skip images that doesn't exists
  151. if( ! file_exists($original_file))
  152. {
  153. continue;
  154. }
  155.  
  156. $big_image = wp_get_attachment_image_src($attachment_id, 'original');
  157.  
  158. # crop by width and height
  159. if($image_max_height && $image_cropping_method == $crop_by_width_and_height)
  160. {
  161. $big_image = laborator_show_img($big_image[0], ($layout_type == 2 ? 630 : 940), $image_max_height, 1);
  162. }
  163. else
  164. {
  165. $big_image = laborator_show_img($big_image[0], ($layout_type == 2 ? 'portfolio-large-img-2' : 'portfolio-large-img'));
  166. }
  167.  
  168. $rel = 'shadowbox[portfolio_gallery];';
  169.  
  170. # Detect Video Link
  171. if($alt_text_video_link = get_video_frames_links($alt_text))
  172. {
  173. $guid = $alt_text_video_link;
  174. $rel .= 'width=700;height=450';
  175. $is_video = true;
  176. }
  177. ?>
  178. <a href="<?php echo $guid; ?>" class="<?php echo $is_video ? 'video' : ''; ?>" rel="<?php echo $rel; ?>" target="_blank"><?php echo $big_image; ?></a>
  179. <?php endforeach; ?>
  180.  
  181. <div class="prev_next_nav"></div>
  182. </div>
  183.  
  184. <!-- item info -->
  185. <div class="item_info">
  186.  
  187. <h1><?php the_title(); ?></h1>
  188.  
  189. <div class="blocks">
  190.  
  191. <!-- description -->
  192. <div class="description<?php echo ! $show_project_details || ! $show_meta_info ? (! $show_share_block ? ' full_c' : ' full') : ( ! $show_share_block ? ' full' : ''); ?>">
  193.  
  194. <div class="scroll-pane">
  195. <?php the_content(); ?>
  196. </div>
  197.  
  198. </div>
  199.  
  200. <?php if($show_meta_info && $show_project_details): ?>
  201. <!-- more info -->
  202. <div class="meta_info<?php echo ! $show_share_block ? ' right' : ''; ?>">
  203.  
  204. <ul>
  205. <?php if($show_client_name): ?>
  206. <li>
  207. <strong><?php _e('Client', TD); ?>:</strong>
  208.  
  209. <?php if($client_web): ?>
  210. <a href="<?php echo $client_web; ?>" target="_blank" class="active"><?php echo $client_name; ?></a>
  211. <?php else: echo $client_name; endif; ?>
  212. </li>
  213. <?php endif; ?>
  214. <?php if($show_category_info): ?>
  215. <li>
  216. <strong><?php _e('Category', TD); ?>:</strong>
  217. <?php the_terms($post_id, 'portfolio-category'); ?>
  218. </li>
  219. <?php endif; ?>
  220.  
  221. <?php if($show_album_date): ?>
  222. <li>
  223. <strong><?php _e('Date', TD); ?>:</strong>
  224. <span><?php echo date_i18n(get_option('date_format'), strtotime($album_date)); ?></span>
  225. </li>
  226. <?php endif; ?>
  227. </ul>
  228.  
  229. <?php if($show_launch_url): ?>
  230. <a href="<?php echo $launch_url; ?>" target="_blank" class="launch"><?php _e('Launch Project', TD); ?></a>
  231. <?php endif; ?>
  232.  
  233. </div>
  234. <?php endif; ?>
  235.  
  236.  
  237. <?php if($show_share_block): ?>
  238. <!-- share & like -->
  239. <div class="share_like<?php echo ! $portfolio_likes ? ' left' : ''; ?>">
  240.  
  241. <!-- share buttons -->
  242. <div class="share_networks<?php echo " sn_count_{$sn_count}"; ?>">
  243.  
  244. <?php if(isset($porftolio_share_networks['twitter'])): ?>
  245. <!-- tweet -->
  246. <div class="share_btn tweet">
  247. <a href="https://twitter.com/share" class="twitter-share-button" data-lang="en">Tweet</a>
  248. <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>
  249. </div>
  250. <!-- end: tweet -->
  251. <?php endif; ?>
  252.  
  253. <?php if(isset($porftolio_share_networks['google'])): ?>
  254. <!-- google plus -->
  255. <div class="share_btn google">
  256. <div class="g-plusone" data-size="medium"></div>
  257.  
  258. <!-- Place this tag after the last +1 button tag. -->
  259. <script type="text/javascript">
  260. (function() {
  261. var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
  262. po.src = 'https://apis.google.com/js/plusone.js';
  263. var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
  264. })();
  265. </script>
  266. </div>
  267. <!-- end: google plus -->
  268. <?php endif; ?>
  269.  
  270.  
  271. <?php if(isset($porftolio_share_networks['facebook'])): ?>
  272. <!-- facebook -->
  273. <script>(function(d, s, id) {
  274. var js, fjs = d.getElementsByTagName(s)[0];
  275. if (d.getElementById(id)) return;
  276. js = d.createElement(s); js.id = id;
  277. js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=343445865761187";
  278. fjs.parentNode.insertBefore(js, fjs);
  279. }(document, 'script', 'facebook-jssdk'));</script>
  280.  
  281. <div class="share_btn">
  282. <div class="fb-like" data-send="false" data-layout="button_count" data-width="" data-show-faces="false" data-font="lucida grande"></div>
  283. </div>
  284. <!-- end: facebook -->
  285. <?php endif; ?>
  286.  
  287.  
  288. <div id="fb-root"></div>
  289.  
  290. <span class="arrow"></span>
  291. </div>
  292.  
  293.  
  294. <?php if(count($porftolio_share_networks)): ?>
  295. <!-- share -->
  296. <a href="#" class="share"><?php _e('Share', TD); ?></a>
  297. <?php endif; ?>
  298.  
  299. <?php if($portfolio_likes): ?>
  300. <!-- like -->
  301. <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>
  302. <?php endif; ?>
  303.  
  304. </div>
  305. <?php endif; ?>
  306.  
  307. </div>
  308.  
  309. </div>
  310.  
  311. </div>
  312.  
  313.  
  314. <?php if(get_data('portfolio_prev_next_nav') && ($prev_post || $next_post)): ?>
  315. <!-- prev / next project -->
  316. <div class="prev_next_project">
  317. <?php if($prev_post): ?>
  318. <a href="<?php echo get_permalink($prev_post->ID); ?>" class="prev">
  319. <i></i>
  320. <span><?php _e('Previous', TD); ?></span>
  321. </a>
  322. <?php endif; ?>
  323.  
  324. <?php if($next_post): ?>
  325. <a href="<?php echo get_permalink($next_post->ID); ?>" class="next">
  326. <span><?php _e('Next', TD); ?></span>
  327. <i></i>
  328. </a>
  329. <?php endif; ?>
  330. </div>
  331. <?php endif; ?>
  332.  
  333. </div>
  334.  
  335.  
  336. <?php
  337. if(get_data('portfolio_related_projects')):
  338.  
  339. # Related Projects
  340. get_template_part('tpls/portfolio', 'related');
  341.  
  342. endif;
  343. ?>
  344.  
  345. </div>
  346.  
  347. </section>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement