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