button.php
620 lines
| 1 | <?php |
| 2 | namespace Elementor; |
| 3 | |
| 4 | use \Elementor\ElementsKit_Widget_Button_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_Button extends Widget_Base { |
| 11 | use \ElementsKit_Lite\Widgets\Widget_Notice; |
| 12 | |
| 13 | public $base; |
| 14 | |
| 15 | public function get_name() { |
| 16 | return Handler::get_name(); |
| 17 | } |
| 18 | |
| 19 | public function get_title() { |
| 20 | return Handler::get_title(); |
| 21 | } |
| 22 | |
| 23 | public function get_icon() { |
| 24 | return Handler::get_icon(); |
| 25 | } |
| 26 | |
| 27 | public function get_categories() { |
| 28 | return Handler::get_categories(); |
| 29 | } |
| 30 | |
| 31 | public function get_keywords() { |
| 32 | return Handler::get_keywords(); |
| 33 | } |
| 34 | |
| 35 | public function get_help_url() { |
| 36 | return 'https://wpmet.com/doc/button/'; |
| 37 | } |
| 38 | |
| 39 | public function get_style_depends() { |
| 40 | return ['ekit-button']; |
| 41 | } |
| 42 | |
| 43 | protected function is_dynamic_content(): bool { |
| 44 | return false; |
| 45 | } |
| 46 | |
| 47 | public function has_widget_inner_wrapper(): bool { |
| 48 | return ! Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' ); |
| 49 | } |
| 50 | |
| 51 | protected function register_controls() { |
| 52 | |
| 53 | |
| 54 | $this->start_controls_section( |
| 55 | 'ekit_btn_section_content', |
| 56 | array( |
| 57 | 'label' => esc_html__( 'Content', 'elementskit-lite' ), |
| 58 | ) |
| 59 | ); |
| 60 | |
| 61 | $this->add_control( |
| 62 | 'ekit_btn_text', |
| 63 | [ |
| 64 | 'label' =>esc_html__( 'Label', 'elementskit-lite' ), |
| 65 | 'type' => Controls_Manager::TEXT, |
| 66 | 'default' =>esc_html__( 'Learn more ', 'elementskit-lite' ), |
| 67 | 'placeholder' =>esc_html__( 'Learn more ', 'elementskit-lite' ), |
| 68 | 'dynamic' => [ |
| 69 | 'active' => true, |
| 70 | ], |
| 71 | ] |
| 72 | ); |
| 73 | |
| 74 | |
| 75 | $this->add_control( |
| 76 | 'ekit_btn_url', |
| 77 | [ |
| 78 | 'label' =>esc_html__( 'URL', 'elementskit-lite' ), |
| 79 | 'type' => Controls_Manager::URL, |
| 80 | 'placeholder' =>esc_url('https://wpmet.com'), |
| 81 | 'dynamic' => [ |
| 82 | 'active' => true, |
| 83 | ], |
| 84 | 'default' => [ |
| 85 | 'url' => '#', |
| 86 | ], |
| 87 | ] |
| 88 | ); |
| 89 | |
| 90 | $this->add_control( |
| 91 | 'ekit_btn_section_settings', |
| 92 | [ |
| 93 | 'label' => esc_html__( 'Settings', 'elementskit-lite' ), |
| 94 | 'type' => Controls_Manager::HEADING, |
| 95 | 'separator' => 'before', |
| 96 | ] |
| 97 | ); |
| 98 | |
| 99 | $this->add_control( |
| 100 | 'ekit_btn_icons__switch', |
| 101 | [ |
| 102 | 'label' => esc_html__('Add icon? ', 'elementskit-lite'), |
| 103 | 'type' => Controls_Manager::SWITCHER, |
| 104 | 'default' => 'yes', |
| 105 | 'label_on' =>esc_html__( 'Yes', 'elementskit-lite' ), |
| 106 | 'label_off' =>esc_html__( 'No', 'elementskit-lite' ), |
| 107 | ] |
| 108 | ); |
| 109 | |
| 110 | $this->add_control( |
| 111 | 'ekit_btn_icons', |
| 112 | [ |
| 113 | 'label' =>esc_html__( 'Icon', 'elementskit-lite' ), |
| 114 | 'type' => Controls_Manager::ICONS, |
| 115 | 'fa4compatibility' => 'ekit_btn_icon', |
| 116 | 'label_block' => true, |
| 117 | 'default' => [ |
| 118 | 'value' => '', |
| 119 | ], |
| 120 | 'condition' => [ |
| 121 | 'ekit_btn_icons__switch' => 'yes' |
| 122 | ] |
| 123 | ] |
| 124 | ); |
| 125 | $this->add_control( |
| 126 | 'ekit_btn_icon_align', |
| 127 | [ |
| 128 | 'label' =>esc_html__( 'Icon Position', 'elementskit-lite' ), |
| 129 | 'type' => Controls_Manager::SELECT, |
| 130 | 'default' => 'left', |
| 131 | 'options' => [ |
| 132 | 'left' =>esc_html__( 'Before', 'elementskit-lite' ), |
| 133 | 'right' =>esc_html__( 'After', 'elementskit-lite' ), |
| 134 | ], |
| 135 | 'condition' => [ |
| 136 | 'ekit_btn_icons__switch' => 'yes' |
| 137 | ] |
| 138 | ] |
| 139 | ); |
| 140 | $this->add_responsive_control( |
| 141 | 'ekit_btn_align', |
| 142 | [ |
| 143 | 'label' =>esc_html__( 'Alignment', 'elementskit-lite' ), |
| 144 | 'type' => Controls_Manager::CHOOSE, |
| 145 | 'default' => 'center', |
| 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 | 'selectors_dictionary' => [ |
| 161 | 'left' => 'justify-content: flex-start;', |
| 162 | 'center' => 'justify-content: center;', |
| 163 | 'right' => 'justify-content: flex-end;', |
| 164 | ], |
| 165 | 'prefix_class' => 'elementor-align-%s', |
| 166 | 'selectors' => [ |
| 167 | '{{WRAPPER}} .ekit-btn-wraper .elementskit-btn' => '{{VALUE}};', |
| 168 | ], |
| 169 | ] |
| 170 | ); |
| 171 | $this->add_control( |
| 172 | 'ekit_btn_class', |
| 173 | [ |
| 174 | 'label' => esc_html__( 'Class', 'elementskit-lite' ), |
| 175 | 'type' => Controls_Manager::TEXT, |
| 176 | 'dynamic' => [ |
| 177 | 'active' => true, |
| 178 | ], |
| 179 | 'placeholder' => esc_html__( 'Class Name', 'elementskit-lite' ), |
| 180 | ] |
| 181 | ); |
| 182 | |
| 183 | $this->add_control( |
| 184 | 'ekit_btn_id', |
| 185 | [ |
| 186 | 'label' => esc_html__( 'id', 'elementskit-lite' ), |
| 187 | 'type' => Controls_Manager::TEXT, |
| 188 | 'dynamic' => [ |
| 189 | 'active' => true, |
| 190 | ], |
| 191 | 'placeholder' => esc_html__( 'ID', 'elementskit-lite' ), |
| 192 | ] |
| 193 | ); |
| 194 | |
| 195 | |
| 196 | $this->end_controls_section(); |
| 197 | |
| 198 | |
| 199 | $this->start_controls_section( |
| 200 | 'ekit_btn_section_style', |
| 201 | [ |
| 202 | 'label' =>esc_html__( 'Button', 'elementskit-lite' ), |
| 203 | 'tab' => Controls_Manager::TAB_STYLE, |
| 204 | ] |
| 205 | ); |
| 206 | |
| 207 | $this->add_responsive_control( |
| 208 | 'width', |
| 209 | [ |
| 210 | 'label' => esc_html__( 'Width (%)', 'elementskit-lite' ), |
| 211 | 'type' => Controls_Manager::SLIDER, |
| 212 | 'selectors' => [ |
| 213 | '{{WRAPPER}} .elementskit-btn' => 'width: {{SIZE}}%;', |
| 214 | ] |
| 215 | ] |
| 216 | ); |
| 217 | |
| 218 | $this->add_responsive_control( |
| 219 | 'ekit_btn_text_padding', |
| 220 | [ |
| 221 | 'label' =>esc_html__( 'Padding', 'elementskit-lite' ), |
| 222 | 'type' => Controls_Manager::DIMENSIONS, |
| 223 | 'size_units' => [ 'px', 'em', '%' ], |
| 224 | 'selectors' => [ |
| 225 | '{{WRAPPER}} .elementskit-btn' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 226 | ], |
| 227 | ] |
| 228 | ); |
| 229 | |
| 230 | $this->add_group_control( |
| 231 | Group_Control_Typography::get_type(), |
| 232 | [ |
| 233 | 'name' => 'ekit_btn_typography', |
| 234 | 'label' =>esc_html__( 'Typography', 'elementskit-lite' ), |
| 235 | 'selector' => '{{WRAPPER}} .elementskit-btn', |
| 236 | ] |
| 237 | ); |
| 238 | |
| 239 | $this->add_group_control( |
| 240 | Group_Control_Text_Shadow::get_type(), |
| 241 | [ |
| 242 | 'name' => 'ekit_btn_shadow', |
| 243 | 'selector' => '{{WRAPPER}} .elementskit-btn', |
| 244 | ] |
| 245 | ); |
| 246 | |
| 247 | $this->start_controls_tabs( 'ekit_btn_tabs_style' ); |
| 248 | |
| 249 | $this->start_controls_tab( |
| 250 | 'ekit_btn_tabnormal', |
| 251 | [ |
| 252 | 'label' =>esc_html__( 'Normal', 'elementskit-lite' ), |
| 253 | ] |
| 254 | ); |
| 255 | |
| 256 | $this->add_control( |
| 257 | 'ekit_btn_text_color', |
| 258 | [ |
| 259 | 'label' =>esc_html__( 'Text Color', 'elementskit-lite' ), |
| 260 | 'type' => Controls_Manager::COLOR, |
| 261 | 'default' => '', |
| 262 | 'selectors' => [ |
| 263 | '{{WRAPPER}} .elementskit-btn' => 'color: {{VALUE}}; fill: {{VALUE}};', |
| 264 | ], |
| 265 | ] |
| 266 | ); |
| 267 | |
| 268 | $this->add_group_control( |
| 269 | Group_Control_Background::get_type(), |
| 270 | array( |
| 271 | 'name' => 'ekit_btn_bg_color', |
| 272 | 'selector' => '{{WRAPPER}} .elementskit-btn', |
| 273 | ) |
| 274 | ); |
| 275 | |
| 276 | $this->end_controls_tab(); |
| 277 | |
| 278 | $this->start_controls_tab( |
| 279 | 'ekit_btn_tab_button_hover', |
| 280 | [ |
| 281 | 'label' =>esc_html__( 'Hover', 'elementskit-lite' ), |
| 282 | ] |
| 283 | ); |
| 284 | |
| 285 | $this->add_control( |
| 286 | 'ekit_btn_hover_color', |
| 287 | [ |
| 288 | 'label' =>esc_html__( 'Text Color', 'elementskit-lite' ), |
| 289 | 'type' => Controls_Manager::COLOR, |
| 290 | 'default' => '#ffffff', |
| 291 | 'selectors' => [ |
| 292 | '{{WRAPPER}} .elementskit-btn:hover' => 'color: {{VALUE}}; fill: {{VALUE}};', |
| 293 | ], |
| 294 | ] |
| 295 | ); |
| 296 | |
| 297 | $this->add_group_control( |
| 298 | Group_Control_Background::get_type(), |
| 299 | array( |
| 300 | 'name' => 'ekit_btn_bg_hover_color', |
| 301 | 'selector' => '{{WRAPPER}} .elementskit-btn:hover', |
| 302 | ) |
| 303 | ); |
| 304 | |
| 305 | $this->end_controls_tab(); |
| 306 | $this->end_controls_tabs(); |
| 307 | $this->end_controls_section(); |
| 308 | |
| 309 | $this->start_controls_section( |
| 310 | 'ekit_btn_border_style_tabs', |
| 311 | [ |
| 312 | 'label' =>esc_html__( 'Border', 'elementskit-lite' ), |
| 313 | 'tab' => Controls_Manager::TAB_STYLE, |
| 314 | ] |
| 315 | ); |
| 316 | |
| 317 | $this->add_responsive_control( |
| 318 | 'ekit_btn_border_style', |
| 319 | [ |
| 320 | 'label' => esc_html_x( 'Border Type', 'Border Control', 'elementskit-lite' ), |
| 321 | 'type' => Controls_Manager::SELECT, |
| 322 | 'options' => [ |
| 323 | 'none' => esc_html__( 'None', 'elementskit-lite' ), |
| 324 | 'solid' => esc_html_x( 'Solid', 'Border Control', 'elementskit-lite' ), |
| 325 | 'double' => esc_html_x( 'Double', 'Border Control', 'elementskit-lite' ), |
| 326 | 'dotted' => esc_html_x( 'Dotted', 'Border Control', 'elementskit-lite' ), |
| 327 | 'dashed' => esc_html_x( 'Dashed', 'Border Control', 'elementskit-lite' ), |
| 328 | 'groove' => esc_html_x( 'Groove', 'Border Control', 'elementskit-lite' ), |
| 329 | ], |
| 330 | 'default' => 'none', |
| 331 | 'selectors' => [ |
| 332 | '{{WRAPPER}} .elementskit-btn' => 'border-style: {{VALUE}};', |
| 333 | ], |
| 334 | ] |
| 335 | ); |
| 336 | $this->add_responsive_control( |
| 337 | 'ekit_btn_border_dimensions', |
| 338 | [ |
| 339 | 'label' => esc_html_x( 'Width', 'Border Control', 'elementskit-lite' ), |
| 340 | 'type' => Controls_Manager::DIMENSIONS, |
| 341 | 'condition' => [ |
| 342 | 'ekit_btn_border_style!' => 'none' |
| 343 | ], |
| 344 | 'selectors' => [ |
| 345 | '{{WRAPPER}} .elementskit-btn' => 'border-width: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 346 | ], |
| 347 | ] |
| 348 | ); |
| 349 | $this->start_controls_tabs( 'xs_tabs_button_border_style' ); |
| 350 | $this->start_controls_tab( |
| 351 | 'ekit_btn_tab_border_normal', |
| 352 | [ |
| 353 | 'label' =>esc_html__( 'Normal', 'elementskit-lite' ), |
| 354 | ] |
| 355 | ); |
| 356 | |
| 357 | $this->add_control( |
| 358 | 'ekit_btn_border_color', |
| 359 | [ |
| 360 | 'label' => esc_html_x( 'Color', 'Border Control', 'elementskit-lite' ), |
| 361 | 'type' => Controls_Manager::COLOR, |
| 362 | 'default' => '', |
| 363 | 'selectors' => [ |
| 364 | '{{WRAPPER}} .elementskit-btn' => 'border-color: {{VALUE}};', |
| 365 | ], |
| 366 | ] |
| 367 | ); |
| 368 | $this->add_responsive_control( |
| 369 | 'ekit_btn_border_radius', |
| 370 | [ |
| 371 | 'label' =>esc_html__( 'Border Radius', 'elementskit-lite' ), |
| 372 | 'type' => Controls_Manager::DIMENSIONS, |
| 373 | 'size_units' => [ 'px', '%'], |
| 374 | 'default' => [ |
| 375 | 'top' => '', |
| 376 | 'right' => '', |
| 377 | 'bottom' => '' , |
| 378 | 'left' => '', |
| 379 | ], |
| 380 | 'selectors' => [ |
| 381 | '{{WRAPPER}} .elementskit-btn' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 382 | ], |
| 383 | ] |
| 384 | ); |
| 385 | $this->end_controls_tab(); |
| 386 | |
| 387 | $this->start_controls_tab( |
| 388 | 'ekit_btn_tab_button_border_hover', |
| 389 | [ |
| 390 | 'label' =>esc_html__( 'Hover', 'elementskit-lite' ), |
| 391 | ] |
| 392 | ); |
| 393 | $this->add_control( |
| 394 | 'ekit_btn_hover_border_color', |
| 395 | [ |
| 396 | 'label' => esc_html_x( 'Color', 'Border Control', 'elementskit-lite' ), |
| 397 | 'type' => Controls_Manager::COLOR, |
| 398 | 'default' => '', |
| 399 | 'selectors' => [ |
| 400 | '{{WRAPPER}} .elementskit-btn:hover' => 'border-color: {{VALUE}};', |
| 401 | ], |
| 402 | ] |
| 403 | ); |
| 404 | $this->add_responsive_control( |
| 405 | 'ekit_btn_border_radius_h', |
| 406 | [ |
| 407 | 'label' =>esc_html__( 'Border Radius', 'elementskit-lite' ), |
| 408 | 'type' => Controls_Manager::DIMENSIONS, |
| 409 | 'size_units' => [ 'px', '%'], |
| 410 | 'selectors' => [ |
| 411 | '{{WRAPPER}} .elementskit-btn:hover' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 412 | ], |
| 413 | ] |
| 414 | ); |
| 415 | $this->end_controls_tab(); |
| 416 | $this->end_controls_tabs(); |
| 417 | $this->end_controls_section(); |
| 418 | |
| 419 | $this->start_controls_section( |
| 420 | 'ekit_btn_box_shadow_style', |
| 421 | [ |
| 422 | 'label' =>esc_html__( 'Shadow', 'elementskit-lite' ), |
| 423 | 'tab' => Controls_Manager::TAB_STYLE, |
| 424 | ] |
| 425 | ); |
| 426 | $this->add_group_control( |
| 427 | Group_Control_Box_Shadow::get_type(), |
| 428 | [ |
| 429 | 'name' => 'ekit_btn_box_shadow_group', |
| 430 | 'selector' => '{{WRAPPER}} .elementskit-btn', |
| 431 | ] |
| 432 | ); |
| 433 | $this->add_group_control( |
| 434 | Group_Control_Box_Shadow::get_type(), |
| 435 | [ |
| 436 | 'name' => 'ekit_btn_hover_box_shadow_group', |
| 437 | 'label' => esc_html__( 'Hover Box Shadow', 'elementskit-lite' ), |
| 438 | 'selector' => '{{WRAPPER}} .elementskit-btn:hover', |
| 439 | ] |
| 440 | ); |
| 441 | |
| 442 | |
| 443 | $this->end_controls_section(); |
| 444 | |
| 445 | $this->start_controls_section( |
| 446 | 'ekit_btn_iconw_style', |
| 447 | [ |
| 448 | 'label' =>esc_html__( 'Icon', 'elementskit-lite' ), |
| 449 | 'tab' => Controls_Manager::TAB_STYLE, |
| 450 | 'condition' => [ |
| 451 | 'ekit_btn_icons__switch' => 'yes' |
| 452 | ] |
| 453 | ] |
| 454 | ); |
| 455 | $this->add_responsive_control( |
| 456 | 'ekit_btn_normal_icon_font_size', |
| 457 | array( |
| 458 | 'label' => esc_html__( 'Font Size', 'elementskit-lite' ), |
| 459 | 'type' => Controls_Manager::SLIDER, |
| 460 | 'size_units' => array( |
| 461 | 'px', 'em', 'rem', |
| 462 | ), |
| 463 | 'range' => array( |
| 464 | 'px' => array( |
| 465 | 'min' => 1, |
| 466 | 'max' => 100, |
| 467 | ), |
| 468 | ), |
| 469 | 'default' => [ |
| 470 | 'unit' => 'px', |
| 471 | 'size' => 14, |
| 472 | ], |
| 473 | 'selectors' => array( |
| 474 | '{{WRAPPER}} .elementskit-btn > :is(i, svg)' => 'font-size: {{SIZE}}{{UNIT}};', |
| 475 | ), |
| 476 | ) |
| 477 | ); |
| 478 | $this->add_responsive_control( |
| 479 | 'ekit_btn_normal_icon_padding_left', |
| 480 | [ |
| 481 | 'label' => esc_html__( 'Add space after icon', 'elementskit-lite' ), |
| 482 | 'type' => Controls_Manager::SLIDER, |
| 483 | 'size_units' => [ 'px' ], |
| 484 | 'range' => [ |
| 485 | 'px' => [ |
| 486 | 'min' => 0, |
| 487 | 'max' => 100, |
| 488 | 'step' => 1, |
| 489 | ], |
| 490 | ], |
| 491 | 'default' => [ |
| 492 | 'unit' => 'px', |
| 493 | 'size' => 5, |
| 494 | ], |
| 495 | 'selectors' => [ |
| 496 | '{{WRAPPER}} .elementskit-btn > i, {{WRAPPER}} .elementskit-btn > svg' => 'margin-right: {{SIZE}}{{UNIT}};', |
| 497 | '.rtl {{WRAPPER}} .elementskit-btn > i, .rtl {{WRAPPER}} .elementskit-btn > svg' => 'margin-left: {{SIZE}}{{UNIT}}; margin-right: 0;', |
| 498 | ], |
| 499 | 'condition' => [ |
| 500 | 'ekit_btn_icon_align' => 'left' |
| 501 | ] |
| 502 | ] |
| 503 | ); |
| 504 | $this->add_responsive_control( |
| 505 | 'ekit_btn_normal_icon_padding_right', |
| 506 | [ |
| 507 | 'label' => esc_html__( 'Add space before icon', 'elementskit-lite' ), |
| 508 | 'type' => Controls_Manager::SLIDER, |
| 509 | 'size_units' => [ 'px' ], |
| 510 | 'range' => [ |
| 511 | 'px' => [ |
| 512 | 'min' => 0, |
| 513 | 'max' => 100, |
| 514 | 'step' =>1, |
| 515 | ], |
| 516 | ], |
| 517 | 'default' => [ |
| 518 | 'unit' => 'px', |
| 519 | 'size' => 5, |
| 520 | ], |
| 521 | 'selectors' => [ |
| 522 | '{{WRAPPER}} .elementskit-btn > i, {{WRAPPER}} .elementskit-btn > svg' => 'margin-left: {{SIZE}}{{UNIT}};', |
| 523 | '.rtl {{WRAPPER}} .elementskit-btn > i, .rtl {{WRAPPER}} .elementskit-btn > svg' => 'margin-left: 0; margin-right: {{SIZE}}{{UNIT}};', |
| 524 | ], |
| 525 | 'condition' => [ |
| 526 | 'ekit_btn_icon_align' => 'right' |
| 527 | ] |
| 528 | ] |
| 529 | ); |
| 530 | |
| 531 | $this->add_responsive_control( |
| 532 | 'ekit_btn_normal_icon_vertical_align', |
| 533 | array( |
| 534 | 'label' => esc_html__( 'Move icon Vertically', 'elementskit-lite' ), |
| 535 | 'type' => Controls_Manager::SLIDER, |
| 536 | 'size_units' => array( |
| 537 | 'px', 'em', 'rem', |
| 538 | ), |
| 539 | 'range' => array( |
| 540 | 'px' => array( |
| 541 | 'min' => -20, |
| 542 | 'max' => 20, |
| 543 | ), |
| 544 | 'em' => array( |
| 545 | 'min' => -5, |
| 546 | 'max' => 5, |
| 547 | ), |
| 548 | 'rem' => array( |
| 549 | 'min' => -5, |
| 550 | 'max' => 5, |
| 551 | ), |
| 552 | ), |
| 553 | 'selectors' => array( |
| 554 | '{{WRAPPER}} .elementskit-btn i, {{WRAPPER}} .elementskit-btn svg' => ' -webkit-transform: translateY({{SIZE}}{{UNIT}}); -ms-transform: translateY({{SIZE}}{{UNIT}}); transform: translateY({{SIZE}}{{UNIT}})', |
| 555 | ), |
| 556 | ) |
| 557 | ); |
| 558 | |
| 559 | $this->end_controls_section(); |
| 560 | |
| 561 | $this->insert_pro_message(); |
| 562 | } |
| 563 | |
| 564 | protected function render( ) { |
| 565 | echo '<div class="ekit-wid-con" >'; |
| 566 | $this->render_raw(); |
| 567 | echo '</div>'; |
| 568 | } |
| 569 | |
| 570 | protected function render_raw( ) { |
| 571 | $settings = $this->get_settings_for_display(); |
| 572 | |
| 573 | $btn_text = $settings['ekit_btn_text']; |
| 574 | $btn_class = ($settings['ekit_btn_class'] != '') ? $settings['ekit_btn_class'] : ''; |
| 575 | $btn_id = ($settings['ekit_btn_id'] != '') ? $settings['ekit_btn_id'] : ''; |
| 576 | |
| 577 | $options_ekit_btn_icon_align = array_keys([ |
| 578 | 'left' => esc_html__( 'Before', 'elementskit-lite' ), |
| 579 | 'right' => esc_html__( 'After', 'elementskit-lite' ), |
| 580 | ]); |
| 581 | |
| 582 | $icon_align = \ElementsKit_Lite\Utils::esc_options($settings['ekit_btn_icon_align'], $options_ekit_btn_icon_align, 'left'); |
| 583 | |
| 584 | if ( ! empty( $settings['ekit_btn_url']['url'] ) ) { |
| 585 | $this->add_link_attributes( 'button', $settings['ekit_btn_url'] ); |
| 586 | } |
| 587 | |
| 588 | // Reset Whitespace for this specific widget |
| 589 | $btn_class .= ' whitespace--normal'; |
| 590 | |
| 591 | $this->add_render_attribute('button', [ |
| 592 | 'class' => 'elementskit-btn ' . $btn_class, |
| 593 | 'id' => $btn_id |
| 594 | ]); |
| 595 | ?> |
| 596 | <div class="ekit-btn-wraper"> |
| 597 | <?php if($icon_align == 'right'): ?> |
| 598 | <a <?php $this->print_render_attribute_string( 'button' ); ?>> |
| 599 | <?php |
| 600 | echo esc_html( $btn_text ); |
| 601 | Icons_Manager::render_icon( $settings['ekit_btn_icons'], [ 'aria-hidden' => 'true' ] ); |
| 602 | ?> |
| 603 | </a> |
| 604 | <?php elseif ($icon_align == 'left') : ?> |
| 605 | <a <?php $this->print_render_attribute_string( 'button' ); ?>> |
| 606 | <?php |
| 607 | Icons_Manager::render_icon( $settings['ekit_btn_icons'], [ 'aria-hidden' => 'true' ] ); |
| 608 | echo esc_html( $btn_text ); |
| 609 | ?> |
| 610 | </a> |
| 611 | <?php else : ?> |
| 612 | <a <?php $this->print_render_attribute_string( 'button' ); ?>> |
| 613 | <?php echo esc_html( $btn_text ); ?> |
| 614 | </a> |
| 615 | <?php endif; ?> |
| 616 | </div> |
| 617 | <?php |
| 618 | } |
| 619 | } |
| 620 |