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