| 1 |
<?php |
| 2 |
namespace Easyel\EasyElements\Widgets; |
| 3 |
use Elementor\Controls_Manager; |
| 4 |
use Elementor\Group_Control_Typography; |
| 5 |
use Elementor\Group_Control_Text_Stroke; |
| 6 |
|
| 7 |
defined('ABSPATH') || die(); |
| 8 |
|
| 9 |
class Easyel_Counter_Widget extends \Elementor\Widget_Base { |
| 10 |
|
| 11 |
|
| 12 |
public function get_name() { |
| 13 |
return 'eel-counter'; |
| 14 |
} |
| 15 |
|
| 16 |
public function get_title() { |
| 17 |
return __( 'Counter', 'easy-elements' ); |
| 18 |
} |
| 19 |
|
| 20 |
public function get_icon() { |
| 21 |
return 'easyicon easyelIcon-counter'; |
| 22 |
} |
| 23 |
|
| 24 |
public function get_categories() { |
| 25 |
return [ 'easyelements_category' ]; |
| 26 |
} |
| 27 |
|
| 28 |
public function get_keywords() { |
| 29 |
return [ 'counter', 'funfact', 'counterup', 'count', 'text' ]; |
| 30 |
} |
| 31 |
|
| 32 |
public function get_style_depends() { |
| 33 |
return [ |
| 34 |
'eel-counter', |
| 35 |
]; |
| 36 |
} |
| 37 |
|
| 38 |
public function get_script_depends() { |
| 39 |
return [ |
| 40 |
'eel-counter', |
| 41 |
]; |
| 42 |
} |
| 43 |
|
| 44 |
protected function register_controls() |
| 45 |
{ |
| 46 |
$this->start_controls_section( |
| 47 |
'section_counter', |
| 48 |
[ |
| 49 |
'label' => esc_html__('Counter', 'easy-elements'), |
| 50 |
] |
| 51 |
); |
| 52 |
|
| 53 |
$this->add_control( |
| 54 |
'number', |
| 55 |
[ |
| 56 |
'label' => esc_html__('Ending Number', 'easy-elements'), |
| 57 |
'type' => Controls_Manager::NUMBER, |
| 58 |
'default' => 500, |
| 59 |
'dynamic' => [ |
| 60 |
'active' => true, |
| 61 |
], |
| 62 |
] |
| 63 |
); |
| 64 |
|
| 65 |
$this->add_control( |
| 66 |
'start_number', |
| 67 |
[ |
| 68 |
'label' => esc_html__('Starting Number', 'easy-elements'), |
| 69 |
'type' => Controls_Manager::NUMBER, |
| 70 |
'default' => 0, |
| 71 |
'dynamic' => [ |
| 72 |
'active' => true, |
| 73 |
], |
| 74 |
] |
| 75 |
); |
| 76 |
|
| 77 |
$this->add_control( |
| 78 |
'prefix', |
| 79 |
[ |
| 80 |
'label' => esc_html__('Number Prefix', 'easy-elements'), |
| 81 |
'type' => Controls_Manager::TEXT, |
| 82 |
'default' => '', |
| 83 |
'dynamic' => [ |
| 84 |
'active' => true, |
| 85 |
], |
| 86 |
] |
| 87 |
); |
| 88 |
|
| 89 |
$this->add_control( |
| 90 |
'suffix', |
| 91 |
[ |
| 92 |
'label' => esc_html__('Number Suffix', 'easy-elements'), |
| 93 |
'type' => Controls_Manager::TEXT, |
| 94 |
'default' => '', |
| 95 |
'dynamic' => [ |
| 96 |
'active' => true, |
| 97 |
], |
| 98 |
] |
| 99 |
); |
| 100 |
|
| 101 |
$this->add_control( |
| 102 |
'duration', |
| 103 |
[ |
| 104 |
'label' => esc_html__('Animation Duration (ms)', 'easy-elements'), |
| 105 |
'type' => Controls_Manager::NUMBER, |
| 106 |
'default' => 1000, |
| 107 |
'placeholder' => 'Suffix', |
| 108 |
] |
| 109 |
); |
| 110 |
|
| 111 |
$this->add_control( |
| 112 |
'format', |
| 113 |
[ |
| 114 |
'label' => __('Separator', 'easy-elements'), |
| 115 |
'type' => \Elementor\Controls_Manager::SELECT, |
| 116 |
'default' => 'default', |
| 117 |
'options' => [ |
| 118 |
'default' => __('Default', 'easy-elements'), |
| 119 |
'comma' => __('Comma', 'easy-elements'), |
| 120 |
'dot' => __('Dot', 'easy-elements'), |
| 121 |
'space' => __('Space', 'easy-elements'), |
| 122 |
'underline' => __('Underline', 'easy-elements'), |
| 123 |
], |
| 124 |
] |
| 125 |
); |
| 126 |
|
| 127 |
$this->add_control( |
| 128 |
'animation_type', |
| 129 |
[ |
| 130 |
'label' => esc_html__('Animation Style', 'easy-elements'), |
| 131 |
'type' => \Elementor\Controls_Manager::SELECT, |
| 132 |
'default' => 'counter', |
| 133 |
'options' => [ |
| 134 |
'counter' => esc_html__('Counter', 'easy-elements'), |
| 135 |
'odometer' => esc_html__('Odometer', 'easy-elements'), |
| 136 |
], |
| 137 |
'description' => esc_html__('Counter: smooth count up. Odometer: rolling digits like a car odometer.', 'easy-elements'), |
| 138 |
] |
| 139 |
); |
| 140 |
|
| 141 |
$this->add_control( |
| 142 |
'cnt-icon-enable', |
| 143 |
[ |
| 144 |
'label' => esc_html__( 'Icon Show', 'easy-elements' ), |
| 145 |
'type' => Controls_Manager::SWITCHER, |
| 146 |
'label_on' => esc_html__( 'Yes', 'easy-elements' ), |
| 147 |
'label_off' => esc_html__( 'No', 'easy-elements' ), |
| 148 |
'return_value' => 'yes', |
| 149 |
'default' => 'no', |
| 150 |
] |
| 151 |
); |
| 152 |
|
| 153 |
$this->add_control( |
| 154 |
'cnt-icon', |
| 155 |
[ |
| 156 |
'label' => esc_html__( 'Icon', 'easy-elements' ), |
| 157 |
'type' => \Elementor\Controls_Manager::ICONS, |
| 158 |
'default' => [ |
| 159 |
'value' => 'fas fa-layer-group', |
| 160 |
'library' => 'fa-solid', |
| 161 |
], |
| 162 |
'condition' => [ |
| 163 |
'cnt-icon-enable' => 'yes', |
| 164 |
] |
| 165 |
] |
| 166 |
); |
| 167 |
|
| 168 |
$this->add_control( |
| 169 |
'title', |
| 170 |
[ |
| 171 |
'label' => esc_html__('Title', 'easy-elements'), |
| 172 |
'type' => Controls_Manager::TEXT, |
| 173 |
'placeholder' => esc_html__('Label', 'easy-elements'), |
| 174 |
'default' => esc_html__('Easy Elements', 'easy-elements'), |
| 175 |
'label_block' => true, |
| 176 |
'dynamic' => [ |
| 177 |
'active' => true, |
| 178 |
], |
| 179 |
] |
| 180 |
); |
| 181 |
|
| 182 |
$this->add_control( |
| 183 |
'title_tag', |
| 184 |
[ |
| 185 |
'label' => esc_html__('Select Title Tag', 'easy-elements'), |
| 186 |
'type' => Controls_Manager::SELECT, |
| 187 |
'default' => 'span', |
| 188 |
'options' => [ |
| 189 |
'h1' => esc_html__('H1', 'easy-elements'), |
| 190 |
'h2' => esc_html__('H2', 'easy-elements'), |
| 191 |
'h3' => esc_html__('H3', 'easy-elements'), |
| 192 |
'h4' => esc_html__('H4', 'easy-elements'), |
| 193 |
'h5' => esc_html__('H5', 'easy-elements'), |
| 194 |
'h6' => esc_html__('H6', 'easy-elements'), |
| 195 |
'p' => esc_html__('P', 'easy-elements'), |
| 196 |
'div' => esc_html__('div', 'easy-elements'), |
| 197 |
'span' => esc_html__('span', 'easy-elements'), |
| 198 |
], |
| 199 |
] |
| 200 |
); |
| 201 |
$this->end_controls_section(); |
| 202 |
|
| 203 |
$this->start_controls_section( |
| 204 |
'counter_styles', |
| 205 |
[ |
| 206 |
'label' => esc_html__('Counter', 'easy-elements'), |
| 207 |
'tab' => Controls_Manager::TAB_STYLE, |
| 208 |
] |
| 209 |
); |
| 210 |
|
| 211 |
$this->add_control( |
| 212 |
'title_position', |
| 213 |
[ |
| 214 |
'label' => esc_html__( 'Title Position', 'easy-elements' ), |
| 215 |
'type' => \Elementor\Controls_Manager::CHOOSE, |
| 216 |
'options' => [ |
| 217 |
'top' => [ |
| 218 |
'title' => esc_html__( 'Top', 'easy-elements' ), |
| 219 |
'icon' => 'eicon-v-align-top', |
| 220 |
], |
| 221 |
'bottom' => [ |
| 222 |
'title' => esc_html__( 'Bottom', 'easy-elements' ), |
| 223 |
'icon' => 'eicon-v-align-bottom', |
| 224 |
], |
| 225 |
'left' => [ |
| 226 |
'title' => esc_html__( 'Left', 'easy-elements' ), |
| 227 |
'icon' => 'eicon-h-align-left', |
| 228 |
], |
| 229 |
'right' => [ |
| 230 |
'title' => esc_html__( 'Right', 'easy-elements' ), |
| 231 |
'icon' => 'eicon-h-align-right', |
| 232 |
], |
| 233 |
], |
| 234 |
'default' => 'bottom', |
| 235 |
'toggle' => false, |
| 236 |
'prefix_class' => 'eel-cnt-title-pos-', |
| 237 |
'condition' => [ |
| 238 |
'title!' => '', |
| 239 |
], |
| 240 |
] |
| 241 |
); |
| 242 |
|
| 243 |
$this->add_responsive_control( |
| 244 |
'content_gap', |
| 245 |
[ |
| 246 |
'label' => esc_html__( 'Content Gap', 'easy-elements' ), |
| 247 |
'type' => \Elementor\Controls_Manager::SLIDER, |
| 248 |
'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ], |
| 249 |
'selectors' => [ |
| 250 |
'{{WRAPPER}} .eel-cnt-content' => 'gap: {{SIZE}}{{UNIT}};', |
| 251 |
'{{WRAPPER}} .eel-cnt-title' => 'margin-top: 0;', |
| 252 |
], |
| 253 |
] |
| 254 |
); |
| 255 |
|
| 256 |
$this->add_responsive_control( |
| 257 |
'content_vertical_align', |
| 258 |
[ |
| 259 |
'label' => esc_html__( 'Vertical Alignment', 'easy-elements' ), |
| 260 |
'type' => \Elementor\Controls_Manager::CHOOSE, |
| 261 |
'options' => [ |
| 262 |
'flex-start' => [ |
| 263 |
'title' => esc_html__( 'Top', 'easy-elements' ), |
| 264 |
'icon' => 'eicon-v-align-top', |
| 265 |
], |
| 266 |
'center' => [ |
| 267 |
'title' => esc_html__( 'Middle', 'easy-elements' ), |
| 268 |
'icon' => 'eicon-v-align-middle', |
| 269 |
], |
| 270 |
'flex-end' => [ |
| 271 |
'title' => esc_html__( 'Bottom', 'easy-elements' ), |
| 272 |
'icon' => 'eicon-v-align-bottom', |
| 273 |
], |
| 274 |
], |
| 275 |
'toggle' => true, |
| 276 |
'selectors' => [ |
| 277 |
'{{WRAPPER}} .eel-cnt-content' => 'align-items: {{VALUE}};', |
| 278 |
], |
| 279 |
'condition' => [ |
| 280 |
'title_position' => [ 'left', 'right' ], |
| 281 |
'title!' => '', |
| 282 |
], |
| 283 |
] |
| 284 |
); |
| 285 |
|
| 286 |
$this->add_responsive_control( |
| 287 |
'sub_pre_gap', |
| 288 |
[ |
| 289 |
'label' => esc_html__( 'Prefix Suffix Gap', 'easy-elements' ), |
| 290 |
'type' => \Elementor\Controls_Manager::SLIDER, |
| 291 |
'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ], |
| 292 |
'selectors' => [ |
| 293 |
'{{WRAPPER}} .eel-cnt-number-wrap' => 'gap: {{SIZE}}{{UNIT}};', |
| 294 |
], |
| 295 |
'conditions' => [ |
| 296 |
'relation' => 'or', |
| 297 |
'terms' => [ |
| 298 |
[ |
| 299 |
'name' => 'prefix', |
| 300 |
'operator' => '!=', |
| 301 |
'value' => '', |
| 302 |
], |
| 303 |
[ |
| 304 |
'name' => 'suffix', |
| 305 |
'operator' => '!=', |
| 306 |
'value' => '', |
| 307 |
], |
| 308 |
], |
| 309 |
], |
| 310 |
] |
| 311 |
); |
| 312 |
|
| 313 |
$this->add_responsive_control( |
| 314 |
'wrap_df_hrzn_align', |
| 315 |
[ |
| 316 |
'label' => esc_html__( 'Horizontal Alignment', 'easy-elements' ), |
| 317 |
'type' => \Elementor\Controls_Manager::CHOOSE, |
| 318 |
'options' => [ |
| 319 |
'start' => [ |
| 320 |
'title' => esc_html__( 'Start', 'easy-elements' ), |
| 321 |
'icon' => 'eicon-h-align-left', |
| 322 |
], |
| 323 |
'center' => [ |
| 324 |
'title' => esc_html__( 'Center', 'easy-elements' ), |
| 325 |
'icon' => 'eicon-h-align-center', |
| 326 |
], |
| 327 |
'end' => [ |
| 328 |
'title' => esc_html__( 'End', 'easy-elements' ), |
| 329 |
'icon' => 'eicon-h-align-right', |
| 330 |
], |
| 331 |
], |
| 332 |
'toggle' => true, |
| 333 |
'selectors' => [ |
| 334 |
'{{WRAPPER}} .eel-cnt-wrap' => 'align-items: {{VALUE}};', |
| 335 |
], |
| 336 |
'condition' => [ |
| 337 |
'cnt-icon-enable!' => 'yes', |
| 338 |
] |
| 339 |
] |
| 340 |
); |
| 341 |
|
| 342 |
$this->add_responsive_control( |
| 343 |
'icon_position', |
| 344 |
[ |
| 345 |
'label' => esc_html__( 'Icon Position', 'easy-elements' ), |
| 346 |
'type' => \Elementor\Controls_Manager::CHOOSE, |
| 347 |
'separator' => 'before', |
| 348 |
'default' => 'top', |
| 349 |
'options' => [ |
| 350 |
'left' => [ |
| 351 |
'title' => esc_html__( 'Left', 'easy-elements' ), |
| 352 |
'icon' => 'eicon-h-align-left', |
| 353 |
], |
| 354 |
'top' => [ |
| 355 |
'title' => esc_html__( 'Top', 'easy-elements' ), |
| 356 |
'icon' => 'eicon-v-align-top', |
| 357 |
], |
| 358 |
'bottom' => [ |
| 359 |
'title' => esc_html__( 'Bottom', 'easy-elements' ), |
| 360 |
'icon' => 'eicon-v-align-bottom', |
| 361 |
], |
| 362 |
'right' => [ |
| 363 |
'title' => esc_html__( 'Right', 'easy-elements' ), |
| 364 |
'icon' => 'eicon-h-align-right', |
| 365 |
], |
| 366 |
], |
| 367 |
'toggle' => true, |
| 368 |
'prefix_class' => 'eel-cnt-icon-pos-', |
| 369 |
'condition' => [ |
| 370 |
'cnt-icon-enable' => 'yes', |
| 371 |
] |
| 372 |
] |
| 373 |
); |
| 374 |
|
| 375 |
$this->add_responsive_control( |
| 376 |
'wrap_vrt_lr_align', |
| 377 |
[ |
| 378 |
'label' => esc_html__( 'Vertical Alignment', 'easy-elements' ), |
| 379 |
'type' => \Elementor\Controls_Manager::CHOOSE, |
| 380 |
'options' => [ |
| 381 |
'start' => [ |
| 382 |
'title' => esc_html__( 'Top', 'easy-elements' ), |
| 383 |
'icon' => 'eicon-h-align-left', |
| 384 |
], |
| 385 |
'center' => [ |
| 386 |
'title' => esc_html__( 'Middle', 'easy-elements' ), |
| 387 |
'icon' => 'eicon-h-align-center', |
| 388 |
], |
| 389 |
'end' => [ |
| 390 |
'title' => esc_html__( 'Bottom', 'easy-elements' ), |
| 391 |
'icon' => 'eicon-h-align-right', |
| 392 |
], |
| 393 |
], |
| 394 |
'toggle' => true, |
| 395 |
'selectors' => [ |
| 396 |
'{{WRAPPER}} .eel-cnt-wrap' => 'align-items: {{VALUE}};', |
| 397 |
], |
| 398 |
'condition' => [ |
| 399 |
'icon_position' => [ 'left', 'right' ], |
| 400 |
'cnt-icon-enable' => 'yes', |
| 401 |
], |
| 402 |
] |
| 403 |
); |
| 404 |
|
| 405 |
$this->add_responsive_control( |
| 406 |
'wrap_hrzn_tb_alig', |
| 407 |
[ |
| 408 |
'label' => esc_html__( 'Horizontal Alignment', 'easy-elements' ), |
| 409 |
'type' => \Elementor\Controls_Manager::CHOOSE, |
| 410 |
'options' => [ |
| 411 |
'start' => [ |
| 412 |
'title' => esc_html__( 'Start', 'easy-elements' ), |
| 413 |
'icon' => 'eicon-h-align-left', |
| 414 |
], |
| 415 |
'center' => [ |
| 416 |
'title' => esc_html__( 'Center', 'easy-elements' ), |
| 417 |
'icon' => 'eicon-h-align-center', |
| 418 |
], |
| 419 |
'end' => [ |
| 420 |
'title' => esc_html__( 'End', 'easy-elements' ), |
| 421 |
'icon' => 'eicon-h-align-right', |
| 422 |
], |
| 423 |
], |
| 424 |
'toggle' => true, |
| 425 |
'selectors' => [ |
| 426 |
'{{WRAPPER}} .eel-cnt-wrap' => 'align-items: {{VALUE}};', |
| 427 |
], |
| 428 |
'condition' => [ |
| 429 |
'icon_position' => [ 'top', 'bottom' ], |
| 430 |
'cnt-icon-enable' => 'yes', |
| 431 |
] |
| 432 |
] |
| 433 |
); |
| 434 |
|
| 435 |
$this->add_responsive_control( |
| 436 |
'wrap_hrzn_lr_align', |
| 437 |
[ |
| 438 |
'label' => esc_html__( 'Horizontal Alignment', 'easy-elements' ), |
| 439 |
'type' => \Elementor\Controls_Manager::CHOOSE, |
| 440 |
'options' => [ |
| 441 |
'start' => [ |
| 442 |
'title' => esc_html__( 'Start', 'easy-elements' ), |
| 443 |
'icon' => 'eicon-h-align-left', |
| 444 |
], |
| 445 |
'center' => [ |
| 446 |
'title' => esc_html__( 'Center', 'easy-elements' ), |
| 447 |
'icon' => 'eicon-h-align-center', |
| 448 |
], |
| 449 |
'end' => [ |
| 450 |
'title' => esc_html__( 'End', 'easy-elements' ), |
| 451 |
'icon' => 'eicon-h-align-right', |
| 452 |
], |
| 453 |
'space-between' => [ |
| 454 |
'title' => esc_html__( 'Stretch', 'easy-elements' ), |
| 455 |
'icon' => 'eicon-grow', |
| 456 |
], |
| 457 |
], |
| 458 |
'toggle' => true, |
| 459 |
'selectors' => [ |
| 460 |
'{{WRAPPER}} .eel-cnt-wrap' => 'justify-content: {{VALUE}};', |
| 461 |
], |
| 462 |
'condition' => [ |
| 463 |
'icon_position' => [ 'left', 'right' ], |
| 464 |
'cnt-icon-enable' => 'yes', |
| 465 |
], |
| 466 |
] |
| 467 |
); |
| 468 |
|
| 469 |
$this->add_responsive_control( |
| 470 |
'icon_gap', |
| 471 |
[ |
| 472 |
'label' => esc_html__( 'Icon Gap', 'easy-elements' ), |
| 473 |
'type' => \Elementor\Controls_Manager::SLIDER, |
| 474 |
'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ], |
| 475 |
'selectors' => [ |
| 476 |
'{{WRAPPER}} .eel-cnt-wrap' => 'gap: {{SIZE}}{{UNIT}};', |
| 477 |
], |
| 478 |
'condition' => [ |
| 479 |
'cnt-icon-enable' => 'yes', |
| 480 |
] |
| 481 |
] |
| 482 |
); |
| 483 |
|
| 484 |
$this->end_controls_section(); |
| 485 |
|
| 486 |
$this->start_controls_section( |
| 487 |
'section_number', |
| 488 |
[ |
| 489 |
'label' => esc_html__('Number', 'easy-elements'), |
| 490 |
'tab' => Controls_Manager::TAB_STYLE, |
| 491 |
'condition' => [ |
| 492 |
'number!' => '' |
| 493 |
] |
| 494 |
] |
| 495 |
); |
| 496 |
|
| 497 |
$this->add_control( |
| 498 |
'number_color', |
| 499 |
[ |
| 500 |
'label' => esc_html__('Color', 'easy-elements'), |
| 501 |
'type' => Controls_Manager::COLOR, |
| 502 |
'selectors' => [ |
| 503 |
'{{WRAPPER}} .eel-cnt-number-wrap' => 'color: {{VALUE}};', |
| 504 |
], |
| 505 |
] |
| 506 |
); |
| 507 |
|
| 508 |
$this->add_group_control( |
| 509 |
Group_Control_Typography::get_type(), |
| 510 |
[ |
| 511 |
'label' => esc_html__('Typography', 'easy-elements'), |
| 512 |
'name' => 'number_typography', |
| 513 |
'selector' => '{{WRAPPER}} .eel-cnt-number-wrap', |
| 514 |
] |
| 515 |
); |
| 516 |
|
| 517 |
$this->add_group_control( |
| 518 |
\Elementor\Group_Control_Text_Stroke::get_type(), |
| 519 |
[ |
| 520 |
'name' => 'number_stroke', |
| 521 |
'selector' => '{{WRAPPER}} .eel-cnt-number-wrap', |
| 522 |
] |
| 523 |
); |
| 524 |
|
| 525 |
$this->add_group_control( |
| 526 |
\Elementor\Group_Control_Text_Shadow::get_type(), |
| 527 |
[ |
| 528 |
'name' => 'number_text_shadow', |
| 529 |
'label' => esc_html__('Text Shadow', 'easy-elements'), |
| 530 |
'selector' => '{{WRAPPER}} .eel-cnt-number-wrap', |
| 531 |
] |
| 532 |
); |
| 533 |
$this->end_controls_section(); |
| 534 |
|
| 535 |
$this->start_controls_section( |
| 536 |
'prefix_styles', |
| 537 |
[ |
| 538 |
'label' => esc_html__('Prefix', 'easy-elements'), |
| 539 |
'tab' => Controls_Manager::TAB_STYLE, |
| 540 |
'condition' => [ |
| 541 |
'prefix!' => '', |
| 542 |
] |
| 543 |
] |
| 544 |
); |
| 545 |
$this->add_control( |
| 546 |
'prefix_color', |
| 547 |
[ |
| 548 |
'label' => esc_html__('Color', 'easy-elements'), |
| 549 |
'type' => Controls_Manager::COLOR, |
| 550 |
'selectors' => [ |
| 551 |
'{{WRAPPER}} .eel-cnt-prefix' => 'color: {{VALUE}};', |
| 552 |
], |
| 553 |
] |
| 554 |
); |
| 555 |
$this->add_group_control( |
| 556 |
Group_Control_Typography::get_type(), |
| 557 |
[ |
| 558 |
'label' => esc_html__('Typography', 'easy-elements'), |
| 559 |
'name' => 'prefix_typography', |
| 560 |
'selector' => '{{WRAPPER}} .eel-cnt-prefix', |
| 561 |
] |
| 562 |
); |
| 563 |
|
| 564 |
$this->add_group_control( |
| 565 |
\Elementor\Group_Control_Text_Shadow::get_type(), |
| 566 |
[ |
| 567 |
'name' => 'prefix_text_shadow', |
| 568 |
'label' => esc_html__('Text Shadow', 'easy-elements'), |
| 569 |
'selector' => '{{WRAPPER}} .eel-cnt-prefix', |
| 570 |
] |
| 571 |
); |
| 572 |
$this->end_controls_section(); |
| 573 |
|
| 574 |
$this->start_controls_section( |
| 575 |
'suffix_styles', |
| 576 |
[ |
| 577 |
'label' => esc_html__('Suffix', 'easy-elements'), |
| 578 |
'tab' => Controls_Manager::TAB_STYLE, |
| 579 |
'condition' => [ |
| 580 |
'suffix!' => '', |
| 581 |
] |
| 582 |
] |
| 583 |
); |
| 584 |
|
| 585 |
$this->add_control( |
| 586 |
'suffix_color', |
| 587 |
[ |
| 588 |
'label' => esc_html__('Color', 'easy-elements'), |
| 589 |
'type' => Controls_Manager::COLOR, |
| 590 |
'selectors' => [ |
| 591 |
'{{WRAPPER}} .eel-cnt-suffix' => 'color: {{VALUE}};', |
| 592 |
], |
| 593 |
] |
| 594 |
); |
| 595 |
|
| 596 |
$this->add_group_control( |
| 597 |
Group_Control_Typography::get_type(), |
| 598 |
[ |
| 599 |
'label' => esc_html__('Typography', 'easy-elements'), |
| 600 |
'name' => 'suffix_typography', |
| 601 |
'selector' => '{{WRAPPER}} .eel-cnt-suffix', |
| 602 |
] |
| 603 |
); |
| 604 |
|
| 605 |
$this->add_group_control( |
| 606 |
\Elementor\Group_Control_Text_Shadow::get_type(), |
| 607 |
[ |
| 608 |
'name' => 'suffix_text_shadow', |
| 609 |
'label' => esc_html__('Text Shadow', 'easy-elements'), |
| 610 |
'selector' => '{{WRAPPER}} .eel-cnt-suffix', |
| 611 |
] |
| 612 |
); |
| 613 |
$this->end_controls_section(); |
| 614 |
|
| 615 |
$this->start_controls_section( |
| 616 |
'title_styles', |
| 617 |
[ |
| 618 |
'label' => esc_html__('Title', 'easy-elements'), |
| 619 |
'tab' => Controls_Manager::TAB_STYLE, |
| 620 |
'condition' => [ |
| 621 |
'title!' => '', |
| 622 |
] |
| 623 |
] |
| 624 |
); |
| 625 |
|
| 626 |
$this->add_control( |
| 627 |
'title_color', |
| 628 |
[ |
| 629 |
'label' => esc_html__('Color', 'easy-elements'), |
| 630 |
'type' => Controls_Manager::COLOR, |
| 631 |
'selectors' => [ |
| 632 |
'{{WRAPPER}} .eel-cnt-title' => 'color: {{VALUE}};', |
| 633 |
], |
| 634 |
] |
| 635 |
); |
| 636 |
|
| 637 |
$this->add_group_control( |
| 638 |
Group_Control_Typography::get_type(), |
| 639 |
[ |
| 640 |
'label' => esc_html__('Typography', 'easy-elements'), |
| 641 |
'name' => 'title_typography', |
| 642 |
'selector' => '{{WRAPPER}} .eel-cnt-title', |
| 643 |
] |
| 644 |
); |
| 645 |
|
| 646 |
$this->add_responsive_control( |
| 647 |
'title_align', |
| 648 |
[ |
| 649 |
'label' => esc_html__( 'Text Alignment', 'easy-elements' ), |
| 650 |
'type' => \Elementor\Controls_Manager::CHOOSE, |
| 651 |
'options' => [ |
| 652 |
'left' => [ |
| 653 |
'title' => esc_html__( 'Left', 'easy-elements' ), |
| 654 |
'icon' => 'eicon-text-align-left', |
| 655 |
], |
| 656 |
'center' => [ |
| 657 |
'title' => esc_html__( 'Center', 'easy-elements' ), |
| 658 |
'icon' => 'eicon-text-align-center', |
| 659 |
], |
| 660 |
'right' => [ |
| 661 |
'title' => esc_html__( 'Right', 'easy-elements' ), |
| 662 |
'icon' => 'eicon-text-align-right', |
| 663 |
], |
| 664 |
'justify' => [ |
| 665 |
'title' => esc_html__( 'Justified', 'easy-elements' ), |
| 666 |
'icon' => 'eicon-text-align-justify', |
| 667 |
], |
| 668 |
], |
| 669 |
'toggle' => true, |
| 670 |
'selectors' => [ |
| 671 |
'{{WRAPPER}} .eel-cnt-title' => 'text-align: {{VALUE}};', |
| 672 |
], |
| 673 |
] |
| 674 |
); |
| 675 |
|
| 676 |
$this->add_group_control( |
| 677 |
\Elementor\Group_Control_Text_Shadow::get_type(), |
| 678 |
[ |
| 679 |
'name' => 'title_text_shadow', |
| 680 |
'label' => esc_html__('Text Shadow', 'easy-elements'), |
| 681 |
'selector' => '{{WRAPPER}} .eel-cnt-title', |
| 682 |
] |
| 683 |
); |
| 684 |
$this->end_controls_section(); |
| 685 |
|
| 686 |
$this->start_controls_section( |
| 687 |
'icon_style', |
| 688 |
[ |
| 689 |
'label' => esc_html__('Icon', 'easy-elements'), |
| 690 |
'tab' => Controls_Manager::TAB_STYLE, |
| 691 |
'condition' => [ |
| 692 |
'cnt-icon-enable' => 'yes', |
| 693 |
] |
| 694 |
] |
| 695 |
); |
| 696 |
|
| 697 |
$this->add_control( |
| 698 |
'icon_color', |
| 699 |
[ |
| 700 |
'label' => esc_html__('Color', 'easy-elements'), |
| 701 |
'type' => Controls_Manager::COLOR, |
| 702 |
'selectors' => [ |
| 703 |
'{{WRAPPER}} .eel-cnt-icon svg' => 'fill: {{VALUE}};', |
| 704 |
'{{WRAPPER}} .eel-cnt-icon svg path' => 'fill: {{VALUE}};', |
| 705 |
'{{WRAPPER}} .eel-cnt-icon i' => 'color: {{VALUE}};', |
| 706 |
], |
| 707 |
] |
| 708 |
); |
| 709 |
|
| 710 |
$this->add_control( |
| 711 |
'icon_bgcolor', |
| 712 |
[ |
| 713 |
'label' => esc_html__('Background', 'easy-elements'), |
| 714 |
'type' => Controls_Manager::COLOR, |
| 715 |
'selectors' => [ |
| 716 |
'{{WRAPPER}} .eel-cnt-icon' => 'background: {{VALUE}};', |
| 717 |
], |
| 718 |
] |
| 719 |
); |
| 720 |
|
| 721 |
$this->add_responsive_control( |
| 722 |
'icon_box_size', |
| 723 |
[ |
| 724 |
'label' => esc_html__( 'Size', 'easy-elements' ), |
| 725 |
'type' => \Elementor\Controls_Manager::SLIDER, |
| 726 |
'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ], |
| 727 |
'range' => [ |
| 728 |
'px' => [ |
| 729 |
'min' => 0, |
| 730 |
'max' => 100, |
| 731 |
'step' => 0, |
| 732 |
], |
| 733 |
'%' => [ |
| 734 |
'min' => 0, |
| 735 |
'max' => 100, |
| 736 |
], |
| 737 |
], |
| 738 |
'selectors' => [ |
| 739 |
'{{WRAPPER}} .eel-cnt-icon' => 'width: {{SIZE}}{{UNIT}} !important;height: {{SIZE}}{{UNIT}} !important;', |
| 740 |
], |
| 741 |
] |
| 742 |
); |
| 743 |
|
| 744 |
$this->add_responsive_control( |
| 745 |
'icon_size', |
| 746 |
[ |
| 747 |
'label' => esc_html__( 'Icon Size', 'easy-elements' ), |
| 748 |
'type' => \Elementor\Controls_Manager::SLIDER, |
| 749 |
'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ], |
| 750 |
'range' => [ |
| 751 |
'px' => [ |
| 752 |
'min' => 0, |
| 753 |
'max' => 100, |
| 754 |
'step' => 0, |
| 755 |
], |
| 756 |
'%' => [ |
| 757 |
'min' => 0, |
| 758 |
'max' => 100, |
| 759 |
], |
| 760 |
], |
| 761 |
'selectors' => [ |
| 762 |
'{{WRAPPER}} .eel-cnt-icon svg' => 'width: {{SIZE}}{{UNIT}} !important;height: {{SIZE}}{{UNIT}} !important;', |
| 763 |
'{{WRAPPER}} .eel-cnt-icon i' => 'font-size: {{SIZE}}{{UNIT}};', |
| 764 |
], |
| 765 |
] |
| 766 |
); |
| 767 |
|
| 768 |
$this->add_responsive_control( |
| 769 |
'icon_border_radius', |
| 770 |
[ |
| 771 |
'label' => esc_html__( 'Border Radius', 'easy-elements' ), |
| 772 |
'type' => \Elementor\Controls_Manager::DIMENSIONS, |
| 773 |
'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ], |
| 774 |
'selectors' => [ |
| 775 |
'{{WRAPPER}} .eel-cnt-icon' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 776 |
], |
| 777 |
] |
| 778 |
); |
| 779 |
|
| 780 |
$this->add_responsive_control( |
| 781 |
'icon_padding', |
| 782 |
[ |
| 783 |
'label' => esc_html__( 'Padding', 'easy-elements' ), |
| 784 |
'type' => \Elementor\Controls_Manager::DIMENSIONS, |
| 785 |
'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ], |
| 786 |
'selectors' => [ |
| 787 |
'{{WRAPPER}} .eel-cnt-icon' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 788 |
], |
| 789 |
] |
| 790 |
); |
| 791 |
|
| 792 |
$this->add_group_control( |
| 793 |
\Elementor\Group_Control_Border::get_type(), |
| 794 |
[ |
| 795 |
'name' => 'icon_border', |
| 796 |
'selector' => '{{WRAPPER}} .eel-cnt-icon', |
| 797 |
] |
| 798 |
); |
| 799 |
|
| 800 |
$this->add_group_control( |
| 801 |
\Elementor\Group_Control_Box_Shadow::get_type(), |
| 802 |
[ |
| 803 |
'name' => 'icon_box_shadow', |
| 804 |
'selector' => '{{WRAPPER}} .eel-cnt-icon', |
| 805 |
] |
| 806 |
); |
| 807 |
$this->end_controls_section(); |
| 808 |
} |
| 809 |
|
| 810 |
protected function render() { |
| 811 |
$settings = $this->get_settings_for_display(); |
| 812 |
$number = isset($settings['number']) && $settings['number'] !== '' ? $settings['number'] : 0; |
| 813 |
$start = isset($settings['start_number']) && $settings['start_number'] !== '' ? $settings['start_number'] : 0; |
| 814 |
$prefix = !empty($settings['prefix']) ? $settings['prefix'] : ''; |
| 815 |
$suffix = !empty($settings['suffix']) ? $settings['suffix'] : ''; |
| 816 |
$title = !empty($settings['title']) ? $settings['title'] : ''; |
| 817 |
$title_tag = !empty($settings['title_tag']) ? $settings['title_tag'] : 'span'; |
| 818 |
|
| 819 |
$duration = !empty($settings['duration']) ? intval($settings['duration']) : 1000; |
| 820 |
$format = !empty($settings['format']) ? $settings['format'] : 'default'; |
| 821 |
$animation = !empty($settings['animation_type']) ? $settings['animation_type'] : 'counter'; |
| 822 |
if (!in_array($animation, ['counter', 'odometer'], true)) { |
| 823 |
$animation = 'counter'; |
| 824 |
} |
| 825 |
|
| 826 |
$allowed_tags = ['h1','h2','h3','h4','h5','h6','p','div','span']; |
| 827 |
if (!in_array($title_tag, $allowed_tags, true)) { |
| 828 |
$title_tag = 'span'; |
| 829 |
} |
| 830 |
|
| 831 |
$icon_enabled = !empty($settings['cnt-icon-enable']) && $settings['cnt-icon-enable'] === 'yes'; |
| 832 |
$icon = $icon_enabled && !empty($settings['cnt-icon']['value']) ? $settings['cnt-icon'] : false; |
| 833 |
|
| 834 |
// Add inline editing |
| 835 |
$this->add_inline_editing_attributes('prefix', 'basic'); |
| 836 |
$this->add_render_attribute('prefix', 'class', 'eel-cnt-prefix'); |
| 837 |
|
| 838 |
$this->add_inline_editing_attributes('suffix', 'basic'); |
| 839 |
$this->add_render_attribute('suffix', 'class', 'eel-cnt-suffix'); |
| 840 |
?> |
| 841 |
<div class="eel-cnt-wrap"> |
| 842 |
|
| 843 |
<?php if ($icon) : ?> |
| 844 |
<div class="eel-cnt-icon"> |
| 845 |
<?php \Elementor\Icons_Manager::render_icon($icon, [ 'aria-hidden' => 'true' ]); ?> |
| 846 |
</div> |
| 847 |
<?php endif; ?> |
| 848 |
|
| 849 |
<div class="eel-cnt-content"> |
| 850 |
|
| 851 |
<?php if ($number !== '') : ?> |
| 852 |
<div class="eel-cnt-number-wrap"> |
| 853 |
|
| 854 |
<?php if ($prefix !== '') : |
| 855 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Safe, output contains trusted HTML attributes. ?> |
| 856 |
<span <?php echo $this->print_render_attribute_string('prefix'); ?>> |
| 857 |
<?php echo esc_html($prefix); ?> |
| 858 |
</span> |
| 859 |
<?php endif; ?> |
| 860 |
|
| 861 |
<span class="eel-cnt-number eel-counter" |
| 862 |
data-count="<?php echo esc_attr($number); ?>" |
| 863 |
data-start="<?php echo esc_attr($start); ?>" |
| 864 |
data-duration="<?php echo esc_attr($duration); ?>" |
| 865 |
data-format="<?php echo esc_attr($format); ?>" |
| 866 |
data-animation="<?php echo esc_attr($animation); ?>"> |
| 867 |
<?php echo esc_html($start); ?> |
| 868 |
</span> |
| 869 |
|
| 870 |
<?php if ($suffix !== '') : |
| 871 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Safe, output contains trusted HTML attributes. ?> |
| 872 |
<span <?php echo $this->print_render_attribute_string('suffix'); ?>> |
| 873 |
<?php echo esc_html($suffix); ?> |
| 874 |
</span> |
| 875 |
<?php endif; ?> |
| 876 |
|
| 877 |
</div> |
| 878 |
<?php endif; ?> |
| 879 |
|
| 880 |
<?php if ($title !== '') : ?> |
| 881 |
<<?php echo esc_attr($title_tag); ?> class="eel-cnt-title"> |
| 882 |
<?php echo wp_kses_post($title); ?> |
| 883 |
</<?php echo esc_attr($title_tag); ?>> |
| 884 |
<?php endif; ?> |
| 885 |
|
| 886 |
</div> |
| 887 |
</div> |
| 888 |
<?php |
| 889 |
} |
| 890 |
} |
| 891 |
|