vc-counter.php 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. /*------------------------------------------------------*/
  3. /* taskereasy Heading
  4. /*------------------------------------------------------*/
  5. vc_map(array(
  6. "name" => esc_html__("Counter", 'taskereasy'),
  7. "base" => "taskereasy_counter",
  8. 'icon' => get_template_directory_uri() . '/assets/images/favicon-icon/shortcode-icon.png',
  9. "class" => "",
  10. "description" => esc_html__("Add taskereasy counter", 'taskereasy'),
  11. "category" => esc_html__('Taskereasy Shortcodes', 'taskereasy'),
  12. "params" => array(
  13. array(
  14. "type" => "param_group",
  15. "heading" => esc_html__("Icon List", 'taskereasy'),
  16. "param_name" => "icon_list",
  17. "params" => array(
  18. array(
  19. "type" => "iconpicker",
  20. "heading" => esc_html__("Icon", 'taskereasy'),
  21. "param_name" => "icon",
  22. ),
  23. array(
  24. "type" => "textfield",
  25. "heading" => esc_html__("Number", 'taskereasy'),
  26. "param_name" => "number",
  27. ),
  28. array(
  29. "type" => "textarea_safe",
  30. "heading" => esc_html__("Subtitle", 'taskereasy'),
  31. "param_name" => "subtext",
  32. ),
  33. array(
  34. 'type' => 'colorpicker',
  35. 'heading' => esc_html__( 'Icon Background', 'taskereasy' ),
  36. 'param_name' => 'icon_color',
  37. ),
  38. ),
  39. ),
  40. array(
  41. 'type' => 'css_editor',
  42. 'heading' => esc_html__( 'CSS', 'taskereasy' ),
  43. 'param_name' => 'custom_design',
  44. 'group' => esc_html__( 'Design options', 'taskereasy' ),
  45. )
  46. )
  47. ));
  48. add_shortcode( 'taskereasy_counter', function($atts, $content = null) {
  49. extract(shortcode_atts(array(
  50. 'icon' => '',
  51. 'number' => '',
  52. 'subtext' => '',
  53. 'icon_color' => '#000000',
  54. 'custom_design' => '',
  55. ), $atts));
  56. $custom_design = vc_shortcode_custom_css_class( $custom_design, ' ' );
  57. $iconlists = vc_param_group_parse_atts( $atts['icon_list'] );
  58. $output = '';
  59. $count = 0;
  60. $output .= '<div class="row">';
  61. foreach ($iconlists as $iconlist) {
  62. $margin = ($count%2 != 0) ? 'top-margin' : 'bottom-margin';
  63. $iconcolor = (isset($iconlists[$count]["icon_color"]))? $iconlists[$count]["icon_color"] : ' ' ;
  64. $output .= '<div class="col-md-6">
  65. <div class="facts-box '.esc_attr($margin).'" style="background-color: '.esc_attr($iconcolor).'">';
  66. if(isset($iconlists[$count]['icon'])){
  67. $output .= '<div class="icon-wp">
  68. <i class="'.esc_attr($iconlists[$count]['icon']).'"></i>
  69. </div>';
  70. }
  71. if(isset($iconlists[$count]['number'])){
  72. $output .= '<h3>'.esc_html($iconlists[$count]['number']).'</h3>';
  73. }
  74. if(isset($iconlists[$count]['subtext'])) {
  75. $output .= '<p>'.esc_html($iconlists[$count]['subtext']).'</p>';
  76. }
  77. $output .= '</div>
  78. </div>';
  79. $count++;
  80. }
  81. $output .= '</div>';
  82. return $output;
  83. });