social-share.php
757 lines
| 1 | <?php |
| 2 | namespace Elementor; |
| 3 | |
| 4 | use \Elementor\ElementsKit_Widget_Social_Share_Handler as Handler; |
| 5 | use \ElementsKit_Lite\Modules\Controls\Controls_Manager as ElementsKit_Controls_Manager; |
| 6 | |
| 7 | if ( ! defined( 'ABSPATH' ) ) exit; |
| 8 | |
| 9 | |
| 10 | class ElementsKit_Widget_Social_Share extends Widget_Base { |
| 11 | use \ElementsKit_Lite\Widgets\Widget_Notice; |
| 12 | |
| 13 | public $base; |
| 14 | |
| 15 | public function get_script_depends() { |
| 16 | return ['goodshare']; |
| 17 | } |
| 18 | |
| 19 | public function get_name() { |
| 20 | return Handler::get_name(); |
| 21 | } |
| 22 | |
| 23 | public function get_title() { |
| 24 | return Handler::get_title(); |
| 25 | } |
| 26 | |
| 27 | public function get_icon() { |
| 28 | return Handler::get_icon(); |
| 29 | } |
| 30 | |
| 31 | public function get_categories() { |
| 32 | return Handler::get_categories(); |
| 33 | } |
| 34 | |
| 35 | public function get_keywords() { |
| 36 | return Handler::get_keywords(); |
| 37 | } |
| 38 | |
| 39 | public function get_help_url() { |
| 40 | return 'https://wpmet.com/doc/social-share/'; |
| 41 | } |
| 42 | |
| 43 | public function get_style_depends() { |
| 44 | return ['ekit-social-share']; |
| 45 | } |
| 46 | |
| 47 | protected function is_dynamic_content(): bool { |
| 48 | return false; |
| 49 | } |
| 50 | |
| 51 | protected function register_controls() { |
| 52 | |
| 53 | // start content section for social media |
| 54 | $this->start_controls_section( |
| 55 | 'ekit_socialshare_section_tab_content', |
| 56 | [ |
| 57 | 'label' => esc_html__('Social Media', 'elementskit-lite'), |
| 58 | ] |
| 59 | ); |
| 60 | |
| 61 | $this->add_control( |
| 62 | 'ekit_socialshare_style', |
| 63 | [ |
| 64 | 'label' => esc_html__( 'Choose Style', 'elementskit-lite' ), |
| 65 | 'type' => Controls_Manager::SELECT, |
| 66 | 'default' => 'icon', |
| 67 | 'options' => [ |
| 68 | 'icon' => esc_html__( 'Icon', 'elementskit-lite' ), |
| 69 | 'text' => esc_html__( 'Text', 'elementskit-lite' ), |
| 70 | 'both' => esc_html__( 'Both', 'elementskit-lite' ), |
| 71 | ], |
| 72 | ] |
| 73 | ); |
| 74 | |
| 75 | $this->add_control( |
| 76 | 'ekit_socialshare_style_icon_position', |
| 77 | [ |
| 78 | 'label' => esc_html__( 'Icon Position', 'elementskit-lite' ), |
| 79 | 'type' => Controls_Manager::SELECT, |
| 80 | 'default' => 'before', |
| 81 | 'options' => [ |
| 82 | 'before' => esc_html__( 'Before', 'elementskit-lite' ), |
| 83 | 'after' => esc_html__( 'After', 'elementskit-lite' ), |
| 84 | ], |
| 85 | 'condition' => [ |
| 86 | 'ekit_socialshare_style' => 'both' |
| 87 | ] |
| 88 | ] |
| 89 | ); |
| 90 | |
| 91 | $this->add_responsive_control( |
| 92 | 'ekit_socialshare_icon_padding_right', |
| 93 | [ |
| 94 | 'label' => esc_html__( 'Spacing Right', 'elementskit-lite' ), |
| 95 | 'type' => Controls_Manager::SLIDER, |
| 96 | 'size_units' => [ 'px' ], |
| 97 | 'range' => [ |
| 98 | 'px' => [ |
| 99 | 'min' => 5, |
| 100 | 'max' => 100, |
| 101 | 'step' => 1, |
| 102 | ], |
| 103 | ], |
| 104 | 'default' => [ |
| 105 | 'unit' => 'px', |
| 106 | 'size' => 5, |
| 107 | ], |
| 108 | 'selectors' => [ |
| 109 | '{{WRAPPER}} a > i' => 'padding-right: {{SIZE}}{{UNIT}};', |
| 110 | ], |
| 111 | 'condition' => [ |
| 112 | 'ekit_socialshare_style' => 'both', |
| 113 | 'ekit_socialshare_style_icon_position' => 'before', |
| 114 | ] |
| 115 | ] |
| 116 | ); |
| 117 | |
| 118 | $this->add_responsive_control( |
| 119 | 'ekit_socialshare_icon_padding_left', |
| 120 | [ |
| 121 | 'label' => esc_html__( 'Spacing Left', 'elementskit-lite' ), |
| 122 | 'type' => Controls_Manager::SLIDER, |
| 123 | 'size_units' => [ 'px' ], |
| 124 | 'range' => [ |
| 125 | 'px' => [ |
| 126 | 'min' => 5, |
| 127 | 'max' => 100, |
| 128 | 'step' => 1, |
| 129 | ], |
| 130 | ], |
| 131 | 'default' => [ |
| 132 | 'unit' => 'px', |
| 133 | 'size' => 5, |
| 134 | ], |
| 135 | 'selectors' => [ |
| 136 | '{{WRAPPER}} a > i' => 'padding-left: {{SIZE}}{{UNIT}};', |
| 137 | ], |
| 138 | 'condition' => [ |
| 139 | 'ekit_socialshare_style' => 'both', |
| 140 | 'ekit_socialshare_style_icon_position' => 'after', |
| 141 | ] |
| 142 | ] |
| 143 | ); |
| 144 | |
| 145 | $this->add_responsive_control( |
| 146 | 'ekit_socialshare_list_align', |
| 147 | [ |
| 148 | 'label' => esc_html__( 'Alignment', 'elementskit-lite' ), |
| 149 | 'type' => Controls_Manager::CHOOSE, |
| 150 | 'options' => [ |
| 151 | 'left' => [ |
| 152 | 'title' => esc_html__( 'Left', 'elementskit-lite' ), |
| 153 | 'icon' => 'eicon-text-align-left', |
| 154 | ], |
| 155 | 'center' => [ |
| 156 | 'title' => esc_html__( 'Center', 'elementskit-lite' ), |
| 157 | 'icon' => 'eicon-text-align-center', |
| 158 | ], |
| 159 | 'right' => [ |
| 160 | 'title' => esc_html__( 'Right', 'elementskit-lite' ), |
| 161 | 'icon' => 'eicon-text-align-right', |
| 162 | ], |
| 163 | ], |
| 164 | 'default' => 'center', |
| 165 | 'toggle' => true, |
| 166 | 'selectors' => [ |
| 167 | '{{WRAPPER}} .ekit_socialshare' => 'text-align: {{VALUE}};', |
| 168 | ], |
| 169 | ] |
| 170 | ); |
| 171 | |
| 172 | $socialshare = new Repeater(); |
| 173 | |
| 174 | // set social icon |
| 175 | $socialshare->add_control( |
| 176 | 'ekit_socialshare_icons', |
| 177 | [ |
| 178 | 'label' => esc_html__( 'Icon', 'elementskit-lite' ), |
| 179 | 'label_block' => true, |
| 180 | 'fa4compatibility' => 'ekit_socialshare_icon', |
| 181 | 'type' => Controls_Manager::ICONS, |
| 182 | 'default' => [ |
| 183 | 'value' => 'icon icon-facebook', |
| 184 | 'library' => 'ekiticons', |
| 185 | ], |
| 186 | ] |
| 187 | ); |
| 188 | |
| 189 | // set social link |
| 190 | $socialshare->add_control( |
| 191 | 'ekit_socialshare_label_text', |
| 192 | [ |
| 193 | 'label' => esc_html__( 'Social Media', 'elementskit-lite' ), |
| 194 | 'type' => Controls_Manager::SELECT, |
| 195 | 'default' => 'facebook', |
| 196 | 'options' => [ |
| 197 | 'facebook' => esc_html__( 'Facebook', 'elementskit-lite' ), |
| 198 | 'twitter' => esc_html__( 'Twitter', 'elementskit-lite' ), |
| 199 | 'pinterest' => esc_html__( 'Pinterest', 'elementskit-lite' ), |
| 200 | 'linkedin' => esc_html__( 'Linkedin', 'elementskit-lite' ), |
| 201 | 'tumblr' => esc_html__( 'Tumblr', 'elementskit-lite' ), |
| 202 | // 'snapchat' => esc_html__( 'Snapchat', 'elementskit-lite' ), |
| 203 | 'flicker' => esc_html__( 'Flicker', 'elementskit-lite' ), |
| 204 | 'vkontakte' => esc_html__( 'Vkontakte', 'elementskit-lite' ), |
| 205 | 'odnoklassniki' => esc_html__( 'Odnoklassniki', 'elementskit-lite' ), |
| 206 | 'moimir' => esc_html__( 'Moimir', 'elementskit-lite' ), |
| 207 | 'live journal' => esc_html__( 'Live journal', 'elementskit-lite' ), |
| 208 | 'blogger' => esc_html__( 'Blogger', 'elementskit-lite' ), |
| 209 | 'digg' => esc_html__( 'Digg', 'elementskit-lite' ), |
| 210 | 'evernote' => esc_html__( 'Evernote', 'elementskit-lite' ), |
| 211 | 'reddit' => esc_html__( 'Reddit', 'elementskit-lite' ), |
| 212 | 'delicious' => esc_html__( 'Delicious', 'elementskit-lite' ), |
| 213 | 'stumbleupon' => esc_html__( 'Stumbleupon', 'elementskit-lite' ), |
| 214 | 'pocket' => esc_html__( 'Pocket', 'elementskit-lite' ), |
| 215 | 'surfingbird' => esc_html__( 'Surfingbird', 'elementskit-lite' ), |
| 216 | 'liveinternet' => esc_html__( 'Liveinternet', 'elementskit-lite' ), |
| 217 | 'buffer' => esc_html__( 'Buffer', 'elementskit-lite' ), |
| 218 | 'instapaper' => esc_html__( 'Instapaper', 'elementskit-lite' ), |
| 219 | 'xing' => esc_html__( 'Xing', 'elementskit-lite' ), |
| 220 | 'wordpress' => esc_html__( 'WordPress', 'elementskit-lite' ), |
| 221 | 'baidu' => esc_html__( 'Baidu', 'elementskit-lite' ), |
| 222 | 'renren' => esc_html__( 'Renren', 'elementskit-lite' ), |
| 223 | 'weibo' => esc_html__( 'Weibo', 'elementskit-lite' ), |
| 224 | 'skype' => esc_html__( 'Skype', 'elementskit-lite' ), |
| 225 | 'telegram' => esc_html__( 'Telegram', 'elementskit-lite' ), |
| 226 | 'viber' => esc_html__( 'Viber', 'elementskit-lite' ), |
| 227 | 'whatsapp' => esc_html__( 'Whatsapp', 'elementskit-lite' ), |
| 228 | 'line' => esc_html__( 'Line', 'elementskit-lite' ), |
| 229 | ], |
| 230 | ] |
| 231 | ); |
| 232 | |
| 233 | // set social icon label |
| 234 | $socialshare->add_control( |
| 235 | 'ekit_socialshare_label', |
| 236 | [ |
| 237 | 'label' => esc_html__( 'Label', 'elementskit-lite' ), |
| 238 | 'type' => Controls_Manager::TEXT, |
| 239 | 'dynamic' => [ |
| 240 | 'active' => true, |
| 241 | ], |
| 242 | ] |
| 243 | ); |
| 244 | |
| 245 | // start tab for content |
| 246 | $socialshare->start_controls_tabs( |
| 247 | 'ekit_socialshare_tabs' |
| 248 | ); |
| 249 | |
| 250 | // start normal tab |
| 251 | $socialshare->start_controls_tab( |
| 252 | 'ekit_socialshare_normal', |
| 253 | [ |
| 254 | 'label' => esc_html__( 'Normal', 'elementskit-lite' ), |
| 255 | ] |
| 256 | ); |
| 257 | |
| 258 | // set social icon color |
| 259 | $socialshare->add_responsive_control( |
| 260 | 'ekit_socialshare_icon_color', |
| 261 | [ |
| 262 | 'label' =>esc_html__( 'Color', 'elementskit-lite' ), |
| 263 | 'type' => Controls_Manager::COLOR, |
| 264 | 'default' => '#222222', |
| 265 | 'selectors' => [ |
| 266 | '{{WRAPPER}} {{CURRENT_ITEM}} > div' => 'color: {{VALUE}};', |
| 267 | '{{WRAPPER}} {{CURRENT_ITEM}} > div svg' => 'fill: {{VALUE}};', |
| 268 | ], |
| 269 | ] |
| 270 | ); |
| 271 | |
| 272 | // set social icon background color |
| 273 | $socialshare->add_responsive_control( |
| 274 | 'ekit_socialshare_icon_bg_color', |
| 275 | [ |
| 276 | 'label' =>esc_html__( 'Background Color', 'elementskit-lite' ), |
| 277 | 'type' => Controls_Manager::COLOR, |
| 278 | 'selectors' => [ |
| 279 | '{{WRAPPER}} {{CURRENT_ITEM}} > div' => 'background-color: {{VALUE}};', |
| 280 | ], |
| 281 | ] |
| 282 | ); |
| 283 | |
| 284 | $socialshare->add_group_control( |
| 285 | Group_Control_Border::get_type(), |
| 286 | [ |
| 287 | 'name' => 'ekit_socialshare_border', |
| 288 | 'label' => esc_html__( 'Border', 'elementskit-lite' ), |
| 289 | 'selector' => '{{WRAPPER}} {{CURRENT_ITEM}} > div', |
| 290 | ] |
| 291 | ); |
| 292 | |
| 293 | $socialshare->add_group_control( |
| 294 | Group_Control_Text_Shadow::get_type(), |
| 295 | [ |
| 296 | 'name' => 'ekit_socialshare_icon_normal_text_shadow', |
| 297 | 'label' => esc_html__( 'Text Shadow', 'elementskit-lite' ), |
| 298 | 'selector' => '{{WRAPPER}} {{CURRENT_ITEM}} > div', |
| 299 | ] |
| 300 | ); |
| 301 | |
| 302 | $socialshare->add_group_control( |
| 303 | Group_Control_Box_Shadow::get_type(), [ |
| 304 | 'name' => 'ekit_socialshare_list_box_shadow', |
| 305 | 'selector' => '{{WRAPPER}} {{CURRENT_ITEM}} > div', |
| 306 | ] |
| 307 | ); |
| 308 | |
| 309 | $socialshare->end_controls_tab(); |
| 310 | // end normal tab |
| 311 | |
| 312 | //start hover tab |
| 313 | $socialshare->start_controls_tab( |
| 314 | 'ekit_socialshare_hover', |
| 315 | [ |
| 316 | 'label' => esc_html__( 'Hover', 'elementskit-lite' ), |
| 317 | ] |
| 318 | ); |
| 319 | |
| 320 | // set social icon color |
| 321 | $socialshare->add_responsive_control( |
| 322 | 'ekit_socialshare_icon_hover_color', |
| 323 | [ |
| 324 | 'label' =>esc_html__( 'Color', 'elementskit-lite' ), |
| 325 | 'type' => Controls_Manager::COLOR, |
| 326 | 'selectors' => [ |
| 327 | '{{WRAPPER}} {{CURRENT_ITEM}} > div:hover' => 'color: {{VALUE}};', |
| 328 | '{{WRAPPER}} {{CURRENT_ITEM}} > div:hover svg' => 'fill: {{VALUE}};' |
| 329 | ], |
| 330 | ] |
| 331 | ); |
| 332 | |
| 333 | // set social icon background color |
| 334 | $socialshare->add_responsive_control( |
| 335 | 'ekit_socialshare_icon_hover_bg_color', |
| 336 | [ |
| 337 | 'label' =>esc_html__( 'Background Color', 'elementskit-lite' ), |
| 338 | 'type' => Controls_Manager::COLOR, |
| 339 | 'default' => '#3b5998', |
| 340 | 'selectors' => [ |
| 341 | '{{WRAPPER}} {{CURRENT_ITEM}} > div:hover' => 'background-color: {{VALUE}};', |
| 342 | ], |
| 343 | ] |
| 344 | ); |
| 345 | |
| 346 | |
| 347 | $socialshare->add_group_control( |
| 348 | Group_Control_Text_Shadow::get_type(), |
| 349 | [ |
| 350 | 'name' => 'ekit_socialshare_icon_hover_text_shadow', |
| 351 | 'label' => esc_html__( 'Text Shadow', 'elementskit-lite' ), |
| 352 | 'selector' => '{{WRAPPER}} {{CURRENT_ITEM}} > div:hover', |
| 353 | ] |
| 354 | ); |
| 355 | |
| 356 | $socialshare->add_group_control( |
| 357 | Group_Control_Box_Shadow::get_type(), [ |
| 358 | 'name' => 'ekit_socialshare_list_box_shadow_hover', |
| 359 | 'selector' => '{{WRAPPER}} {{CURRENT_ITEM}} > div:hover', |
| 360 | ] |
| 361 | ); |
| 362 | |
| 363 | $socialshare->add_group_control( |
| 364 | Group_Control_Border::get_type(), |
| 365 | [ |
| 366 | 'name' => 'ekit_socialshare_border_hover', |
| 367 | 'label' => esc_html__( 'Border', 'elementskit-lite' ), |
| 368 | 'selector' => '{{WRAPPER}} {{CURRENT_ITEM}} > div:hover', |
| 369 | ] |
| 370 | ); |
| 371 | |
| 372 | $socialshare->end_controls_tab(); |
| 373 | //end hover tab |
| 374 | |
| 375 | $socialshare->end_controls_tabs(); |
| 376 | |
| 377 | |
| 378 | // set social icon add new control |
| 379 | $this->add_control( |
| 380 | 'ekit_socialshare_add_icons', |
| 381 | [ |
| 382 | 'label' => esc_html__('Add Social Media', 'elementskit-lite'), |
| 383 | 'type' => Controls_Manager::REPEATER, |
| 384 | 'fields' => $socialshare->get_controls(), |
| 385 | 'default' => [ |
| 386 | [ |
| 387 | 'ekit_socialshare_icons' => [ |
| 388 | 'value' => 'icon icon-facebook', |
| 389 | 'library' => 'ekiticons' |
| 390 | ], |
| 391 | 'ekit_socialshare_icon_hover_bg_color' => '#3b5998', |
| 392 | 'ekit_socialshare_label_text' => 'facebook', |
| 393 | ], |
| 394 | [ |
| 395 | 'ekit_socialshare_icons' => [ |
| 396 | 'value' => 'icon icon-twitter', |
| 397 | 'library' => 'ekiticons' |
| 398 | ], |
| 399 | 'ekit_socialshare_icon_hover_bg_color' => '#1da1f2', |
| 400 | 'ekit_socialshare_label_text' => 'twitter', |
| 401 | ], |
| 402 | [ |
| 403 | 'ekit_socialshare_icons' => [ |
| 404 | 'value' => 'icon icon-linkedin', |
| 405 | 'library' => 'ekiticons' |
| 406 | ], |
| 407 | 'ekit_socialshare_icon_hover_bg_color' => '#0077b5', |
| 408 | 'ekit_socialshare_label_text' => 'linkedin', |
| 409 | ], |
| 410 | ], |
| 411 | 'title_field' => '{{{ ekit_socialshare_label_text }}}', |
| 412 | |
| 413 | ] |
| 414 | ); |
| 415 | |
| 416 | $this->end_controls_section(); |
| 417 | // end content section |
| 418 | |
| 419 | // start style section control |
| 420 | |
| 421 | // start Social media tab |
| 422 | $this->start_controls_section( |
| 423 | 'ekit_socialshare_section_tab_style', |
| 424 | [ |
| 425 | 'label' => esc_html__('Social Media', 'elementskit-lite'), |
| 426 | 'tab' => Controls_Manager::TAB_STYLE, |
| 427 | ] |
| 428 | ); |
| 429 | // Alignment |
| 430 | $this->add_responsive_control( |
| 431 | 'ekit_socialshare_list_item_align', |
| 432 | [ |
| 433 | 'label' => esc_html__( 'Alignment', 'elementskit-lite' ), |
| 434 | 'type' => Controls_Manager::CHOOSE, |
| 435 | 'options' => [ |
| 436 | 'left' => [ |
| 437 | 'title' => esc_html__( 'Left', 'elementskit-lite' ), |
| 438 | 'icon' => 'eicon-text-align-left', |
| 439 | ], |
| 440 | 'center' => [ |
| 441 | 'title' => esc_html__( 'Center', 'elementskit-lite' ), |
| 442 | 'icon' => 'eicon-text-align-center', |
| 443 | ], |
| 444 | 'right' => [ |
| 445 | 'title' => esc_html__( 'Right', 'elementskit-lite' ), |
| 446 | 'icon' => 'eicon-text-align-right', |
| 447 | ], |
| 448 | ], |
| 449 | 'default' => 'center', |
| 450 | 'toggle' => true, |
| 451 | 'selectors' => [ |
| 452 | '{{WRAPPER}} .ekit_socialshare > li > div' => 'text-align: {{VALUE}};', |
| 453 | ], |
| 454 | ] |
| 455 | ); |
| 456 | |
| 457 | // Display design |
| 458 | $this->add_responsive_control( |
| 459 | 'ekit_socialshare_list_display', |
| 460 | [ |
| 461 | 'label' => esc_html__( 'Display', 'elementskit-lite' ), |
| 462 | 'type' => Controls_Manager::SELECT, |
| 463 | 'default' => 'inline-block', |
| 464 | 'options' => [ |
| 465 | 'inline-block' => esc_html__( 'Inline Block', 'elementskit-lite' ), |
| 466 | 'block' => esc_html__( 'Block', 'elementskit-lite' ), |
| 467 | ], |
| 468 | 'selectors' => [ |
| 469 | '{{WRAPPER}} .ekit_socialshare > li' => 'display: {{VALUE}};', |
| 470 | ], |
| 471 | ] |
| 472 | ); |
| 473 | |
| 474 | // text decoration |
| 475 | $this->add_responsive_control( |
| 476 | 'ekit_socialshare_list_decoration_box', |
| 477 | [ |
| 478 | 'label' => esc_html__( 'Decoration', 'elementskit-lite' ), |
| 479 | 'type' => Controls_Manager::SELECT, |
| 480 | 'default' => 'none', |
| 481 | 'options' => [ |
| 482 | 'none' => esc_html__( 'None', 'elementskit-lite' ), |
| 483 | 'underline' => esc_html__( 'Underline', 'elementskit-lite' ), |
| 484 | 'overline' => esc_html__( 'Overline', 'elementskit-lite' ), |
| 485 | 'line-through' => esc_html__( 'Line Through', 'elementskit-lite' ), |
| 486 | |
| 487 | ], |
| 488 | 'selectors' => ['{{WRAPPER}} .ekit_socialshare > li > div' => 'text-decoration: {{VALUE}};'], |
| 489 | ] |
| 490 | ); |
| 491 | |
| 492 | // border radius |
| 493 | $this->add_responsive_control( |
| 494 | 'ekit_socialshare_list_border_radius', |
| 495 | [ |
| 496 | 'label' => esc_html__( 'Border radius', 'elementskit-lite' ), |
| 497 | 'type' => Controls_Manager::DIMENSIONS, |
| 498 | 'size_units' => [ 'px', '%', 'em' ], |
| 499 | 'default' => [ |
| 500 | 'top' => '50', |
| 501 | 'right' => '50', |
| 502 | 'bottom' => '50' , |
| 503 | 'left' => '50', |
| 504 | 'unit' => '%', |
| 505 | ], |
| 506 | 'selectors' => [ |
| 507 | '{{WRAPPER}} .ekit_socialshare > li > div' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 508 | ], |
| 509 | ] |
| 510 | ); |
| 511 | |
| 512 | $this->add_control( |
| 513 | 'ekit_socialshare_list_style_use_height_and_width', |
| 514 | [ |
| 515 | 'label' => esc_html__( 'Use Height Width', 'elementskit-lite' ), |
| 516 | 'type' => Controls_Manager::SWITCHER, |
| 517 | 'label_on' => esc_html__( 'Show', 'elementskit-lite' ), |
| 518 | 'label_off' => esc_html__( 'Hide', 'elementskit-lite' ), |
| 519 | 'return_value' => 'yes', |
| 520 | 'default' => 'yes', |
| 521 | ] |
| 522 | ); |
| 523 | |
| 524 | $this->add_responsive_control( |
| 525 | 'ekit_socialshare_list_item_width', |
| 526 | [ |
| 527 | 'label' => esc_html__( 'Width', 'elementskit-lite' ), |
| 528 | 'type' => Controls_Manager::SLIDER, |
| 529 | 'size_units' => [ 'px' ], |
| 530 | 'default' => [ |
| 531 | 'unit' => 'px', |
| 532 | 'size' => 40, |
| 533 | ], |
| 534 | 'range' => [ |
| 535 | 'px' => [ |
| 536 | 'min' => 0, |
| 537 | 'max' => 200 |
| 538 | ], |
| 539 | ], |
| 540 | 'selectors' => [ |
| 541 | '{{WRAPPER}} .ekit_socialshare > li > div' => 'width: {{SIZE}}{{UNIT}};', |
| 542 | ], |
| 543 | 'condition' => [ |
| 544 | 'ekit_socialshare_list_style_use_height_and_width' => 'yes', |
| 545 | 'ekit_socialshare_style' => 'icon', |
| 546 | ] |
| 547 | ] |
| 548 | ); |
| 549 | |
| 550 | $this->add_responsive_control( |
| 551 | 'ekit_socialshare_list_item_height', |
| 552 | [ |
| 553 | 'label' => esc_html__( 'Height', 'elementskit-lite' ), |
| 554 | 'type' => Controls_Manager::SLIDER, |
| 555 | 'size_units' => [ 'px' ], |
| 556 | 'default' => [ |
| 557 | 'unit' => 'px', |
| 558 | 'size' => 40, |
| 559 | ], |
| 560 | 'range' => [ |
| 561 | 'px' => [ |
| 562 | 'min' => 0, |
| 563 | 'max' => 200 |
| 564 | ], |
| 565 | ], |
| 566 | 'selectors' => [ |
| 567 | '{{WRAPPER}} .ekit_socialshare > li > div' => 'height: {{SIZE}}{{UNIT}}; cursor: pointer;', |
| 568 | ], |
| 569 | 'condition' => [ |
| 570 | 'ekit_socialshare_list_style_use_height_and_width' => 'yes', |
| 571 | 'ekit_socialshare_style' => 'icon', |
| 572 | ] |
| 573 | ] |
| 574 | ); |
| 575 | |
| 576 | $this->add_responsive_control( |
| 577 | 'ekit_socialshare_list_line_height', |
| 578 | [ |
| 579 | 'label' => esc_html__( 'Line Height', 'elementskit-lite' ), |
| 580 | 'type' => Controls_Manager::SLIDER, |
| 581 | 'size_units' => [ 'px', '%' ], |
| 582 | 'range' => [ |
| 583 | 'px' => [ |
| 584 | 'min' => 0, |
| 585 | 'max' => 200, |
| 586 | 'step' => 1, |
| 587 | ], |
| 588 | '%' => [ |
| 589 | 'min' => 0, |
| 590 | 'max' => 100, |
| 591 | ], |
| 592 | ], |
| 593 | 'default' => [ |
| 594 | 'unit' => 'px', |
| 595 | 'size' => 40, |
| 596 | ], |
| 597 | 'selectors' => [ |
| 598 | '{{WRAPPER}} .ekit_socialshare > li > div' => 'line-height: {{SIZE}}{{UNIT}};', |
| 599 | ], |
| 600 | 'condition' => [ |
| 601 | 'ekit_socialshare_list_style_use_height_and_width' => 'yes' |
| 602 | ] |
| 603 | ] |
| 604 | ); |
| 605 | |
| 606 | $this->add_responsive_control( |
| 607 | 'ekit_socialshare_list_icon_size', |
| 608 | [ |
| 609 | 'label' => esc_html__( 'Icon Size', 'elementskit-lite' ), |
| 610 | 'type' => Controls_Manager::SLIDER, |
| 611 | 'size_units' => [ 'px', '%' ], |
| 612 | 'range' => [ |
| 613 | 'px' => [ |
| 614 | 'min' => 1, |
| 615 | 'max' => 100, |
| 616 | 'step' => 5, |
| 617 | ], |
| 618 | '%' => [ |
| 619 | 'min' => 1, |
| 620 | 'max' => 100, |
| 621 | ], |
| 622 | ], |
| 623 | 'selectors' => [ |
| 624 | '{{WRAPPER}} .ekit_socialshare > li > div i' => 'font-size: {{SIZE}}{{UNIT}};', |
| 625 | '{{WRAPPER}} .ekit_socialshare > li > div svg' => 'max-width: {{SIZE}}{{UNIT}};', |
| 626 | ], |
| 627 | ] |
| 628 | ); |
| 629 | |
| 630 | $this->add_group_control( |
| 631 | Group_Control_Typography::get_type(), |
| 632 | [ |
| 633 | 'name' => 'ekit_socialshare_list_typography', |
| 634 | 'label' => esc_html__( 'Typography', 'elementskit-lite' ), |
| 635 | 'selector' => '{{WRAPPER}} .ekit_socialshare > li > div', |
| 636 | ] |
| 637 | ); |
| 638 | |
| 639 | |
| 640 | // margin style |
| 641 | |
| 642 | $this->add_responsive_control( |
| 643 | 'ekit_socialshare_list_margin', |
| 644 | [ |
| 645 | 'label' => esc_html__('Margin', 'elementskit-lite'), |
| 646 | 'type' => Controls_Manager::DIMENSIONS, |
| 647 | 'size_units' => ['px', 'em'], |
| 648 | 'default' => [ |
| 649 | 'top' => '5', |
| 650 | 'right' => '5', |
| 651 | 'bottom' => '5' , |
| 652 | 'left' => '5', |
| 653 | ], |
| 654 | 'selectors' => [ |
| 655 | '{{WRAPPER}} .ekit_socialshare > li' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 656 | ], |
| 657 | ] |
| 658 | ); |
| 659 | |
| 660 | $this->add_responsive_control( |
| 661 | 'ekit_socialshare_list_padding', |
| 662 | [ |
| 663 | 'label' => esc_html__('Padding', 'elementskit-lite'), |
| 664 | 'type' => Controls_Manager::DIMENSIONS, |
| 665 | 'size_units' => ['px', 'em'], |
| 666 | 'selectors' => [ |
| 667 | '{{WRAPPER}} .ekit_socialshare > li div' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 668 | ], |
| 669 | ] |
| 670 | ); |
| 671 | |
| 672 | $this->end_controls_section(); |
| 673 | |
| 674 | $this->insert_pro_message(); |
| 675 | } |
| 676 | |
| 677 | protected function render( ) { |
| 678 | echo '<div class="ekit-wid-con" >'; |
| 679 | $this->render_raw(); |
| 680 | echo '</div>'; |
| 681 | } |
| 682 | |
| 683 | protected function render_raw( ) { |
| 684 | $settings = $this->get_settings(); |
| 685 | extract($settings); |
| 686 | ?> |
| 687 | <ul class="ekit_socialshare"> |
| 688 | <?php foreach ($ekit_socialshare_add_icons as $icon): |
| 689 | |
| 690 | if($icon['ekit_socialshare_label_text'] == 'instagram') { |
| 691 | continue; |
| 692 | } |
| 693 | |
| 694 | if($icon['ekit_socialshare_icons'] != ''): ?> |
| 695 | <li class="elementor-repeater-item-<?php echo esc_attr( $icon[ '_id' ] ); ?>" data-social="<?php echo esc_attr((preg_replace('/[#$%^&*()+=\-\[\]\';,.\/{}|":<>?~\\\\ ]/', '', strtolower($icon['ekit_socialshare_label_text']))))?>"> |
| 696 | <?php |
| 697 | // Human-readable network name for the accessible label. |
| 698 | $ekit_share_network = ( '' !== $icon['ekit_socialshare_label'] ) |
| 699 | ? $icon['ekit_socialshare_label'] |
| 700 | : ucwords( preg_replace('/[#$%^&*()+=\-\[\]\';,.\/{}|":<>?~\\\\]/', ' ', $icon['ekit_socialshare_label_text']) ); |
| 701 | /* translators: %s: social network name (e.g. Facebook). */ |
| 702 | $ekit_share_label = sprintf( esc_attr__( 'Share on %s', 'elementskit-lite' ), $ekit_share_network ); |
| 703 | ?> |
| 704 | <div class="<?php echo esc_attr((preg_replace('/[#$%^&*()+=\-\[\]\';,.\/{}|":<>?~\\\\ ]/', '', strtolower($icon['ekit_socialshare_label_text']))))?>"> |
| 705 | <?php // Keyboard-operable share control; reset to inherit the wrapping div in social-share.scss. ?> |
| 706 | <button type="button" aria-label="<?php echo esc_attr( $ekit_share_label ); ?>"> |
| 707 | <?php if($settings['ekit_socialshare_style'] != 'text' && $settings['ekit_socialshare_style_icon_position'] == 'before'): ?> |
| 708 | |
| 709 | <?php |
| 710 | // new icon |
| 711 | $migrated = isset( $icon['__fa4_migrated']['ekit_socialshare_icons'] ); |
| 712 | // Check if its a new widget without previously selected icon using the old Icon control |
| 713 | $is_new = empty( $icon['ekit_socialshare_icon'] ); |
| 714 | if ( $is_new || $migrated ) { |
| 715 | // new icon |
| 716 | Icons_Manager::render_icon( $icon['ekit_socialshare_icons'], [ 'aria-hidden' => 'true' ] ); |
| 717 | } else { |
| 718 | ?> |
| 719 | <i class="<?php echo esc_attr($icon['ekit_socialshare_icon']); ?>" aria-hidden="true"></i> |
| 720 | <?php |
| 721 | } |
| 722 | ?> |
| 723 | |
| 724 | <?php endif; ?> |
| 725 | <?php if($settings['ekit_socialshare_style'] != 'icon' ): ?> |
| 726 | <?php if ($icon['ekit_socialshare_label'] == '') : ?> |
| 727 | <?php echo esc_html(preg_replace('/[#$%^&*()+=\-\[\]\';,.\/{}|":<>?~\\\\]/', ' ', ucwords($icon['ekit_socialshare_label_text'])));?> |
| 728 | <?php else : ?> |
| 729 | <?php echo esc_html($icon['ekit_socialshare_label'])?> |
| 730 | <?php endif; ?> |
| 731 | <?php endif; ?> |
| 732 | <?php if($settings['ekit_socialshare_style'] != 'text' && $settings['ekit_socialshare_style_icon_position'] == 'after'): ?> |
| 733 | <?php |
| 734 | // new icon |
| 735 | $migrated = isset( $icon['__fa4_migrated']['ekit_socialshare_icons'] ); |
| 736 | // Check if its a new widget without previously selected icon using the old Icon control |
| 737 | $is_new = empty( $icon['ekit_socialshare_icon'] ); |
| 738 | if ( $is_new || $migrated ) { |
| 739 | // new icon |
| 740 | Icons_Manager::render_icon( $icon['ekit_socialshare_icons'], [ 'aria-hidden' => 'true' ] ); |
| 741 | } else { |
| 742 | ?> |
| 743 | <i class="<?php echo esc_attr($icon['ekit_socialshare_icon']); ?>" aria-hidden="true"></i> |
| 744 | <?php |
| 745 | } |
| 746 | ?> |
| 747 | <?php endif; ?> |
| 748 | </button> |
| 749 | </div> |
| 750 | </li> |
| 751 | <?php endif; ?> |
| 752 | <?php endforeach; ?> |
| 753 | </ul> |
| 754 | <?php |
| 755 | } |
| 756 | } |
| 757 |