vc-pricing.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <?php
  2. /*------------------------------------------------------*/
  3. /* taskereasy Heading
  4. /*------------------------------------------------------*/
  5. vc_map(array(
  6. "name" => esc_html__("Pricing", 'taskereasy'),
  7. "base" => "taskereasy_pricing",
  8. 'icon' => get_template_directory_uri() . '/assets/images/favicon-icon/shortcode-icon.png',
  9. "class" => "",
  10. "description" => esc_html__("Add taskereasy pricing", 'taskereasy'),
  11. "category" => esc_html__('Taskereasy Shortcodes', 'taskereasy'),
  12. "params" => array(
  13. array(
  14. "type" => "param_group",
  15. "heading" => esc_html__("Price List", 'taskereasy'),
  16. "param_name" => "price_list",
  17. "params" => array(
  18. array(
  19. "type" => "textfield",
  20. "heading" => esc_html__("Title", 'taskereasy'),
  21. "param_name" => "title",
  22. ),
  23. array(
  24. "type" => "textfield",
  25. "heading" => esc_html__("price", 'taskereasy'),
  26. "param_name" => "price",
  27. ),
  28. array(
  29. 'type' => 'dropdown',
  30. 'heading' => esc_html__( 'Limit', 'taskereasy' ),
  31. 'param_name' => 'limit',
  32. 'value' => array('Monthly' => 'monthly', 'Yearly' => 'yearly'),
  33. ),
  34. array(
  35. "type" => "param_group",
  36. "heading" => esc_html__("Features", 'taskereasy'),
  37. "param_name" => "features",
  38. "params" => array(
  39. array(
  40. "type" => "textfield",
  41. "heading" => esc_html__("", 'taskereasy'),
  42. "param_name" => "feature",
  43. ),
  44. )
  45. ),
  46. array(
  47. 'type' => 'checkbox',
  48. 'heading' => esc_html__( 'Plan Tag', 'taskereasy' ),
  49. 'param_name' => 'plan_tag',
  50. 'value' => ''
  51. ),
  52. array(
  53. 'type' => 'vc_link',
  54. 'heading' => esc_html__( 'Button Link', 'taskereasy' ),
  55. 'param_name' => 'btn_link',
  56. ),
  57. array(
  58. 'type' => 'dropdown',
  59. 'heading' => esc_html__( 'Button Style', 'taskereasy' ),
  60. 'param_name' => 'btn_style',
  61. 'value' => array('Style 1' => 'style1', 'Style 2' => 'style2')
  62. ),
  63. )
  64. ),
  65. array(
  66. 'type' => 'css_editor',
  67. 'heading' => esc_html__( 'CSS', 'taskereasy' ),
  68. 'param_name' => 'custom_design',
  69. 'group' => esc_html__( 'Design options', 'taskereasy' ),
  70. )
  71. )
  72. ));
  73. add_shortcode( 'taskereasy_pricing', function($atts, $content = null) {
  74. extract(shortcode_atts(array(
  75. 'price_list' => '',
  76. 'custom_design' => '',
  77. 'btn_style' => 'style1',
  78. 'btn_link' => '',
  79. 'plan_tag' => '',
  80. ), $atts));
  81. $custom_design = vc_shortcode_custom_css_class( $custom_design, ' ' );
  82. $pricelist = vc_param_group_parse_atts( $atts['price_list'] );
  83. $output = '';
  84. $count = 0;
  85. $output .='<div class="price-section">
  86. <div class="row">';
  87. foreach ($pricelist as $price) {
  88. $count_feature = 0;
  89. $features_list = vc_param_group_parse_atts($pricelist[$count]['features']);
  90. $btnlink = vc_build_link( $pricelist[$count]['btn_link'] );
  91. $btn_link = !empty($btnlink['url']) ? $btnlink['url'] : '#';
  92. $btn_title = $btnlink['title'];
  93. $btn_target = !empty($btnlink['target']) ? $btnlink['target'] : '_self';
  94. $output .= '<div class="col-lg-4">
  95. <div class="price-wrap">';
  96. if(isset($pricelist[$count]['plan_tag']) ){
  97. $output .= '<div class="plan-tag">'.esc_html__("Popular", "taskereasy").'</div>';
  98. }
  99. $output .= '<h5>'.esc_html($pricelist[$count]['title']).'</h5>
  100. <div class="price">$'.esc_html($pricelist[$count]['price']).' <span>/'.esc_html($pricelist[$count]['limit']).'</span></div>
  101. <ul>';
  102. foreach ( $features_list as $feature) {
  103. $output .= '<li>'.esc_html($features_list[$count_feature]['feature']).'</li>';
  104. $count_feature++;
  105. }
  106. $output .='</ul>';
  107. if(html_entity_decode(vc_value_from_safe($btn_style, true)) == 'style1'){
  108. if($btn_title){
  109. $output .= '<a href="'.esc_url($btn_link).'" class="btn" target="'.esc_attr($btn_target).'" >'.esc_html($btn_title).' <i class="fa fa-angle-right"></i></a>';
  110. }
  111. }
  112. if(html_entity_decode(vc_value_from_safe($btn_style, true)) == 'style2'){
  113. if($btn_title){
  114. $output .= '<a href="'.esc_url($btn_link).'" class="btn btn-secondary" target="'.esc_attr($btn_target).'">'.esc_html($btn_title).' <i class="fa fa-angle-right"></i></a>';
  115. }
  116. }
  117. $output .= '</div>
  118. </div>
  119. ';
  120. $count++;
  121. }
  122. $output .= '</div> </div>';
  123. return $output;
  124. });