vc-image-text.php 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. <?php
  2. /*------------------------------------------------------*/
  3. /* taskereasy Heading
  4. /*------------------------------------------------------*/
  5. vc_map(array(
  6. "name" => esc_html__("Image with text", 'taskereasy'),
  7. "base" => "taskereasy_image_text",
  8. 'icon' => get_template_directory_uri() . '/assets/images/favicon-icon/shortcode-icon.png',
  9. "class" => "",
  10. "description" => esc_html__("Add taskereasy image with text", 'taskereasy'),
  11. "category" => esc_html__('Taskereasy Shortcodes', 'taskereasy'),
  12. "params" => array(
  13. array(
  14. "type" => "dropdown",
  15. "heading" => esc_html__("Style", 'taskereasy'),
  16. "param_name" => "img_style",
  17. "value" => array('Style 1' => 'style1', 'Style 2' => 'style2', 'Style 3' => 'style3', 'Style 4' => 'style4'),
  18. ),
  19. array(
  20. "type" => "param_group",
  21. "heading" => esc_html__("Image Block", 'taskereasy'),
  22. "param_name" => "img_block",
  23. "dependency" => array(
  24. 'element' => 'img_style',
  25. 'value' => 'style4'
  26. ),
  27. "params" => array(
  28. array(
  29. "type" => "attach_image",
  30. "heading" => esc_html__("Image", 'taskereasy'),
  31. "param_name" => "image",
  32. ),
  33. array(
  34. "type" => "textfield",
  35. "heading" => esc_html__("Image Size", 'taskereasy'),
  36. "param_name" => "image_size",
  37. "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)).'
  38. ),
  39. array(
  40. "type" => "textfield",
  41. "heading" => esc_html__("Title", 'taskereasy'),
  42. "param_name" => "title",
  43. ),
  44. array(
  45. "type" => "textarea_safe",
  46. "heading" => esc_html__("Subtitle", 'taskereasy'),
  47. "param_name" => "subtext",
  48. ),
  49. array(
  50. "type" => "textarea_safe",
  51. "heading" => esc_html__("Description", 'taskereasy'),
  52. "param_name" => "description",
  53. ),
  54. array(
  55. "type" => "textfield",
  56. "heading" => esc_html__("Number", 'taskereasy'),
  57. "param_name" => "number",
  58. ),
  59. ),
  60. ),
  61. array(
  62. "type" => "attach_image",
  63. "heading" => esc_html__("Image", 'taskereasy'),
  64. "param_name" => "image",
  65. 'dependency' => array(
  66. 'element' => 'img_style',
  67. 'value' => array('style1', 'style2', 'style3')
  68. ),
  69. ),
  70. array(
  71. "type" => "textfield",
  72. "heading" => esc_html__("Image Size", 'taskereasy'),
  73. "param_name" => "image_size",
  74. 'dependency' => array(
  75. 'element' => 'img_style',
  76. 'value' => array('style1', 'style2', 'style3')
  77. ),
  78. "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)).'
  79. ),
  80. array(
  81. "type" => "textfield",
  82. "heading" => esc_html__("Title", 'taskereasy'),
  83. "param_name" => "title",
  84. 'dependency' => array(
  85. 'element' => 'img_style',
  86. 'value' => array('style1', 'style2', 'style3')
  87. ),
  88. ),
  89. array(
  90. "type" => "textarea_safe",
  91. "heading" => esc_html__("Subtitle", 'taskereasy'),
  92. 'dependency' => array(
  93. 'element' => 'img_style',
  94. 'value' => array('style1', 'style2', 'style3')
  95. ),
  96. "param_name" => "subtext",
  97. ),
  98. array(
  99. "type" => "textfield",
  100. "heading" => esc_html__("Number", 'taskereasy'),
  101. "param_name" => "number",
  102. 'dependency' => array(
  103. 'element' => 'img_style',
  104. 'value' => array('style1', 'style2', 'style3')
  105. ),
  106. ),
  107. array(
  108. "type" => "vc_link",
  109. "heading" => esc_html__("Button Link", 'taskereasy'),
  110. "param_name" => "btn_link",
  111. 'dependency' => array(
  112. 'element' => 'img_style',
  113. 'value' => array('style1', 'style2', 'style3')
  114. ),
  115. "value" => ''
  116. ),
  117. array(
  118. 'type' => 'dropdown',
  119. 'heading' => esc_html__( 'Button Style', 'taskereasy' ),
  120. 'param_name' => 'btn_style',
  121. 'dependency' => array(
  122. 'element' => 'img_style',
  123. 'value' => array('style1', 'style2', 'style3')
  124. ),
  125. 'value' => array('Style 1' => 'style1', 'Style 2' => 'style2')
  126. ),
  127. array(
  128. 'type' => 'css_editor',
  129. 'heading' => esc_html__( 'CSS', 'taskereasy' ),
  130. 'param_name' => 'custom_design',
  131. 'group' => esc_html__( 'Design options', 'taskereasy' ),
  132. )
  133. )
  134. ));
  135. add_shortcode( 'taskereasy_image_text', function($atts, $content = null) {
  136. extract(shortcode_atts(array(
  137. 'img_style' => 'style1',
  138. 'image' => '',
  139. 'image_size' => 'full',
  140. 'title' => '',
  141. 'img_block' => '',
  142. 'subtext' => '',
  143. 'number' => '',
  144. 'btn_link' => '',
  145. 'btn_style' => 'style1',
  146. 'custom_design' => '',
  147. ), $atts));
  148. $custom_design = vc_shortcode_custom_css_class( $custom_design, ' ' );
  149. $imgstyle = html_entity_decode(vc_value_from_safe($img_style, true));
  150. $image_url = html_entity_decode(vc_value_from_safe($image, true));
  151. $img_size = html_entity_decode(vc_value_from_safe($image_size, true));
  152. $imageurl = wp_get_attachment_image_src( $image_url, $img_size );
  153. $title_text = html_entity_decode(vc_value_from_safe($title, true));
  154. $subtitle = html_entity_decode(vc_value_from_safe($subtext, true));
  155. $number = html_entity_decode(vc_value_from_safe($number, true));
  156. $btnlink = vc_build_link( $btn_link);
  157. $btn_link = !empty($btnlink['url']) ? $btnlink['url'] : '#';
  158. $btn_title = $btnlink['title'];
  159. $btn_target = !empty($btnlink['target']) ? $btnlink['target'] : '_self';
  160. $count = 0;
  161. $output = '';
  162. if($imgstyle == 'style1'){
  163. $output .='
  164. <section class="section-padding '.$custom_design.'">
  165. <div class="container">
  166. <div class="row">
  167. <div class="col-lg-6 order-md-12">
  168. <div class="about-info">
  169. <div class="p-0">
  170. <h2>'.$title_text.'</h2>
  171. </div>
  172. <p>'.$subtitle.'</p>';
  173. if(html_entity_decode(vc_value_from_safe($btn_style, true)) == 'style1'){
  174. $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>';
  175. }
  176. if(html_entity_decode(vc_value_from_safe($btn_style, true)) == 'style2'){
  177. $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>';
  178. }
  179. $output .= '</div>
  180. </div>
  181. <div class="col-lg-6">
  182. <div class="img-wrap">
  183. <img src="'.esc_url($imageurl[0]).'" alt="image">
  184. </div>
  185. </div>
  186. </div>
  187. </div>
  188. </section>';
  189. }
  190. if($imgstyle == 'style2'){
  191. $output .= '<div class="benefits-box">
  192. <div class="number-wp">'.esc_html($number).'</div>';
  193. if($imageurl[0]){
  194. $output .= '<img src="'.esc_url($imageurl[0]).'" alt="image">';
  195. }
  196. $output .= '<h5>'.esc_html($title_text).'</h5>
  197. <p>'.esc_html($subtitle).'</p>
  198. </div>';
  199. }
  200. if($imgstyle == 'style3'){
  201. $output .= '<div class="features_box">
  202. <div class="icon_wrap">
  203. <div class="icon_wrap-inner">';
  204. if($imageurl[0]){
  205. $output .= '<img src="'.esc_url($imageurl[0]).'" alt="icon">';
  206. }
  207. $output .= '</div></div>
  208. <h6>'.esc_html($title_text).'</h6>
  209. <p>'.esc_html($subtitle).'</p>
  210. </div>';
  211. }
  212. if($imgstyle == 'style4'){
  213. $img_block = vc_param_group_parse_atts( $atts['img_block'] );
  214. $output .='<div class="benefits-slider-wrapper center-slider">';
  215. foreach ($img_block as $block) {
  216. $img_id = $block['image'];
  217. $imgurl = wp_get_attachment_image_src($img_id, $img_size);
  218. $output .=
  219. '<div class="benefits-item">
  220. <div class="benefits-item-no">'.esc_html($block['number']).'</div>
  221. <div class="benefit-img-wrpr">';
  222. if(!empty($imgurl[0])){
  223. $output .= '<img src="'.esc_url($imgurl[0]).'" alt="icon">';
  224. }
  225. $output.='
  226. <h3>'.esc_html($block['subtext']).'</h3>
  227. </div>
  228. <div class="benefit-content-wrpr">
  229. <h6>'.esc_html($block['title']).'</h6>
  230. <p>'.esc_html($block['description']).'</p>
  231. </div>
  232. </div>';
  233. $count++;
  234. }
  235. $output.='</div>';
  236. }
  237. return $output;
  238. });