Our_Testimonials.php (13058B)
1 <?php 2 3 namespace Welbim\Helper\Elementor\Widgets; 4 5 use Elementor\Utils; 6 use Elementor\Controls_Manager; 7 use Elementor\Widget_Base; 8 use Elementor\Plugin; 9 use \Elementor\Repeater; 10 use Elementor\Group_Control_Typography; 11 12 class Our_Testimonials extends Widget_Base 13 { 14 15 public function get_name() 16 { 17 return 'our_testimonials'; 18 } 19 20 public function get_title() 21 { 22 return esc_html__('Welbim Testimonials', 'welbim'); 23 } 24 25 public function get_icon() 26 { 27 return 'sds-widget-ico'; 28 } 29 30 public function get_categories() 31 { 32 return ['Welbim']; 33 } 34 35 protected function _register_controls() 36 { 37 38 $this->start_controls_section( 39 'general', 40 [ 41 'label' => esc_html__('General', 'welbim'), 42 ] 43 ); 44 45 $this->add_control( 46 'layout_style', 47 [ 48 'label' => __('Layout', 'welbim'), 49 'type' => \Elementor\Controls_Manager::SELECT, 50 'default' => '1', 51 'options' => [ 52 '1' => __('One', 'welbim'), 53 '2' => __('Two', 'welbim'), 54 ], 55 ] 56 ); 57 58 $this->add_control( 59 'sub_title', 60 [ 61 'label' => esc_html__('Sub Title', 'welbim'), 62 'type' => Controls_Manager::TEXT, 63 'label_block' => true, 64 'default' => __('Our Testimonials', 'welbim'), 65 ] 66 ); 67 68 $this->add_control( 69 'title', 70 [ 71 'label' => esc_html__('Title', 'welbim'), 72 'type' => Controls_Manager::TEXT, 73 'label_block' => true, 74 'default' => __('What they say', 'welbim'), 75 ] 76 ); 77 78 $this->add_control( 79 'bg_image', 80 [ 81 'label' => esc_html__('Background Image', 'welbim'), 82 'type' => Controls_Manager::MEDIA, 83 'default' => [ 84 'url' => Utils::get_placeholder_image_src(), 85 ], 86 ] 87 ); 88 89 $this->end_controls_section(); 90 91 $this->start_controls_section( 92 'item', 93 [ 94 'label' => esc_html__('Item One', 'welbim'), 95 ] 96 ); 97 98 $repeater1 = new Repeater(); 99 100 $repeater1->add_control( 101 'item_author_image', 102 [ 103 'label' => esc_html__('Author Image', 'welbim'), 104 'type' => Controls_Manager::MEDIA, 105 'default' => [ 106 'url' => Utils::get_placeholder_image_src(), 107 ], 108 ] 109 ); 110 111 $repeater1->add_control( 112 'item_author_title', 113 [ 114 'label' => esc_html__('Author Title', 'welbim'), 115 'type' => Controls_Manager::TEXT, 116 'label_block' => true, 117 'default' => __('Jessica Brown', 'welbim'), 118 ] 119 ); 120 121 $repeater1->add_control( 122 'item_designation', 123 [ 124 'label' => esc_html__('Designation', 'welbim'), 125 'type' => Controls_Manager::TEXT, 126 'label_block' => true, 127 'default' => __('Co-Founder', 'welbim'), 128 ] 129 ); 130 131 $repeater1->add_control( 132 'item_discription', 133 [ 134 'label' => esc_html__('Discription', 'welbim'), 135 'type' => Controls_Manager::TEXTAREA, 136 'rows' => 6, 137 'default' => __('I have just had two of the most productive work weeks I have had in years. Ben was perfectly matched to my temperament, and has been taking all the backlogged work off my plate and finishing it.', 'welbim'), 138 'placeholder' => esc_html__('Type your description here', 'welbim'), 139 ] 140 ); 141 142 $this->add_control( 143 'items1', 144 [ 145 'label' => esc_html__('Repeater List', 'welbim'), 146 'type' => Controls_Manager::REPEATER, 147 'fields' => $repeater1->get_controls(), 148 'default' => [ 149 [ 150 'list_title' => esc_html__('Title #1', 'welbim'), 151 'list_content' => esc_html__('Item content. Click the edit button to change this text.', 'welbim'), 152 ], 153 [ 154 'list_title' => esc_html__('Title #2', 'welbim'), 155 'list_content' => esc_html__('Item content. Click the edit button to change this text.', 'welbim'), 156 ], 157 ], 158 ] 159 ); 160 161 $this->end_controls_section(); 162 163 $this->start_controls_section( 164 'item2', 165 [ 166 'label' => esc_html__('Item Two', 'welbim'), 167 'condition' => [ 168 'layout_style' => '1', 169 ] 170 ] 171 ); 172 173 $repeater2 = new Repeater(); 174 175 $repeater2->add_control( 176 'item_title', 177 [ 178 'label' => esc_html__('Title', 'welbim'), 179 'type' => Controls_Manager::TEXT, 180 'default' => __('', 'welbim'), 181 ] 182 ); 183 184 $repeater2->add_control( 185 'icon', 186 [ 187 'label' => __('Icon', 'text-domain'), 188 'type' => \Elementor\Controls_Manager::ICONS, 189 ] 190 ); 191 192 $this->add_control( 193 'items2', 194 [ 195 'label' => esc_html__('Repeater List', 'welbim'), 196 'type' => Controls_Manager::REPEATER, 197 'fields' => $repeater2->get_controls(), 198 'default' => [ 199 [ 200 'list_title' => esc_html__('Title #1', 'welbim'), 201 'list_content' => esc_html__('Item content. Click the edit button to change this text.', 'welbim'), 202 ], 203 [ 204 'list_title' => esc_html__('Title #2', 'welbim'), 205 'list_content' => esc_html__('Item content. Click the edit button to change this text.', 'welbim'), 206 ], 207 ], 208 ] 209 ); 210 211 $this->end_controls_section(); 212 213 //Typography Section 214 $this->start_controls_section( 215 'typography_section', 216 array( 217 'label' => __('Typography Section', 'welbim'), 218 'tab' => Controls_Manager::TAB_STYLE, 219 ) 220 ); 221 222 $this->add_group_control( 223 Group_Control_Typography::get_type(), 224 array( 225 'name' => 'subtitle_typography', 226 'label' => __('Sub Title', 'welbim'), 227 'selector' => '{{WRAPPER}} .sec-title .sub-title', 228 229 ) 230 ); 231 232 $this->add_group_control( 233 Group_Control_Typography::get_type(), 234 array( 235 'name' => 'title_typography', 236 'label' => __('Title', 'welbim'), 237 'selector' => '{{WRAPPER}} .sec-title h2', 238 239 ) 240 ); 241 242 $this->add_group_control( 243 Group_Control_Typography::get_type(), 244 array( 245 'name' => 'item_title_typography', 246 'label' => __('Item Title', 'welbim'), 247 'selector' => '{{WRAPPER}} .testimonials-section .icon-box h4', 248 249 ) 250 ); 251 252 253 $this->end_controls_section(); 254 255 //Color Section 256 $this->start_controls_section( 257 'color_section', 258 array( 259 'label' => __('Color Section', 'welbim'), 260 'tab' => \Elementor\Controls_Manager::TAB_STYLE, 261 ) 262 ); 263 264 $this->add_control( 265 'subtitle_color', 266 array( 267 'label' => __('Sub Title Color', 'welbim'), 268 'separator' => 'before', 269 'type' => \Elementor\Controls_Manager::COLOR, 270 'selectors' => array( 271 '{{WRAPPER}} .sec-title .sub-title' => 'color: {{VALUE}}', 272 ), 273 ) 274 ); 275 276 $this->add_control( 277 'title_color', 278 array( 279 'label' => __('Title Color', 'welbim'), 280 'separator' => 'before', 281 'type' => \Elementor\Controls_Manager::COLOR, 282 'selectors' => array( 283 '{{WRAPPER}} .sec-title h2' => 'color: {{VALUE}}', 284 ), 285 ) 286 ); 287 288 $this->add_control( 289 'item_title_color', 290 array( 291 'label' => __('Item title Color', 'welbim'), 292 'separator' => 'before', 293 'type' => \Elementor\Controls_Manager::COLOR, 294 'selectors' => array( 295 '{{WRAPPER}} .testimonials-section .icon-box h4' => 'color: {{VALUE}}', 296 ), 297 ) 298 ); 299 300 $this->add_control( 301 'item_icon_color', 302 array( 303 'label' => __('Item Icon Color', 'welbim'), 304 'separator' => 'before', 305 'type' => \Elementor\Controls_Manager::COLOR, 306 'selectors' => array( 307 '{{WRAPPER}} .testimonials-section .icon-box .icon' => 'color: {{VALUE}}', 308 ), 309 ) 310 ); 311 312 313 $this->add_control( 314 'item_icon_bg_color', 315 array( 316 'label' => __('Item Icon BG Color', 'welbim'), 317 'separator' => 'before', 318 'type' => \Elementor\Controls_Manager::COLOR, 319 'selectors' => array( 320 '{{WRAPPER}} .testimonials-section .icon-box .icon' => 'background-color: {{VALUE}}', 321 ), 322 ) 323 ); 324 325 $this->add_control( 326 'Designation_color', 327 array( 328 'label' => __('Designation Color', 'welbim'), 329 'separator' => 'before', 330 'type' => \Elementor\Controls_Manager::COLOR, 331 'selectors' => array( 332 '{{WRAPPER}} .testimonial-block .author-title span' => 'color: {{VALUE}}', 333 ), 334 ) 335 ); 336 337 338 $this->end_controls_section(); 339 } 340 protected function render() 341 { 342 $settings = $this->get_settings_for_display(); 343 $sub_title = $settings["sub_title"]; 344 $title = $settings["title"]; 345 $layout_style = $settings["layout_style"]; 346 if ($layout_style == '1') { 347 $bg_image = $settings["bg_image"]["url"]; 348 ?> 349 <section class="testimonials-section" style="background-image: url(<?php echo $bg_image; ?>);"> 350 <div class="auto-container"> 351 <div class="row"> 352 <div class="col-lg-8"> 353 <div class="sec-title"> 354 <div class="sub-title"><?php echo $sub_title; ?></div> 355 <h2><?php echo $title; ?></h2> 356 </div> 357 <div class="testimonial-block-area"> 358 <div class="swiper-container testimonial-thumbs"> 359 <div class="swiper-wrapper"> 360 <?php 361 $i = 1; 362 foreach ($settings["items1"] as $item) { 363 $item_author_image = ($item["item_author_image"]["id"] != "") ? wp_get_attachment_image($item["item_author_image"]["id"], "full") : $item["item_author_image"]["url"]; 364 $item_author_image_alt = get_post_meta($item["item_author_image"]["id"], "_wp_attachment_image_alt", true); 365 ?> 366 <div class="swiper-slide"> 367 <div class="author-thumb"> 368 <?php 369 if (wp_http_validate_url($item_author_image)) { 370 ?> 371 <img src="<?php echo esc_url($item_author_image); ?>" alt="<?php esc_url($item_author_image_alt); ?>"> 372 <?php 373 } else { 374 echo $item_author_image; 375 } 376 ?> 377 </div> 378 </div> 379 <?php 380 $i++; 381 } 382 ?> 383 </div> 384 </div> 385 <!-- Swiper --> 386 <div class="swiper-container testimonial-content"> 387 <div class="swiper-wrapper"> 388 <?php 389 $i = 1; 390 foreach ($settings["items1"] as $item) { 391 $item_author_title = $item["item_author_title"]; 392 $item_designation = $item["item_designation"]; 393 $item_discription = $item["item_discription"]; 394 ?> 395 <div class="swiper-slide"> 396 <!-- Testimonial Block --> 397 <div class="testimonial-block"> 398 <div class="inner-box"> 399 <div class="text"><?php echo $item_discription; ?></div> 400 <div class="author-title"><?php echo $item_author_title; ?> <span>/ <?php echo $item_designation; ?></span></div> 401 </div> 402 </div> 403 </div> 404 <?php 405 $i++; 406 } 407 ?> 408 </div> 409 </div> 410 </div> 411 </div> 412 <div class="testimonials-ico-sec col-lg-4"> 413 <?php 414 $i = 1; 415 foreach ($settings["items2"] as $item) { 416 $item_title = $item["item_title"]; 417 ?> 418 <div class="icon-box "> 419 <div class="icon"><?php \Elementor\Icons_Manager::render_icon($item['icon'], ['aria-hidden' => 'true']); ?></div> 420 <h4><?php echo $item_title; ?></h4> 421 </div> 422 <?php 423 $i++; 424 } 425 ?> 426 </div> 427 </div> 428 </div> 429 </section> 430 <?php 431 } elseif ($layout_style == '2') { 432 $bg_image = $settings["bg_image"]["url"]; 433 ?> 434 <section class="testimonials-section-two pt-0" style="background-image: url(<?php echo $bg_image; ?>)"> 435 <div class="auto-container"> 436 <div class="sec-title text-center"> 437 <div class="sub-title text-center"><?php echo $sub_title; ?></div> 438 <h2><?php echo $title; ?></h2> 439 </div> 440 <div class="row"> 441 <div class="theme_carousel owl-theme owl-carousel" data-options='{"loop": true, "margin": 0, "autoheight":true, "lazyload":true, "nav": true, "dots": true, "autoplay": true, "autoplayTimeout": 6000, "smartSpeed": 1000, "responsive":{ "0" :{ "items": "1" }, "600" :{ "items" : "1" }, "768" :{ "items" : "2" } , "992":{ "items" : "2" }, "1200":{ "items" : "3" }}}'> 442 <?php 443 $i = 1; 444 foreach ($settings["items1"] as $item) { 445 $item_author_title = $item["item_author_title"]; 446 $item_designation = $item["item_designation"]; 447 $item_discription = $item["item_discription"]; 448 $item_author_image = ($item["item_author_image"]["id"] != "") ? wp_get_attachment_image_url($item["item_author_image"]["id"], "full") : $item["item_author_image"]["url"]; 449 $item_author_image_alt = get_post_meta($item["item_author_image"]["id"], "_wp_attachment_image_alt", true); 450 ?> 451 <div class="testimonial-block-two"> 452 <div class="inner-box"> 453 <div class="text"><?php echo $item_discription; ?></div> 454 <h4><?php echo $item_author_title; ?><span><?php echo $item_designation; ?></span></h4> 455 <div class="author-thumb"> 456 <?php 457 if (wp_http_validate_url($item_author_image)) { 458 ?> 459 <img src="<?php echo esc_url($item_author_image); ?>" alt="<?php esc_url($item_author_image_alt); ?>"> 460 <?php 461 } else { 462 echo $item_author_image; 463 } 464 ?> 465 </div> 466 </div> 467 </div> 468 <?php 469 $i++; 470 } 471 ?> 472 <!-- End --> 473 </div> 474 </div> 475 </div> 476 </section> 477 <?php 478 } 479 } 480 }