templates
4 months ago
Accordion.php
9 months ago
Alerts_Box.php
9 months ago
Blog_Grid.php
6 months ago
Cheat_Sheet.php
6 months ago
Counter.php
6 months ago
Dynamic_Faq.php
1 month ago
Icon_Box.php
6 months ago
Integrations.php
6 months ago
List_Item.php
9 months ago
Tabs.php
6 months ago
Team_Carousel.php
6 months ago
Testimonial.php
6 months ago
Timeline.php
9 months ago
Video_Playlist.php
6 months ago
Video_Popup.php
6 months ago
List_Item.php
511 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Use namespace to avoid conflict |
| 4 | */ |
| 5 | |
| 6 | namespace SPEL\Widgets; |
| 7 | |
| 8 | use Elementor\Group_Control_Border; |
| 9 | use Elementor\Group_Control_Box_Shadow; |
| 10 | use Elementor\Repeater; |
| 11 | use Elementor\Widget_Base; |
| 12 | use Elementor\Controls_Manager; |
| 13 | use Elementor\Group_Control_Typography; |
| 14 | |
| 15 | // Exit if accessed directly |
| 16 | if ( ! defined( 'ABSPATH' ) ) { |
| 17 | exit; |
| 18 | } |
| 19 | |
| 20 | |
| 21 | /** |
| 22 | * Class Alerts_box |
| 23 | * |
| 24 | * @package spider\Widgets |
| 25 | * @since 1.0.0 |
| 26 | */ |
| 27 | class List_Item extends Widget_Base { |
| 28 | public function get_name(): string { |
| 29 | return 'docly_list_item'; // ID of the widget (Don't change this name) |
| 30 | } |
| 31 | |
| 32 | public function get_title(): string { |
| 33 | return esc_html__( 'List Items', 'spider-elements' ); |
| 34 | } |
| 35 | |
| 36 | public function get_icon(): string { |
| 37 | return 'eicon-bullet-list spel-icon'; |
| 38 | } |
| 39 | |
| 40 | public function get_keywords(): array { |
| 41 | return [ 'spider', 'spider elements', 'icon list', 'icon', 'list' ]; |
| 42 | } |
| 43 | |
| 44 | public function get_categories(): array { |
| 45 | return [ 'spider-elements' ]; |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Name: get_style_depends() |
| 50 | * Desc: Register the required CSS dependencies for the frontend. |
| 51 | */ |
| 52 | public function get_style_depends(): array { |
| 53 | return [ 'elegant-icon', 'spel-main' ]; |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Name: register_controls() |
| 58 | * Desc: Register controls for these widgets |
| 59 | * Params: no params |
| 60 | * Return: @void |
| 61 | * Since: @1.0.0 |
| 62 | * Package: @spider-elements |
| 63 | * Author: spider-themes |
| 64 | */ |
| 65 | protected function register_controls(): void { |
| 66 | $this->elementor_content_control(); |
| 67 | $this->elementor_style_control(); |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * Name: elementor_content_control() |
| 72 | * Desc: Register the Content Tab output on the Elementor editor. |
| 73 | * Params: no params |
| 74 | * Return: @void |
| 75 | * Since: @1.0.0 |
| 76 | * Package: @spider-elements |
| 77 | * Author: spider-themes |
| 78 | */ |
| 79 | public function elementor_content_control(): void { |
| 80 | |
| 81 | //============================ Icon List ============================// |
| 82 | $this->start_controls_section( |
| 83 | 'section_icon', [ |
| 84 | 'label' => esc_html__( 'Icon List', 'spider-elements' ), |
| 85 | ] |
| 86 | ); |
| 87 | |
| 88 | $this->add_control( |
| 89 | 'style', [ |
| 90 | 'label' => esc_html__( 'List Order', 'spider-elements' ), |
| 91 | 'type' => Controls_Manager::SELECT, |
| 92 | 'options' => [ |
| 93 | 'unordered_list' => esc_html__( 'Unordered List', 'spider-elements' ), |
| 94 | 'order_list' => esc_html__( 'Ordered List', 'spider-elements' ), |
| 95 | ], |
| 96 | 'default' => 'unordered_list', |
| 97 | ] |
| 98 | ); |
| 99 | |
| 100 | $this->add_control( |
| 101 | 'list_icon', [ |
| 102 | 'label' => esc_html__( 'Icon', 'spider-elements' ), |
| 103 | 'type' => \Elementor\Controls_Manager::ICONS, |
| 104 | 'default' => [ |
| 105 | 'value' => 'fas fa-circle', |
| 106 | 'library' => 'fa-solid', |
| 107 | ], |
| 108 | 'condition' => [ |
| 109 | 'style' => 'unordered_list', // Only show when "Unordered List" is selected |
| 110 | ], |
| 111 | ] |
| 112 | ); |
| 113 | |
| 114 | // Add control for an ordered list type |
| 115 | $this->add_control( |
| 116 | 'order_type', [ |
| 117 | 'label' => esc_html__( 'Order Type', 'spider-elements' ), |
| 118 | 'type' => Controls_Manager::SELECT, |
| 119 | 'options' => [ |
| 120 | 'numeric' => esc_html__( 'Numeric', 'spider-elements' ), |
| 121 | 'alpha' => esc_html__( 'Alphabetic', 'spider-elements' ), |
| 122 | 'roman' => esc_html__( 'Roman Numerals', 'spider-elements' ), |
| 123 | ], |
| 124 | 'default' => 'numeric', |
| 125 | 'condition' => [ |
| 126 | 'style' => 'order_list', // Only show when "Ordered List" is selected |
| 127 | ], |
| 128 | ] |
| 129 | ); |
| 130 | |
| 131 | $repeater = new Repeater(); |
| 132 | $repeater->add_control( |
| 133 | 'text', [ |
| 134 | 'label' => esc_html__( 'Title', 'spider-elements' ), |
| 135 | 'type' => Controls_Manager::TEXT, |
| 136 | 'label_block' => true, |
| 137 | 'default' => esc_html__( 'List Item', 'spider-elements' ), |
| 138 | 'dynamic' => [ |
| 139 | 'active' => true, |
| 140 | ], |
| 141 | ] |
| 142 | ); |
| 143 | |
| 144 | $this->add_control( |
| 145 | 'ul_icon_list', [ |
| 146 | 'label' => 'Icon List', |
| 147 | 'type' => Controls_Manager::REPEATER, |
| 148 | 'fields' => $repeater->get_controls(), |
| 149 | 'title_field' => '{{{ text }}}', |
| 150 | 'prevent_empty' => false, |
| 151 | 'default' => [ |
| 152 | [ 'text' => esc_html__( 'List Item 1', 'spider-elements' ) ], |
| 153 | [ 'text' => esc_html__( 'List Item 2', 'spider-elements' ) ], |
| 154 | [ 'text' => esc_html__( 'List Item 3', 'spider-elements' ) ], |
| 155 | ], |
| 156 | ] |
| 157 | ); |
| 158 | |
| 159 | $this->end_controls_section(); // End Icon List |
| 160 | |
| 161 | } |
| 162 | |
| 163 | |
| 164 | /** |
| 165 | * Name: elementor_style_control() |
| 166 | * Desc: Register the Style Tab output on the Elementor editor. |
| 167 | * Params: no params |
| 168 | * Return: @void |
| 169 | * Since: @1.0.0 |
| 170 | * Package: @spider-elements |
| 171 | * Author: spider-themes |
| 172 | */ |
| 173 | public function elementor_style_control(): void { |
| 174 | |
| 175 | //============================ List Item ============================// |
| 176 | $this->start_controls_section( |
| 177 | 'section_icon_list', [ |
| 178 | 'label' => esc_html__( 'List', 'spider-elements' ), |
| 179 | 'tab' => Controls_Manager::TAB_STYLE, |
| 180 | ] |
| 181 | ); |
| 182 | |
| 183 | $this->add_responsive_control( |
| 184 | 'space_between', [ |
| 185 | 'label' => esc_html__( 'Space Between', 'spider-elements' ), |
| 186 | 'type' => Controls_Manager::SLIDER, |
| 187 | 'range' => [ |
| 188 | 'px' => [ |
| 189 | 'max' => 100, |
| 190 | ], |
| 191 | ], |
| 192 | 'selectors' => [ |
| 193 | '{{WRAPPER}} .spel-steps-panel .item-list li' => 'margin-top: {{SIZE}}{{UNIT}}; margin-bottom: {{SIZE}}{{UNIT}}', |
| 194 | ], |
| 195 | ] |
| 196 | ); |
| 197 | |
| 198 | $this->add_responsive_control( |
| 199 | 'text_indent', [ |
| 200 | 'label' => esc_html__( 'Text Indent', 'spider-elements' ), |
| 201 | 'type' => Controls_Manager::SLIDER, |
| 202 | 'range' => [ |
| 203 | 'px' => [ |
| 204 | 'max' => 100, |
| 205 | ], |
| 206 | ], |
| 207 | 'selectors' => [ |
| 208 | '{{WRAPPER}} .spel-steps-panel .item-list li' => is_rtl() ? 'padding-right: {{SIZE}}{{UNIT}};' : 'padding-left: {{SIZE}}{{UNIT}};', |
| 209 | ], |
| 210 | ] |
| 211 | ); |
| 212 | |
| 213 | $this->add_responsive_control( |
| 214 | 'icon_align', [ |
| 215 | 'label' => esc_html__( 'Alignment', 'spider-elements' ), |
| 216 | 'type' => Controls_Manager::CHOOSE, |
| 217 | 'separator' => 'after', |
| 218 | 'options' => [ |
| 219 | 'start' => [ |
| 220 | 'title' => esc_html__( 'Left', 'spider-elements' ), |
| 221 | 'icon' => 'eicon-h-align-left', |
| 222 | ], |
| 223 | 'center' => [ |
| 224 | 'title' => esc_html__( 'Center', 'spider-elements' ), |
| 225 | 'icon' => 'eicon-h-align-center', |
| 226 | ], |
| 227 | 'end' => [ |
| 228 | 'title' => esc_html__( 'Right', 'spider-elements' ), |
| 229 | 'icon' => 'eicon-h-align-right', |
| 230 | ], |
| 231 | ], |
| 232 | 'selectors' => [ |
| 233 | '{{WRAPPER}} .spel-steps-panel' => 'justify-content: {{VALUE}};', |
| 234 | ], |
| 235 | ] |
| 236 | ); |
| 237 | |
| 238 | $this->add_group_control( |
| 239 | Group_Control_Typography::get_type(), [ |
| 240 | 'name' => 'content_typography', |
| 241 | 'selector' => '{{WRAPPER}} .spel-steps-panel .item-list li', |
| 242 | ] |
| 243 | ); |
| 244 | |
| 245 | $this->add_control( |
| 246 | 'text_color', [ |
| 247 | 'label' => esc_html__( 'Text Color', 'spider-elements' ), |
| 248 | 'type' => Controls_Manager::COLOR, |
| 249 | 'default' => '', |
| 250 | 'selectors' => [ |
| 251 | '{{WRAPPER}} .spel-steps-panel .item-list li' => 'color: {{VALUE}};', |
| 252 | ], |
| 253 | ] |
| 254 | ); |
| 255 | |
| 256 | $this->end_controls_section(); // End List |
| 257 | |
| 258 | |
| 259 | //============================ Style Icon ============================// |
| 260 | $this->start_controls_section( |
| 261 | 'style_icon', [ |
| 262 | 'label' => esc_html__( 'Icon', 'spider-elements' ), |
| 263 | 'tab' => Controls_Manager::TAB_STYLE, |
| 264 | ] |
| 265 | ); |
| 266 | |
| 267 | $this->add_control( |
| 268 | 'icon_color', [ |
| 269 | 'label' => esc_html__( 'Color', 'spider-elements' ), |
| 270 | 'type' => Controls_Manager::COLOR, |
| 271 | 'default' => '', |
| 272 | 'selectors' => [ |
| 273 | '{{WRAPPER}} .item-list li .icon i' => 'color: {{VALUE}};', |
| 274 | '{{WRAPPER}} .item-list li .icon svg' => 'fill: {{VALUE}};', |
| 275 | '{{WRAPPER}} .spel-steps-panel .ordered li::before' => 'color: {{VALUE}};', |
| 276 | '{{WRAPPER}} .spel-steps-panel .ordered.alpha li::before' => 'color: {{VALUE}};', |
| 277 | '{{WRAPPER}} .spel-steps-panel .ordered.roman li::before' => 'color: {{VALUE}};', |
| 278 | ], |
| 279 | ] |
| 280 | ); |
| 281 | |
| 282 | $this->add_control( |
| 283 | 'icon_bg_color', [ |
| 284 | 'label' => esc_html__( 'Background', 'spider-elements' ), |
| 285 | 'type' => Controls_Manager::COLOR, |
| 286 | 'default' => '', |
| 287 | 'selectors' => [ |
| 288 | '{{WRAPPER}} .item-list li .icon' => 'background: {{VALUE}};', |
| 289 | '{{WRAPPER}} .spel-steps-panel .ordered li::before' => 'background: {{VALUE}};', |
| 290 | ], |
| 291 | ] |
| 292 | ); |
| 293 | |
| 294 | $this->add_control( |
| 295 | 'icon_divider_color', [ |
| 296 | 'label' => esc_html__( 'Divider Color', 'spider-elements' ), |
| 297 | 'type' => Controls_Manager::COLOR, |
| 298 | 'default' => '', |
| 299 | 'selectors' => [ |
| 300 | '{{WRAPPER}} .item-list::after' => 'background: {{VALUE}};', |
| 301 | ], |
| 302 | ] |
| 303 | ); |
| 304 | |
| 305 | $this->add_responsive_control( |
| 306 | 'icon_divider_position', [ |
| 307 | 'label' => esc_html__( 'Divider Position', 'spider-elements' ), |
| 308 | 'type' => Controls_Manager::SLIDER, |
| 309 | 'range' => [ |
| 310 | 'px' => [ |
| 311 | 'min' => 0, |
| 312 | 'max' => 100, |
| 313 | ], |
| 314 | ], |
| 315 | 'selectors' => [ |
| 316 | '{{WRAPPER}} .spel-steps-panel .item-list::after' => 'left: {{SIZE}}{{UNIT}};', |
| 317 | ], |
| 318 | ] |
| 319 | ); |
| 320 | |
| 321 | $this->add_responsive_control( |
| 322 | 'icon_size', [ |
| 323 | 'label' => esc_html__( 'Size', 'spider-elements' ), |
| 324 | 'type' => Controls_Manager::SLIDER, |
| 325 | 'range' => [ |
| 326 | 'px' => [ |
| 327 | 'min' => 6, |
| 328 | ], |
| 329 | ], |
| 330 | 'selectors' => [ |
| 331 | '{{WRAPPER}} .item-list li .icon i' => 'font-size: {{SIZE}}{{UNIT}};', |
| 332 | '{{WRAPPER}} .ordered li::before' => 'font-size: {{SIZE}}{{UNIT}};', |
| 333 | ], |
| 334 | ] |
| 335 | ); |
| 336 | |
| 337 | $this->add_responsive_control( |
| 338 | 'icon_bg_size', [ |
| 339 | 'label' => esc_html__( 'Background Size', 'spider-elements' ), |
| 340 | 'type' => Controls_Manager::SLIDER, |
| 341 | 'range' => [ |
| 342 | 'px' => [ |
| 343 | 'min' => 6, |
| 344 | ], |
| 345 | ], |
| 346 | 'selectors' => [ |
| 347 | '{{WRAPPER}} .item-list li .icon' => 'width:{{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};', |
| 348 | '{{WRAPPER}} .ordered li::before' => 'width:{{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};', |
| 349 | ], |
| 350 | ] |
| 351 | ); |
| 352 | |
| 353 | $this->add_responsive_control( |
| 354 | 'icon_line_height', [ |
| 355 | 'label' => esc_html__( 'Line Height', 'spider-elements' ), |
| 356 | 'type' => Controls_Manager::SLIDER, |
| 357 | 'range' => [ |
| 358 | 'px' => [ |
| 359 | 'min' => 6, |
| 360 | ], |
| 361 | ], |
| 362 | 'selectors' => [ |
| 363 | '{{WRAPPER}} .item-list li' => 'line-height: {{SIZE}}{{UNIT}};', |
| 364 | ], |
| 365 | ] |
| 366 | ); |
| 367 | |
| 368 | $this->end_controls_section(); // End Style Icon |
| 369 | |
| 370 | |
| 371 | //============================ Style Background ============================// |
| 372 | $this->start_controls_section( |
| 373 | 'style_icon_box', [ |
| 374 | 'label' => esc_html__( 'Box Container', 'spider-elements' ), |
| 375 | 'tab' => Controls_Manager::TAB_STYLE, |
| 376 | ] |
| 377 | ); |
| 378 | |
| 379 | $this->add_group_control( |
| 380 | Group_Control_Box_Shadow::get_type(), [ |
| 381 | 'name' => 'box_shadow', |
| 382 | 'selector' => '{{WRAPPER}} .spel-steps-panel', |
| 383 | ] |
| 384 | ); |
| 385 | |
| 386 | $this->add_responsive_control( |
| 387 | 'box_padding', [ |
| 388 | 'label' => esc_html__( 'Padding', 'spider-elements' ), |
| 389 | 'type' => Controls_Manager::DIMENSIONS, |
| 390 | 'size_units' => [ 'px', '%', 'em' ], |
| 391 | 'selectors' => [ |
| 392 | '{{WRAPPER}} .spel-steps-panel' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 393 | ], |
| 394 | 'default' => [ |
| 395 | 'unit' => 'px', // The selected CSS Unit. 'px', '%', 'em', |
| 396 | ], |
| 397 | ] |
| 398 | ); |
| 399 | |
| 400 | $this->add_group_control( |
| 401 | Group_Control_Border::get_type(), [ |
| 402 | 'name' => 'border', |
| 403 | 'label' => esc_html__( 'Border', 'spider-elements' ), |
| 404 | 'selector' => '{{WRAPPER}} .spel-steps-panel', |
| 405 | 'separator' => 'before', |
| 406 | ] |
| 407 | ); |
| 408 | |
| 409 | $this->add_control( |
| 410 | 'border_radius', [ |
| 411 | 'label' => esc_html__( 'Border Radius', 'spider-elements' ), |
| 412 | 'type' => Controls_Manager::DIMENSIONS, |
| 413 | 'size_units' => [ 'px', '%' ], |
| 414 | 'selectors' => [ |
| 415 | '{{WRAPPER}} .spel-steps-panel' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 416 | ], |
| 417 | ] |
| 418 | ); |
| 419 | |
| 420 | $this->add_group_control( |
| 421 | \Elementor\Group_Control_Background::get_type(), |
| 422 | [ |
| 423 | 'name' => 'box_bg_color', |
| 424 | 'types' => [ 'classic', 'gradient' ], |
| 425 | 'selector' => '{{WRAPPER}} .spel-steps-panel', |
| 426 | ] |
| 427 | ); |
| 428 | |
| 429 | $this->end_controls_section(); // End Style Background |
| 430 | |
| 431 | } |
| 432 | |
| 433 | |
| 434 | /** |
| 435 | * Name: elementor_render() |
| 436 | * Desc: Render the widget output on the frontend. |
| 437 | * Params: no params |
| 438 | * Return: @void |
| 439 | * Since: @1.0.0 |
| 440 | * Package: @spider-elements |
| 441 | * Author: spider-themes |
| 442 | */ |
| 443 | protected function render(): void { |
| 444 | |
| 445 | $settings = $this->get_settings_for_display(); |
| 446 | $icon_list = $settings['ul_icon_list'] ?? ''; |
| 447 | $order_type = $settings['order_type'] ?? ''; |
| 448 | $style = $settings['style'] ?? 'order_list'; |
| 449 | |
| 450 | // Determine list class |
| 451 | $list_class = ''; |
| 452 | if ( $style === 'order_list' ) { |
| 453 | $list_class = match ( $order_type ) { |
| 454 | 'alpha' => ' alpha', |
| 455 | 'roman' => ' roman', |
| 456 | default => '', |
| 457 | }; |
| 458 | } |
| 459 | |
| 460 | if ( $settings['style'] == 'unordered_list' ) { |
| 461 | ?> |
| 462 | <div class="spel-steps-panel"> |
| 463 | <ul class="item-list unordered"> |
| 464 | <?php |
| 465 | if ( ! empty( $icon_list ) ) { |
| 466 | foreach ( $icon_list as $item ) { |
| 467 | if ( ! empty( $item['text'] ) ) { ?> |
| 468 | <li class="elementor-repeater-item-<?php echo esc_attr( $item['_id'] ); ?>"> |
| 469 | <?php |
| 470 | if ( ! empty( $settings['list_icon']['value'] ) ) { ?> |
| 471 | <span class="icon"> |
| 472 | <?php \Elementor\Icons_Manager::render_icon( $settings['list_icon'] ); ?> |
| 473 | </span> |
| 474 | <?php |
| 475 | } |
| 476 | echo esc_html( $item['text'] ); |
| 477 | |
| 478 | ?> |
| 479 | </li> |
| 480 | <?php |
| 481 | } |
| 482 | } |
| 483 | } |
| 484 | ?> |
| 485 | </ul> |
| 486 | </div> |
| 487 | <?php |
| 488 | } elseif ( $settings['style'] == 'order_list' ) { |
| 489 | ?> |
| 490 | <div class="spel-steps-panel"> |
| 491 | <ol class="item-list ordered<?php echo esc_attr( $list_class ); ?> ?>"> |
| 492 | <?php |
| 493 | if ( ! empty( $icon_list ) ) { |
| 494 | foreach ( $icon_list as $item ) { |
| 495 | if ( ! empty( $item['text'] ) ) { ?> |
| 496 | <li class="elementor-repeater-item-<?php echo esc_attr( $item['_id'] ); ?>"> |
| 497 | <?php echo esc_html( $item['text'] ) ?> |
| 498 | </li> |
| 499 | <?php |
| 500 | } |
| 501 | } |
| 502 | } |
| 503 | ?> |
| 504 | </ol> |
| 505 | </div> |
| 506 | <?php |
| 507 | } |
| 508 | |
| 509 | } |
| 510 | } |
| 511 |