| 1 |
<?php |
| 2 |
namespace UiCoreElements\Utils; |
| 3 |
|
| 4 |
use Elementor\Controls_Manager; |
| 5 |
use Elementor\Plugin; |
| 6 |
use Elementor\Utils; |
| 7 |
use Elementor\Repeater; |
| 8 |
use Elementor\Icons_Manager; |
| 9 |
use Elementor\Group_Control_Image_Size; |
| 10 |
use Elementor\Group_Control_Box_Shadow; |
| 11 |
use Elementor\Group_Control_Border; |
| 12 |
use Elementor\Group_Control_Typography; |
| 13 |
use Elementor\Group_Control_Text_Shadow; |
| 14 |
use Elementor\Core\Kits\Documents\Tabs\Global_Colors; |
| 15 |
use UiCoreElements\Helper; |
| 16 |
|
| 17 |
|
| 18 |
defined('ABSPATH') || exit(); |
| 19 |
|
| 20 |
trait Testimonial_Trait { |
| 21 |
|
| 22 |
// Content Controls Functions |
| 23 |
function TRAIT_register_testimonial_repeater_controls($logo) |
| 24 |
{ |
| 25 |
$this->start_controls_section( |
| 26 |
'section_reviewer_content', |
| 27 |
[ |
| 28 |
'label' => __($logo, 'uicore-elements'), |
| 29 |
'tab' => Controls_Manager::TAB_CONTENT, |
| 30 |
] |
| 31 |
); |
| 32 |
|
| 33 |
$repeater = new Repeater(); |
| 34 |
|
| 35 |
$repeater->add_control( |
| 36 |
'avatar', |
| 37 |
[ |
| 38 |
'label' => __('Avatar', 'uicore-elements'), |
| 39 |
'type' => Controls_Manager::MEDIA, |
| 40 |
'render_type' => 'template', |
| 41 |
'dynamic' => [ |
| 42 |
'active' => true, |
| 43 |
], |
| 44 |
'default' => [ |
| 45 |
'url' => Utils::get_placeholder_image_src(), |
| 46 |
], |
| 47 |
] |
| 48 |
); |
| 49 |
$repeater->add_control( |
| 50 |
'reviewer_name', |
| 51 |
[ |
| 52 |
'label' => __('Name', 'uicore-elements'), |
| 53 |
'type' => Controls_Manager::TEXT, |
| 54 |
'dynamic' => [ |
| 55 |
'active' => true, |
| 56 |
], |
| 57 |
'default' => __('Adam Smith', 'uicore-elements'), |
| 58 |
'placeholder' => __('Enter reviewer name', 'uicore-elements'), |
| 59 |
'label_block' => true, |
| 60 |
] |
| 61 |
); |
| 62 |
$repeater->add_control( |
| 63 |
'reviewer_job_title', |
| 64 |
[ |
| 65 |
'label' => __('Job Title', 'uicore-elements'), |
| 66 |
'type' => Controls_Manager::TEXT, |
| 67 |
'dynamic' => [ |
| 68 |
'active' => true, |
| 69 |
], |
| 70 |
'default' => __('SEO Expert', 'uicore-elements'), |
| 71 |
'placeholder' => __('Enter reviewer job title', 'uicore-elements'), |
| 72 |
'label_block' => true, |
| 73 |
] |
| 74 |
); |
| 75 |
$repeater->add_control( |
| 76 |
'rating_number', |
| 77 |
[ |
| 78 |
'label' => __( 'Rating', 'uicore-elements' ), |
| 79 |
'type' => Controls_Manager::SLIDER, |
| 80 |
'size_units' => [ 'px' ], |
| 81 |
'default' => [ |
| 82 |
'size' => 4.5, |
| 83 |
], |
| 84 |
'range' => [ |
| 85 |
'px' => [ |
| 86 |
'min' => 0, |
| 87 |
'max' => 5, |
| 88 |
'step' => .5, |
| 89 |
], |
| 90 |
], |
| 91 |
'dynamic' => [ |
| 92 |
'active' => true, |
| 93 |
], |
| 94 |
] |
| 95 |
); |
| 96 |
$repeater->add_control( |
| 97 |
'review_text', |
| 98 |
[ |
| 99 |
'label' => __('Review Text', 'uicore-elements'), |
| 100 |
'type' => Controls_Manager::WYSIWYG, |
| 101 |
'dynamic' => [ |
| 102 |
'active' => true, |
| 103 |
], |
| 104 |
'default' => __('Click edit button to change this text. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.', 'uicore-elements'), |
| 105 |
'placeholder' => __('Enter review text', 'uicore-elements'), |
| 106 |
] |
| 107 |
); |
| 108 |
$repeater->add_control( |
| 109 |
'image', |
| 110 |
[ |
| 111 |
'label' => __('Secondary Image', 'uicore-elements'), |
| 112 |
'type' => Controls_Manager::MEDIA, |
| 113 |
'render_type' => 'template', |
| 114 |
'dynamic' => [ |
| 115 |
'active' => true, |
| 116 |
], |
| 117 |
'default' => [ |
| 118 |
'url' => Utils::get_placeholder_image_src(), |
| 119 |
], |
| 120 |
] |
| 121 |
); |
| 122 |
$this->add_control( |
| 123 |
'review_items', |
| 124 |
[ |
| 125 |
'show_label' => false, |
| 126 |
'type' => Controls_Manager::REPEATER, |
| 127 |
'fields' => $repeater->get_controls(), |
| 128 |
'title_field' => '{{{ reviewer_name }}}', |
| 129 |
'default' => [ |
| 130 |
[ |
| 131 |
'reviewer_name' => __( 'Adam', 'uicore-elements' ), |
| 132 |
'reviewer_job_title' => __( 'SEO Expert', 'uicore-elements' ), |
| 133 |
], |
| 134 |
[ |
| 135 |
'reviewer_name' => __( 'Karl', 'uicore-elements' ), |
| 136 |
'reviewer_job_title' => __( 'Designer', 'uicore-elements' ), |
| 137 |
], |
| 138 |
[ |
| 139 |
'reviewer_name' => __( 'Maria', 'uicore-elements' ), |
| 140 |
'reviewer_job_title' => __( 'Developer', 'uicore-elements' ), |
| 141 |
], |
| 142 |
[ |
| 143 |
'reviewer_name' => __( 'Michael', 'uicore-elements' ), |
| 144 |
'reviewer_job_title' => __( 'Manager', 'uicore-elements' ), |
| 145 |
], |
| 146 |
[ |
| 147 |
'reviewer_name' => __( 'Lena', 'uicore-elements' ), |
| 148 |
'reviewer_job_title' => __( 'CEO', 'uicore-elements' ), |
| 149 |
], |
| 150 |
[ |
| 151 |
'reviewer_name' => __( 'Jennifer', 'uicore-elements' ), |
| 152 |
'reviewer_job_title' => __( 'Consultant', 'uicore-elements' ), |
| 153 |
], |
| 154 |
] |
| 155 |
] |
| 156 |
); |
| 157 |
|
| 158 |
$this->end_controls_section(); |
| 159 |
} |
| 160 |
function TRAIT_register_testimonial_additional_controls() |
| 161 |
{ |
| 162 |
$this->add_control( |
| 163 |
'show_reviewer_name', |
| 164 |
[ |
| 165 |
'label' => __('Show Name', 'uicore-elements'), |
| 166 |
'type' => Controls_Manager::SWITCHER, |
| 167 |
'default' => 'yes', |
| 168 |
'separator' => 'before', |
| 169 |
] |
| 170 |
); |
| 171 |
$this->add_control( |
| 172 |
'review_name_tag', |
| 173 |
[ |
| 174 |
'label' => __('Name HTML Tag', 'uicore-elements'), |
| 175 |
'type' => Controls_Manager::SELECT, |
| 176 |
'default' => 'h4', |
| 177 |
'options' => Helper::get_title_tags(), |
| 178 |
'condition' => [ |
| 179 |
'show_reviewer_name' => 'yes', |
| 180 |
] |
| 181 |
] |
| 182 |
); |
| 183 |
$this->add_control( |
| 184 |
'show_reviewer_job_title', |
| 185 |
[ |
| 186 |
'label' => __('Show Job Title', 'uicore-elements'), |
| 187 |
'type' => Controls_Manager::SWITCHER, |
| 188 |
'default' => 'yes', |
| 189 |
'separator' => 'before', |
| 190 |
] |
| 191 |
); |
| 192 |
$this->add_control( |
| 193 |
'show_reviewer_rating', |
| 194 |
[ |
| 195 |
'label' => __('Show Rating', 'uicore-elements'), |
| 196 |
'type' => Controls_Manager::SWITCHER, |
| 197 |
'default' => 'yes', |
| 198 |
'separator' => 'before' |
| 199 |
] |
| 200 |
); |
| 201 |
$this->add_control( |
| 202 |
'rating_type', |
| 203 |
[ |
| 204 |
'label' => __( 'Rating Type', 'uicore-elements' ), |
| 205 |
'type' => Controls_Manager::SELECT, |
| 206 |
'default' => 'star', |
| 207 |
'options' => [ |
| 208 |
'star' => __( 'Star', 'uicore-elements' ), |
| 209 |
'number' => __( 'Number', 'uicore-elements' ), |
| 210 |
], |
| 211 |
'condition' => [ |
| 212 |
'show_reviewer_rating' => 'yes' |
| 213 |
] |
| 214 |
] |
| 215 |
); |
| 216 |
$this->add_control( |
| 217 |
'show_reviewer_text', |
| 218 |
[ |
| 219 |
'label' => __('Show Review Text', 'uicore-elements'), |
| 220 |
'type' => Controls_Manager::SWITCHER, |
| 221 |
'default' => 'yes', |
| 222 |
'separator' => 'before', |
| 223 |
] |
| 224 |
); |
| 225 |
$this->add_control( |
| 226 |
'show_reviewer_image', |
| 227 |
[ |
| 228 |
'label' => __('Show Image', 'uicore-elements'), |
| 229 |
'type' => Controls_Manager::SWITCHER, |
| 230 |
'default' => 'yes', |
| 231 |
'separator' => 'before', |
| 232 |
] |
| 233 |
); |
| 234 |
$this->add_group_control( |
| 235 |
Group_Control_Image_Size::get_type(), |
| 236 |
[ |
| 237 |
'name' => 'image_media_size', |
| 238 |
'default' => 'medium', |
| 239 |
'condition' => [ |
| 240 |
'show_reviewer_image' => 'yes' |
| 241 |
] |
| 242 |
] |
| 243 |
); |
| 244 |
$this->add_control( |
| 245 |
'show_reviewer_avatar', |
| 246 |
[ |
| 247 |
'label' => __('Show Avatar', 'uicore-elements'), |
| 248 |
'type' => Controls_Manager::SWITCHER, |
| 249 |
'default' => 'yes', |
| 250 |
'separator' => 'before', |
| 251 |
] |
| 252 |
); |
| 253 |
$this->add_group_control( |
| 254 |
Group_Control_Image_Size::get_type(), |
| 255 |
[ |
| 256 |
'name' => 'avatar_media_size', |
| 257 |
'default' => 'medium', |
| 258 |
'condition' => [ |
| 259 |
'show_reviewer_avatar' => 'yes' |
| 260 |
] |
| 261 |
] |
| 262 |
); |
| 263 |
$this->add_control( |
| 264 |
'image_inline', |
| 265 |
[ |
| 266 |
'label' => esc_html__('Image Inline', 'uicore-elements'), |
| 267 |
'type' => Controls_Manager::SWITCHER, |
| 268 |
'condition' => [ |
| 269 |
'show_reviewer_avatar' => 'yes' |
| 270 |
], |
| 271 |
'prefix_class' => 'ui-e-img-inline-', |
| 272 |
'render_type' => 'template', |
| 273 |
'condition' => [ |
| 274 |
'layout' => ['layout_1', 'layout_2', 'layout_3'], |
| 275 |
'show_reviewer_avatar' => 'yes' |
| 276 |
] |
| 277 |
] |
| 278 |
); |
| 279 |
$this->add_responsive_control( |
| 280 |
'v_alignment', |
| 281 |
[ |
| 282 |
'label' => __('Image Alignment', 'uicore-elements'), |
| 283 |
'type' => Controls_Manager::CHOOSE, |
| 284 |
'default' => 'flex-start', |
| 285 |
'toggle' => false, |
| 286 |
'options' => [ |
| 287 |
'flex-start' => [ |
| 288 |
'title' => __( 'Top', 'uicore-elements' ), |
| 289 |
'icon' => 'eicon-v-align-top', |
| 290 |
], |
| 291 |
'center' => [ |
| 292 |
'title' => __( 'Center', 'uicore-elements' ), |
| 293 |
'icon' => 'eicon-v-align-middle', |
| 294 |
], |
| 295 |
'flex-end' => [ |
| 296 |
'title' => __( 'Bottom', 'uicore-elements' ), |
| 297 |
'icon' => 'eicon-v-align-bottom', |
| 298 |
], |
| 299 |
], |
| 300 |
'selectors' => [ |
| 301 |
'{{WRAPPER}} .ui-e-item' => '--ui-e-img-alignment: {{VALUE}};', |
| 302 |
], |
| 303 |
'condition' => [ |
| 304 |
'layout' => 'layout_6' |
| 305 |
], |
| 306 |
] |
| 307 |
); |
| 308 |
$this->add_control( |
| 309 |
'show_reviewer_divider', |
| 310 |
[ |
| 311 |
'label' => __('Show Divider', 'uicore-elements'), |
| 312 |
'type' => Controls_Manager::SWITCHER, |
| 313 |
'default' => 'yes', |
| 314 |
'separator' => 'before', |
| 315 |
'condition' => [ |
| 316 |
'layout' => 'layout_3' |
| 317 |
] |
| 318 |
] |
| 319 |
); |
| 320 |
$this->add_responsive_control( |
| 321 |
'h_alignment', |
| 322 |
[ |
| 323 |
'label' => __('Content Alignment', 'uicore-elements'), |
| 324 |
'type' => Controls_Manager::CHOOSE, |
| 325 |
'options' => [ |
| 326 |
'left' => [ |
| 327 |
'title' => __('Left', 'uicore-elements'), |
| 328 |
'icon' => 'eicon-text-align-left', |
| 329 |
], |
| 330 |
'center' => [ |
| 331 |
'title' => __('Center', 'uicore-elements'), |
| 332 |
'icon' => 'eicon-text-align-center', |
| 333 |
], |
| 334 |
'right' => [ |
| 335 |
'title' => __('Right', 'uicore-elements'), |
| 336 |
'icon' => 'eicon-text-align-right', |
| 337 |
], |
| 338 |
'justify' => [ |
| 339 |
'title' => __('Justified', 'uicore-elements'), |
| 340 |
'icon' => 'eicon-text-align-justify', |
| 341 |
], |
| 342 |
], |
| 343 |
'prefix_class' => 'ui-e-h-align-', |
| 344 |
'selectors' => [ |
| 345 |
'{{WRAPPER}} .ui-e-item' => 'text-align: {{VALUE}};', |
| 346 |
], |
| 347 |
'separator' => 'before' |
| 348 |
] |
| 349 |
); |
| 350 |
$this->add_responsive_control( |
| 351 |
'content_v_alignment', |
| 352 |
[ |
| 353 |
'label' => __('Vertical Alignment', 'uicore-elements'), |
| 354 |
'type' => Controls_Manager::CHOOSE, |
| 355 |
'default' => 'center', |
| 356 |
'options' => [ |
| 357 |
'start' => [ |
| 358 |
'title' => __('Left', 'uicore-elements'), |
| 359 |
'icon' => 'eicon-align-start-v', |
| 360 |
], |
| 361 |
'center' => [ |
| 362 |
'title' => __('Center', 'uicore-elements'), |
| 363 |
'icon' => 'eicon-align-center-v', |
| 364 |
], |
| 365 |
'end' => [ |
| 366 |
'title' => __('Right', 'uicore-elements'), |
| 367 |
'icon' => 'eicon-align-end-v', |
| 368 |
], |
| 369 |
], |
| 370 |
'selectors' => [ |
| 371 |
'{{WRAPPER}} .ui-e-item' => '--ui-e-content-v-alignment: {{VALUE}};', |
| 372 |
] |
| 373 |
] |
| 374 |
); |
| 375 |
} |
| 376 |
|
| 377 |
// Style Controls Functions} |
| 378 |
function register_testimonial_image_controls() |
| 379 |
{ |
| 380 |
$this->start_controls_section( |
| 381 |
'section_style_avatar', |
| 382 |
[ |
| 383 |
'label' => __('Avatar', 'uicore-elements'), |
| 384 |
'tab' => Controls_Manager::TAB_STYLE, |
| 385 |
'condition' => [ |
| 386 |
'show_reviewer_avatar' => 'yes' |
| 387 |
] |
| 388 |
] |
| 389 |
); |
| 390 |
|
| 391 |
$this->add_group_control( |
| 392 |
Group_Control_Border::get_type(), |
| 393 |
[ |
| 394 |
'name' => 'avatar_border', |
| 395 |
'selector' => '{{WRAPPER}} .ui-e-testimonial-avatar img' |
| 396 |
] |
| 397 |
); |
| 398 |
$this->add_control( |
| 399 |
'avatar_radius', |
| 400 |
[ |
| 401 |
'label' => esc_html__('Border Radius', 'uicore-elements'), |
| 402 |
'type' => Controls_Manager::DIMENSIONS, |
| 403 |
'size_units' => ['px', 'em', '%'], |
| 404 |
'selectors' => [ |
| 405 |
'{{WRAPPER}} .ui-e-testimonial-avatar img' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 406 |
], |
| 407 |
] |
| 408 |
); |
| 409 |
$this->add_control( |
| 410 |
'avatar_padding', |
| 411 |
[ |
| 412 |
'label' => __('Padding', 'uicore-elements'), |
| 413 |
'type' => Controls_Manager::DIMENSIONS, |
| 414 |
'size_units' => ['px', 'em', '%'], |
| 415 |
'selectors' => [ |
| 416 |
'{{WRAPPER}} .ui-e-testimonial-avatar img' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 417 |
], |
| 418 |
] |
| 419 |
); |
| 420 |
$this->add_responsive_control( |
| 421 |
'avatar_size', |
| 422 |
[ |
| 423 |
'label' => __('Size', 'uicore-elements'), |
| 424 |
'type' => Controls_Manager::SLIDER, |
| 425 |
'default' => [ |
| 426 |
'size' => 40, |
| 427 |
'unit' => '%' |
| 428 |
], |
| 429 |
'range' => [ |
| 430 |
'%' => [ |
| 431 |
'min' => 1, |
| 432 |
'max' => 100, |
| 433 |
], |
| 434 |
], |
| 435 |
'selectors' => [ |
| 436 |
'{{WRAPPER}}' => '--ui-e-avatar-size: {{SIZE}}%;', |
| 437 |
], |
| 438 |
'condition' => [ |
| 439 |
'layout!' => 'layout_5', |
| 440 |
] |
| 441 |
] |
| 442 |
); |
| 443 |
$this->add_control( |
| 444 |
'avatar_size_px', |
| 445 |
[ |
| 446 |
'label' => __('Size', 'uicore-elements'), |
| 447 |
'type' => Controls_Manager::SLIDER, |
| 448 |
'default' => [ |
| 449 |
'size' => 80, |
| 450 |
'unit' => 'px' |
| 451 |
], |
| 452 |
'range' => [ |
| 453 |
'px' => [ |
| 454 |
'min' => 1, |
| 455 |
'max' => 250, |
| 456 |
], |
| 457 |
], |
| 458 |
'selectors' => [ |
| 459 |
'{{WRAPPER}}' => '--ui-e-avatar-size: {{SIZE}}{{UNIT}};', |
| 460 |
], |
| 461 |
'condition' => [ |
| 462 |
'layout' => 'layout_5', |
| 463 |
] |
| 464 |
] |
| 465 |
); |
| 466 |
$this->add_control( |
| 467 |
'avatar_spacing', |
| 468 |
[ |
| 469 |
'label' => __('Spacing', 'uicore-elements'), |
| 470 |
'type' => Controls_Manager::SLIDER, |
| 471 |
'default' => [ |
| 472 |
'size' => 15, |
| 473 |
], |
| 474 |
'selectors' => [ |
| 475 |
'{{WRAPPER}}' => '--ui-e-avatar-spacing: {{SIZE}}{{UNIT}}' |
| 476 |
], |
| 477 |
] |
| 478 |
); |
| 479 |
$this->add_group_control( |
| 480 |
Group_Control_Box_Shadow::get_type(), |
| 481 |
[ |
| 482 |
'name' => 'avatar_shadow', |
| 483 |
'selector' => '{{WRAPPER}} .ui-e-testimonial-avatar img' |
| 484 |
] |
| 485 |
); |
| 486 |
$this->add_control( |
| 487 |
'avatar_offset_toggle', |
| 488 |
[ |
| 489 |
'label' => __('Offset', 'uicore-elements'), |
| 490 |
'type' => Controls_Manager::POPOVER_TOGGLE, |
| 491 |
'label_off' => __('None', 'uicore-elements'), |
| 492 |
'label_on' => __('Custom', 'uicore-elements'), |
| 493 |
'return_value' => 'yes', |
| 494 |
] |
| 495 |
); |
| 496 |
$this->start_popover(); |
| 497 |
|
| 498 |
$this->add_responsive_control( |
| 499 |
'avatar_horizontal_offset', |
| 500 |
[ |
| 501 |
'label' => __('Horizontal', 'uicore-elements'), |
| 502 |
'type' => Controls_Manager::SLIDER, |
| 503 |
'default' => [ |
| 504 |
'size' => 0, |
| 505 |
], |
| 506 |
'tablet_default' => [ |
| 507 |
'size' => 0, |
| 508 |
], |
| 509 |
'mobile_default' => [ |
| 510 |
'size' => 0, |
| 511 |
], |
| 512 |
'range' => [ |
| 513 |
'px' => [ |
| 514 |
'min' => -200, |
| 515 |
'max' => 200, |
| 516 |
], |
| 517 |
], |
| 518 |
'condition' => [ |
| 519 |
'avatar_offset_toggle' => 'yes' |
| 520 |
], |
| 521 |
'render_type' => 'ui', |
| 522 |
'selectors' => [ |
| 523 |
'{{WRAPPER}}' => '--ui-e-avatar-h-offset: {{SIZE}}px;' |
| 524 |
], |
| 525 |
] |
| 526 |
); |
| 527 |
$this->add_responsive_control( |
| 528 |
'avatar_vertical_offset', |
| 529 |
[ |
| 530 |
'label' => __('Vertical', 'uicore-elements'), |
| 531 |
'type' => Controls_Manager::SLIDER, |
| 532 |
'default' => [ |
| 533 |
'size' => 0, |
| 534 |
], |
| 535 |
'tablet_default' => [ |
| 536 |
'size' => 0, |
| 537 |
], |
| 538 |
'mobile_default' => [ |
| 539 |
'size' => 0, |
| 540 |
], |
| 541 |
'range' => [ |
| 542 |
'px' => [ |
| 543 |
'min' => -200, |
| 544 |
'max' => 200, |
| 545 |
], |
| 546 |
], |
| 547 |
'condition' => [ |
| 548 |
'avatar_offset_toggle' => 'yes' |
| 549 |
], |
| 550 |
'render_type' => 'ui', |
| 551 |
'selectors' => [ |
| 552 |
'{{WRAPPER}}' => '--ui-e-avatar-v-offset: {{SIZE}}px;' |
| 553 |
], |
| 554 |
] |
| 555 |
); |
| 556 |
$this->end_popover(); |
| 557 |
|
| 558 |
$this->end_controls_section(); |
| 559 |
$this->start_controls_section( |
| 560 |
'section_style_image', |
| 561 |
[ |
| 562 |
'label' => __('Secondary Image', 'uicore-elements'), |
| 563 |
'tab' => Controls_Manager::TAB_STYLE, |
| 564 |
'condition' => [ |
| 565 |
'show_reviewer_image' => 'yes' |
| 566 |
] |
| 567 |
] |
| 568 |
); |
| 569 |
$this->add_control( |
| 570 |
'image_size', |
| 571 |
[ |
| 572 |
'label' => __('Size', 'uicore-elements'), |
| 573 |
'type' => Controls_Manager::SLIDER, |
| 574 |
'default' => [ |
| 575 |
'size' => 40, |
| 576 |
'unit' => 'px' |
| 577 |
], |
| 578 |
'range' => [ |
| 579 |
'px' => [ |
| 580 |
'min' => 10, |
| 581 |
'max' => 500, |
| 582 |
], |
| 583 |
], |
| 584 |
'selectors' => [ |
| 585 |
'{{WRAPPER}}' => '--ui-e-image-size: {{SIZE}}{{UNIT}};', |
| 586 |
], |
| 587 |
] |
| 588 |
); |
| 589 |
$this->add_control( |
| 590 |
'image_spacing', |
| 591 |
[ |
| 592 |
'label' => __('Spacing', 'uicore-elements'), |
| 593 |
'type' => Controls_Manager::SLIDER, |
| 594 |
'default' => [ |
| 595 |
'size' => 15, |
| 596 |
], |
| 597 |
'selectors' => [ |
| 598 |
'{{WRAPPER}}' => '--ui-e-img-spacing: {{SIZE}}{{UNIT}}' |
| 599 |
], |
| 600 |
'condition' => [ |
| 601 |
'layout!' => ['layout_2', 'layout_4', 'layout_6'], |
| 602 |
] |
| 603 |
] |
| 604 |
); |
| 605 |
$this->add_control( |
| 606 |
'image_offset_toggle', |
| 607 |
[ |
| 608 |
'label' => __('Offset', 'uicore-elements'), |
| 609 |
'type' => Controls_Manager::POPOVER_TOGGLE, |
| 610 |
'label_off' => __('None', 'uicore-elements'), |
| 611 |
'label_on' => __('Custom', 'uicore-elements'), |
| 612 |
'return_value' => 'yes', |
| 613 |
] |
| 614 |
); |
| 615 |
$this->start_popover(); |
| 616 |
|
| 617 |
$this->add_responsive_control( |
| 618 |
'image_horizontal_offset', |
| 619 |
[ |
| 620 |
'label' => __('Horizontal', 'uicore-elements'), |
| 621 |
'type' => Controls_Manager::SLIDER, |
| 622 |
'default' => [ |
| 623 |
'size' => 0, |
| 624 |
], |
| 625 |
'tablet_default' => [ |
| 626 |
'size' => 0, |
| 627 |
], |
| 628 |
'mobile_default' => [ |
| 629 |
'size' => 0, |
| 630 |
], |
| 631 |
'range' => [ |
| 632 |
'px' => [ |
| 633 |
'min' => -200, |
| 634 |
'max' => 200, |
| 635 |
], |
| 636 |
], |
| 637 |
'condition' => [ |
| 638 |
'image_offset_toggle' => 'yes' |
| 639 |
], |
| 640 |
'render_type' => 'ui', |
| 641 |
'selectors' => [ |
| 642 |
'{{WRAPPER}}' => '--ui-e-img-h-offset: {{SIZE}}px;' |
| 643 |
], |
| 644 |
] |
| 645 |
); |
| 646 |
$this->add_responsive_control( |
| 647 |
'image_vertical_offset', |
| 648 |
[ |
| 649 |
'label' => __('Vertical', 'uicore-elements'), |
| 650 |
'type' => Controls_Manager::SLIDER, |
| 651 |
'default' => [ |
| 652 |
'size' => 0, |
| 653 |
], |
| 654 |
'tablet_default' => [ |
| 655 |
'size' => 0, |
| 656 |
], |
| 657 |
'mobile_default' => [ |
| 658 |
'size' => 0, |
| 659 |
], |
| 660 |
'range' => [ |
| 661 |
'px' => [ |
| 662 |
'min' => -200, |
| 663 |
'max' => 200, |
| 664 |
], |
| 665 |
], |
| 666 |
'condition' => [ |
| 667 |
'image_offset_toggle' => 'yes' |
| 668 |
], |
| 669 |
'render_type' => 'ui', |
| 670 |
'selectors' => [ |
| 671 |
'{{WRAPPER}}' => '--ui-e-img-v-offset: {{SIZE}}px;' |
| 672 |
], |
| 673 |
] |
| 674 |
); |
| 675 |
$this->end_popover(); |
| 676 |
$this->end_controls_section(); |
| 677 |
} |
| 678 |
function register_testimonial_name_controls() |
| 679 |
{ |
| 680 |
$this->start_controls_section( |
| 681 |
'section_style_name', |
| 682 |
[ |
| 683 |
'label' => __('Name', 'uicore-elements'), |
| 684 |
'tab' => Controls_Manager::TAB_STYLE, |
| 685 |
'condition' => [ |
| 686 |
'show_reviewer_name' => 'yes', |
| 687 |
] |
| 688 |
] |
| 689 |
); |
| 690 |
|
| 691 |
$this->add_control( |
| 692 |
'name_color', |
| 693 |
[ |
| 694 |
'label' => __('Color', 'uicore-elements'), |
| 695 |
'type' => Controls_Manager::COLOR, |
| 696 |
'selectors' => [ |
| 697 |
'{{WRAPPER}} .ui-e-testimonial-name' => 'color: {{VALUE}};', |
| 698 |
], |
| 699 |
] |
| 700 |
); |
| 701 |
$this->add_control( |
| 702 |
'name_hover_color', |
| 703 |
[ |
| 704 |
'label' => __('Hover Color', 'uicore-elements'), |
| 705 |
'type' => Controls_Manager::COLOR, |
| 706 |
'selectors' => [ |
| 707 |
'{{WRAPPER}} .ui-e-item:hover .ui-e-testimonial-name' => 'color: {{VALUE}};', |
| 708 |
], |
| 709 |
] |
| 710 |
); |
| 711 |
$this->add_control( |
| 712 |
'name_bottom_space', |
| 713 |
[ |
| 714 |
'label' => __('Spacing', 'uicore-elements'), |
| 715 |
'type' => Controls_Manager::SLIDER, |
| 716 |
'range' => [ |
| 717 |
'px' => [ |
| 718 |
'min' => 0, |
| 719 |
'max' => 100, |
| 720 |
], |
| 721 |
], |
| 722 |
'selectors' => [ |
| 723 |
'{{WRAPPER}} .ui-e-testimonial-name' => 'padding-bottom: {{SIZE}}{{UNIT}};', |
| 724 |
], |
| 725 |
] |
| 726 |
); |
| 727 |
$this->add_group_control( |
| 728 |
Group_Control_Typography::get_type(), |
| 729 |
[ |
| 730 |
'name' => 'name_typography', |
| 731 |
'selector' => '{{WRAPPER}} .ui-e-testimonial-name', |
| 732 |
] |
| 733 |
); |
| 734 |
$this->add_group_control( |
| 735 |
Group_Control_Text_Shadow::get_type(), |
| 736 |
[ |
| 737 |
'name' => 'name_shadow', |
| 738 |
'label' => __( 'Text Shadow', 'uicore-elements' ), |
| 739 |
'selector' => '{{WRAPPER}} .ui-e-testimonial-name', |
| 740 |
] |
| 741 |
); |
| 742 |
|
| 743 |
$this->end_controls_section(); |
| 744 |
} |
| 745 |
function register_testimonial_job_controls() |
| 746 |
{ |
| 747 |
$this->start_controls_section( |
| 748 |
'section_style_job_title', |
| 749 |
[ |
| 750 |
'label' => __('Job Title', 'uicore-elements'), |
| 751 |
'tab' => Controls_Manager::TAB_STYLE, |
| 752 |
'condition' => [ |
| 753 |
'show_reviewer_job_title' => 'yes', |
| 754 |
] |
| 755 |
] |
| 756 |
); |
| 757 |
|
| 758 |
$this->add_control( |
| 759 |
'job_title_color', |
| 760 |
[ |
| 761 |
'label' => __('Color', 'uicore-elements'), |
| 762 |
'type' => Controls_Manager::COLOR, |
| 763 |
'selectors' => [ |
| 764 |
'{{WRAPPER}} .ui-e-testimonial-job-title' => 'color: {{VALUE}};', |
| 765 |
], |
| 766 |
] |
| 767 |
); |
| 768 |
$this->add_control( |
| 769 |
'job_title_hover_color', |
| 770 |
[ |
| 771 |
'label' => __('Hover Color', 'uicore-elements'), |
| 772 |
'type' => Controls_Manager::COLOR, |
| 773 |
'selectors' => [ |
| 774 |
'{{WRAPPER}} .ui-e-item:hover .ui-e-testimonial-job-title' => 'color: {{VALUE}};', |
| 775 |
], |
| 776 |
] |
| 777 |
); |
| 778 |
$this->add_control( |
| 779 |
'job_title_bottom_space', |
| 780 |
[ |
| 781 |
'label' => __('Spacing', 'uicore-elements'), |
| 782 |
'type' => Controls_Manager::SLIDER, |
| 783 |
'range' => [ |
| 784 |
'px' => [ |
| 785 |
'min' => 0, |
| 786 |
'max' => 100, |
| 787 |
], |
| 788 |
], |
| 789 |
'default' => [ |
| 790 |
'size' => 10, |
| 791 |
'unit' => 'px' |
| 792 |
], |
| 793 |
'selectors' => [ |
| 794 |
'{{WRAPPER}} .ui-e-testimonial-job-title' => 'padding-bottom: {{SIZE}}{{UNIT}};', |
| 795 |
], |
| 796 |
] |
| 797 |
); |
| 798 |
$this->add_group_control( |
| 799 |
Group_Control_Typography::get_type(), |
| 800 |
[ |
| 801 |
'name' => 'job_title_typography', |
| 802 |
'selector' => '{{WRAPPER}} .ui-e-testimonial-job-title', |
| 803 |
] |
| 804 |
); |
| 805 |
|
| 806 |
$this->end_controls_section(); |
| 807 |
} |
| 808 |
function register_testimonial_text_controls() |
| 809 |
{ |
| 810 |
$this->start_controls_section( |
| 811 |
'section_style_text', |
| 812 |
[ |
| 813 |
'label' => __('Text', 'uicore-elements'), |
| 814 |
'tab' => Controls_Manager::TAB_STYLE, |
| 815 |
'condition' => [ |
| 816 |
'show_reviewer_text' => 'yes', |
| 817 |
] |
| 818 |
] |
| 819 |
); |
| 820 |
|
| 821 |
$this->add_control( |
| 822 |
'text_color', |
| 823 |
[ |
| 824 |
'label' => __('Color', 'uicore-elements'), |
| 825 |
'type' => Controls_Manager::COLOR, |
| 826 |
'selectors' => [ |
| 827 |
'{{WRAPPER}} .ui-e-testimonial-text' => 'color: {{VALUE}};', |
| 828 |
], |
| 829 |
] |
| 830 |
); |
| 831 |
$this->add_control( |
| 832 |
'text_hover_color', |
| 833 |
[ |
| 834 |
'label' => __('Hover Color', 'uicore-elements'), |
| 835 |
'type' => Controls_Manager::COLOR, |
| 836 |
'selectors' => [ |
| 837 |
'{{WRAPPER}} .ui-e-item:hover .ui-e-testimonial-text' => 'color: {{VALUE}};', |
| 838 |
], |
| 839 |
] |
| 840 |
); |
| 841 |
$this->add_group_control( |
| 842 |
Group_Control_Typography::get_type(), |
| 843 |
[ |
| 844 |
'name' => 'text_typography', |
| 845 |
'selector' => '{{WRAPPER}} .ui-e-testimonial-text', |
| 846 |
] |
| 847 |
); |
| 848 |
$this->add_control( |
| 849 |
'text_bottom_space', |
| 850 |
[ |
| 851 |
'label' => __('Spacing', 'uicore-elements'), |
| 852 |
'type' => Controls_Manager::SLIDER, |
| 853 |
'range' => [ |
| 854 |
'px' => [ |
| 855 |
'min' => 0, |
| 856 |
'max' => 100, |
| 857 |
], |
| 858 |
], |
| 859 |
'default' => [ |
| 860 |
'size' => 15, |
| 861 |
'unit' => 'px' |
| 862 |
], |
| 863 |
'selectors' => [ |
| 864 |
'{{WRAPPER}} .ui-e-testimonial-text' => 'padding-bottom: {{SIZE}}{{UNIT}};', |
| 865 |
], |
| 866 |
] |
| 867 |
); |
| 868 |
|
| 869 |
$this->end_controls_section(); |
| 870 |
} |
| 871 |
function register_testimonial_rating_controls() |
| 872 |
{ |
| 873 |
$this->start_controls_section( |
| 874 |
'section_style_rating', |
| 875 |
[ |
| 876 |
'label' => esc_html__('Rating', 'uicore-elements'), |
| 877 |
'tab' => Controls_Manager::TAB_STYLE, |
| 878 |
'condition' => [ |
| 879 |
'show_reviewer_rating' => 'yes', |
| 880 |
], |
| 881 |
] |
| 882 |
); |
| 883 |
|
| 884 |
// If SVG inline, we only need one color control because the semi-star bg color hack is not enabled with this experiment |
| 885 |
if(Plugin::$instance->experiments->is_feature_active('e_font_icon_svg')) { |
| 886 |
$this->add_control( |
| 887 |
'active_rating_color', |
| 888 |
[ |
| 889 |
'label' => esc_html__('Color', 'uicore-elements'), |
| 890 |
'type' => Controls_Manager::COLOR, |
| 891 |
'default' => '#ffab1a', |
| 892 |
'selectors' => [ |
| 893 |
'{{WRAPPER}} .ui-e-testimonial-rating svg' => 'fill: {{VALUE}};', |
| 894 |
], |
| 895 |
'condition' => [ |
| 896 |
'rating_type' => 'star', |
| 897 |
], |
| 898 |
] |
| 899 |
); |
| 900 |
// Without the experiment, two colors are usefull because <i> elements can be cut and printed as decimal-stars |
| 901 |
} else { |
| 902 |
$this->add_control( |
| 903 |
'active_rating_color', |
| 904 |
[ |
| 905 |
'label' => esc_html__('Active Color', 'uicore-elements'), |
| 906 |
'type' => Controls_Manager::COLOR, |
| 907 |
'default' => '#ffab1a', |
| 908 |
'selectors' => [ |
| 909 |
'{{WRAPPER}} .ui-e-testimonial-rating .ui-e-marked i' => 'color: {{VALUE}};', |
| 910 |
], |
| 911 |
'condition' => [ |
| 912 |
'rating_type' => 'star', |
| 913 |
], |
| 914 |
] |
| 915 |
); |
| 916 |
$this->add_control( |
| 917 |
'rating_color', |
| 918 |
[ |
| 919 |
'label' => esc_html__('Color', 'uicore-elements'), |
| 920 |
'type' => Controls_Manager::COLOR, |
| 921 |
'default' => '#ccd6df', |
| 922 |
'selectors' => [ |
| 923 |
'{{WRAPPER}} .ui-e-testimonial-rating .ui-e-unmarked i' => 'color: {{VALUE}};', |
| 924 |
], |
| 925 |
'condition' => [ |
| 926 |
'rating_type' => 'star', |
| 927 |
], |
| 928 |
] |
| 929 |
); |
| 930 |
} |
| 931 |
$this->add_control( |
| 932 |
'rating_number_color', |
| 933 |
[ |
| 934 |
'label' => esc_html__('Color', 'uicore-elements'), |
| 935 |
'type' => Controls_Manager::COLOR, |
| 936 |
'selectors' => [ |
| 937 |
'{{WRAPPER}} .ui-e-testimonial-rating' => 'color: {{VALUE}};', |
| 938 |
], |
| 939 |
'condition' => [ |
| 940 |
'rating_type' => 'number', |
| 941 |
], |
| 942 |
] |
| 943 |
); |
| 944 |
$this->add_control( |
| 945 |
'rating_background', |
| 946 |
[ |
| 947 |
'label' => __( 'Background Color', 'uicore-elements' ), |
| 948 |
'type' => Controls_Manager::COLOR, |
| 949 |
'selectors' => [ |
| 950 |
'{{WRAPPER}} .ui-e-testimonial-rating' => 'background-color: {{VALUE}};', |
| 951 |
], |
| 952 |
'condition' => [ |
| 953 |
'rating_type' => 'star', |
| 954 |
], |
| 955 |
] |
| 956 |
); |
| 957 |
$this->add_control( |
| 958 |
'rating_number_background', |
| 959 |
[ |
| 960 |
'label' => __( 'Background Color', 'uicore-elements' ), |
| 961 |
'type' => Controls_Manager::COLOR, |
| 962 |
'selectors' => [ |
| 963 |
'{{WRAPPER}} .ui-e-testimonial-rating' => 'background-color: {{VALUE}};', |
| 964 |
], |
| 965 |
'global' => [ |
| 966 |
'default' => Global_Colors::COLOR_PRIMARY, |
| 967 |
], |
| 968 |
'condition' => [ |
| 969 |
'rating_type' => 'number', |
| 970 |
], |
| 971 |
] |
| 972 |
); |
| 973 |
|
| 974 |
$this->add_group_control( |
| 975 |
Group_Control_Border::get_type(), |
| 976 |
[ |
| 977 |
'name' => 'rating_border', |
| 978 |
'selector' => '{{WRAPPER}} .ui-e-testimonial-rating', |
| 979 |
] |
| 980 |
); |
| 981 |
$this->add_control( |
| 982 |
'rating_border_radius', |
| 983 |
[ |
| 984 |
'label' => __( 'Border Radius', 'uicore-elements' ), |
| 985 |
'type' => Controls_Manager::DIMENSIONS, |
| 986 |
'size_units' => [ 'px', 'em', '%' ], |
| 987 |
'selectors' => [ |
| 988 |
'{{WRAPPER}} .ui-e-testimonial-rating' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 989 |
], |
| 990 |
] |
| 991 |
); |
| 992 |
$this->add_control( |
| 993 |
'rating_padding', |
| 994 |
[ |
| 995 |
'label' => esc_html__('Padding', 'uicore-elements'), |
| 996 |
'type' => Controls_Manager::DIMENSIONS, |
| 997 |
'size_units' => ['px', 'em', '%'], |
| 998 |
'selectors' => [ |
| 999 |
'{{WRAPPER}} .ui-e-testimonial-rating' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 1000 |
], |
| 1001 |
] |
| 1002 |
); |
| 1003 |
$this->add_control( |
| 1004 |
'rating_margin', |
| 1005 |
[ |
| 1006 |
'label' => esc_html__('Margin', 'uicore-elements'), |
| 1007 |
'type' => Controls_Manager::DIMENSIONS, |
| 1008 |
'size_units' => ['px', '%'], |
| 1009 |
'selectors' => [ |
| 1010 |
'{{WRAPPER}} .ui-e-testimonial-rating' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 1011 |
], |
| 1012 |
] |
| 1013 |
); |
| 1014 |
$this->add_control( |
| 1015 |
'rating_size', |
| 1016 |
[ |
| 1017 |
'label' => esc_html__('Size', 'uicore-elements'), |
| 1018 |
'type' => Controls_Manager::SLIDER, |
| 1019 |
'default' => [ |
| 1020 |
'size' => 14, |
| 1021 |
'unit' => 'px' |
| 1022 |
], |
| 1023 |
'selectors' => [ |
| 1024 |
'{{WRAPPER}} .ui-e-testimonial-rating' => 'font-size: {{SIZE}}{{UNIT}};', |
| 1025 |
'{{WRAPPER}} .ui-e-testimonial-rating svg' => 'width: {{SIZE}}{{UNIT}};', |
| 1026 |
], |
| 1027 |
] |
| 1028 |
); |
| 1029 |
$this->add_control( |
| 1030 |
'rating_space_between', |
| 1031 |
[ |
| 1032 |
'label' => esc_html__('Space Between', 'uicore-elements'), |
| 1033 |
'type' => Controls_Manager::SLIDER, |
| 1034 |
'range' => [ |
| 1035 |
'px' => [ |
| 1036 |
'min' => 0, |
| 1037 |
'max' => 10, |
| 1038 |
], |
| 1039 |
], |
| 1040 |
'selectors' => [ |
| 1041 |
'{{WRAPPER}} .ui-e-testimonial-rating .ui-e-icon + .ui-e-icon' => 'margin-left: {{SIZE}}{{UNIT}};', // star type |
| 1042 |
'{{WRAPPER}} .ui-e-testimonial-rating span' => 'margin-right: {{SIZE}}{{UNIT}};', // number type |
| 1043 |
], |
| 1044 |
'condition' => [ |
| 1045 |
'rating_type' => 'star', |
| 1046 |
], |
| 1047 |
] |
| 1048 |
); |
| 1049 |
|
| 1050 |
$this->end_controls_section(); |
| 1051 |
} |
| 1052 |
function register_testimonial_divider_controls() |
| 1053 |
{ |
| 1054 |
$this->start_controls_section( |
| 1055 |
'section_style_divider', |
| 1056 |
[ |
| 1057 |
'label' => __('Divider', 'uicore-elements'), |
| 1058 |
'tab' => Controls_Manager::TAB_STYLE, |
| 1059 |
'condition' => [ |
| 1060 |
'layout' => 'layout_3', |
| 1061 |
'show_reviewer_divider' => 'yes' |
| 1062 |
] |
| 1063 |
] |
| 1064 |
); |
| 1065 |
|
| 1066 |
$this->add_control( |
| 1067 |
'divider_color', |
| 1068 |
[ |
| 1069 |
'label' => __('Color', 'uicore-elements'), |
| 1070 |
'type' => Controls_Manager::COLOR, |
| 1071 |
'selectors' => [ |
| 1072 |
'{{WRAPPER}} .ui-e-testimonial-divider' => 'border-color: {{VALUE}};', |
| 1073 |
], |
| 1074 |
] |
| 1075 |
); |
| 1076 |
$this->add_control( |
| 1077 |
'divider_spacing', |
| 1078 |
[ |
| 1079 |
'label' => __('Spacing', 'uicore-elements'), |
| 1080 |
'type' => Controls_Manager::SLIDER, |
| 1081 |
'default' => [ |
| 1082 |
'size' => 20, |
| 1083 |
'unit' => 'px' |
| 1084 |
], |
| 1085 |
'selectors' => [ |
| 1086 |
'{{WRAPPER}} .ui-e-testimonial-divider' => 'margin-bottom: {{SIZE}}{{UNIT}};', |
| 1087 |
], |
| 1088 |
] |
| 1089 |
); |
| 1090 |
|
| 1091 |
$this->end_controls_section(); |
| 1092 |
} |
| 1093 |
|
| 1094 |
// Register all Style Controls at once but Cards Controls since different widgets may/may not require an 'active' state |
| 1095 |
function TRAIT_register_style_controls() |
| 1096 |
{ |
| 1097 |
$this->register_testimonial_image_controls(); |
| 1098 |
$this->register_testimonial_name_controls(); |
| 1099 |
$this->register_testimonial_job_controls(); |
| 1100 |
$this->register_testimonial_text_controls(); |
| 1101 |
$this->register_testimonial_rating_controls(); |
| 1102 |
$this->register_testimonial_divider_controls(); |
| 1103 |
} |
| 1104 |
// Register all Animation Controls at once |
| 1105 |
function TRAIT_register_testimonial_animation_controls() |
| 1106 |
{ |
| 1107 |
$this->TRAIT_register_entrance_animations_controls(); // animate each item |
| 1108 |
// Hover Animations -- IMPORTANT: any new animation added here must also be added on condition list to the animation wrapper at TRAIT_render_review_item() |
| 1109 |
$this->TRAIT_register_hover_animation_control( |
| 1110 |
'Item Hover Animation', |
| 1111 |
[], |
| 1112 |
['underline'] |
| 1113 |
); |
| 1114 |
$this->TRAIT_register_hover_animation_control( |
| 1115 |
'Image Animations', |
| 1116 |
['show_reviewer_image' => 'yes'], |
| 1117 |
['underline'] |
| 1118 |
); |
| 1119 |
$this->TRAIT_register_hover_animation_control( |
| 1120 |
'Avatar Animations', |
| 1121 |
['show_reviewer_avatar' => 'yes'], |
| 1122 |
['underline'] |
| 1123 |
); |
| 1124 |
$this->TRAIT_register_hover_animation_control( |
| 1125 |
'Text Animations', |
| 1126 |
['show_reviewer_text' => 'yes'], |
| 1127 |
['zoom', 'underline'] |
| 1128 |
); |
| 1129 |
$this->TRAIT_register_hover_animation_control( |
| 1130 |
'Name Animations', |
| 1131 |
['show_reviewer_name' => 'yes'], |
| 1132 |
['zoom'] |
| 1133 |
); |
| 1134 |
$this->TRAIT_register_hover_animation_control( |
| 1135 |
'Job Animations', |
| 1136 |
['show_reviewer_job_title' => 'yes'], |
| 1137 |
['zoom'] |
| 1138 |
); |
| 1139 |
$this->TRAIT_register_hover_animation_control( |
| 1140 |
'Rating Animations', |
| 1141 |
['show_reviewer_rating' => 'yes'], |
| 1142 |
['underline'] |
| 1143 |
); |
| 1144 |
} |
| 1145 |
// Register specific Controls that can't be called in blocks because are positioned differently on widgets, or used only by specific testimonial types, such as grid or carousel |
| 1146 |
function TRAIT_register_specific_testimonial_controls($arg) |
| 1147 |
{ |
| 1148 |
|
| 1149 |
switch ($arg){ |
| 1150 |
case 'layout' : |
| 1151 |
$this->add_control( |
| 1152 |
'layout', |
| 1153 |
[ |
| 1154 |
'label' => esc_html__( 'Layout', 'uicore-elements' ), |
| 1155 |
'type' => Controls_Manager::SELECT, |
| 1156 |
'default' => 'layout_1', |
| 1157 |
'options' => [ |
| 1158 |
'layout_1' => esc_html__( 'Layout 1', 'uicore-elements' ), |
| 1159 |
'layout_2' => esc_html__( 'Layout 2', 'uicore-elements' ), |
| 1160 |
'layout_3' => esc_html__( 'Layout 3', 'uicore-elements' ), |
| 1161 |
'layout_4' => esc_html__( 'Layout 4', 'uicore-elements' ), |
| 1162 |
'layout_5' => esc_html__( 'Layout 5', 'uicore-elements' ), |
| 1163 |
'layout_6' => esc_html__( 'Layout 6', 'uicore-elements' ), |
| 1164 |
], |
| 1165 |
'render_type' => 'template', |
| 1166 |
'prefix_class' => 'ui-e-', |
| 1167 |
'frontend_available' => true |
| 1168 |
] |
| 1169 |
); |
| 1170 |
break; |
| 1171 |
|
| 1172 |
case 'item_animations' : |
| 1173 |
$this->add_control( |
| 1174 |
'item_hover_animation', |
| 1175 |
[ |
| 1176 |
'label' => esc_html__( 'Item Hover Animation', 'uicore-elements' ), |
| 1177 |
'type' => Controls_Manager::SELECT, |
| 1178 |
'default' => '', |
| 1179 |
'label_block' => true, |
| 1180 |
'options' => $this->get_animations(), |
| 1181 |
] |
| 1182 |
); |
| 1183 |
break; |
| 1184 |
} |
| 1185 |
|
| 1186 |
} |
| 1187 |
|
| 1188 |
// HTML Rendering Functions |
| 1189 |
function render_reviewer_avatar($item) |
| 1190 |
{ |
| 1191 |
$settings = $this->get_settings_for_display(); |
| 1192 |
|
| 1193 |
if ( ! $settings['show_reviewer_avatar'] ) { |
| 1194 |
return; |
| 1195 |
} |
| 1196 |
|
| 1197 |
?> |
| 1198 |
<div class="ui-e-testimonial-avatar <?php esc_attr_e($settings['avatar_animations']);?>"> |
| 1199 |
<?php |
| 1200 |
$avatar_url = Group_Control_Image_Size::get_attachment_image_src($item['avatar']['id'], 'avatar_media_size', $settings); |
| 1201 |
if (!$avatar_url) { |
| 1202 |
printf('<img src="%1$s" alt="%2$s">', $item['avatar']['url'], esc_html($item['reviewer_name'])); |
| 1203 |
} else { |
| 1204 |
print(wp_get_attachment_image( |
| 1205 |
$item['avatar']['id'], |
| 1206 |
$settings['avatar_media_size_size'], |
| 1207 |
false, |
| 1208 |
[ |
| 1209 |
'alt' => esc_html($item['reviewer_name']) |
| 1210 |
] |
| 1211 |
)); |
| 1212 |
} |
| 1213 |
?> |
| 1214 |
</div> |
| 1215 |
<?php |
| 1216 |
} |
| 1217 |
function render_reviewer_secondary_image($item) |
| 1218 |
{ |
| 1219 |
$settings = $this->get_settings_for_display(); |
| 1220 |
|
| 1221 |
$thumb_url = Group_Control_Image_Size::get_attachment_image_src($item['image']['id'], 'image_media_size', $settings); |
| 1222 |
|
| 1223 |
if ( ! $settings['show_reviewer_image'] || !$thumb_url ) { |
| 1224 |
return; |
| 1225 |
} |
| 1226 |
|
| 1227 |
?> |
| 1228 |
<div class="ui-e-testimonial-image <?php esc_attr_e($settings['image_animations']);?>"> |
| 1229 |
<?php |
| 1230 |
if ($thumb_url) { |
| 1231 |
print(wp_get_attachment_image( |
| 1232 |
$item['image']['id'], |
| 1233 |
$settings['image_media_size_size'], |
| 1234 |
false, |
| 1235 |
[] |
| 1236 |
)); |
| 1237 |
} |
| 1238 |
?> |
| 1239 |
</div> |
| 1240 |
<?php |
| 1241 |
} |
| 1242 |
function render_reviewer_name($item) |
| 1243 |
{ |
| 1244 |
$settings = $this->get_settings_for_display(); |
| 1245 |
|
| 1246 |
if ( ! $settings['show_reviewer_name'] ) { |
| 1247 |
return; |
| 1248 |
} |
| 1249 |
|
| 1250 |
?> |
| 1251 |
<?php if ( $item['reviewer_name'] ) : ?> |
| 1252 |
<<?php esc_html_e($settings['review_name_tag']); ?> class="ui-e-testimonial-name <?php esc_attr_e($settings['name_animations']);?>"> |
| 1253 |
<span><?php echo wp_kses_post($item['reviewer_name']);?></span> |
| 1254 |
</<?php esc_html_e($settings['review_name_tag']); ?>> |
| 1255 |
<?php endif; ?> |
| 1256 |
<?php |
| 1257 |
} |
| 1258 |
function render_reviewer_job_title($item) |
| 1259 |
{ |
| 1260 |
$settings = $this->get_settings_for_display(); |
| 1261 |
|
| 1262 |
if ( ! $settings['show_reviewer_job_title'] ) { |
| 1263 |
return; |
| 1264 |
} |
| 1265 |
|
| 1266 |
?> |
| 1267 |
<?php if ( $item['reviewer_job_title'] ) : ?> |
| 1268 |
<div class="ui-e-testimonial-job-title <?php esc_attr_e($settings['job_animations']);?>"> |
| 1269 |
<span><?php esc_html_e($item['reviewer_job_title']); ?></span> |
| 1270 |
</div> |
| 1271 |
<?php endif; ?> |
| 1272 |
<?php |
| 1273 |
} |
| 1274 |
function render_review_text($item) |
| 1275 |
{ |
| 1276 |
$settings = $this->get_settings_for_display(); |
| 1277 |
|
| 1278 |
if ( ! $settings['show_reviewer_text'] ) { |
| 1279 |
return; |
| 1280 |
} |
| 1281 |
|
| 1282 |
?> |
| 1283 |
<?php if ( $item['review_text'] ) : ?> |
| 1284 |
<div class="ui-e-testimonial-text <?php esc_attr_e($settings['text_animations']);?>"> |
| 1285 |
<?php echo wp_kses_post( $item['review_text'] ); ?> |
| 1286 |
</div> |
| 1287 |
<?php endif; ?> |
| 1288 |
<?php |
| 1289 |
} |
| 1290 |
function render_review_rating($item) |
| 1291 |
{ |
| 1292 |
|
| 1293 |
$settings = $this->get_settings_for_display(); |
| 1294 |
|
| 1295 |
$ID = $item['_id']; |
| 1296 |
if ( !$settings['show_reviewer_rating'] ) { |
| 1297 |
return; |
| 1298 |
} |
| 1299 |
|
| 1300 |
$rating_value = $item['rating_number']['size']; // get rating value |
| 1301 |
|
| 1302 |
if ($settings['rating_type'] == 'star') { |
| 1303 |
|
| 1304 |
?> |
| 1305 |
<div class="ui-e-testimonial-rating <?php esc_attr_e($settings['rating_animations']);?>"> |
| 1306 |
<?php |
| 1307 |
|
| 1308 |
$rating_scale = 5; |
| 1309 |
|
| 1310 |
if ( '' === $rating_value ) { |
| 1311 |
$rating_value = $rating_scale; |
| 1312 |
} |
| 1313 |
|
| 1314 |
$rating_value = floatval( $rating_value ); |
| 1315 |
$rating_value = round( $rating_value, 2 ); |
| 1316 |
|
| 1317 |
for ( $index = 1; $index <= $rating_scale; $index++ ) { |
| 1318 |
|
| 1319 |
// SVG Method (uses font-awesome library for it's half-star icon, and can prints full and half-star) |
| 1320 |
if (Plugin::$instance->experiments->is_feature_active('e_font_icon_svg')){ |
| 1321 |
?> |
| 1322 |
<div class="ui-e-icon"> |
| 1323 |
<?php |
| 1324 |
if ( $rating_value >= $index ) { |
| 1325 |
echo Icons_Manager::try_get_icon_html( ['value' => 'fas fa-star', 'library' => 'fa-solid'], [ 'aria-hidden' => 'true' ] ); |
| 1326 |
} elseif ( intval( ceil( $rating_value ) ) === $index ) { |
| 1327 |
echo Icons_Manager::try_get_icon_html( ['value' => 'fas fa-star-half', 'library' => 'fa-solid'], ['aria-hidden' => 'true'] ); |
| 1328 |
} |
| 1329 |
?> |
| 1330 |
</div> |
| 1331 |
<?php |
| 1332 |
// Font Icon Method (uses elementor library and can print decimal specific stars) |
| 1333 |
} else { |
| 1334 |
|
| 1335 |
if ( $rating_value >= $index ) { |
| 1336 |
$width = '100%'; // Full star if rate superior to current loop |
| 1337 |
} elseif ( intval( ceil( $rating_value ) ) === $index ) { |
| 1338 |
$width = ( $rating_value - ( $index - 1 ) ) * 100 . '%'; // Semi-star, calculating the width based on the decimal value |
| 1339 |
} else { |
| 1340 |
$width = '0%'; // No star if rate inferior to current loop |
| 1341 |
} |
| 1342 |
|
| 1343 |
// Creates the atts |
| 1344 |
$this->add_render_attribute( "icon_marked_$ID" . "_$index", [ |
| 1345 |
'class' => 'ui-e-marked', |
| 1346 |
] ); |
| 1347 |
if ( '100%' !== $width ) { |
| 1348 |
$this->add_render_attribute( "icon_marked_$ID" . "_$index", [ |
| 1349 |
'style' => '--ui-e-rate-width: ' . $width . ';', |
| 1350 |
] ); |
| 1351 |
} |
| 1352 |
|
| 1353 |
?> |
| 1354 |
<div class="ui-e-icon"> |
| 1355 |
<div <?php $this->print_render_attribute_string( "icon_marked_$ID" . "_$index",); ?>> |
| 1356 |
<?php echo Icons_Manager::try_get_icon_html( ['value' => 'eicon-star','library' => 'eicons'], [ 'aria-hidden' => 'true' ] );?> |
| 1357 |
</div> |
| 1358 |
<div class="ui-e-unmarked"> |
| 1359 |
<?php echo Icons_Manager::try_get_icon_html( ['value' => 'eicon-star','library' => 'eicons'], [ 'aria-hidden' => 'true' ] );?> |
| 1360 |
</div> |
| 1361 |
</div> |
| 1362 |
<?php |
| 1363 |
} |
| 1364 |
} |
| 1365 |
?> |
| 1366 |
</div> |
| 1367 |
<?php |
| 1368 |
|
| 1369 |
} else { // number type rating |
| 1370 |
?> |
| 1371 |
<div class="ui-e-testimonial-rating number"> |
| 1372 |
<span><?php esc_html_e($rating_value);?></span> |
| 1373 |
</div> |
| 1374 |
<?php |
| 1375 |
} |
| 1376 |
} |
| 1377 |
function render_review_divider() |
| 1378 |
{ |
| 1379 |
$settings = $this->get_settings_for_display(); |
| 1380 |
|
| 1381 |
if ( !$settings['show_reviewer_divider'] ) { |
| 1382 |
return; |
| 1383 |
} |
| 1384 |
|
| 1385 |
?> |
| 1386 |
<span class="ui-e-testimonial-divider"></span> |
| 1387 |
<?php |
| 1388 |
} |
| 1389 |
function TRAIT_render_review_item($item, $layout) |
| 1390 |
{ |
| 1391 |
$settings = $this->get_settings_for_display(); |
| 1392 |
|
| 1393 |
// Atts used by some layouts |
| 1394 |
$atts = [ |
| 1395 |
'inline' => $settings['image_inline'] == 'yes' ? true : false, |
| 1396 |
]; |
| 1397 |
|
| 1398 |
// Get entrance and item hover animation classes |
| 1399 |
$entrance = (isset($settings['animate_items']) && $settings['animate_items'] == 'ui-e-grid-animate') ? 'elementor-invisible' : ''; |
| 1400 |
$hover = isset($settings['item_hover_animation']) ? $settings['item_hover_animation'] : null; |
| 1401 |
$animations = sprintf('%s %s', $entrance, $hover); |
| 1402 |
|
| 1403 |
// Get all elements animation control options (triggered by .ui-e-animations-wrp:hover) |
| 1404 |
$animation_options = [ |
| 1405 |
$settings['image_animations'], |
| 1406 |
$settings['avatar_animations'], |
| 1407 |
$settings['text_animations'], |
| 1408 |
$settings['name_animations'], |
| 1409 |
$settings['job_animations'], |
| 1410 |
$settings['rating_animations'] |
| 1411 |
]; |
| 1412 |
// get item animation only if is not slider, |
| 1413 |
if (!str_contains($this->get_name(), 'slider')) { |
| 1414 |
$animation_options[] = $settings['item_hover_animation']; |
| 1415 |
} |
| 1416 |
// check if any of the animation are set |
| 1417 |
$has_animation = array_filter($animation_options, function($value) { |
| 1418 |
return $value !== ''; |
| 1419 |
}); |
| 1420 |
// and also check if entrance is set |
| 1421 |
$has_animation = $entrance !== '' ? true : $has_animation; |
| 1422 |
|
| 1423 |
// TODO: remove `ui-e-item-wrp`, at least, 2 releases after 1.0.6 |
| 1424 |
?> |
| 1425 |
|
| 1426 |
<div class="ui-e-wrp swiper-slide"> |
| 1427 |
<?php if (!empty($has_animation)) : ?> |
| 1428 |
<div class="ui-e-animations-wrp <?php echo esc_attr($animations);?>"> |
| 1429 |
<?php endif; ?> |
| 1430 |
<div class="ui-e-item-wrp ui-e-item"> |
| 1431 |
<?php |
| 1432 |
switch($layout){ |
| 1433 |
case 'layout_2' : |
| 1434 |
$this->render_layout_2($item, $atts); |
| 1435 |
break; |
| 1436 |
case 'layout_3' : |
| 1437 |
$this->render_layout_3($item, $atts); |
| 1438 |
break; |
| 1439 |
case 'layout_4' : |
| 1440 |
$this->render_layout_4($item); |
| 1441 |
break; |
| 1442 |
case 'layout_5' : |
| 1443 |
$this->render_layout_5($item); |
| 1444 |
break; |
| 1445 |
case 'layout_6' : |
| 1446 |
$this->render_layout_6($item); |
| 1447 |
break; |
| 1448 |
default: |
| 1449 |
$this->render_layout_1($item, $atts); |
| 1450 |
break; |
| 1451 |
} |
| 1452 |
?> |
| 1453 |
</div> |
| 1454 |
<?php if (!empty($has_animation)) : ?> |
| 1455 |
</div> |
| 1456 |
<?php endif; ?> |
| 1457 |
</div> |
| 1458 |
<?php |
| 1459 |
} |
| 1460 |
|
| 1461 |
// Layouts |
| 1462 |
function render_layout_1($item, $atts) |
| 1463 |
{ |
| 1464 |
|
| 1465 |
$this->render_reviewer_secondary_image($item); |
| 1466 |
?> |
| 1467 |
<div class="ui-e-content"> |
| 1468 |
|
| 1469 |
<?php $this->render_review_text($item); ?> |
| 1470 |
|
| 1471 |
<?php if ($atts['inline']) : ?> |
| 1472 |
|
| 1473 |
<div class="ui-e-testimonial-flex"> |
| 1474 |
<?php $this->render_reviewer_avatar($item); ?> |
| 1475 |
<div class="ui-e-inner-content"> |
| 1476 |
<?php |
| 1477 |
$this->render_reviewer_name($item); |
| 1478 |
$this->render_reviewer_job_title($item); |
| 1479 |
$this->render_review_rating($item); |
| 1480 |
?> |
| 1481 |
</div> |
| 1482 |
</div> |
| 1483 |
|
| 1484 |
<?php else : |
| 1485 |
$this->render_reviewer_avatar($item); |
| 1486 |
$this->render_reviewer_name($item); |
| 1487 |
$this->render_reviewer_job_title($item); |
| 1488 |
$this->render_review_rating($item); |
| 1489 |
endif; ?> |
| 1490 |
|
| 1491 |
</div> |
| 1492 |
<?php |
| 1493 |
} |
| 1494 |
function render_layout_2($item, $atts) |
| 1495 |
{ |
| 1496 |
?> |
| 1497 |
<div class="ui-e-content"> |
| 1498 |
|
| 1499 |
<?php if ($atts['inline']) : ?> |
| 1500 |
<div class="ui-e-testimonial-flex"> |
| 1501 |
<?php $this->render_reviewer_avatar($item); ?> |
| 1502 |
<div class="ui-e-inner-content"> |
| 1503 |
<?php |
| 1504 |
$this->render_reviewer_name($item); |
| 1505 |
$this->render_reviewer_job_title($item); |
| 1506 |
$this->render_review_rating($item); |
| 1507 |
?> |
| 1508 |
</div> |
| 1509 |
</div> |
| 1510 |
|
| 1511 |
<?php else : |
| 1512 |
$this->render_reviewer_avatar($item); |
| 1513 |
$this->render_reviewer_name($item); |
| 1514 |
$this->render_reviewer_job_title($item); |
| 1515 |
$this->render_review_rating($item); |
| 1516 |
endif; ?> |
| 1517 |
|
| 1518 |
<?php $this->render_review_text($item); ?> |
| 1519 |
</div> |
| 1520 |
|
| 1521 |
<?php |
| 1522 |
$this->render_reviewer_secondary_image($item); |
| 1523 |
} |
| 1524 |
function render_layout_3($item, $atts) |
| 1525 |
{ |
| 1526 |
$this->render_reviewer_secondary_image($item); |
| 1527 |
?> |
| 1528 |
<div class="ui-e-content"> |
| 1529 |
|
| 1530 |
<?php |
| 1531 |
$this->render_review_rating($item); |
| 1532 |
$this->render_review_text($item); |
| 1533 |
$this->render_review_divider(); |
| 1534 |
?> |
| 1535 |
|
| 1536 |
<?php if ($atts['inline']) :?> |
| 1537 |
|
| 1538 |
<div class="ui-e-testimonial-flex"> |
| 1539 |
<?php $this->render_reviewer_avatar($item); ?> |
| 1540 |
<div class="ui-e-inner-content"> |
| 1541 |
<?php $this->render_reviewer_name($item); ?> |
| 1542 |
<?php $this->render_reviewer_job_title($item); ?> |
| 1543 |
</div> |
| 1544 |
</div> |
| 1545 |
|
| 1546 |
<?php else : |
| 1547 |
$this->render_reviewer_avatar($item); |
| 1548 |
$this->render_reviewer_name($item); |
| 1549 |
$this->render_reviewer_job_title($item); |
| 1550 |
endif; ?> |
| 1551 |
</div> |
| 1552 |
<?php |
| 1553 |
} |
| 1554 |
function render_layout_4($item) |
| 1555 |
{ |
| 1556 |
?> |
| 1557 |
<div class="ui-e-testimonial-flex"> |
| 1558 |
<?php $this->render_reviewer_avatar($item); ?> |
| 1559 |
<?php $this->render_reviewer_secondary_image($item); ?> |
| 1560 |
</div> |
| 1561 |
|
| 1562 |
<div class="ui-e-content"> |
| 1563 |
<?php |
| 1564 |
$this->render_review_text($item); |
| 1565 |
$this->render_reviewer_name($item); |
| 1566 |
$this->render_reviewer_job_title($item); |
| 1567 |
$this->render_review_rating($item); |
| 1568 |
?> |
| 1569 |
</div> |
| 1570 |
<?php |
| 1571 |
} |
| 1572 |
function render_layout_5($item) |
| 1573 |
{ |
| 1574 |
?> |
| 1575 |
<div class="ui-e-testimonial-flex"> |
| 1576 |
<div class="ui-e-content"> |
| 1577 |
|
| 1578 |
<?php |
| 1579 |
$this->render_reviewer_secondary_image($item); |
| 1580 |
$this->render_review_text($item); |
| 1581 |
$this->render_review_rating($item); |
| 1582 |
$this->render_reviewer_name($item); |
| 1583 |
$this->render_reviewer_job_title($item); |
| 1584 |
?> |
| 1585 |
</div> |
| 1586 |
<?php $this->render_reviewer_avatar($item); ?> |
| 1587 |
</div> |
| 1588 |
<?php |
| 1589 |
} |
| 1590 |
function render_layout_6($item) |
| 1591 |
{ |
| 1592 |
?> |
| 1593 |
<div class="ui-e-testimonial-flex"> |
| 1594 |
|
| 1595 |
<?php $this->render_reviewer_avatar($item); ?> |
| 1596 |
|
| 1597 |
<div class="ui-e-content"> |
| 1598 |
<?php |
| 1599 |
$this->render_reviewer_name($item); |
| 1600 |
$this->render_reviewer_job_title($item); |
| 1601 |
$this->render_review_rating($item); |
| 1602 |
$this->render_review_text($item); |
| 1603 |
$this->render_reviewer_secondary_image($item); |
| 1604 |
?> |
| 1605 |
</div> |
| 1606 |
</div> |
| 1607 |
<?php |
| 1608 |
} |
| 1609 |
} |