item.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php
  2. /**
  3. * Single portfolio item used in a loop
  4. *
  5. * @package vamtam/consulting
  6. */
  7. list( $terms_slug, $terms_name ) = vamtam_get_portfolio_terms();
  8. $item_class = array();
  9. $item_class[] = $settings->show_title ? 'has-title' : 'no-title';
  10. $item_class[] = $settings->description ? 'has-description' : 'no-description';
  11. $item_class[] = 'state-closed';
  12. $item_class[] = 'vamtam-project';
  13. $item_class[] = $settings->hover_animation;
  14. $item_class[] = 'cbp-item';
  15. $featured = vamtam_sanitize_bool( vamtam_post_meta( get_the_id(), 'featured-project', true ) );
  16. $starting_width = 100 / $settings->columns;
  17. if ( $featured ) {
  18. $starting_width *= 2;
  19. }
  20. $gallery = $href = '';
  21. extract( vamtam_get_portfolio_options() );
  22. $video_url = ( $type === 'video' && ! empty( $href ) ) ? $href : '';
  23. $single_url = $type === 'link' ? get_post_meta( get_the_ID(), 'vamtam-portfolio-format-link', true ) : get_permalink();
  24. $suffix = ( 'mosaic' === $settings->layout ) ? 'normal' : 'loop';
  25. if ( $featured ) {
  26. $suffix .= '-featured';
  27. }
  28. $cbp_singlepage = '';
  29. if ( 'ajax' === $settings->link_opens && 'link' !== $type ) {
  30. $cbp_singlepage = 'cbp-singlePage';
  31. }
  32. $has_details = ( $settings->show_title || $settings->description ) && ( 'video' !== $type || empty( $video_url ) || has_post_thumbnail() );
  33. ?>
  34. <div data-id="<?php the_id()?>" data-type="<?php echo esc_attr( implode( ' ', $terms_slug ) )?>" <?php post_class( implode( ' ', $item_class ) ); ?> style="width: <?php echo intval( $starting_width ) ?>%">
  35. <div class="portfolio-item-wrapper">
  36. <?php if ( $has_details ) : ?>
  37. <div class="portfolio_details">
  38. <a href="<?php echo esc_url( $single_url ) ?>" class="project-title <?php echo esc_attr( $cbp_singlepage ) ?>" target="<?php echo esc_attr( $link_target ) ?>">
  39. <span class="text-wrapper">
  40. <?php if ( $settings->show_title ) : ?>
  41. <span class="title">
  42. <?php the_title()?>
  43. </span>
  44. <?php endif ?>
  45. <?php if ( $settings->description ) : ?>
  46. <span class="excerpt"><?php echo strip_tags( get_the_excerpt(), '<span><bold><b><i><em>' ) ?></span>
  47. <?php endif ?>
  48. </span>
  49. </a>
  50. <a href="<?php echo esc_url( $single_url ) ?>" class="link-read-more"><?php esc_html_e( 'Case study →', 'vamtam-consulting' ); ?></a>
  51. <?php if ( $settings->lightbox_button === 'true' && 'mosaic' === $settings->layout && ( has_post_thumbnail() || ! empty( $video_url ) || ! empty( $gallery ) ) ) : ?>
  52. <div class="lightbox-wrapper">
  53. <?php
  54. if ( 'gallery' === $type && ! empty( $gallery ) ) :
  55. echo do_shortcode( str_replace( 'vamtam_gallery', 'vamtam_gallery_lightbox', $gallery ) );
  56. else :
  57. if ( 'video' === $type ) {
  58. $link = $video_url;
  59. } else {
  60. $image = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full' );
  61. $link = $image[0];
  62. }
  63. ?>
  64. <a href="<?php echo esc_url( $link ) ?>" class="cbp-lightbox icon theme" title="<?php esc_attr_e( 'View Media', 'vamtam-consulting' ) ?>" data-title="<?php the_title_attribute() ?>"><?php vamtam_icon( 'vamtam-theme-magnifier' ) ?></a>
  65. <?php endif ?>
  66. </div>
  67. <?php endif ?>
  68. </div>
  69. <?php endif ?>
  70. <div class="portfolio-image">
  71. <?php
  72. if ( ! empty( $gallery ) ) :
  73. echo do_shortcode( $gallery );
  74. elseif ( ! empty( $video_url ) && ! has_post_thumbnail() ) :
  75. global $wp_embed;
  76. echo do_shortcode( $wp_embed->run_shortcode( '[embed]' . $video_url . '[/embed]' ) );
  77. echo '<a href="' . esc_url( $video_url ) . '" class="cbp-lightbox" title="" data-title="' . esc_attr( get_the_title() ) . '" style="display:none"></a>';
  78. elseif ( has_post_thumbnail() ) :
  79. ?>
  80. <a href="<?php echo esc_url( $single_url ) ?>" class="meta <?php echo esc_attr( $cbp_singlepage ) ?>" target="<?php echo esc_attr( $link_target ) ?>">
  81. <?php
  82. VamtamOverrides::unlimited_image_sizes();
  83. the_post_thumbnail( apply_filters( 'vamtam_portfolio_loop_image_size', VAMTAM_THUMBNAIL_PREFIX . "{$suffix}-4", $suffix, $settings->columns ) );
  84. VamtamOverrides::limit_image_sizes();
  85. ?>
  86. </a>
  87. <?php endif ?>
  88. </div>
  89. </div>
  90. </div>