PageRenderTime 55ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/handy/THEME/handystore/handystore/shortcodes/builder_shortcodes/testimonials/testimonials.php

https://gitlab.com/hop23typhu/list-theme
PHP | 231 lines | 197 code | 18 blank | 16 comment | 23 complexity | 102f0a1535be3149d2002a8fe78917a7 MD5 | raw file
  1. <?php
  2. if ( ! class_exists( 'IG_Testimonials' ) ) {
  3. class IG_Testimonials extends IG_Pb_Shortcode_Parent {
  4. public function __construct() {
  5. parent::__construct();
  6. }
  7. /**
  8. * DEFINE configuration information of shortcode
  9. */
  10. public function element_config() {
  11. $this->config['shortcode'] = strtolower( __CLASS__ );
  12. $this->config['name'] = esc_html__( 'PT Testimonials', 'plumtree' );
  13. $this->config['has_subshortcode'] = 'IG_Item_' . str_replace( 'IG_', '', __CLASS__ );
  14. $this->config['edit_using_ajax'] = true;
  15. $this->config['exception'] = array(
  16. 'default_content' => esc_html__( 'PT Testimonials', 'plumtree' ),
  17. 'data-modal-title' => esc_html__( 'PT Testimonials', 'plumtree' ),
  18. );
  19. }
  20. /**
  21. * DEFINE setting options of shortcode
  22. */
  23. public function element_items() {
  24. $this->items = array(
  25. 'content' => array(
  26. array(
  27. 'name' => esc_html__( 'Element Title', 'plumtree' ),
  28. 'id' => 'el_title',
  29. 'type' => 'text_field',
  30. 'class' => 'jsn-input-xxlarge-fluid',
  31. 'std' => esc_html__( 'Testimonials', 'plumtree' ),
  32. 'role' => 'title',
  33. 'tooltip' => esc_html__( 'Set title for current element for identifying easily', 'plumtree' )
  34. ),
  35. array(
  36. 'id' => 'testimonials_items',
  37. 'type' => 'group',
  38. 'shortcode' => ucfirst( __CLASS__ ),
  39. 'sub_item_type' => $this->config['has_subshortcode'],
  40. 'sub_items' => array(
  41. array('std' => ''),
  42. array('std' => ''),
  43. ),
  44. ),
  45. ),
  46. 'styling' => array(
  47. array(
  48. 'name' => esc_html__( 'Items per Slide', 'plumtree' ),
  49. 'id' => 'per_slide',
  50. 'type' => 'select',
  51. 'std' => '3',
  52. 'options' => array(
  53. '1' => esc_html__( '1 item', 'plumtree' ),
  54. '2' => esc_html__( '2 items', 'plumtree' ),
  55. '3' => esc_html__( '3 items', 'plumtree' ),
  56. ),
  57. ),
  58. array(
  59. 'name' => esc_html__( 'Dimension', 'plumtree' ),
  60. 'container_class' => 'combo-group',
  61. 'id' => 'dimension',
  62. 'type' => 'dimension',
  63. 'extended_ids' => array( 'dimension_width', 'dimension_height', 'dimension_width_unit' ),
  64. 'dimension_width' => array( 'std' => '' ),
  65. 'dimension_height' => array( 'std' => '' ),
  66. 'dimension_width_unit' => array(
  67. 'options' => array( 'px' => 'px', '%' => '%' ),
  68. 'std' => 'px',
  69. ),
  70. 'tooltip' => esc_html__( 'Set width and height of element', 'plumtree' ),
  71. ),
  72. array(
  73. 'name' => esc_html__( 'Transition Type', 'plumtree' ),
  74. 'id' => 'transition_type',
  75. 'type' => 'select',
  76. 'std' => 'fade',
  77. 'options' => array(
  78. 'fade' => esc_html__( 'Fade', 'plumtree' ),
  79. 'backSlide' => esc_html__( 'Back Slide', 'plumtree' ),
  80. 'goDown' => esc_html__( 'Go Down', 'plumtree' ),
  81. 'fadeUp' => esc_html__( 'Fade Up', 'plumtree' ),
  82. ),
  83. ),
  84. array(
  85. 'name' => esc_html__( 'Show Page Navigation', 'plumtree' ),
  86. 'id' => 'show_indicator',
  87. 'type' => 'radio',
  88. 'std' => 'yes',
  89. 'options' => array( 'yes' => esc_html__( 'Yes', 'plumtree' ), 'no' => esc_html__( 'No', 'plumtree' ) ),
  90. 'tooltip' => esc_html__( 'Show/hide navigation buttons under your carousel', 'plumtree' ),
  91. ),
  92. array(
  93. 'name' => esc_html__( 'Show Arrows', 'plumtree' ),
  94. 'id' => 'show_arrows',
  95. 'type' => 'radio',
  96. 'std' => 'yes',
  97. 'options' => array( 'yes' => esc_html__( 'Yes', 'plumtree' ), 'no' => esc_html__( 'No', 'plumtree' ) ),
  98. 'tooltip' => esc_html__( 'Show/hide arrow buttons', 'plumtree' ),
  99. ),
  100. array(
  101. 'name' => esc_html__( 'Autoplay', 'plumtree' ),
  102. 'id' => 'autoplay',
  103. 'type' => 'radio',
  104. 'std' => 'false',
  105. 'options' => array( 'yes' => esc_html__( 'Yes', 'plumtree' ), 'no' => esc_html__( 'No', 'plumtree' ) ),
  106. 'tooltip' => esc_html__( 'Whether to running your carousel automatically or not', 'plumtree' ),
  107. ),
  108. array(
  109. 'name' => esc_html__( 'Add "lazyload" to this element?', 'plumtree' ),
  110. 'id' => 'lazyload',
  111. 'type' => 'radio',
  112. 'std' => 'no',
  113. 'options' => array( 'yes' => esc_html__( 'Yes', 'plumtree' ), 'no' => esc_html__( 'No', 'plumtree' ) ),
  114. ),
  115. )
  116. );
  117. }
  118. /**
  119. * DEFINE shortcode content
  120. *
  121. * @param type $atts
  122. * @param type $content
  123. */
  124. public function element_shortcode_full( $atts = null, $content = null ) {
  125. $arr_params = shortcode_atts( $this->config['params'], $atts );
  126. extract( $arr_params );
  127. $html_output = '';
  128. $lazy_param = '';
  129. // Container Styles
  130. $container_class = 'pt-testimonials '.$css_suffix;
  131. $container_id = uniqid('owl',false);
  132. if ($arr_params['lazyload'] == 'yes') { $lazy_param = ' data-expand="-100"'; $container_class = $container_class.' lazyload'; }
  133. $container_class = ( ! empty( $container_class ) ) ? ' class="' . $container_class . '"' : '';
  134. $styles = array();
  135. if ( ! empty( $dimension_width ) )
  136. $styles[] = "width : {$dimension_width}{$dimension_width_unit};";
  137. if ( ! empty( $dimension_height ) )
  138. $styles[] = "height : {$dimension_height}px;";
  139. $styles = trim( implode( ' ', $styles ) );
  140. $styles = ! empty( $styles ) ? "style='$styles'" : '';
  141. // Carousel Parameters
  142. $owlAutoPlay = 'false';
  143. if ( $autoplay == 'yes' )
  144. $owlAutoPlay = 'true';
  145. $owlPagination = 'false';
  146. if ( $show_indicator == 'yes' )
  147. $owlPagination = 'true';
  148. $owlTransition = $transition_type;
  149. // Get Carousel Items
  150. $sub_shortcode = IG_Pb_Helper_Shortcode::remove_autop( $content );
  151. $items = explode( '<!--separate-->', $sub_shortcode );
  152. array_pop($items);
  153. $total = count($items);
  154. $new_items = '';
  155. if ( $total<(int)$per_slide || (int)$per_slide==1 ) {
  156. foreach ($items as $position => $item) {
  157. $new_items .= '<div class="carousel-item">'.$item.'</div>';
  158. }
  159. } else {
  160. foreach ($items as $position => $item) {
  161. $current_position = $position + 1;
  162. if ( ($current_position == 1) || ($current_position % (int)$per_slide == 1) ) {
  163. $new_items .= '<div class="carousel-item">'.$item;
  164. if ($current_position == $total) {
  165. $new_items .= '</div>';
  166. }
  167. } elseif ( $current_position == $total ) {
  168. $new_items .= $item.'</div>';
  169. } elseif ( $current_position % (int)$per_slide == 0 ) {
  170. $new_items .= $item.'</div>';
  171. } else {
  172. $new_items .= $item;
  173. }
  174. }
  175. }
  176. $carousel_content = $new_items;
  177. // Output Carousel
  178. $html_output .= "<div{$container_class} id='{$container_id}'{$lazy_param}>";
  179. $html_output .= "<div class='title-wrapper'><h3>{$el_title}</h3>";
  180. if ( $show_arrows == 'yes' ) { $html_output .= "<span class='prev'></span><span class='next'></span>"; }
  181. $html_output .= "</div><div class='carousel-container per-slide-{$per_slide}' {$styles}>";
  182. $html_output .= $carousel_content;
  183. $html_output .= "</div></div>";
  184. $html_output.='
  185. <script type="text/javascript">
  186. (function($) {
  187. $(document).ready(function() {
  188. var owl = $("#'.$container_id.' .carousel-container");
  189. owl.owlCarousel({
  190. navigation : false,
  191. pagination : '.$owlPagination.',
  192. autoPlay : '.$owlAutoPlay.',
  193. slideSpeed : 300,
  194. paginationSpeed : 400,
  195. singleItem : true,
  196. transitionStyle : "'.$owlTransition.'",
  197. });
  198. // Custom Navigation Events
  199. $("#'.$container_id.'").find(".next").click(function(){
  200. owl.trigger("owl.next");
  201. })
  202. $("#'.$container_id.'").find(".prev").click(function(){
  203. owl.trigger("owl.prev");
  204. })
  205. });
  206. })(jQuery);
  207. </script>';
  208. return $this->element_wrapper( $html_output, $arr_params );
  209. }
  210. }
  211. }