Advertisement
rdusnr

Untitled

Jul 7th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.58 KB | None | 0 0
  1. <?php
  2. /**
  3. * Shortcode attributes
  4. * @var $atts
  5. * @var $title
  6. * @var $source
  7. * @var $type
  8. * @var $onclick
  9. * @var $custom_links
  10. * @var $custom_links_target
  11. * @var $img_size
  12. * @var $external_img_size
  13. * @var $images
  14. * @var $custom_srcs
  15. * @var $el_class
  16. * @var $interval
  17. * @var $css
  18. *
  19. * KLEO ADDED
  20. * @var $grid_number
  21. * @var $gap
  22. *
  23. * Shortcode class
  24. * @var $this WPBakeryShortCode_VC_gallery
  25. */
  26.  
  27. $attributes = vc_map_get_attributes( $this->getShortcode(), $atts );
  28. extract( $attributes );
  29.  
  30. $default_src = vc_asset_url( 'vc/no_image.png' );
  31.  
  32. /* backward compatibility */
  33. if ( empty( $source ) ) {
  34. $source = 'media_library';
  35. }
  36. if ( empty( $css ) ) {
  37. $css = '';
  38. }
  39.  
  40. $gal_images = $gal_images_thumb = '';
  41. $el_start = '';
  42. $el_end = '';
  43. $slides_wrap_start = '';
  44. $slides_wrap_end = '';
  45.  
  46. $el_class = $this->getExtraClass( $el_class );
  47. if ( 'thumbs' == $type ) {
  48. $slides_wrap_start = '<div class="kleo-gallery-image">';
  49. $slides_wrap_end = '</div>';
  50. } elseif ( 'grid' == $type ) {
  51. wp_enqueue_script( 'isotope' );
  52. if ( '' != $enable_animation ) {
  53. $main_css_animation = ' animate-when-almost-visible one-by-one-general';
  54. } else {
  55. $main_css_animation = '';
  56. }
  57. $slides_wrap_start = '<ul class="responsive-cols per-row-' . $grid_number . $main_css_animation . ' kleo-masonry">';
  58. $slides_wrap_end = '</ul>';
  59. }
  60.  
  61. //get images
  62. if ( '' == $images ) {
  63. $images = '-1,-2,-3';
  64. }
  65.  
  66. $pretty_rel_random = ' rel="prettyPhoto[rel-' . rand() . ']"'; //rel-'.rand();
  67.  
  68. if ( 'custom_link' === $onclick ) {
  69. $custom_links = vc_value_from_safe( $custom_links );
  70. $custom_links = explode( ',', $custom_links );
  71. }
  72.  
  73. switch ( $source ) {
  74. case 'media_library':
  75. $images = explode( ',', $images );
  76. break;
  77.  
  78. case 'external_link':
  79. $images = vc_value_from_safe( $custom_srcs );
  80. $images = explode( ',', $images );
  81. break;
  82. }
  83.  
  84. if ( 'thumbs' == $type ) {
  85.  
  86. if ( '' != $enable_animation && 'yes' != $thumbs_over_img ) {
  87. $main_css_animation = ' th-fade';
  88. } else {
  89. $main_css_animation = '';
  90. }
  91.  
  92. $gal_images_thumb .= '<div class="kleo-gallery kleo-no-popup kleo-carousel-container animate-when-almost-visible">'
  93. . '<div class="kleo-thumbs-carousel kleo-thumbs-animated' . $main_css_animation . '" data-min-items=6 data-max-items=6>';
  94. }
  95.  
  96. $elem_id = kleo_vc_elem_increment();
  97. $i = - 1;
  98. foreach ( $images as $attach_id ) {
  99. $i ++;
  100.  
  101. switch ( $source ) {
  102. case 'media_library':
  103. $post_thumbnail = array();
  104. $post_thumbnail['thumbnail'] = '<img src="' . vc_asset_url( 'vc/no_image.png' ) . '" />';
  105. $post_thumbnail['p_img_large'][0] = vc_asset_url( 'vc/no_image.png' );
  106.  
  107. if ( $attach_id > 0 ) {
  108. $img_path = wp_get_attachment_image_src( $attach_id, 'full' );
  109. if ( null != $img_path ) {
  110. $post_thumbnail = wpb_getImageBySize( array(
  111. 'attach_id' => $attach_id,
  112. 'thumb_size' => $img_size,
  113. ) );
  114. }
  115. }
  116.  
  117. $thumbnail = $post_thumbnail['thumbnail'];
  118. $p_img_large = $post_thumbnail['p_img_large'][0];
  119.  
  120. $data_attr_show_caption = '';
  121.  
  122. $post = get_post( $attach_id );
  123.  
  124. if( $show_caption != '' ){
  125. $data_attr_show_caption = ' data-caption="' . esc_attr($post->post_excerpt). '"';
  126. }
  127.  
  128. break;
  129.  
  130. case 'external_link':
  131. $attach_id = esc_attr( $attach_id );
  132. $dimensions = vcExtractDimensions( $external_img_size );
  133. $hwstring = $dimensions ? image_hwstring( $dimensions[0], $dimensions[1] ) : '';
  134. $thumbnail = '<img ' . $hwstring . ' src="' . $attach_id . '" />';
  135. $p_img_large = $attach_id;
  136. break;
  137. }
  138.  
  139. $link_start = $link_end = '';
  140.  
  141. if ( 'thumbs' == $type ) {
  142. $link_start .= '<div id="gall_' . $elem_id . '_' . $i . '">';
  143. } elseif ( 'grid' == $type ) {
  144. if ( '' != $enable_animation ) {
  145. $main_css_animation = 'el-zero-fade';
  146. } else {
  147. $main_css_animation = '';
  148. }
  149. $link_start .= '<li class="' . $main_css_animation . '"><div class="kleo-gallery-inner">';
  150. }
  151.  
  152. switch ( $onclick ) {
  153. case 'img_link_large':
  154. $link_start .= '<a href="' . $p_img_large . '" target="' . $custom_links_target . '"' . $data_attr_show_caption . '>';
  155. if ( 'grid' == $type ) {
  156. $link_start .= kleo_get_img_overlay();
  157. }
  158. $link_end .= '</a>';
  159. break;
  160.  
  161. case 'link_image':
  162. $link_start .= '<a class="prettyphoto" href="' . $p_img_large . '"' . $pretty_rel_random . $data_attr_show_caption . '>';
  163. $link_end .= '</a>';
  164. break;
  165.  
  166. case 'custom_link':
  167. if ( ! empty( $custom_links[ $i ] ) ) {
  168. $link_start .= '<a href="' . $custom_links[ $i ] . '"' . ( ! empty( $custom_links_target ) ? ' target="' . $custom_links_target . '"' : '' ) . '>';
  169. if ( 'grid' == $type ) {
  170. $link_start .= kleo_get_img_overlay();
  171. }
  172. $link_end .= '</a>';
  173. }
  174. break;
  175. }
  176.  
  177. if ( 'thumbs' == $type ) {
  178. $link_end .= '</div>';
  179. $gal_images .= $link_start . '<img src="' . $p_img_large . '">' . $link_end;
  180. $gal_images_thumb .= '<a href="#gall_' . $elem_id . '_' . $i . '">' . $thumbnail . kleo_get_img_overlay() . '</a>';
  181. } elseif ( 'grid' == $type ) {
  182. $link_end .= '</div></li>';
  183. $gal_images .= $link_start . $thumbnail . $link_end;
  184. }
  185. }
  186.  
  187. if ( 'thumbs' == $type ) {
  188. $gal_images_thumb .= '</div>
  189. <a class="kleo-thumbs-prev" href="#"><i class="icon-angle-left"></i></a>
  190. <a class="kleo-thumbs-next" href="#"><i class="icon-angle-right"></i></a>
  191. </div>';
  192. }
  193.  
  194. $class_to_filter = 'wpb_gallery wpb_content_element vc_clearfix';
  195.  
  196. if ( 'thumbs' == $type && 'yes' == $thumbs_over_img ) {
  197. $class_to_filter .= ' thumbs-over-img';
  198. }
  199.  
  200. $class_to_filter .= vc_shortcode_custom_css_class( $css, ' ' ) . $this->getExtraClass( $el_class );
  201. $css_class = apply_filters( VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, $class_to_filter, $this->settings['base'], $atts );
  202.  
  203. $output .= "\n\t" . '<div class="' . $css_class . '">';
  204. $output .= "\n\t\t" . '<div class="wpb_wrapper">';
  205. $output .= wpb_widget_title( array( 'title' => $title, 'extraclass' => 'wpb_gallery_heading' ) );
  206.  
  207. $gap = '' != $gap ? ' kleo-' . $gap . '-gap' : '';
  208.  
  209. if ( 'thumbs' == $type && '' != $enable_animation && 'yes' == $thumbs_over_img ) {
  210. $main_css_animation = ' animated animate-when-almost-visible el-fade';
  211. } else {
  212. $main_css_animation = '';
  213. }
  214.  
  215. $output .= '<div class="kleo-gallery-container kleo-gallery-' . $type . $gap . $main_css_animation . '">' . $slides_wrap_start . $gal_images . $slides_wrap_end . $gal_images_thumb . '</div>';
  216. $output .= "\n\t\t" . '</div> ';
  217. $output .= "\n\t" . '</div> ';
  218.  
  219. echo $output;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement