traits
5 months ago
accordion.php
10 months ago
alert.php
10 months ago
audio.php
1 year ago
button.php
10 months ago
common-base.php
8 months ago
common-optimized.php
1 year ago
common.php
1 year ago
counter.php
5 months ago
divider.php
7 months ago
google-maps.php
1 year ago
heading.php
4 months ago
html.php
1 year ago
icon-box.php
5 months ago
icon-list.php
5 months ago
icon.php
5 months ago
image-box.php
5 months ago
image-carousel.php
5 months ago
image-gallery.php
5 months ago
image.php
5 months ago
inner-section.php
2 years ago
menu-anchor.php
1 year ago
progress.php
11 months ago
rating.php
10 months ago
read-more.php
1 year ago
shortcode.php
1 year ago
sidebar.php
1 year ago
social-icons.php
2 months ago
spacer.php
1 year ago
star-rating.php
5 months ago
tabs.php
5 months ago
testimonial.php
5 months ago
text-editor.php
5 months ago
toggle.php
10 months ago
video.php
7 months ago
wordpress.php
1 year ago
social-icons.php
717 lines
| 1 | <?php |
| 2 | namespace Elementor; |
| 3 | |
| 4 | if ( ! defined( 'ABSPATH' ) ) { |
| 5 | exit; // Exit if accessed directly. |
| 6 | } |
| 7 | |
| 8 | /** |
| 9 | * Elementor social icons widget. |
| 10 | * |
| 11 | * Elementor widget that displays icons to social pages like Facebook and Twitter. |
| 12 | * |
| 13 | * @since 1.0.0 |
| 14 | */ |
| 15 | class Widget_Social_Icons extends Widget_Base { |
| 16 | |
| 17 | /** |
| 18 | * Get widget name. |
| 19 | * |
| 20 | * Retrieve social icons widget name. |
| 21 | * |
| 22 | * @since 1.0.0 |
| 23 | * @access public |
| 24 | * |
| 25 | * @return string Widget name. |
| 26 | */ |
| 27 | public function get_name() { |
| 28 | return 'social-icons'; |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * Get widget title. |
| 33 | * |
| 34 | * Retrieve social icons widget title. |
| 35 | * |
| 36 | * @since 1.0.0 |
| 37 | * @access public |
| 38 | * |
| 39 | * @return string Widget title. |
| 40 | */ |
| 41 | public function get_title() { |
| 42 | return esc_html__( 'Social Icons', 'elementor' ); |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * Get widget icon. |
| 47 | * |
| 48 | * Retrieve social icons widget icon. |
| 49 | * |
| 50 | * @since 1.0.0 |
| 51 | * @access public |
| 52 | * |
| 53 | * @return string Widget icon. |
| 54 | */ |
| 55 | public function get_icon() { |
| 56 | return 'eicon-social-icons'; |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * Get widget keywords. |
| 61 | * |
| 62 | * Retrieve the list of keywords the widget belongs to. |
| 63 | * |
| 64 | * @since 2.1.0 |
| 65 | * @access public |
| 66 | * |
| 67 | * @return array Widget keywords. |
| 68 | */ |
| 69 | public function get_keywords() { |
| 70 | return [ 'social', 'icon', 'link' ]; |
| 71 | } |
| 72 | |
| 73 | protected function is_dynamic_content(): bool { |
| 74 | return false; |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * Get style dependencies. |
| 79 | * |
| 80 | * Retrieve the list of style dependencies the widget requires. |
| 81 | * |
| 82 | * @since 3.24.0 |
| 83 | * @access public |
| 84 | * |
| 85 | * @return array Widget style dependencies. |
| 86 | */ |
| 87 | public function get_style_depends(): array { |
| 88 | return [ 'widget-social-icons', 'e-apple-webkit' ]; |
| 89 | } |
| 90 | |
| 91 | public function has_widget_inner_wrapper(): bool { |
| 92 | return ! Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' ); |
| 93 | } |
| 94 | |
| 95 | /** |
| 96 | * Register social icons widget controls. |
| 97 | * |
| 98 | * Adds different input fields to allow the user to change and customize the widget settings. |
| 99 | * |
| 100 | * @since 3.1.0 |
| 101 | * @access protected |
| 102 | */ |
| 103 | protected function register_controls() { |
| 104 | $this->start_controls_section( |
| 105 | 'section_social_icon', |
| 106 | [ |
| 107 | 'label' => esc_html__( 'Social Icons', 'elementor' ), |
| 108 | ] |
| 109 | ); |
| 110 | |
| 111 | $repeater = new Repeater(); |
| 112 | |
| 113 | $repeater->add_control( |
| 114 | 'social_icon', |
| 115 | [ |
| 116 | 'label' => esc_html__( 'Icon', 'elementor' ), |
| 117 | 'type' => Controls_Manager::ICONS, |
| 118 | 'fa4compatibility' => 'social', |
| 119 | 'default' => [ |
| 120 | 'value' => 'fab fa-wordpress', |
| 121 | 'library' => 'fa-brands', |
| 122 | ], |
| 123 | 'recommended' => [ |
| 124 | 'fa-brands' => [ |
| 125 | 'android', |
| 126 | 'apple', |
| 127 | 'behance', |
| 128 | 'bitbucket', |
| 129 | 'codepen', |
| 130 | 'delicious', |
| 131 | 'deviantart', |
| 132 | 'digg', |
| 133 | 'dribbble', |
| 134 | 'elementor', |
| 135 | 'facebook', |
| 136 | 'flickr', |
| 137 | 'foursquare', |
| 138 | 'free-code-camp', |
| 139 | 'github', |
| 140 | 'gitlab', |
| 141 | 'globe', |
| 142 | 'houzz', |
| 143 | 'instagram', |
| 144 | 'jsfiddle', |
| 145 | 'linkedin', |
| 146 | 'medium', |
| 147 | 'meetup', |
| 148 | 'mix', |
| 149 | 'mixcloud', |
| 150 | 'odnoklassniki', |
| 151 | 'pinterest', |
| 152 | 'product-hunt', |
| 153 | 'reddit', |
| 154 | 'shopping-cart', |
| 155 | 'skype', |
| 156 | 'slideshare', |
| 157 | 'snapchat', |
| 158 | 'soundcloud', |
| 159 | 'spotify', |
| 160 | 'stack-overflow', |
| 161 | 'steam', |
| 162 | 'telegram', |
| 163 | 'thumb-tack', |
| 164 | 'threads', |
| 165 | 'tripadvisor', |
| 166 | 'tumblr', |
| 167 | 'twitch', |
| 168 | 'twitter', |
| 169 | 'viber', |
| 170 | 'vimeo', |
| 171 | 'vk', |
| 172 | 'weibo', |
| 173 | 'weixin', |
| 174 | 'whatsapp', |
| 175 | 'wordpress', |
| 176 | 'xing', |
| 177 | 'x-twitter', |
| 178 | 'yelp', |
| 179 | 'youtube', |
| 180 | '500px', |
| 181 | ], |
| 182 | 'fa-solid' => [ |
| 183 | 'envelope', |
| 184 | 'link', |
| 185 | 'rss', |
| 186 | ], |
| 187 | ], |
| 188 | ] |
| 189 | ); |
| 190 | |
| 191 | $repeater->add_control( |
| 192 | 'link', |
| 193 | [ |
| 194 | 'label' => esc_html__( 'Link', 'elementor' ), |
| 195 | 'type' => Controls_Manager::URL, |
| 196 | 'default' => [ |
| 197 | 'is_external' => 'true', |
| 198 | ], |
| 199 | 'dynamic' => [ |
| 200 | 'active' => true, |
| 201 | ], |
| 202 | ] |
| 203 | ); |
| 204 | |
| 205 | $repeater->add_control( |
| 206 | 'item_icon_color', |
| 207 | [ |
| 208 | 'label' => esc_html__( 'Color', 'elementor' ), |
| 209 | 'type' => Controls_Manager::SELECT, |
| 210 | 'default' => 'default', |
| 211 | 'options' => [ |
| 212 | 'default' => esc_html__( 'Official Color', 'elementor' ), |
| 213 | 'custom' => esc_html__( 'Custom', 'elementor' ), |
| 214 | ], |
| 215 | ] |
| 216 | ); |
| 217 | |
| 218 | $repeater->add_control( |
| 219 | 'item_icon_primary_color', |
| 220 | [ |
| 221 | 'label' => esc_html__( 'Primary Color', 'elementor' ), |
| 222 | 'type' => Controls_Manager::COLOR, |
| 223 | 'condition' => [ |
| 224 | 'item_icon_color' => 'custom', |
| 225 | ], |
| 226 | 'selectors' => [ |
| 227 | '{{WRAPPER}} {{CURRENT_ITEM}}.elementor-social-icon' => 'background-color: {{VALUE}};', |
| 228 | ], |
| 229 | ] |
| 230 | ); |
| 231 | |
| 232 | $repeater->add_control( |
| 233 | 'item_icon_secondary_color', |
| 234 | [ |
| 235 | 'label' => esc_html__( 'Secondary Color', 'elementor' ), |
| 236 | 'type' => Controls_Manager::COLOR, |
| 237 | 'condition' => [ |
| 238 | 'item_icon_color' => 'custom', |
| 239 | ], |
| 240 | 'selectors' => [ |
| 241 | '{{WRAPPER}} {{CURRENT_ITEM}}.elementor-social-icon i' => 'color: {{VALUE}};', |
| 242 | '{{WRAPPER}} {{CURRENT_ITEM}}.elementor-social-icon svg' => 'fill: {{VALUE}};', |
| 243 | ], |
| 244 | ] |
| 245 | ); |
| 246 | |
| 247 | $this->add_control( |
| 248 | 'social_icon_list', |
| 249 | [ |
| 250 | 'label' => esc_html__( 'Social Icons', 'elementor' ), |
| 251 | 'type' => Controls_Manager::REPEATER, |
| 252 | 'fields' => $repeater->get_controls(), |
| 253 | 'default' => [ |
| 254 | [ |
| 255 | 'social_icon' => [ |
| 256 | 'value' => 'fab fa-facebook', |
| 257 | 'library' => 'fa-brands', |
| 258 | ], |
| 259 | ], |
| 260 | [ |
| 261 | 'social_icon' => [ |
| 262 | 'value' => 'fab fa-x-twitter', |
| 263 | 'library' => 'fa-brands', |
| 264 | ], |
| 265 | ], |
| 266 | [ |
| 267 | 'social_icon' => [ |
| 268 | 'value' => 'fab fa-youtube', |
| 269 | 'library' => 'fa-brands', |
| 270 | ], |
| 271 | ], |
| 272 | ], |
| 273 | 'title_field' => '<# var migrated = "undefined" !== typeof __fa4_migrated, social = ( "undefined" === typeof social ) ? false : social; #>{{{ elementor.helpers.getSocialNetworkNameFromIcon( social_icon, social, true, migrated, true ) }}}', |
| 274 | ] |
| 275 | ); |
| 276 | |
| 277 | $this->add_control( |
| 278 | 'shape', |
| 279 | [ |
| 280 | 'label' => esc_html__( 'Shape', 'elementor' ), |
| 281 | 'type' => Controls_Manager::SELECT, |
| 282 | 'default' => 'rounded', |
| 283 | 'options' => [ |
| 284 | 'square' => esc_html__( 'Square', 'elementor' ), |
| 285 | 'rounded' => esc_html__( 'Rounded', 'elementor' ), |
| 286 | 'circle' => esc_html__( 'Circle', 'elementor' ), |
| 287 | ], |
| 288 | 'prefix_class' => 'elementor-shape-', |
| 289 | ] |
| 290 | ); |
| 291 | |
| 292 | $this->add_responsive_control( |
| 293 | 'columns', |
| 294 | [ |
| 295 | 'label' => esc_html__( 'Columns', 'elementor' ), |
| 296 | 'type' => Controls_Manager::SELECT, |
| 297 | 'default' => '0', |
| 298 | 'options' => [ |
| 299 | '0' => esc_html__( 'Auto', 'elementor' ), |
| 300 | '1' => '1', |
| 301 | '2' => '2', |
| 302 | '3' => '3', |
| 303 | '4' => '4', |
| 304 | '5' => '5', |
| 305 | '6' => '6', |
| 306 | ], |
| 307 | 'prefix_class' => 'elementor-grid%s-', |
| 308 | 'selectors' => [ |
| 309 | '{{WRAPPER}}' => '--grid-template-columns: repeat({{VALUE}}, auto);', |
| 310 | ], |
| 311 | ] |
| 312 | ); |
| 313 | |
| 314 | $align_selector = Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' ) && ! $this->has_widget_inner_wrapper() |
| 315 | ? '{{WRAPPER}}' |
| 316 | : '{{WRAPPER}} .elementor-widget-container'; |
| 317 | |
| 318 | $this->add_responsive_control( |
| 319 | 'align', |
| 320 | [ |
| 321 | 'label' => esc_html__( 'Alignment', 'elementor' ), |
| 322 | 'type' => Controls_Manager::CHOOSE, |
| 323 | 'options' => [ |
| 324 | 'left' => [ |
| 325 | 'title' => esc_html__( 'Left', 'elementor' ), |
| 326 | 'icon' => 'eicon-text-align-left', |
| 327 | ], |
| 328 | 'center' => [ |
| 329 | 'title' => esc_html__( 'Center', 'elementor' ), |
| 330 | 'icon' => 'eicon-text-align-center', |
| 331 | ], |
| 332 | 'right' => [ |
| 333 | 'title' => esc_html__( 'Right', 'elementor' ), |
| 334 | 'icon' => 'eicon-text-align-right', |
| 335 | ], |
| 336 | ], |
| 337 | 'prefix_class' => 'e-grid-align%s-', |
| 338 | 'default' => 'center', |
| 339 | 'selectors' => [ |
| 340 | $align_selector => 'text-align: {{VALUE}}', |
| 341 | ], |
| 342 | ] |
| 343 | ); |
| 344 | |
| 345 | $this->end_controls_section(); |
| 346 | |
| 347 | $this->start_controls_section( |
| 348 | 'section_social_style', |
| 349 | [ |
| 350 | 'label' => esc_html__( 'Icon', 'elementor' ), |
| 351 | 'tab' => Controls_Manager::TAB_STYLE, |
| 352 | ] |
| 353 | ); |
| 354 | |
| 355 | $this->add_control( |
| 356 | 'icon_color', |
| 357 | [ |
| 358 | 'label' => esc_html__( 'Color', 'elementor' ), |
| 359 | 'type' => Controls_Manager::SELECT, |
| 360 | 'default' => 'default', |
| 361 | 'options' => [ |
| 362 | 'default' => esc_html__( 'Official Color', 'elementor' ), |
| 363 | 'custom' => esc_html__( 'Custom', 'elementor' ), |
| 364 | ], |
| 365 | ] |
| 366 | ); |
| 367 | |
| 368 | $this->add_control( |
| 369 | 'icon_primary_color', |
| 370 | [ |
| 371 | 'label' => esc_html__( 'Primary Color', 'elementor' ), |
| 372 | 'type' => Controls_Manager::COLOR, |
| 373 | 'condition' => [ |
| 374 | 'icon_color' => 'custom', |
| 375 | ], |
| 376 | 'selectors' => [ |
| 377 | '{{WRAPPER}} .elementor-social-icon' => 'background-color: {{VALUE}};', |
| 378 | ], |
| 379 | ] |
| 380 | ); |
| 381 | |
| 382 | $this->add_control( |
| 383 | 'icon_secondary_color', |
| 384 | [ |
| 385 | 'label' => esc_html__( 'Secondary Color', 'elementor' ), |
| 386 | 'type' => Controls_Manager::COLOR, |
| 387 | 'condition' => [ |
| 388 | 'icon_color' => 'custom', |
| 389 | ], |
| 390 | 'selectors' => [ |
| 391 | '{{WRAPPER}} .elementor-social-icon i' => 'color: {{VALUE}};', |
| 392 | '{{WRAPPER}} .elementor-social-icon svg' => 'fill: {{VALUE}};', |
| 393 | ], |
| 394 | ] |
| 395 | ); |
| 396 | |
| 397 | $this->add_responsive_control( |
| 398 | 'icon_size', |
| 399 | [ |
| 400 | 'label' => esc_html__( 'Size', 'elementor' ), |
| 401 | 'type' => Controls_Manager::SLIDER, |
| 402 | // The `%' and `em` units are not supported as the widget implements icons differently then other icons. |
| 403 | 'size_units' => [ 'px', 'rem', 'vw', 'custom' ], |
| 404 | 'range' => [ |
| 405 | 'px' => [ |
| 406 | 'min' => 6, |
| 407 | 'max' => 300, |
| 408 | ], |
| 409 | ], |
| 410 | 'selectors' => [ |
| 411 | '{{WRAPPER}}' => '--icon-size: {{SIZE}}{{UNIT}}', |
| 412 | ], |
| 413 | ] |
| 414 | ); |
| 415 | |
| 416 | $this->add_responsive_control( |
| 417 | 'icon_padding', |
| 418 | [ |
| 419 | 'label' => esc_html__( 'Padding', 'elementor' ), |
| 420 | 'type' => Controls_Manager::SLIDER, |
| 421 | // The `%' unit is not supported. |
| 422 | 'size_units' => [ 'px', 'em', 'rem', 'custom' ], |
| 423 | 'selectors' => [ |
| 424 | '{{WRAPPER}} .elementor-social-icon' => '--icon-padding: {{SIZE}}{{UNIT}}', |
| 425 | ], |
| 426 | 'default' => [ |
| 427 | 'unit' => 'em', |
| 428 | ], |
| 429 | 'tablet_default' => [ |
| 430 | 'unit' => 'em', |
| 431 | ], |
| 432 | 'mobile_default' => [ |
| 433 | 'unit' => 'em', |
| 434 | ], |
| 435 | 'range' => [ |
| 436 | 'px' => [ |
| 437 | 'max' => 50, |
| 438 | ], |
| 439 | 'em' => [ |
| 440 | 'min' => 0, |
| 441 | 'max' => 5, |
| 442 | ], |
| 443 | 'rem' => [ |
| 444 | 'min' => 0, |
| 445 | 'max' => 5, |
| 446 | ], |
| 447 | ], |
| 448 | ] |
| 449 | ); |
| 450 | |
| 451 | $this->add_responsive_control( |
| 452 | 'icon_spacing', |
| 453 | [ |
| 454 | 'label' => esc_html__( 'Spacing', 'elementor' ), |
| 455 | 'type' => Controls_Manager::SLIDER, |
| 456 | 'size_units' => [ 'px', 'em', 'rem', 'custom' ], |
| 457 | 'range' => [ |
| 458 | 'px' => [ |
| 459 | 'max' => 100, |
| 460 | ], |
| 461 | 'em' => [ |
| 462 | 'min' => 0, |
| 463 | 'max' => 10, |
| 464 | ], |
| 465 | 'rem' => [ |
| 466 | 'min' => 0, |
| 467 | 'max' => 10, |
| 468 | ], |
| 469 | ], |
| 470 | 'default' => [ |
| 471 | 'size' => 5, |
| 472 | ], |
| 473 | 'selectors' => [ |
| 474 | '{{WRAPPER}}' => '--grid-column-gap: {{SIZE}}{{UNIT}}', |
| 475 | ], |
| 476 | ] |
| 477 | ); |
| 478 | |
| 479 | $this->add_responsive_control( |
| 480 | 'row_gap', |
| 481 | [ |
| 482 | 'label' => esc_html__( 'Rows Gap', 'elementor' ), |
| 483 | 'type' => Controls_Manager::SLIDER, |
| 484 | 'size_units' => [ 'px', 'em', 'rem', 'custom' ], |
| 485 | 'default' => [ |
| 486 | 'size' => 0, |
| 487 | ], |
| 488 | 'selectors' => [ |
| 489 | '{{WRAPPER}}' => '--grid-row-gap: {{SIZE}}{{UNIT}}', |
| 490 | ], |
| 491 | ] |
| 492 | ); |
| 493 | |
| 494 | $this->add_group_control( |
| 495 | Group_Control_Border::get_type(), |
| 496 | [ |
| 497 | 'name' => 'image_border', // We know this mistake - TODO: 'icon_border' (for hover control condition also) |
| 498 | 'selector' => '{{WRAPPER}} .elementor-social-icon', |
| 499 | 'separator' => 'before', |
| 500 | ] |
| 501 | ); |
| 502 | |
| 503 | $this->add_responsive_control( |
| 504 | 'border_radius', |
| 505 | [ |
| 506 | 'label' => esc_html__( 'Border Radius', 'elementor' ), |
| 507 | 'type' => Controls_Manager::DIMENSIONS, |
| 508 | 'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ], |
| 509 | 'selectors' => [ |
| 510 | '{{WRAPPER}} .elementor-icon' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 511 | ], |
| 512 | ] |
| 513 | ); |
| 514 | |
| 515 | $this->end_controls_section(); |
| 516 | |
| 517 | $this->start_controls_section( |
| 518 | 'section_social_hover', |
| 519 | [ |
| 520 | 'label' => esc_html__( 'Icon Hover', 'elementor' ), |
| 521 | 'tab' => Controls_Manager::TAB_STYLE, |
| 522 | ] |
| 523 | ); |
| 524 | |
| 525 | $this->add_control( |
| 526 | 'hover_primary_color', |
| 527 | [ |
| 528 | 'label' => esc_html__( 'Primary Color', 'elementor' ), |
| 529 | 'type' => Controls_Manager::COLOR, |
| 530 | 'default' => '', |
| 531 | 'condition' => [ |
| 532 | 'icon_color' => 'custom', |
| 533 | ], |
| 534 | 'selectors' => [ |
| 535 | '{{WRAPPER}} .elementor-social-icon:hover' => 'background-color: {{VALUE}};', |
| 536 | ], |
| 537 | ] |
| 538 | ); |
| 539 | |
| 540 | $this->add_control( |
| 541 | 'hover_secondary_color', |
| 542 | [ |
| 543 | 'label' => esc_html__( 'Secondary Color', 'elementor' ), |
| 544 | 'type' => Controls_Manager::COLOR, |
| 545 | 'default' => '', |
| 546 | 'condition' => [ |
| 547 | 'icon_color' => 'custom', |
| 548 | ], |
| 549 | 'selectors' => [ |
| 550 | '{{WRAPPER}} .elementor-social-icon:hover i' => 'color: {{VALUE}};', |
| 551 | '{{WRAPPER}} .elementor-social-icon:hover svg' => 'fill: {{VALUE}};', |
| 552 | ], |
| 553 | ] |
| 554 | ); |
| 555 | |
| 556 | $this->add_control( |
| 557 | 'hover_border_color', |
| 558 | [ |
| 559 | 'label' => esc_html__( 'Border Color', 'elementor' ), |
| 560 | 'type' => Controls_Manager::COLOR, |
| 561 | 'default' => '', |
| 562 | 'condition' => [ |
| 563 | 'image_border_border!' => '', |
| 564 | ], |
| 565 | 'selectors' => [ |
| 566 | '{{WRAPPER}} .elementor-social-icon:hover' => 'border-color: {{VALUE}};', |
| 567 | ], |
| 568 | ] |
| 569 | ); |
| 570 | |
| 571 | $this->add_control( |
| 572 | 'hover_animation', |
| 573 | [ |
| 574 | 'label' => esc_html__( 'Hover Animation', 'elementor' ), |
| 575 | 'type' => Controls_Manager::HOVER_ANIMATION, |
| 576 | ] |
| 577 | ); |
| 578 | |
| 579 | $this->end_controls_section(); |
| 580 | } |
| 581 | |
| 582 | /** |
| 583 | * Render social icons widget output on the frontend. |
| 584 | * |
| 585 | * Written in PHP and used to generate the final HTML. |
| 586 | * |
| 587 | * @since 1.0.0 |
| 588 | * @access protected |
| 589 | */ |
| 590 | protected function render() { |
| 591 | $settings = $this->get_settings_for_display(); |
| 592 | |
| 593 | $this->add_render_attribute( 'wrapper', 'class', [ 'elementor-social-icons-wrapper', 'elementor-grid' ] ); |
| 594 | $this->add_render_attribute( 'item_wrapper', 'class', 'elementor-grid-item' ); |
| 595 | |
| 596 | if ( count( $settings['social_icon_list'] ) > 1 ) { |
| 597 | $this->add_render_attribute( 'wrapper', 'role', 'list' ); |
| 598 | $this->add_render_attribute( 'item_wrapper', 'role', 'listitem' ); |
| 599 | } |
| 600 | |
| 601 | $fallback_defaults = [ |
| 602 | 'fa fa-facebook', |
| 603 | 'fa fa-x-twitter', |
| 604 | 'fa fa-google-plus', |
| 605 | ]; |
| 606 | |
| 607 | $class_animation = ''; |
| 608 | |
| 609 | if ( ! empty( $settings['hover_animation'] ) ) { |
| 610 | $class_animation = ' elementor-animation-' . $settings['hover_animation']; |
| 611 | } |
| 612 | |
| 613 | $migration_allowed = Icons_Manager::is_migration_allowed(); |
| 614 | |
| 615 | ?> |
| 616 | <div <?php $this->print_render_attribute_string( 'wrapper' ); ?>> |
| 617 | <?php |
| 618 | foreach ( $settings['social_icon_list'] as $index => $item ) { |
| 619 | $migrated = isset( $item['__fa4_migrated']['social_icon'] ); |
| 620 | $is_new = empty( $item['social'] ) && $migration_allowed; |
| 621 | $social = ''; |
| 622 | |
| 623 | // add old default |
| 624 | if ( empty( $item['social'] ) && ! $migration_allowed ) { |
| 625 | $item['social'] = isset( $fallback_defaults[ $index ] ) ? $fallback_defaults[ $index ] : 'fa fa-wordpress'; |
| 626 | } |
| 627 | |
| 628 | if ( ! empty( $item['social'] ) ) { |
| 629 | $social = str_replace( 'fa fa-', '', $item['social'] ); |
| 630 | } |
| 631 | |
| 632 | if ( ( $is_new || $migrated ) && 'svg' !== $item['social_icon']['library'] ) { |
| 633 | $social = explode( ' ', $item['social_icon']['value'], 2 ); |
| 634 | if ( empty( $social[1] ) ) { |
| 635 | $social = ''; |
| 636 | } else { |
| 637 | $social = str_replace( 'fa-', '', $social[1] ); |
| 638 | } |
| 639 | } |
| 640 | if ( 'svg' === $item['social_icon']['library'] ) { |
| 641 | $social = get_post_meta( $item['social_icon']['value']['id'], '_wp_attachment_image_alt', true ); |
| 642 | } |
| 643 | |
| 644 | $link_key = 'link_' . $index; |
| 645 | |
| 646 | $this->add_render_attribute( $link_key, 'class', [ |
| 647 | 'elementor-icon', |
| 648 | 'elementor-social-icon', |
| 649 | 'elementor-social-icon-' . $social . $class_animation, |
| 650 | 'elementor-repeater-item-' . $item['_id'], |
| 651 | ] ); |
| 652 | |
| 653 | $this->add_link_attributes( $link_key, $item['link'] ); |
| 654 | |
| 655 | ?> |
| 656 | <span <?php $this->print_render_attribute_string( 'item_wrapper' ); ?>> |
| 657 | <a <?php $this->print_render_attribute_string( $link_key ); ?>> |
| 658 | <span class="elementor-screen-only"><?php echo esc_html( ucwords( $social ) ); ?></span> |
| 659 | <?php |
| 660 | if ( $is_new || $migrated ) { |
| 661 | Icons_Manager::render_icon( $item['social_icon'], [ 'aria-hidden' => 'true' ] ); |
| 662 | } else { ?> |
| 663 | <i class="<?php echo esc_attr( $item['social'] ); ?>" aria-hidden="true"></i> |
| 664 | <?php } ?> |
| 665 | </a> |
| 666 | </span> |
| 667 | <?php } ?> |
| 668 | </div> |
| 669 | <?php |
| 670 | } |
| 671 | |
| 672 | /** |
| 673 | * Render social icons widget output in the editor. |
| 674 | * |
| 675 | * Written as a Backbone JavaScript template and used to generate the live preview. |
| 676 | * |
| 677 | * @since 2.9.0 |
| 678 | * @access protected |
| 679 | */ |
| 680 | protected function content_template() { |
| 681 | ?> |
| 682 | <# |
| 683 | view.addRenderAttribute( 'wrapper', 'class', [ 'elementor-social-icons-wrapper', 'elementor-grid' ] ); |
| 684 | view.addRenderAttribute( 'item_wrapper', 'class', 'elementor-grid-item' ); |
| 685 | |
| 686 | if ( settings.social_icon_list.length > 1 ) { |
| 687 | view.addRenderAttribute( 'wrapper', 'role', 'list' ); |
| 688 | view.addRenderAttribute( 'item_wrapper', 'role', 'listitem' ); |
| 689 | } |
| 690 | |
| 691 | var iconsHTML = {}; |
| 692 | #> |
| 693 | <div {{{ view.getRenderAttributeString( 'wrapper' ) }}}> |
| 694 | <# _.each( settings.social_icon_list, function( item, index ) { |
| 695 | var link = item.link ? item.link.url : '', |
| 696 | migrated = elementor.helpers.isIconMigrated( item, 'social_icon' ); |
| 697 | social = elementor.helpers.getSocialNetworkNameFromIcon( item.social_icon, item.social, false, migrated ); |
| 698 | #> |
| 699 | <span {{{ view.getRenderAttributeString( 'item_wrapper' ) }}}> |
| 700 | <a class="elementor-icon elementor-social-icon elementor-social-icon-{{ social }} elementor-animation-{{ settings.hover_animation }} elementor-repeater-item-{{item._id}}" href="{{ elementor.helpers.sanitizeUrl( link ) }}"> |
| 701 | <span class="elementor-screen-only">{{{ social }}}</span> |
| 702 | <# |
| 703 | iconsHTML[ index ] = elementor.helpers.renderIcon( view, item.social_icon, {}, 'i', 'object' ); |
| 704 | if ( ( ! item.social || migrated ) && iconsHTML[ index ] && iconsHTML[ index ].rendered ) { #> |
| 705 | {{{ iconsHTML[ index ].value }}} |
| 706 | <# } else { #> |
| 707 | <i class="{{ item.social }}"></i> |
| 708 | <# } |
| 709 | #> |
| 710 | </a> |
| 711 | </span> |
| 712 | <# } ); #> |
| 713 | </div> |
| 714 | <?php |
| 715 | } |
| 716 | } |
| 717 |