/wp-content/plugins/grve-osmosis-vc-extension/shortcodes/grve_counter.php

https://github.com/Canuckaholic/Pop-Digital · PHP · 213 lines · 182 code · 25 blank · 6 comment · 7 complexity · b8482cea923a62f95c61c1c21f64f9b5 MD5 · raw file

  1. <?php
  2. /**
  3. * Counter Shortcode
  4. */
  5. if( !function_exists( 'grve_counter_shortcode' ) ) {
  6. function grve_counter_shortcode( $atts, $content ) {
  7. $output = $link_start = $link_end = $retina_data = $data = $el_class = '';
  8. extract(
  9. shortcode_atts(
  10. array(
  11. 'counter_start_val' => '0',
  12. 'counter_end_val' => '100',
  13. 'counter_prefix' => '',
  14. 'counter_suffix' => '',
  15. 'counter_decimal_points' => '0',
  16. 'counter_color' => '',
  17. 'title' => '',
  18. 'icon' => '',
  19. 'icon_type' => '',
  20. 'icon_color' => '',
  21. 'animation' => '',
  22. 'animation_delay' => '200',
  23. 'margin_bottom' => '',
  24. 'el_class' => '',
  25. ),
  26. $atts
  27. )
  28. );
  29. $counter_classes = array( 'grve-element' );
  30. array_push( $counter_classes, 'grve-counter' );
  31. array_push( $counter_classes, 'grve-align-center' );
  32. if ( !empty( $animation ) ) {
  33. array_push( $counter_classes, 'grve-animated-item' );
  34. array_push( $counter_classes, $animation);
  35. $data = ' data-delay="' . esc_attr( $animation_delay ) . '"';
  36. }
  37. if ( !empty ( $el_class ) ) {
  38. array_push( $counter_classes, $el_class);
  39. }
  40. $counter_class_string = implode( ' ', $counter_classes );
  41. $icon_classes = array( 'grve-icon' );
  42. if ( 'icon' == $icon_type ) {
  43. array_push( $icon_classes, 'fa fa-' . $icon );
  44. }
  45. $icon_class_string = implode( ' ', $icon_classes );
  46. $style = grve_vce_build_margin_bottom_style( $margin_bottom );
  47. $output .= '<div class="' . esc_attr( $counter_class_string ) . '" style="' . $style . '"' . $data . '>';
  48. if ( 'icon' == $icon_type ) {
  49. $output .= ' <div class="' . esc_attr( $icon_class_string ) . ' grve-color-' . esc_attr( $icon_color ) . '"></div>';
  50. }
  51. $output .= ' <div class="grve-counter-content">';
  52. $output .= ' <div class="grve-counter-item grve-color-' . esc_attr( $counter_color ) . '">';
  53. $output .= ' <span data-prefix="' . esc_attr( $counter_prefix ) . '" data-suffix="' . esc_attr( $counter_suffix ) . '" data-start-val="' . esc_attr( $counter_start_val ) . '" data-end-val="' . esc_attr( $counter_end_val ) . '" data-decimal-points="' . esc_attr( $counter_decimal_points ) . '">' . $counter_start_val. '</span>';
  54. $output .= '</div>';
  55. $output .= ' <h5 class="grve-counter-title">' . $title. '</h5>';
  56. $output .= ' </div>';
  57. $output .= '</div>';
  58. return $output;
  59. }
  60. add_shortcode( 'grve_counter', 'grve_counter_shortcode' );
  61. }
  62. /**
  63. * Add shortcode to Visual Composer
  64. */
  65. vc_map( array(
  66. "name" => __( "Counter", "grve-osmosis-vc-extension" ),
  67. "description" => __( "Add a counter with icon and title", "grve-osmosis-vc-extension" ),
  68. "base" => "grve_counter",
  69. "class" => "",
  70. "icon" => "icon-wpb-grve-counter",
  71. "category" => __( "Content", "js_composer" ),
  72. "params" => array(
  73. array(
  74. "type" => "textfield",
  75. "heading" => __( "Counter Start Number", "grve-osmosis-vc-extension" ),
  76. "param_name" => "counter_start_val",
  77. "value" => "0",
  78. "description" => __( "Enter counter start number.", "grve-osmosis-vc-extension" ),
  79. "admin_label" => true,
  80. ),
  81. array(
  82. "type" => "textfield",
  83. "heading" => __( "Counter End Number", "grve-osmosis-vc-extension" ),
  84. "param_name" => "counter_end_val",
  85. "value" => "100",
  86. "description" => __( "Enter counter end number.", "grve-osmosis-vc-extension" ),
  87. "admin_label" => true,
  88. ),
  89. array(
  90. "type" => "textfield",
  91. "heading" => __( "Counter Decimal Points", "grve-osmosis-vc-extension" ),
  92. "param_name" => "counter_decimal_points",
  93. "value" => "0",
  94. "description" => __( "Number of decimal points.", "grve-osmosis-vc-extension" ),
  95. ),
  96. array(
  97. "type" => "textfield",
  98. "heading" => __( "Counter Prefix", "grve-osmosis-vc-extension" ),
  99. "param_name" => "counter_prefix",
  100. "value" => "",
  101. "description" => __( "Enter counter prefix.", "grve-osmosis-vc-extension" ),
  102. ),
  103. array(
  104. "type" => "textfield",
  105. "heading" => __( "Counter Suffix", "grve-osmosis-vc-extension" ),
  106. "param_name" => "counter_suffix",
  107. "value" => "",
  108. "description" => __( "Enter counter suffix.", "grve-osmosis-vc-extension" ),
  109. ),
  110. array(
  111. "type" => "dropdown",
  112. "heading" => __( "Counter Color", "grve-osmosis-vc-extension" ),
  113. "param_name" => "counter_color",
  114. "value" => array(
  115. __( "Primary 1", "grve-osmosis-vc-extension" ) => 'primary-1',
  116. __( "Primary 2", "grve-osmosis-vc-extension" ) => 'primary-2',
  117. __( "Primary 3", "grve-osmosis-vc-extension" ) => 'primary-3',
  118. __( "Primary 4", "grve-osmosis-vc-extension" ) => 'primary-4',
  119. __( "Primary 5", "grve-osmosis-vc-extension" ) => 'primary-5',
  120. __( "Green", "grve-osmosis-vc-extension" ) => 'green',
  121. __( "Orange", "grve-osmosis-vc-extension" ) => 'orange',
  122. __( "Red", "grve-osmosis-vc-extension" ) => 'red',
  123. __( "Blue", "grve-osmosis-vc-extension" ) => 'blue',
  124. __( "Aqua", "grve-osmosis-vc-extension" ) => 'aqua',
  125. __( "Purple", "grve-osmosis-vc-extension" ) => 'purple',
  126. __( "Black", "grve-osmosis-vc-extension" ) => 'black',
  127. __( "Grey", "grve-osmosis-vc-extension" ) => 'grey',
  128. __( "White", "grve-osmosis-vc-extension" ) => 'white',
  129. ),
  130. "description" => __( "Color of the counter.", "grve-osmosis-vc-extension" ),
  131. ),
  132. array(
  133. "type" => "dropdown",
  134. "heading" => __( "Icon type", "grve-osmosis-vc-extension" ),
  135. "param_name" => "icon_type",
  136. "value" => array(
  137. __( "No Icon", "grve-osmosis-vc-extension" ) => '',
  138. __( "Icon", "grve-osmosis-vc-extension" ) => 'icon',
  139. ),
  140. "description" => '',
  141. "admin_label" => true,
  142. ),
  143. array(
  144. "type" => "grve_icon",
  145. "heading" => __( 'Icon', "grve-osmosis-vc-extension" ),
  146. "param_name" => "icon",
  147. "value" => 'adjust',
  148. "description" => __( "Select an icon.", "grve-osmosis-vc-extension" ),
  149. "dependency" => Array( 'element' => "icon_type", 'value' => array( 'icon' ) ),
  150. ),
  151. array(
  152. "type" => "dropdown",
  153. "heading" => __( "Icon Color", "grve-osmosis-vc-extension" ),
  154. "param_name" => "icon_color",
  155. "value" => array(
  156. __( "Primary 1", "grve-osmosis-vc-extension" ) => 'primary-1',
  157. __( "Primary 2", "grve-osmosis-vc-extension" ) => 'primary-2',
  158. __( "Primary 3", "grve-osmosis-vc-extension" ) => 'primary-3',
  159. __( "Primary 4", "grve-osmosis-vc-extension" ) => 'primary-4',
  160. __( "Primary 5", "grve-osmosis-vc-extension" ) => 'primary-5',
  161. __( "Green", "grve-osmosis-vc-extension" ) => 'green',
  162. __( "Orange", "grve-osmosis-vc-extension" ) => 'orange',
  163. __( "Red", "grve-osmosis-vc-extension" ) => 'red',
  164. __( "Blue", "grve-osmosis-vc-extension" ) => 'blue',
  165. __( "Aqua", "grve-osmosis-vc-extension" ) => 'aqua',
  166. __( "Purple", "grve-osmosis-vc-extension" ) => 'purple',
  167. __( "Black", "grve-osmosis-vc-extension" ) => 'black',
  168. __( "Grey", "grve-osmosis-vc-extension" ) => 'grey',
  169. __( "White", "grve-osmosis-vc-extension" ) => 'white',
  170. ),
  171. "description" => __( "Color of the icon.", "grve-osmosis-vc-extension" ),
  172. "dependency" => Array( 'element' => "icon_type", 'value' => array( 'icon' ) ),
  173. ),
  174. array(
  175. "type" => "textfield",
  176. "heading" => __( "Title", "grve-osmosis-vc-extension" ),
  177. "param_name" => "title",
  178. "value" => "Sample Title",
  179. "description" => __( "Enter counter title.", "grve-osmosis-vc-extension" ),
  180. "admin_label" => true,
  181. ),
  182. $grve_vce_add_animation,
  183. $grve_vce_add_animation_delay,
  184. $grve_vce_add_margin_bottom,
  185. $grve_vce_add_el_class,
  186. )
  187. ) );
  188. ?>