vc-faq.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. /*------------------------------------------------------*/
  3. /* taskereasy Heading
  4. /*------------------------------------------------------*/
  5. vc_map(array(
  6. "name" => esc_html__("FAQs", 'taskereasy'),
  7. "base" => "taskereasy_faqs",
  8. 'icon' => get_template_directory_uri() . '/assets/images/favicon-icon/shortcode-icon.png',
  9. "class" => "",
  10. "description" => esc_html__("Add taskereasy faqs", 'taskereasy'),
  11. "category" => esc_html__('Taskereasy Shortcodes', 'taskereasy'),
  12. "params" => array(
  13. array(
  14. "type" => "param_group",
  15. "heading" => esc_html__("FAQs", 'taskereasy'),
  16. "param_name" => "faqs_list",
  17. "value" => '',
  18. "params" => array(
  19. array(
  20. "type" => "textfield",
  21. "heading" => esc_html__("Title", 'taskereasy'),
  22. "param_name" => "title",
  23. ),
  24. array(
  25. "type" => "textarea_safe",
  26. "heading" => esc_html__("Description", 'taskereasy'),
  27. "param_name" => "faq_description",
  28. ),
  29. array(
  30. "type" => "checkbox",
  31. "heading" => esc_html__("Show Icon", 'taskereasy'),
  32. "param_name" => "show_icon",
  33. ),
  34. array(
  35. "type" => "iconpicker",
  36. "heading" => esc_html__("Icon", 'taskereasy'),
  37. "param_name" => "faq_icon",
  38. "dependency" => array('element' => "show_icon", 'not_empty' => TRUE),
  39. ),
  40. array(
  41. "type" => "colorpicker",
  42. "heading" => esc_html__("Icon Color", 'taskereasy'),
  43. "param_name" => "icon_color",
  44. "dependency" => array('element' => "show_icon", 'not_empty' => TRUE),
  45. ),
  46. ),
  47. ),
  48. array(
  49. 'type' => 'css_editor',
  50. 'heading' => esc_html__( 'CSS', 'taskereasy' ),
  51. 'param_name' => 'custom_design',
  52. 'group' => esc_html__( 'Design options', 'taskereasy' ),
  53. ),
  54. )
  55. ));
  56. add_shortcode( 'taskereasy_faqs', function($atts, $content = null) {
  57. extract(shortcode_atts(array(
  58. 'faq_icon' => '',
  59. 'icon_color' => '#000000',
  60. 'custom_design' => '',
  61. ), $atts));
  62. $custom_design = vc_shortcode_custom_css_class( $custom_design, ' ' );
  63. $faqs_list = vc_param_group_parse_atts( $atts['faqs_list'] );
  64. $output = '';
  65. $count = 0;
  66. $showicon = ($faqs_list[$count]['show_icon'] == 'true') ? 'showicon' : '';
  67. $output .='<div id="accordion" class="'.$custom_design.'">';
  68. foreach ($faqs_list as $faq) {
  69. if($count == 0) { $show = 'show'; } else{ $show = '';}
  70. $output .= '<div class="card">
  71. <div class="card-header" id="heading'.esc_attr($count).'">
  72. <div class="btn btn-link '.esc_attr($showicon).'" data-toggle="collapse" data-target="#collapse-'.esc_attr($count).'" role="button" aria-expanded="true" aria-controls="collapse-'.esc_attr($count).'">';
  73. if($faqs_list[$count]['show_icon'] == 'true'){
  74. $output .= '<div class="list-icon" style="background-color: '.esc_attr($faqs_list[$count]['icon_color']).';"><i class="'.esc_attr($faqs_list[$count]['faq_icon']).'"></i></div>';
  75. }
  76. $output.= $faqs_list[$count]['title'].'
  77. </div>
  78. </div>
  79. <div id="collapse-'.esc_attr($count).'" class="collapse '.esc_attr($show).'" aria-labelledby="heading'.esc_attr($count).'" data-parent="#accordion">
  80. <div class="card-body">
  81. '.esc_html($faqs_list[$count]['faq_description']).'
  82. </div>
  83. </div>
  84. </div>';
  85. $count++;
  86. }
  87. $output .= '</div>
  88. ';
  89. return $output;
  90. });