vc-slider.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  2. /*------------------------------------------------------*/
  3. /* taskereasy Heading
  4. /*------------------------------------------------------*/
  5. vc_map(array(
  6. "name" => esc_html__("Slider", 'taskereasy'),
  7. "base" => "taskereasy_slider",
  8. 'icon' => get_template_directory_uri() . '/assets/images/favicon-icon/shortcode-icon.png',
  9. "class" => "",
  10. "description" => esc_html__("Add taskereasy Slider", 'taskereasy'),
  11. "category" => esc_html__('Taskereasy Shortcodes', 'taskereasy'),
  12. "params" => array(
  13. array(
  14. "type" => "param_group",
  15. "heading" => esc_html__("Slide", 'taskereasy'),
  16. "param_name" => "slide",
  17. "params" => array(
  18. array(
  19. "type" => "attach_image",
  20. "heading" => esc_html__("Image", 'taskereasy'),
  21. "param_name" => "image",
  22. ),
  23. array(
  24. "type" => "textfield",
  25. "heading" => esc_html__("Image Size", 'taskereasy'),
  26. "param_name" => "image_size",
  27. "description" => 'Enter image size (Example: "thumbnail", "medium", "large", "full" or other sizes defined by theme). Alternatively enter size in pixels (Example: 200x100 (Width x Height)).'
  28. ),
  29. array(
  30. "type" => "textfield",
  31. "heading" => esc_html__("Title", 'taskereasy'),
  32. "param_name" => "title",
  33. ),
  34. array(
  35. "type" => "textarea_safe",
  36. "heading" => esc_html__("Subtitle", 'taskereasy'),
  37. "param_name" => "subtext",
  38. ),
  39. array(
  40. "type" => "vc_link",
  41. "heading" => esc_html__("Button Link", 'taskereasy'),
  42. "param_name" => "btn_link",
  43. "value" => ''
  44. ),
  45. array(
  46. 'type' => 'dropdown',
  47. 'heading' => esc_html__( 'Button Style', 'taskereasy' ),
  48. 'param_name' => 'btn_style',
  49. 'value' => array('Style 1' => 'style1', 'Style 2' => 'style2')
  50. ),
  51. )
  52. ),
  53. array(
  54. 'type' => 'textfield',
  55. 'heading' => esc_html__( 'Row ID', 'taskereasy' ),
  56. 'param_name' => 'id',
  57. ),
  58. array(
  59. 'type' => 'css_editor',
  60. 'heading' => esc_html__( 'CSS', 'taskereasy' ),
  61. 'param_name' => 'custom_design',
  62. 'group' => esc_html__( 'Design options', 'taskereasy' ),
  63. )
  64. )
  65. ));
  66. add_shortcode( 'taskereasy_slider', function($atts, $content = null) {
  67. extract(shortcode_atts(array(
  68. 'title' => '',
  69. 'subtext' => '',
  70. 'image' => '',
  71. 'image_size' => '',
  72. 'id' => '',
  73. 'custom_design' => '',
  74. ), $atts));
  75. $custom_design = vc_shortcode_custom_css_class( $custom_design, ' ' );
  76. $slides = vc_param_group_parse_atts( $atts['slide'] );
  77. $id = html_entity_decode(vc_value_from_safe($id, true));
  78. $output = '';
  79. $count = 0;
  80. //$output .= print_r($slides);
  81. $output .= '<div id="'.$id.'">
  82. <div class="owl-carousel">';
  83. foreach ($slides as $slide) {
  84. $img_id = $slides[$count]['image'];
  85. $img_size = $slides[$count]['image_size'];
  86. $imageurl = wp_get_attachment_image_src( $img_id, $img_size );
  87. $btnlink = vc_build_link( $slides[$count]['btn_link'] );
  88. $btn_url = $btnlink['url'];
  89. $btn_title = $btnlink['title'];
  90. $btn_target = $btnlink['target'];
  91. $output .='
  92. <div class="item" style="background-image:url('.$imageurl[0].')">
  93. <div class="intro-text">
  94. <h1>'.$slides[$count]['title'].'</h1>
  95. <p>'.$slides[$count]['subtext'].'</p>';
  96. if($slides[$count]['btn_style'] == 'style1'){
  97. $output .= '<a href="'.esc_url($btn_url).'" class="btn" target="'.esc_attr($btn_target).'" >'.esc_html($btn_title).' <i class="fa fa-angle-right"></i></a>';
  98. }
  99. if($slides[$count]['btn_style'] == 'style2'){
  100. $output .= '<a href="'.esc_url($btn_url).'" class="btn btn-secondary" target="'.esc_attr($btn_target).'" >'.esc_html($btn_title).' <i class="fa fa-angle-right"></i></a>';
  101. }
  102. $output .= ' </div>
  103. </div>
  104. ';
  105. $count++;
  106. }
  107. $output .= '</div></div>';
  108. return $output;
  109. });