| 1 |
<?php |
| 2 |
namespace Elementor; |
| 3 |
|
| 4 |
if ( ! defined( 'ABSPATH' ) ) { |
| 5 |
exit; // Exit if accessed directly. |
| 6 |
} |
| 7 |
|
| 8 |
use Elementor\Core\Kits\Documents\Tabs\Global_Colors; |
| 9 |
use Elementor\Core\Kits\Documents\Tabs\Global_Typography; |
| 10 |
|
| 11 |
/** |
| 12 |
* Elementor icon list widget. |
| 13 |
* |
| 14 |
* Elementor widget that displays a bullet list with any chosen icons and texts. |
| 15 |
* |
| 16 |
* @since 1.0.0 |
| 17 |
*/ |
| 18 |
class Widget_Icon_List extends Widget_Base { |
| 19 |
|
| 20 |
/** |
| 21 |
* Get widget name. |
| 22 |
* |
| 23 |
* Retrieve icon list widget name. |
| 24 |
* |
| 25 |
* @since 1.0.0 |
| 26 |
* @access public |
| 27 |
* |
| 28 |
* @return string Widget name. |
| 29 |
*/ |
| 30 |
public function get_name() { |
| 31 |
return 'icon-list'; |
| 32 |
} |
| 33 |
|
| 34 |
/** |
| 35 |
* Get widget title. |
| 36 |
* |
| 37 |
* Retrieve icon list widget title. |
| 38 |
* |
| 39 |
* @since 1.0.0 |
| 40 |
* @access public |
| 41 |
* |
| 42 |
* @return string Widget title. |
| 43 |
*/ |
| 44 |
public function get_title() { |
| 45 |
return esc_html__( 'Icon List', 'elementor' ); |
| 46 |
} |
| 47 |
|
| 48 |
/** |
| 49 |
* Get widget icon. |
| 50 |
* |
| 51 |
* Retrieve icon list widget icon. |
| 52 |
* |
| 53 |
* @since 1.0.0 |
| 54 |
* @access public |
| 55 |
* |
| 56 |
* @return string Widget icon. |
| 57 |
*/ |
| 58 |
public function get_icon() { |
| 59 |
return 'eicon-bullet-list'; |
| 60 |
} |
| 61 |
|
| 62 |
/** |
| 63 |
* Get widget keywords. |
| 64 |
* |
| 65 |
* Retrieve the list of keywords the widget belongs to. |
| 66 |
* |
| 67 |
* @since 2.1.0 |
| 68 |
* @access public |
| 69 |
* |
| 70 |
* @return array Widget keywords. |
| 71 |
*/ |
| 72 |
public function get_keywords() { |
| 73 |
return [ 'icon list', 'icon', 'list' ]; |
| 74 |
} |
| 75 |
|
| 76 |
protected function is_dynamic_content(): bool { |
| 77 |
return false; |
| 78 |
} |
| 79 |
|
| 80 |
public function has_widget_inner_wrapper(): bool { |
| 81 |
return ! Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' ); |
| 82 |
} |
| 83 |
|
| 84 |
/** |
| 85 |
* Get style dependencies. |
| 86 |
* |
| 87 |
* Retrieve the list of style dependencies the widget requires. |
| 88 |
* |
| 89 |
* @since 3.24.0 |
| 90 |
* @access public |
| 91 |
* |
| 92 |
* @return array Widget style dependencies. |
| 93 |
*/ |
| 94 |
public function get_style_depends(): array { |
| 95 |
return [ 'widget-icon-list' ]; |
| 96 |
} |
| 97 |
|
| 98 |
/** |
| 99 |
* Register icon list widget controls. |
| 100 |
* |
| 101 |
* Adds different input fields to allow the user to change and customize the widget settings. |
| 102 |
* |
| 103 |
* @since 3.1.0 |
| 104 |
* @access protected |
| 105 |
*/ |
| 106 |
protected function register_controls() { |
| 107 |
$this->start_controls_section( |
| 108 |
'section_icon', |
| 109 |
[ |
| 110 |
'label' => esc_html__( 'Icon List', 'elementor' ), |
| 111 |
] |
| 112 |
); |
| 113 |
|
| 114 |
$this->add_control( |
| 115 |
'view', |
| 116 |
[ |
| 117 |
'label' => esc_html__( 'Layout', 'elementor' ), |
| 118 |
'type' => Controls_Manager::CHOOSE, |
| 119 |
'default' => 'traditional', |
| 120 |
'options' => [ |
| 121 |
'traditional' => [ |
| 122 |
'title' => esc_html__( 'Default', 'elementor' ), |
| 123 |
'icon' => 'eicon-editor-list-ul', |
| 124 |
], |
| 125 |
'inline' => [ |
| 126 |
'title' => esc_html__( 'Inline', 'elementor' ), |
| 127 |
'icon' => 'eicon-ellipsis-h', |
| 128 |
], |
| 129 |
], |
| 130 |
'render_type' => 'template', |
| 131 |
'classes' => 'elementor-control-start-end', |
| 132 |
'style_transfer' => true, |
| 133 |
'prefix_class' => 'elementor-icon-list--layout-', |
| 134 |
] |
| 135 |
); |
| 136 |
|
| 137 |
$repeater = new Repeater(); |
| 138 |
|
| 139 |
$repeater->add_control( |
| 140 |
'text', |
| 141 |
[ |
| 142 |
'label' => esc_html__( 'Text', 'elementor' ), |
| 143 |
'type' => Controls_Manager::TEXT, |
| 144 |
'label_block' => true, |
| 145 |
'placeholder' => esc_html__( 'List Item', 'elementor' ), |
| 146 |
'default' => esc_html__( 'List Item', 'elementor' ), |
| 147 |
'dynamic' => [ |
| 148 |
'active' => true, |
| 149 |
], |
| 150 |
] |
| 151 |
); |
| 152 |
|
| 153 |
$repeater->add_control( |
| 154 |
'selected_icon', |
| 155 |
[ |
| 156 |
'label' => esc_html__( 'Icon', 'elementor' ), |
| 157 |
'type' => Controls_Manager::ICONS, |
| 158 |
'default' => [ |
| 159 |
'value' => 'fas fa-check', |
| 160 |
'library' => 'fa-solid', |
| 161 |
], |
| 162 |
'fa4compatibility' => 'icon', |
| 163 |
] |
| 164 |
); |
| 165 |
|
| 166 |
$repeater->add_control( |
| 167 |
'link', |
| 168 |
[ |
| 169 |
'label' => esc_html__( 'Link', 'elementor' ), |
| 170 |
'type' => Controls_Manager::URL, |
| 171 |
'dynamic' => [ |
| 172 |
'active' => true, |
| 173 |
], |
| 174 |
] |
| 175 |
); |
| 176 |
|
| 177 |
$this->add_control( |
| 178 |
'icon_list', |
| 179 |
[ |
| 180 |
'label' => esc_html__( 'Items', 'elementor' ), |
| 181 |
'type' => Controls_Manager::REPEATER, |
| 182 |
'fields' => $repeater->get_controls(), |
| 183 |
'default' => [ |
| 184 |
[ |
| 185 |
'text' => esc_html__( 'List Item #1', 'elementor' ), |
| 186 |
'selected_icon' => [ |
| 187 |
'value' => 'fas fa-check', |
| 188 |
'library' => 'fa-solid', |
| 189 |
], |
| 190 |
], |
| 191 |
[ |
| 192 |
'text' => esc_html__( 'List Item #2', 'elementor' ), |
| 193 |
'selected_icon' => [ |
| 194 |
'value' => 'fas fa-times', |
| 195 |
'library' => 'fa-solid', |
| 196 |
], |
| 197 |
], |
| 198 |
[ |
| 199 |
'text' => esc_html__( 'List Item #3', 'elementor' ), |
| 200 |
'selected_icon' => [ |
| 201 |
'value' => 'fas fa-dot-circle', |
| 202 |
'library' => 'fa-solid', |
| 203 |
], |
| 204 |
], |
| 205 |
], |
| 206 |
'title_field' => '{{{ elementor.helpers.renderIcon( this, selected_icon, {}, "i", "panel" ) || \'<i class="{{ icon }}" aria-hidden="true"></i>\' }}} {{{ text }}}', |
| 207 |
] |
| 208 |
); |
| 209 |
|
| 210 |
$this->add_control( |
| 211 |
'link_click', |
| 212 |
[ |
| 213 |
'label' => esc_html__( 'Apply Link On', 'elementor' ), |
| 214 |
'type' => Controls_Manager::SELECT, |
| 215 |
'options' => [ |
| 216 |
'full_width' => esc_html__( 'Full Width', 'elementor' ), |
| 217 |
'inline' => esc_html__( 'Inline', 'elementor' ), |
| 218 |
], |
| 219 |
'default' => 'full_width', |
| 220 |
'separator' => 'before', |
| 221 |
'prefix_class' => 'elementor-list-item-link-', |
| 222 |
] |
| 223 |
); |
| 224 |
|
| 225 |
$this->end_controls_section(); |
| 226 |
|
| 227 |
$this->start_controls_section( |
| 228 |
'section_icon_list', |
| 229 |
[ |
| 230 |
'label' => esc_html__( 'List', 'elementor' ), |
| 231 |
'tab' => Controls_Manager::TAB_STYLE, |
| 232 |
] |
| 233 |
); |
| 234 |
|
| 235 |
$this->add_responsive_control( |
| 236 |
'space_between', |
| 237 |
[ |
| 238 |
'label' => esc_html__( 'Space Between', 'elementor' ), |
| 239 |
'type' => Controls_Manager::SLIDER, |
| 240 |
'size_units' => [ 'px', 'em', 'rem', 'custom' ], |
| 241 |
'range' => [ |
| 242 |
'px' => [ |
| 243 |
'max' => 50, |
| 244 |
], |
| 245 |
], |
| 246 |
'selectors' => [ |
| 247 |
'{{WRAPPER}} .elementor-icon-list-items:not(.elementor-inline-items) .elementor-icon-list-item:not(:last-child)' => 'padding-block-end: calc({{SIZE}}{{UNIT}}/2)', |
| 248 |
'{{WRAPPER}} .elementor-icon-list-items:not(.elementor-inline-items) .elementor-icon-list-item:not(:first-child)' => 'margin-block-start: calc({{SIZE}}{{UNIT}}/2)', |
| 249 |
'{{WRAPPER}} .elementor-icon-list-items.elementor-inline-items .elementor-icon-list-item' => 'margin-inline: calc({{SIZE}}{{UNIT}}/2)', |
| 250 |
'{{WRAPPER}} .elementor-icon-list-items.elementor-inline-items' => 'margin-inline: calc(-{{SIZE}}{{UNIT}}/2)', |
| 251 |
'{{WRAPPER}} .elementor-icon-list-items.elementor-inline-items .elementor-icon-list-item:after' => 'inset-inline-end: calc(-{{SIZE}}{{UNIT}}/2)', |
| 252 |
], |
| 253 |
] |
| 254 |
); |
| 255 |
|
| 256 |
$this->add_responsive_control( |
| 257 |
'icon_align', |
| 258 |
[ |
| 259 |
'label' => esc_html__( 'Alignment', 'elementor' ), |
| 260 |
'type' => Controls_Manager::CHOOSE, |
| 261 |
'options' => [ |
| 262 |
'start' => [ |
| 263 |
'title' => esc_html__( 'Start', 'elementor' ), |
| 264 |
'icon' => 'eicon-h-align-left', |
| 265 |
], |
| 266 |
'center' => [ |
| 267 |
'title' => esc_html__( 'Center', 'elementor' ), |
| 268 |
'icon' => 'eicon-h-align-center', |
| 269 |
], |
| 270 |
'end' => [ |
| 271 |
'title' => esc_html__( 'End', 'elementor' ), |
| 272 |
'icon' => 'eicon-h-align-right', |
| 273 |
], |
| 274 |
], |
| 275 |
'classes_dictionary' => [ |
| 276 |
'left' => is_rtl() ? 'end' : 'start', |
| 277 |
'right' => is_rtl() ? 'start' : 'end', |
| 278 |
], |
| 279 |
'prefix_class' => 'elementor%s-align-', |
| 280 |
'classes' => 'elementor-control-start-end', |
| 281 |
] |
| 282 |
); |
| 283 |
|
| 284 |
$this->add_control( |
| 285 |
'divider', |
| 286 |
[ |
| 287 |
'label' => esc_html__( 'Divider', 'elementor' ), |
| 288 |
'type' => Controls_Manager::SWITCHER, |
| 289 |
'label_off' => esc_html__( 'Off', 'elementor' ), |
| 290 |
'label_on' => esc_html__( 'On', 'elementor' ), |
| 291 |
'selectors' => [ |
| 292 |
'{{WRAPPER}} .elementor-icon-list-item:not(:last-child):after' => 'content: ""', |
| 293 |
], |
| 294 |
'separator' => 'before', |
| 295 |
] |
| 296 |
); |
| 297 |
|
| 298 |
$this->add_control( |
| 299 |
'divider_style', |
| 300 |
[ |
| 301 |
'label' => esc_html__( 'Style', 'elementor' ), |
| 302 |
'type' => Controls_Manager::SELECT, |
| 303 |
'options' => [ |
| 304 |
'solid' => esc_html__( 'Solid', 'elementor' ), |
| 305 |
'double' => esc_html__( 'Double', 'elementor' ), |
| 306 |
'dotted' => esc_html__( 'Dotted', 'elementor' ), |
| 307 |
'dashed' => esc_html__( 'Dashed', 'elementor' ), |
| 308 |
], |
| 309 |
'default' => 'solid', |
| 310 |
'condition' => [ |
| 311 |
'divider' => 'yes', |
| 312 |
], |
| 313 |
'selectors' => [ |
| 314 |
'{{WRAPPER}} .elementor-icon-list-items:not(.elementor-inline-items) .elementor-icon-list-item:not(:last-child):after' => 'border-block-start-style: {{VALUE}}', |
| 315 |
'{{WRAPPER}} .elementor-icon-list-items.elementor-inline-items .elementor-icon-list-item:not(:last-child):after' => 'border-inline-start-style: {{VALUE}}', |
| 316 |
], |
| 317 |
] |
| 318 |
); |
| 319 |
|
| 320 |
$this->add_control( |
| 321 |
'divider_weight', |
| 322 |
[ |
| 323 |
'label' => esc_html__( 'Weight', 'elementor' ), |
| 324 |
'type' => Controls_Manager::SLIDER, |
| 325 |
'size_units' => [ 'px', 'em', 'rem', 'custom' ], |
| 326 |
'default' => [ |
| 327 |
'size' => 1, |
| 328 |
], |
| 329 |
'range' => [ |
| 330 |
'px' => [ |
| 331 |
'min' => 1, |
| 332 |
'max' => 20, |
| 333 |
], |
| 334 |
], |
| 335 |
'condition' => [ |
| 336 |
'divider' => 'yes', |
| 337 |
], |
| 338 |
'selectors' => [ |
| 339 |
'{{WRAPPER}} .elementor-icon-list-items:not(.elementor-inline-items) .elementor-icon-list-item:not(:last-child):after' => 'border-block-start-width: {{SIZE}}{{UNIT}}', |
| 340 |
'{{WRAPPER}} .elementor-inline-items .elementor-icon-list-item:not(:last-child):after' => 'border-inline-start-width: {{SIZE}}{{UNIT}}', |
| 341 |
], |
| 342 |
] |
| 343 |
); |
| 344 |
|
| 345 |
$this->add_control( |
| 346 |
'divider_width', |
| 347 |
[ |
| 348 |
'label' => esc_html__( 'Width', 'elementor' ), |
| 349 |
'type' => Controls_Manager::SLIDER, |
| 350 |
'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ], |
| 351 |
'default' => [ |
| 352 |
'unit' => '%', |
| 353 |
], |
| 354 |
'condition' => [ |
| 355 |
'divider' => 'yes', |
| 356 |
'view!' => 'inline', |
| 357 |
], |
| 358 |
'selectors' => [ |
| 359 |
'{{WRAPPER}} .elementor-icon-list-item:not(:last-child):after' => 'width: {{SIZE}}{{UNIT}}', |
| 360 |
], |
| 361 |
] |
| 362 |
); |
| 363 |
|
| 364 |
$this->add_control( |
| 365 |
'divider_height', |
| 366 |
[ |
| 367 |
'label' => esc_html__( 'Height', 'elementor' ), |
| 368 |
'type' => Controls_Manager::SLIDER, |
| 369 |
'size_units' => [ 'px', '%', 'em', 'rem', 'vh', 'custom' ], |
| 370 |
'default' => [ |
| 371 |
'unit' => '%', |
| 372 |
], |
| 373 |
'range' => [ |
| 374 |
'px' => [ |
| 375 |
'min' => 1, |
| 376 |
'max' => 100, |
| 377 |
], |
| 378 |
'%' => [ |
| 379 |
'min' => 1, |
| 380 |
'max' => 100, |
| 381 |
], |
| 382 |
'vh' => [ |
| 383 |
'min' => 1, |
| 384 |
'max' => 100, |
| 385 |
], |
| 386 |
], |
| 387 |
'condition' => [ |
| 388 |
'divider' => 'yes', |
| 389 |
'view' => 'inline', |
| 390 |
], |
| 391 |
'selectors' => [ |
| 392 |
'{{WRAPPER}} .elementor-icon-list-item:not(:last-child):after' => 'height: {{SIZE}}{{UNIT}}', |
| 393 |
], |
| 394 |
] |
| 395 |
); |
| 396 |
|
| 397 |
$this->add_control( |
| 398 |
'divider_color', |
| 399 |
[ |
| 400 |
'label' => esc_html__( 'Color', 'elementor' ), |
| 401 |
'type' => Controls_Manager::COLOR, |
| 402 |
'default' => '#ddd', |
| 403 |
'global' => [ |
| 404 |
'default' => Global_Colors::COLOR_TEXT, |
| 405 |
], |
| 406 |
'condition' => [ |
| 407 |
'divider' => 'yes', |
| 408 |
], |
| 409 |
'selectors' => [ |
| 410 |
'{{WRAPPER}} .elementor-icon-list-item:not(:last-child):after' => 'border-color: {{VALUE}}', |
| 411 |
], |
| 412 |
] |
| 413 |
); |
| 414 |
|
| 415 |
$this->end_controls_section(); |
| 416 |
|
| 417 |
$this->start_controls_section( |
| 418 |
'section_icon_style', |
| 419 |
[ |
| 420 |
'label' => esc_html__( 'Icon', 'elementor' ), |
| 421 |
'tab' => Controls_Manager::TAB_STYLE, |
| 422 |
] |
| 423 |
); |
| 424 |
|
| 425 |
$this->start_controls_tabs( 'icon_colors' ); |
| 426 |
|
| 427 |
$this->start_controls_tab( |
| 428 |
'icon_colors_normal', |
| 429 |
[ |
| 430 |
'label' => esc_html__( 'Normal', 'elementor' ), |
| 431 |
] |
| 432 |
); |
| 433 |
|
| 434 |
$this->add_control( |
| 435 |
'icon_color', |
| 436 |
[ |
| 437 |
'label' => esc_html__( 'Color', 'elementor' ), |
| 438 |
'type' => Controls_Manager::COLOR, |
| 439 |
'default' => '', |
| 440 |
'selectors' => [ |
| 441 |
'{{WRAPPER}} .elementor-icon-list-icon i' => 'color: {{VALUE}};', |
| 442 |
'{{WRAPPER}} .elementor-icon-list-icon svg' => 'fill: {{VALUE}};', |
| 443 |
], |
| 444 |
'global' => [ |
| 445 |
'default' => Global_Colors::COLOR_PRIMARY, |
| 446 |
], |
| 447 |
] |
| 448 |
); |
| 449 |
|
| 450 |
$this->end_controls_tab(); |
| 451 |
|
| 452 |
$this->start_controls_tab( |
| 453 |
'icon_colors_hover', |
| 454 |
[ |
| 455 |
'label' => esc_html__( 'Hover', 'elementor' ), |
| 456 |
] |
| 457 |
); |
| 458 |
|
| 459 |
$this->add_control( |
| 460 |
'icon_color_hover', |
| 461 |
[ |
| 462 |
'label' => esc_html__( 'Color', 'elementor' ), |
| 463 |
'type' => Controls_Manager::COLOR, |
| 464 |
'default' => '', |
| 465 |
'selectors' => [ |
| 466 |
'{{WRAPPER}} .elementor-icon-list-item:hover .elementor-icon-list-icon i' => 'color: {{VALUE}};', |
| 467 |
'{{WRAPPER}} .elementor-icon-list-item:hover .elementor-icon-list-icon svg' => 'fill: {{VALUE}};', |
| 468 |
], |
| 469 |
] |
| 470 |
); |
| 471 |
|
| 472 |
$this->add_control( |
| 473 |
'icon_color_hover_transition', |
| 474 |
[ |
| 475 |
'label' => esc_html__( 'Transition Duration', 'elementor' ), |
| 476 |
'type' => Controls_Manager::SLIDER, |
| 477 |
'size_units' => [ 's', 'ms', 'custom' ], |
| 478 |
'default' => [ |
| 479 |
'unit' => 's', |
| 480 |
'size' => 0.3, |
| 481 |
], |
| 482 |
'selectors' => [ |
| 483 |
'{{WRAPPER}} .elementor-icon-list-icon i' => 'transition: color {{SIZE}}{{UNIT}}', |
| 484 |
'{{WRAPPER}} .elementor-icon-list-icon svg' => 'transition: fill {{SIZE}}{{UNIT}}', |
| 485 |
], |
| 486 |
] |
| 487 |
); |
| 488 |
|
| 489 |
$this->end_controls_tab(); |
| 490 |
|
| 491 |
$this->end_controls_tabs(); |
| 492 |
|
| 493 |
$this->add_responsive_control( |
| 494 |
'icon_size', |
| 495 |
[ |
| 496 |
'label' => esc_html__( 'Size', 'elementor' ), |
| 497 |
'type' => Controls_Manager::SLIDER, |
| 498 |
'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ], |
| 499 |
'default' => [ |
| 500 |
'size' => 14, |
| 501 |
], |
| 502 |
'range' => [ |
| 503 |
'px' => [ |
| 504 |
'min' => 6, |
| 505 |
], |
| 506 |
'%' => [ |
| 507 |
'min' => 6, |
| 508 |
], |
| 509 |
'vw' => [ |
| 510 |
'min' => 6, |
| 511 |
], |
| 512 |
], |
| 513 |
'separator' => 'before', |
| 514 |
'selectors' => [ |
| 515 |
'{{WRAPPER}}' => '--e-icon-list-icon-size: {{SIZE}}{{UNIT}};', |
| 516 |
], |
| 517 |
] |
| 518 |
); |
| 519 |
|
| 520 |
$this->add_control( |
| 521 |
'text_indent', |
| 522 |
[ |
| 523 |
'label' => esc_html__( 'Gap', 'elementor' ), |
| 524 |
'type' => Controls_Manager::SLIDER, |
| 525 |
'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ], |
| 526 |
'range' => [ |
| 527 |
'px' => [ |
| 528 |
'max' => 50, |
| 529 |
], |
| 530 |
], |
| 531 |
'separator' => 'after', |
| 532 |
'selectors' => [ |
| 533 |
'{{WRAPPER}} .elementor-icon-list-icon' => 'padding-inline-end: {{SIZE}}{{UNIT}};', |
| 534 |
], |
| 535 |
] |
| 536 |
); |
| 537 |
|
| 538 |
$e_icon_list_icon_css_var = 'var(--e-icon-list-icon-size, 1em)'; |
| 539 |
$e_icon_list_icon_align_left = sprintf( '0 calc(%s * 0.25) 0 0', $e_icon_list_icon_css_var ); |
| 540 |
$e_icon_list_icon_align_center = sprintf( '0 calc(%s * 0.125)', $e_icon_list_icon_css_var ); |
| 541 |
$e_icon_list_icon_align_right = sprintf( '0 0 0 calc(%s * 0.25)', $e_icon_list_icon_css_var ); |
| 542 |
|
| 543 |
$this->add_responsive_control( |
| 544 |
'icon_self_align', |
| 545 |
[ |
| 546 |
'label' => esc_html__( 'Horizontal Alignment', 'elementor' ), |
| 547 |
'type' => Controls_Manager::CHOOSE, |
| 548 |
'options' => [ |
| 549 |
'left' => [ |
| 550 |
'title' => esc_html__( 'Left', 'elementor' ), |
| 551 |
'icon' => 'eicon-h-align-left', |
| 552 |
], |
| 553 |
'center' => [ |
| 554 |
'title' => esc_html__( 'Center', 'elementor' ), |
| 555 |
'icon' => 'eicon-h-align-center', |
| 556 |
], |
| 557 |
'right' => [ |
| 558 |
'title' => esc_html__( 'Right', 'elementor' ), |
| 559 |
'icon' => 'eicon-h-align-right', |
| 560 |
], |
| 561 |
], |
| 562 |
'default' => '', |
| 563 |
'selectors_dictionary' => [ |
| 564 |
'left' => sprintf( '--e-icon-list-icon-align: left; --e-icon-list-icon-margin: %s;', $e_icon_list_icon_align_left ), |
| 565 |
'center' => sprintf( '--e-icon-list-icon-align: center; --e-icon-list-icon-margin: %s;', $e_icon_list_icon_align_center ), |
| 566 |
'right' => sprintf( '--e-icon-list-icon-align: right; --e-icon-list-icon-margin: %s;', $e_icon_list_icon_align_right ), |
| 567 |
], |
| 568 |
'selectors' => [ |
| 569 |
'{{WRAPPER}}' => '{{VALUE}}', |
| 570 |
], |
| 571 |
] |
| 572 |
); |
| 573 |
|
| 574 |
$this->add_responsive_control( |
| 575 |
'icon_self_vertical_align', |
| 576 |
[ |
| 577 |
'label' => esc_html__( 'Vertical Alignment', 'elementor' ), |
| 578 |
'type' => Controls_Manager::CHOOSE, |
| 579 |
'options' => [ |
| 580 |
'flex-start' => [ |
| 581 |
'title' => esc_html__( 'Start', 'elementor' ), |
| 582 |
'icon' => 'eicon-v-align-top', |
| 583 |
], |
| 584 |
'center' => [ |
| 585 |
'title' => esc_html__( 'Center', 'elementor' ), |
| 586 |
'icon' => 'eicon-v-align-middle', |
| 587 |
], |
| 588 |
'flex-end' => [ |
| 589 |
'title' => esc_html__( 'End', 'elementor' ), |
| 590 |
'icon' => 'eicon-v-align-bottom', |
| 591 |
], |
| 592 |
], |
| 593 |
'default' => '', |
| 594 |
'selectors' => [ |
| 595 |
'{{WRAPPER}}' => '--icon-vertical-align: {{VALUE}};', |
| 596 |
], |
| 597 |
] |
| 598 |
); |
| 599 |
|
| 600 |
$this->add_responsive_control( |
| 601 |
'icon_vertical_offset', |
| 602 |
[ |
| 603 |
'label' => esc_html__( 'Adjust Vertical Position', 'elementor' ), |
| 604 |
'type' => Controls_Manager::SLIDER, |
| 605 |
'size_units' => [ 'px', 'em', 'rem', 'custom' ], |
| 606 |
'default' => [ |
| 607 |
'size' => 0, |
| 608 |
], |
| 609 |
'range' => [ |
| 610 |
'px' => [ |
| 611 |
'min' => -15, |
| 612 |
'max' => 15, |
| 613 |
], |
| 614 |
'em' => [ |
| 615 |
'min' => -1, |
| 616 |
'max' => 1, |
| 617 |
], |
| 618 |
], |
| 619 |
'selectors' => [ |
| 620 |
'{{WRAPPER}}' => '--icon-vertical-offset: {{SIZE}}{{UNIT}};', |
| 621 |
], |
| 622 |
] |
| 623 |
); |
| 624 |
|
| 625 |
$this->end_controls_section(); |
| 626 |
|
| 627 |
$this->start_controls_section( |
| 628 |
'section_text_style', |
| 629 |
[ |
| 630 |
'label' => esc_html__( 'Text', 'elementor' ), |
| 631 |
'tab' => Controls_Manager::TAB_STYLE, |
| 632 |
] |
| 633 |
); |
| 634 |
|
| 635 |
$this->add_group_control( |
| 636 |
Group_Control_Typography::get_type(), |
| 637 |
[ |
| 638 |
'name' => 'icon_typography', |
| 639 |
'selector' => '{{WRAPPER}} .elementor-icon-list-item > .elementor-icon-list-text, {{WRAPPER}} .elementor-icon-list-item > a', |
| 640 |
'global' => [ |
| 641 |
'default' => Global_Typography::TYPOGRAPHY_TEXT, |
| 642 |
], |
| 643 |
] |
| 644 |
); |
| 645 |
|
| 646 |
$this->add_group_control( |
| 647 |
Group_Control_Text_Shadow::get_type(), |
| 648 |
[ |
| 649 |
'name' => 'text_shadow', |
| 650 |
'selector' => '{{WRAPPER}} .elementor-icon-list-text', |
| 651 |
] |
| 652 |
); |
| 653 |
|
| 654 |
$this->start_controls_tabs( 'text_colors' ); |
| 655 |
|
| 656 |
$this->start_controls_tab( |
| 657 |
'text_colors_normal', |
| 658 |
[ |
| 659 |
'label' => esc_html__( 'Normal', 'elementor' ), |
| 660 |
] |
| 661 |
); |
| 662 |
|
| 663 |
$this->add_control( |
| 664 |
'text_color', |
| 665 |
[ |
| 666 |
'label' => esc_html__( 'Color', 'elementor' ), |
| 667 |
'type' => Controls_Manager::COLOR, |
| 668 |
'default' => '', |
| 669 |
'selectors' => [ |
| 670 |
'{{WRAPPER}} .elementor-icon-list-text' => 'color: {{VALUE}};', |
| 671 |
], |
| 672 |
'global' => [ |
| 673 |
'default' => Global_Colors::COLOR_SECONDARY, |
| 674 |
], |
| 675 |
] |
| 676 |
); |
| 677 |
|
| 678 |
$this->end_controls_tab(); |
| 679 |
|
| 680 |
$this->start_controls_tab( |
| 681 |
'text_colors_hover', |
| 682 |
[ |
| 683 |
'label' => esc_html__( 'Hover', 'elementor' ), |
| 684 |
] |
| 685 |
); |
| 686 |
|
| 687 |
$this->add_control( |
| 688 |
'text_color_hover', |
| 689 |
[ |
| 690 |
'label' => esc_html__( 'Color', 'elementor' ), |
| 691 |
'type' => Controls_Manager::COLOR, |
| 692 |
'default' => '', |
| 693 |
'selectors' => [ |
| 694 |
'{{WRAPPER}} .elementor-icon-list-item:hover .elementor-icon-list-text' => 'color: {{VALUE}};', |
| 695 |
], |
| 696 |
] |
| 697 |
); |
| 698 |
|
| 699 |
$this->add_control( |
| 700 |
'text_color_hover_transition', |
| 701 |
[ |
| 702 |
'label' => esc_html__( 'Transition Duration', 'elementor' ), |
| 703 |
'type' => Controls_Manager::SLIDER, |
| 704 |
'size_units' => [ 's', 'ms', 'custom' ], |
| 705 |
'default' => [ |
| 706 |
'unit' => 's', |
| 707 |
'size' => 0.3, |
| 708 |
], |
| 709 |
'selectors' => [ |
| 710 |
'{{WRAPPER}} .elementor-icon-list-text' => 'transition: color {{SIZE}}{{UNIT}}', |
| 711 |
], |
| 712 |
] |
| 713 |
); |
| 714 |
|
| 715 |
$this->end_controls_tab(); |
| 716 |
|
| 717 |
$this->end_controls_tabs(); |
| 718 |
|
| 719 |
$this->end_controls_section(); |
| 720 |
} |
| 721 |
|
| 722 |
/** |
| 723 |
* Render icon list widget output on the frontend. |
| 724 |
* |
| 725 |
* Written in PHP and used to generate the final HTML. |
| 726 |
* |
| 727 |
* @since 1.0.0 |
| 728 |
* @access protected |
| 729 |
*/ |
| 730 |
protected function render() { |
| 731 |
$settings = $this->get_settings_for_display(); |
| 732 |
$fallback_defaults = [ |
| 733 |
'fa fa-check', |
| 734 |
'fa fa-times', |
| 735 |
'fa fa-dot-circle-o', |
| 736 |
]; |
| 737 |
|
| 738 |
$this->add_render_attribute( 'icon_list', 'class', 'elementor-icon-list-items' ); |
| 739 |
$this->add_render_attribute( 'list_item', 'class', 'elementor-icon-list-item' ); |
| 740 |
|
| 741 |
if ( 'inline' === $settings['view'] ) { |
| 742 |
$this->add_render_attribute( 'icon_list', 'class', 'elementor-inline-items' ); |
| 743 |
$this->add_render_attribute( 'list_item', 'class', 'elementor-inline-item' ); |
| 744 |
} |
| 745 |
?> |
| 746 |
<ul <?php $this->print_render_attribute_string( 'icon_list' ); ?>> |
| 747 |
<?php |
| 748 |
foreach ( $settings['icon_list'] as $index => $item ) : |
| 749 |
$repeater_setting_key = $this->get_repeater_setting_key( 'text', 'icon_list', $index ); |
| 750 |
|
| 751 |
$this->add_render_attribute( $repeater_setting_key, 'class', 'elementor-icon-list-text' ); |
| 752 |
|
| 753 |
$this->add_inline_editing_attributes( $repeater_setting_key ); |
| 754 |
$migration_allowed = Icons_Manager::is_migration_allowed(); |
| 755 |
?> |
| 756 |
<li <?php $this->print_render_attribute_string( 'list_item' ); ?>> |
| 757 |
<?php |
| 758 |
if ( ! empty( $item['link']['url'] ) ) { |
| 759 |
$link_key = 'link_' . $index; |
| 760 |
|
| 761 |
$this->add_link_attributes( $link_key, $item['link'] ); |
| 762 |
?> |
| 763 |
<a <?php $this->print_render_attribute_string( $link_key ); ?>> |
| 764 |
|
| 765 |
<?php |
| 766 |
} |
| 767 |
|
| 768 |
// add old default |
| 769 |
if ( ! isset( $item['icon'] ) && ! $migration_allowed ) { |
| 770 |
$item['icon'] = isset( $fallback_defaults[ $index ] ) ? $fallback_defaults[ $index ] : 'fa fa-check'; |
| 771 |
} |
| 772 |
|
| 773 |
$migrated = isset( $item['__fa4_migrated']['selected_icon'] ); |
| 774 |
$is_new = ! isset( $item['icon'] ) && $migration_allowed; |
| 775 |
if ( ! empty( $item['icon'] ) || ( ! empty( $item['selected_icon']['value'] ) && $is_new ) ) : |
| 776 |
?> |
| 777 |
<span class="elementor-icon-list-icon"> |
| 778 |
<?php |
| 779 |
if ( $is_new || $migrated ) { |
| 780 |
Icons_Manager::render_icon( $item['selected_icon'], [ 'aria-hidden' => 'true' ] ); |
| 781 |
} else { ?> |
| 782 |
<i class="<?php echo esc_attr( $item['icon'] ); ?>" aria-hidden="true"></i> |
| 783 |
<?php } ?> |
| 784 |
</span> |
| 785 |
<?php endif; ?> |
| 786 |
<span <?php $this->print_render_attribute_string( $repeater_setting_key ); ?>><?php echo wp_kses_post( $item['text'] ); ?></span> |
| 787 |
<?php if ( ! empty( $item['link']['url'] ) ) : ?> |
| 788 |
</a> |
| 789 |
<?php endif; ?> |
| 790 |
</li> |
| 791 |
<?php |
| 792 |
endforeach; |
| 793 |
?> |
| 794 |
</ul> |
| 795 |
<?php |
| 796 |
} |
| 797 |
|
| 798 |
/** |
| 799 |
* Render icon list widget output in the editor. |
| 800 |
* |
| 801 |
* Written as a Backbone JavaScript template and used to generate the live preview. |
| 802 |
* |
| 803 |
* @since 2.9.0 |
| 804 |
* @access protected |
| 805 |
*/ |
| 806 |
public function render_markdown(): string { |
| 807 |
$settings = $this->get_settings_for_display(); |
| 808 |
|
| 809 |
if ( empty( $settings['icon_list'] ) ) { |
| 810 |
return ''; |
| 811 |
} |
| 812 |
|
| 813 |
$lines = []; |
| 814 |
|
| 815 |
foreach ( $settings['icon_list'] as $item ) { |
| 816 |
$text = Utils::html_to_plain_text( $item['text'] ?? '' ); |
| 817 |
|
| 818 |
if ( empty( $text ) ) { |
| 819 |
continue; |
| 820 |
} |
| 821 |
|
| 822 |
if ( ! empty( $item['link']['url'] ) ) { |
| 823 |
$text = '[' . $text . '](' . esc_url( $item['link']['url'] ) . ')'; |
| 824 |
} |
| 825 |
|
| 826 |
$lines[] = '- ' . $text; |
| 827 |
} |
| 828 |
|
| 829 |
return implode( "\n", $lines ); |
| 830 |
} |
| 831 |
|
| 832 |
protected function content_template() { |
| 833 |
?> |
| 834 |
<# |
| 835 |
view.addRenderAttribute( 'icon_list', 'class', 'elementor-icon-list-items' ); |
| 836 |
view.addRenderAttribute( 'list_item', 'class', 'elementor-icon-list-item' ); |
| 837 |
|
| 838 |
if ( 'inline' == settings.view ) { |
| 839 |
view.addRenderAttribute( 'icon_list', 'class', 'elementor-inline-items' ); |
| 840 |
view.addRenderAttribute( 'list_item', 'class', 'elementor-inline-item' ); |
| 841 |
} |
| 842 |
var iconsHTML = {}, |
| 843 |
migrated = {}; |
| 844 |
#> |
| 845 |
<# if ( settings.icon_list ) { #> |
| 846 |
<ul {{{ view.getRenderAttributeString( 'icon_list' ) }}}> |
| 847 |
<# _.each( settings.icon_list, function( item, index ) { |
| 848 |
|
| 849 |
var iconTextKey = view.getRepeaterSettingKey( 'text', 'icon_list', index ); |
| 850 |
|
| 851 |
view.addRenderAttribute( iconTextKey, 'class', 'elementor-icon-list-text' ); |
| 852 |
|
| 853 |
view.addInlineEditingAttributes( iconTextKey ); #> |
| 854 |
|
| 855 |
<li {{{ view.getRenderAttributeString( 'list_item' ) }}}> |
| 856 |
<# if ( item.link && item.link?.url ) { #> |
| 857 |
<a href="{{ elementor.helpers.sanitizeUrl( item.link?.url ) }}"> |
| 858 |
<# } #> |
| 859 |
<# if ( item.icon || item.selected_icon.value ) { #> |
| 860 |
<span class="elementor-icon-list-icon"> |
| 861 |
<# |
| 862 |
iconsHTML[ index ] = elementor.helpers.renderIcon( view, item.selected_icon, { 'aria-hidden': true }, 'i', 'object' ); |
| 863 |
migrated[ index ] = elementor.helpers.isIconMigrated( item, 'selected_icon' ); |
| 864 |
if ( iconsHTML[ index ] && iconsHTML[ index ].rendered && ( ! item.icon || migrated[ index ] ) ) { #> |
| 865 |
{{{ iconsHTML[ index ].value }}} |
| 866 |
<# } else { #> |
| 867 |
<i class="{{ item.icon }}" aria-hidden="true"></i> |
| 868 |
<# } |
| 869 |
#> |
| 870 |
</span> |
| 871 |
<# } #> |
| 872 |
<span {{{ view.getRenderAttributeString( iconTextKey ) }}}>{{{ item.text }}}</span> |
| 873 |
<# if ( item.link && item.link?.url ) { #> |
| 874 |
</a> |
| 875 |
<# } #> |
| 876 |
</li> |
| 877 |
<# |
| 878 |
} ); #> |
| 879 |
</ul> |
| 880 |
<# } #> |
| 881 |
|
| 882 |
<?php |
| 883 |
} |
| 884 |
|
| 885 |
public function on_import( $element ) { |
| 886 |
return Icons_Manager::on_import_migration( $element, 'icon', 'selected_icon', true ); |
| 887 |
} |
| 888 |
} |
| 889 |
|