vc-button.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /*------------------------------------------------------*/
  3. /* taskereasy Heading
  4. /*------------------------------------------------------*/
  5. vc_map(array(
  6. "name" => esc_html__("Button", 'taskereasy'),
  7. "base" => "taskereasy_button",
  8. 'icon' => get_template_directory_uri() . '/assets/images/favicon-icon/shortcode-icon.png',
  9. "class" => "",
  10. "description" => esc_html__("Add taskereasy button", 'taskereasy'),
  11. "category" => esc_html__('Taskereasy Shortcodes', 'taskereasy'),
  12. "params" => array(
  13. array(
  14. "type" => "vc_link",
  15. "heading" => esc_html__("URL", 'taskereasy'),
  16. "param_name" => "btn_link",
  17. "value" => ''
  18. ),
  19. array(
  20. 'type' => 'dropdown',
  21. 'heading' => esc_html__( 'Button Style', 'taskereasy' ),
  22. 'param_name' => 'btn_style',
  23. 'value' => array('Style 1' => 'style1', 'Style 2' => 'style2')
  24. ),
  25. array(
  26. 'type' => 'dropdown',
  27. 'heading' => esc_html__( 'Button Alignment', 'taskereasy' ),
  28. 'param_name' => 'btn_align',
  29. 'value' => array('Left' => 'text-left', 'Center' => 'text-center', 'Right' => 'text-right')
  30. ),
  31. array(
  32. 'type' => 'css_editor',
  33. 'heading' => esc_html__( 'CSS', 'taskereasy' ),
  34. 'param_name' => 'custom_design',
  35. 'group' => esc_html__( 'Design options', 'taskereasy' ),
  36. )
  37. )
  38. ));
  39. add_shortcode( 'taskereasy_button', function($atts, $content = null) {
  40. extract(shortcode_atts(array(
  41. 'btn_link' => '',
  42. 'btn_style' => 'style1',
  43. 'btn_align' => 'text-left',
  44. 'custom_design' => '',
  45. ), $atts));
  46. $custom_design = vc_shortcode_custom_css_class( $custom_design, ' ' );
  47. $btnlink = vc_build_link( $btn_link );
  48. $btn_link = !empty($btnlink['url']) ? $btnlink['url'] : '#';
  49. $btn_title = $btnlink['title'];
  50. $btn_target = !empty($btnlink['target']) ? $btnlink['target'] : '_self';
  51. $output = '';
  52. $output .='
  53. <div class="'.esc_attr($custom_design).' vc-button '.esc_attr($btn_align).'">';
  54. if(html_entity_decode(vc_value_from_safe($btn_style, true)) == 'style1'){
  55. $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>';
  56. }
  57. if(html_entity_decode(vc_value_from_safe($btn_style, true)) == 'style2'){
  58. $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>';
  59. }
  60. $output .=' </div>';
  61. return $output;
  62. });