vc-heading.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /*------------------------------------------------------*/
  3. /* taskereasy Heading
  4. /*------------------------------------------------------*/
  5. vc_map(array(
  6. "name" => esc_html__("Heading", 'taskereasy'),
  7. "base" => "taskereasy_text_heading",
  8. 'icon' => get_template_directory_uri() . '/assets/images/favicon-icon/shortcode-icon.png',
  9. "class" => "",
  10. "description" => esc_html__("Add taskereasy Text Heading", 'taskereasy'),
  11. "category" => esc_html__('Taskereasy Shortcodes', 'taskereasy'),
  12. "params" => array(
  13. array(
  14. "type" => "textfield",
  15. "heading" => esc_html__("Title", 'taskereasy'),
  16. "param_name" => "title",
  17. ),
  18. array(
  19. "type" => "textarea_safe",
  20. "heading" => esc_html__("Subtitle", 'taskereasy'),
  21. "param_name" => "subtext",
  22. ),
  23. array(
  24. 'type' => 'dropdown',
  25. 'heading' => esc_html__( 'Show Text', 'taskereasy' ),
  26. 'param_name' => 'align',
  27. 'value' => array('Center' => 1, 'Left' => 2),
  28. ),
  29. array(
  30. 'type' => 'css_editor',
  31. 'heading' => esc_html__( 'CSS', 'taskereasy' ),
  32. 'param_name' => 'custom_design',
  33. 'group' => esc_html__( 'Design options', 'taskereasy' ),
  34. )
  35. )
  36. ));
  37. add_shortcode( 'taskereasy_text_heading', function($atts, $content = null) {
  38. extract(shortcode_atts(array(
  39. 'title' => '',
  40. 'subtext' => '',
  41. 'align' => '',
  42. 'custom_design' => '',
  43. ), $atts));
  44. $class = ($align==2)?'section-header-left':'text-center';
  45. $custom_design = vc_shortcode_custom_css_class( $custom_design, ' ' );
  46. $output = '';
  47. $output .='
  48. <div class="'.esc_attr($custom_design).' section-header '.$class.'">
  49. <h3 class="section-title">'.html_entity_decode(vc_value_from_safe($title, true)).'</h3>';
  50. if( $subtext != '' ) {
  51. $output .= '<p class="section-subtitle">' . html_entity_decode(vc_value_from_safe($subtext, true)) . '</p>';
  52. }
  53. $output .='
  54. </div>
  55. ';
  56. return $output;
  57. });