| @@ -10,12 +10,11 @@ | ||
| 10 | 10 | use Elementor\Group_Control_Text_Shadow; |
| 11 | 11 | use Elementor\Group_Control_Typography; |
| 12 | 12 | use Elementor\Icons_Manager; |
| 13 | 13 | use Elementor\Widget_Base; |
| 14 | -use Elementor\Plugin; | |
| 15 | 14 | |
| 16 | 15 | if ( ! defined( 'ABSPATH' ) ) { |
| 17 | - exit; // Exit if accessed directly. | |
| 16 | + exit; // Exit if accessed directly | |
| 18 | 17 | } |
| 19 | 18 | |
| 20 | 19 | trait Button_Trait { |
| 21 | 20 | /** |
| @@ -47,8 +46,10 @@ | ||
| 47 | 46 | * |
| 48 | 47 | * @type array $section_condition Set of conditions to hide the controls. |
| 49 | 48 | * @type string $button_text Text contained in button. |
| 50 | 49 | * @type string $text_control_label Name for the label of the text control. |
| 50 | + * @type string $alignment_control_prefix_class Prefix class name for the button alignment control. | |
| 51 | + * @type string $alignment_default Default alignment for the button. | |
| 51 | 52 | * @type array $icon_exclude_inline_options Set of icon types to exclude from icon controls. |
| 52 | 53 | * } |
| 53 | 54 | */ |
| 54 | 55 | protected function register_button_content_controls( $args = [] ) { |
| @@ -55,8 +56,10 @@ | ||
| 55 | 56 | $default_args = [ |
| 56 | 57 | 'section_condition' => [], |
| 57 | 58 | 'button_default_text' => esc_html__( 'Click here', 'elementor' ), |
| 58 | 59 | 'text_control_label' => esc_html__( 'Text', 'elementor' ), |
| 60 | + 'alignment_control_prefix_class' => 'elementor%s-align-', | |
| 61 | + 'alignment_default' => '', | |
| 59 | 62 | 'icon_exclude_inline_options' => [], |
| 60 | 63 | ]; |
| 61 | 64 | |
| 62 | 65 | $args = wp_parse_args( $args, $default_args ); |
| @@ -100,8 +103,9 @@ | ||
| 100 | 103 | 'type' => Controls_Manager::URL, |
| 101 | 104 | 'dynamic' => [ |
| 102 | 105 | 'active' => true, |
| 103 | 106 | ], |
| 107 | + 'placeholder' => esc_html__( 'https://your-link.com', 'elementor' ), | |
| 104 | 108 | 'default' => [ |
| 105 | 109 | 'url' => '#', |
| 106 | 110 | ], |
| 107 | 111 | 'condition' => $args['section_condition'], |
| @@ -107,8 +111,37 @@ | ||
| 107 | 111 | 'condition' => $args['section_condition'], |
| 108 | 112 | ] |
| 109 | 113 | ); |
| 110 | 114 | |
| 115 | + $this->add_responsive_control( | |
| 116 | + 'align', | |
| 117 | + [ | |
| 118 | + 'label' => esc_html__( 'Alignment', 'elementor' ), | |
| 119 | + 'type' => Controls_Manager::CHOOSE, | |
| 120 | + 'options' => [ | |
| 121 | + 'left' => [ | |
| 122 | + 'title' => esc_html__( 'Left', 'elementor' ), | |
| 123 | + 'icon' => 'eicon-text-align-left', | |
| 124 | + ], | |
| 125 | + 'center' => [ | |
| 126 | + 'title' => esc_html__( 'Center', 'elementor' ), | |
| 127 | + 'icon' => 'eicon-text-align-center', | |
| 128 | + ], | |
| 129 | + 'right' => [ | |
| 130 | + 'title' => esc_html__( 'Right', 'elementor' ), | |
| 131 | + 'icon' => 'eicon-text-align-right', | |
| 132 | + ], | |
| 133 | + 'justify' => [ | |
| 134 | + 'title' => esc_html__( 'Justified', 'elementor' ), | |
| 135 | + 'icon' => 'eicon-text-align-justify', | |
| 136 | + ], | |
| 137 | + ], | |
| 138 | + 'prefix_class' => $args['alignment_control_prefix_class'], | |
| 139 | + 'default' => $args['alignment_default'], | |
| 140 | + 'condition' => $args['section_condition'], | |
| 141 | + ] | |
| 142 | + ); | |
| 143 | + | |
| 111 | 144 | $this->add_control( |
| 112 | 145 | 'size', |
| 113 | 146 | [ |
| 114 | 147 | 'label' => esc_html__( 'Size', 'elementor' ), |
| @@ -115,9 +148,9 @@ | ||
| 115 | 148 | 'type' => Controls_Manager::SELECT, |
| 116 | 149 | 'default' => 'sm', |
| 117 | 150 | 'options' => self::get_button_sizes(), |
| 118 | 151 | 'style_transfer' => true, |
| 119 | - 'condition' => array_merge( $args['section_condition'], [ 'size[value]!' => 'sm' ] ), // a workaround to hide the control, unless it's in use (not default). | |
| 152 | + 'condition' => $args['section_condition'], | |
| 120 | 153 | ] |
| 121 | 154 | ); |
| 122 | 155 | |
| 123 | 156 | $this->add_control( |
| @@ -136,35 +169,15 @@ | ||
| 136 | 169 | $this->add_control( |
| 137 | 170 | 'icon_align', |
| 138 | 171 | [ |
| 139 | 172 | 'label' => esc_html__( 'Icon Position', 'elementor' ), |
| 140 | - 'type' => Controls_Manager::CHOOSE, | |
| 141 | - 'default' => is_rtl() ? 'row-reverse' : 'row', | |
| 173 | + 'type' => Controls_Manager::SELECT, | |
| 174 | + 'default' => 'left', | |
| 142 | 175 | 'options' => [ |
| 143 | - 'row' => [ | |
| 144 | - 'title' => esc_html__( 'Start', 'elementor' ), | |
| 145 | - 'icon' => 'eicon-h-align-left', | |
| 146 | - ], | |
| 147 | - 'row-reverse' => [ | |
| 148 | - 'title' => esc_html__( 'End', 'elementor' ), | |
| 149 | - 'icon' => 'eicon-h-align-right', | |
| 150 | - ], | |
| 176 | + 'left' => esc_html__( 'Before', 'elementor' ), | |
| 177 | + 'right' => esc_html__( 'After', 'elementor' ), | |
| 151 | 178 | ], |
| 152 | - 'classes' => 'elementor-control-start-end', | |
| 153 | - 'selectors_dictionary' => [ | |
| 154 | - 'left' => is_rtl() ? 'row-reverse' : 'row', | |
| 155 | - 'right' => is_rtl() ? 'row' : 'row-reverse', | |
| 156 | - ], | |
| 157 | - 'selectors' => [ | |
| 158 | - '{{WRAPPER}} .elementor-button-content-wrapper' => 'flex-direction: {{VALUE}};', | |
| 159 | - ], | |
| 160 | - 'condition' => array_merge( | |
| 161 | - $args['section_condition'], | |
| 162 | - [ | |
| 163 | - 'text!' => '', | |
| 164 | - 'selected_icon[value]!' => '', | |
| 165 | - ] | |
| 166 | - ), | |
| 179 | + 'condition' => array_merge( $args['section_condition'], [ 'selected_icon[value]!' => '' ] ), | |
| 167 | 180 | ] |
| 168 | 181 | ); |
| 169 | 182 | |
| 170 | 183 | $this->add_control( |
| @@ -171,34 +184,32 @@ | ||
| 171 | 184 | 'icon_indent', |
| 172 | 185 | [ |
| 173 | 186 | 'label' => esc_html__( 'Icon Spacing', 'elementor' ), |
| 174 | 187 | 'type' => Controls_Manager::SLIDER, |
| 175 | - 'size_units' => [ 'px', 'em', 'rem', 'custom' ], | |
| 176 | 188 | 'range' => [ |
| 177 | 189 | 'px' => [ |
| 178 | 190 | 'max' => 50, |
| 179 | 191 | ], |
| 180 | - 'em' => [ | |
| 181 | - 'max' => 5, | |
| 182 | - ], | |
| 183 | - 'rem' => [ | |
| 184 | - 'max' => 5, | |
| 185 | - ], | |
| 186 | 192 | ], |
| 187 | 193 | 'selectors' => [ |
| 188 | - '{{WRAPPER}} .elementor-button .elementor-button-content-wrapper' => 'gap: {{SIZE}}{{UNIT}};', | |
| 194 | + '{{WRAPPER}} .elementor-button .elementor-align-icon-right' => 'margin-left: {{SIZE}}{{UNIT}};', | |
| 195 | + '{{WRAPPER}} .elementor-button .elementor-align-icon-left' => 'margin-right: {{SIZE}}{{UNIT}};', | |
| 189 | 196 | ], |
| 190 | - 'condition' => array_merge( | |
| 191 | - $args['section_condition'], | |
| 192 | - [ | |
| 193 | - 'text!' => '', | |
| 194 | - 'selected_icon[value]!' => '', | |
| 195 | - ] | |
| 196 | - ), | |
| 197 | + 'condition' => $args['section_condition'], | |
| 197 | 198 | ] |
| 198 | 199 | ); |
| 199 | 200 | |
| 200 | 201 | $this->add_control( |
| 202 | + 'view', | |
| 203 | + [ | |
| 204 | + 'label' => esc_html__( 'View', 'elementor' ), | |
| 205 | + 'type' => Controls_Manager::HIDDEN, | |
| 206 | + 'default' => 'traditional', | |
| 207 | + 'condition' => $args['section_condition'], | |
| 208 | + ] | |
| 209 | + ); | |
| 210 | + | |
| 211 | + $this->add_control( | |
| 201 | 212 | 'button_css_id', |
| 202 | 213 | [ |
| 203 | 214 | 'label' => esc_html__( 'Button ID', 'elementor' ), |
| 204 | 215 | 'type' => Controls_Manager::TEXT, |
| @@ -204,16 +215,12 @@ | ||
| 204 | 215 | 'type' => Controls_Manager::TEXT, |
| 205 | 216 | 'dynamic' => [ |
| 206 | 217 | 'active' => true, |
| 207 | 218 | ], |
| 208 | - 'ai' => [ | |
| 209 | - 'active' => false, | |
| 210 | - ], | |
| 211 | 219 | 'default' => '', |
| 212 | 220 | 'title' => esc_html__( 'Add your custom id WITHOUT the Pound key. e.g: my-id', 'elementor' ), |
| 213 | 221 | 'description' => sprintf( |
| 214 | - /* translators: 1: `<code>` opening tag, 2: `</code>` closing tag. */ | |
| 215 | - esc_html__( 'Please make sure the ID is unique and not used elsewhere on the page. This field allows %1$sA-z 0-9%2$s & underscore chars without spaces.', 'elementor' ), | |
| 222 | + esc_html__( 'Please make sure the ID is unique and not used elsewhere on the page this form is displayed. This field allows %1$sA-z 0-9%2$s & underscore chars without spaces.', 'elementor' ), | |
| 216 | 223 | '<code>', |
| 217 | 224 | '</code>' |
| 218 | 225 | ), |
| 219 | 226 | 'separator' => 'before', |
| @@ -221,91 +228,15 @@ | ||
| 221 | 228 | ] |
| 222 | 229 | ); |
| 223 | 230 | } |
| 224 | 231 | |
| 225 | - /** | |
| 226 | - * @since 3.4.0 | |
| 227 | - * | |
| 228 | - * @param array $args { | |
| 229 | - * An array of values for the button adjustments. | |
| 230 | - * | |
| 231 | - * @type array $section_condition Set of conditions to hide the controls. | |
| 232 | - * @type string $alignment_default Default position for the button. | |
| 233 | - * @type string $alignment_control_prefix_class Prefix class name for the button position control. | |
| 234 | - * @type string $content_alignment_default Default alignment for the button content. | |
| 235 | - * } | |
| 236 | - */ | |
| 237 | 232 | protected function register_button_style_controls( $args = [] ) { |
| 238 | 233 | $default_args = [ |
| 239 | 234 | 'section_condition' => [], |
| 240 | - 'alignment_default' => '', | |
| 241 | - 'alignment_control_prefix_class' => 'elementor%s-align-', | |
| 242 | - 'content_alignment_default' => '', | |
| 243 | 235 | ]; |
| 244 | 236 | |
| 245 | 237 | $args = wp_parse_args( $args, $default_args ); |
| 246 | 238 | |
| 247 | - $this->add_responsive_control( | |
| 248 | - 'align', | |
| 249 | - [ | |
| 250 | - 'label' => esc_html__( 'Position', 'elementor' ), | |
| 251 | - 'type' => Controls_Manager::CHOOSE, | |
| 252 | - 'options' => [ | |
| 253 | - 'left' => [ | |
| 254 | - 'title' => esc_html__( 'Left', 'elementor' ), | |
| 255 | - 'icon' => 'eicon-h-align-left', | |
| 256 | - ], | |
| 257 | - 'center' => [ | |
| 258 | - 'title' => esc_html__( 'Center', 'elementor' ), | |
| 259 | - 'icon' => 'eicon-h-align-center', | |
| 260 | - ], | |
| 261 | - 'right' => [ | |
| 262 | - 'title' => esc_html__( 'Right', 'elementor' ), | |
| 263 | - 'icon' => 'eicon-h-align-right', | |
| 264 | - ], | |
| 265 | - 'justify' => [ | |
| 266 | - 'title' => esc_html__( 'Stretch', 'elementor' ), | |
| 267 | - 'icon' => 'eicon-h-align-stretch', | |
| 268 | - ], | |
| 269 | - ], | |
| 270 | - 'prefix_class' => $args['alignment_control_prefix_class'], | |
| 271 | - 'default' => $args['alignment_default'], | |
| 272 | - 'condition' => $args['section_condition'], | |
| 273 | - ] | |
| 274 | - ); | |
| 275 | - | |
| 276 | - $this->add_responsive_control( | |
| 277 | - 'content_align', | |
| 278 | - [ | |
| 279 | - 'label' => esc_html__( 'Alignment', 'elementor' ), | |
| 280 | - 'type' => Controls_Manager::CHOOSE, | |
| 281 | - 'options' => [ | |
| 282 | - 'start' => [ | |
| 283 | - 'title' => esc_html__( 'Start', 'elementor' ), | |
| 284 | - 'icon' => 'eicon-text-align-left', | |
| 285 | - ], | |
| 286 | - 'center' => [ | |
| 287 | - 'title' => esc_html__( 'Center', 'elementor' ), | |
| 288 | - 'icon' => 'eicon-text-align-center', | |
| 289 | - ], | |
| 290 | - 'end' => [ | |
| 291 | - 'title' => esc_html__( 'End', 'elementor' ), | |
| 292 | - 'icon' => 'eicon-text-align-right', | |
| 293 | - ], | |
| 294 | - 'space-between' => [ | |
| 295 | - 'title' => esc_html__( 'Space between', 'elementor' ), | |
| 296 | - 'icon' => 'eicon-text-align-justify', | |
| 297 | - ], | |
| 298 | - ], | |
| 299 | - 'default' => $args['content_alignment_default'], | |
| 300 | - 'classes' => 'elementor-control-start-end', | |
| 301 | - 'selectors' => [ | |
| 302 | - '{{WRAPPER}} .elementor-button .elementor-button-content-wrapper' => 'justify-content: {{VALUE}};', | |
| 303 | - ], | |
| 304 | - 'condition' => array_merge( $args['section_condition'], [ 'align' => 'justify' ] ), | |
| 305 | - ] | |
| 306 | - ); | |
| 307 | - | |
| 308 | 239 | $this->add_group_control( |
| 309 | 240 | Group_Control_Typography::get_type(), |
| 310 | 241 | [ |
| 311 | 242 | 'name' => 'typography', |
| @@ -371,17 +302,8 @@ | ||
| 371 | 302 | 'condition' => $args['section_condition'], |
| 372 | 303 | ] |
| 373 | 304 | ); |
| 374 | 305 | |
| 375 | - $this->add_group_control( | |
| 376 | - Group_Control_Box_Shadow::get_type(), | |
| 377 | - [ | |
| 378 | - 'name' => 'button_box_shadow', | |
| 379 | - 'selector' => '{{WRAPPER}} .elementor-button', | |
| 380 | - 'condition' => $args['section_condition'], | |
| 381 | - ] | |
| 382 | - ); | |
| 383 | - | |
| 384 | 306 | $this->end_controls_tab(); |
| 385 | 307 | |
| 386 | 308 | $this->start_controls_tab( |
| 387 | 309 | 'tab_button_hover', |
| @@ -424,8 +346,11 @@ | ||
| 424 | 346 | 'button_hover_border_color', |
| 425 | 347 | [ |
| 426 | 348 | 'label' => esc_html__( 'Border Color', 'elementor' ), |
| 427 | 349 | 'type' => Controls_Manager::COLOR, |
| 350 | + 'condition' => [ | |
| 351 | + 'border_border!' => '', | |
| 352 | + ], | |
| 428 | 353 | 'selectors' => [ |
| 429 | 354 | '{{WRAPPER}} .elementor-button:hover, {{WRAPPER}} .elementor-button:focus' => 'border-color: {{VALUE}};', |
| 430 | 355 | ], |
| 431 | 356 | 'condition' => $args['section_condition'], |
| @@ -431,33 +356,9 @@ | ||
| 431 | 356 | 'condition' => $args['section_condition'], |
| 432 | 357 | ] |
| 433 | 358 | ); |
| 434 | 359 | |
| 435 | - $this->add_group_control( | |
| 436 | - Group_Control_Box_Shadow::get_type(), | |
| 437 | - [ | |
| 438 | - 'name' => 'button_hover_box_shadow', | |
| 439 | - 'selector' => '{{WRAPPER}} .elementor-button:hover, {{WRAPPER}} .elementor-button:focus', | |
| 440 | - 'condition' => $args['section_condition'], | |
| 441 | - ] | |
| 442 | - ); | |
| 443 | - | |
| 444 | 360 | $this->add_control( |
| 445 | - 'button_hover_transition_duration', | |
| 446 | - [ | |
| 447 | - 'label' => esc_html__( 'Transition Duration', 'elementor' ), | |
| 448 | - 'type' => Controls_Manager::SLIDER, | |
| 449 | - 'size_units' => [ 's', 'ms', 'custom' ], | |
| 450 | - 'default' => [ | |
| 451 | - 'unit' => 's', | |
| 452 | - ], | |
| 453 | - 'selectors' => [ | |
| 454 | - '{{WRAPPER}} .elementor-button' => 'transition-duration: {{SIZE}}{{UNIT}};', | |
| 455 | - ], | |
| 456 | - ] | |
| 457 | - ); | |
| 458 | - | |
| 459 | - $this->add_control( | |
| 460 | 361 | 'hover_animation', |
| 461 | 362 | [ |
| 462 | 363 | 'label' => esc_html__( 'Hover Animation', 'elementor' ), |
| 463 | 364 | 'type' => Controls_Manager::HOVER_ANIMATION, |
| @@ -483,9 +384,9 @@ | ||
| 483 | 384 | 'border_radius', |
| 484 | 385 | [ |
| 485 | 386 | 'label' => esc_html__( 'Border Radius', 'elementor' ), |
| 486 | 387 | 'type' => Controls_Manager::DIMENSIONS, |
| 487 | - 'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ], | |
| 388 | + 'size_units' => [ 'px', '%', 'em' ], | |
| 488 | 389 | 'selectors' => [ |
| 489 | 390 | '{{WRAPPER}} .elementor-button' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 490 | 391 | ], |
| 491 | 392 | 'condition' => $args['section_condition'], |
| @@ -491,14 +392,23 @@ | ||
| 491 | 392 | 'condition' => $args['section_condition'], |
| 492 | 393 | ] |
| 493 | 394 | ); |
| 494 | 395 | |
| 396 | + $this->add_group_control( | |
| 397 | + Group_Control_Box_Shadow::get_type(), | |
| 398 | + [ | |
| 399 | + 'name' => 'button_box_shadow', | |
| 400 | + 'selector' => '{{WRAPPER}} .elementor-button', | |
| 401 | + 'condition' => $args['section_condition'], | |
| 402 | + ] | |
| 403 | + ); | |
| 404 | + | |
| 495 | 405 | $this->add_responsive_control( |
| 496 | 406 | 'text_padding', |
| 497 | 407 | [ |
| 498 | 408 | 'label' => esc_html__( 'Padding', 'elementor' ), |
| 499 | 409 | 'type' => Controls_Manager::DIMENSIONS, |
| 500 | - 'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ], | |
| 410 | + 'size_units' => [ 'px', 'em', '%' ], | |
| 501 | 411 | 'selectors' => [ |
| 502 | 412 | '{{WRAPPER}} .elementor-button' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 503 | 413 | ], |
| 504 | 414 | 'separator' => 'before', |
| @@ -516,9 +426,9 @@ | ||
| 516 | 426 | * |
| 517 | 427 | * @since 3.4.0 |
| 518 | 428 | * @access protected |
| 519 | 429 | */ |
| 520 | - protected function render_button( ?Widget_Base $instance = null ) { | |
| 430 | + protected function render_button( Widget_Base $instance = null ) { | |
| 521 | 431 | if ( empty( $instance ) ) { |
| 522 | 432 | $instance = $this; |
| 523 | 433 | } |
| 524 | 434 | |
| @@ -523,25 +433,18 @@ | ||
| 523 | 433 | } |
| 524 | 434 | |
| 525 | 435 | $settings = $instance->get_settings_for_display(); |
| 526 | 436 | |
| 527 | - if ( empty( $settings['text'] ) && empty( $settings['selected_icon']['value'] ) ) { | |
| 528 | - return; | |
| 529 | - } | |
| 530 | - | |
| 531 | - $optimized_markup = Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' ); | |
| 532 | - | |
| 533 | 437 | $instance->add_render_attribute( 'wrapper', 'class', 'elementor-button-wrapper' ); |
| 534 | 438 | |
| 535 | - $instance->add_render_attribute( 'button', 'class', 'elementor-button' ); | |
| 536 | - | |
| 537 | 439 | if ( ! empty( $settings['link']['url'] ) ) { |
| 538 | 440 | $instance->add_link_attributes( 'button', $settings['link'] ); |
| 539 | 441 | $instance->add_render_attribute( 'button', 'class', 'elementor-button-link' ); |
| 540 | - } else { | |
| 541 | - $instance->add_render_attribute( 'button', 'role', 'button' ); | |
| 542 | 442 | } |
| 543 | 443 | |
| 444 | + $instance->add_render_attribute( 'button', 'class', 'elementor-button' ); | |
| 445 | + $instance->add_render_attribute( 'button', 'role', 'button' ); | |
| 446 | + | |
| 544 | 447 | if ( ! empty( $settings['button_css_id'] ) ) { |
| 545 | 448 | $instance->add_render_attribute( 'button', 'id', $settings['button_css_id'] ); |
| 546 | 449 | } |
| 547 | 450 | |
| @@ -546,10 +449,8 @@ | ||
| 546 | 449 | } |
| 547 | 450 | |
| 548 | 451 | if ( ! empty( $settings['size'] ) ) { |
| 549 | 452 | $instance->add_render_attribute( 'button', 'class', 'elementor-size-' . $settings['size'] ); |
| 550 | - } else { | |
| 551 | - $instance->add_render_attribute( 'button', 'class', 'elementor-size-sm' ); // BC, to make sure the class is always present | |
| 552 | 453 | } |
| 553 | 454 | |
| 554 | 455 | if ( ! empty( $settings['hover_animation'] ) ) { |
| 555 | 456 | $instance->add_render_attribute( 'button', 'class', 'elementor-animation-' . $settings['hover_animation'] ); |
| @@ -554,17 +455,13 @@ | ||
| 554 | 455 | if ( ! empty( $settings['hover_animation'] ) ) { |
| 555 | 456 | $instance->add_render_attribute( 'button', 'class', 'elementor-animation-' . $settings['hover_animation'] ); |
| 556 | 457 | } |
| 557 | 458 | ?> |
| 558 | - <?php if ( ! $optimized_markup ) : ?> | |
| 559 | 459 | <div <?php $instance->print_render_attribute_string( 'wrapper' ); ?>> |
| 560 | - <?php endif; ?> | |
| 561 | 460 | <a <?php $instance->print_render_attribute_string( 'button' ); ?>> |
| 562 | 461 | <?php $this->render_text( $instance ); ?> |
| 563 | 462 | </a> |
| 564 | - <?php if ( ! $optimized_markup ) : ?> | |
| 565 | 463 | </div> |
| 566 | - <?php endif; ?> | |
| 567 | 464 | <?php |
| 568 | 465 | } |
| 569 | 466 | |
| 570 | 467 | /** |
| @@ -577,50 +474,18 @@ | ||
| 577 | 474 | */ |
| 578 | 475 | protected function content_template() { |
| 579 | 476 | ?> |
| 580 | 477 | <# |
| 581 | - if ( '' === settings.text && '' === settings.selected_icon.value ) { | |
| 582 | - return; | |
| 583 | - } | |
| 584 | - | |
| 585 | - const optimized_markup = elementorCommon.config.experimentalFeatures.e_optimized_markup; | |
| 586 | - | |
| 587 | - view.addRenderAttribute( 'wrapper', 'class', 'elementor-button-wrapper' ); | |
| 588 | - | |
| 589 | - view.addRenderAttribute( 'button', 'class', 'elementor-button' ); | |
| 590 | - | |
| 591 | - if ( '' !== settings.link?.url ) { | |
| 592 | - view.addRenderAttribute( 'button', 'href', elementor.helpers.sanitizeUrl( settings.link?.url ) ); | |
| 593 | - view.addRenderAttribute( 'button', 'class', 'elementor-button-link' ); | |
| 594 | - } else { | |
| 595 | - view.addRenderAttribute( 'button', 'role', 'button' ); | |
| 596 | - } | |
| 597 | - | |
| 598 | - if ( '' !== settings.button_css_id ) { | |
| 599 | - view.addRenderAttribute( 'button', 'id', settings.button_css_id ); | |
| 600 | - } | |
| 601 | - | |
| 602 | - if ( '' !== settings.size ) { | |
| 603 | - view.addRenderAttribute( 'button', 'class', 'elementor-size-' + settings.size ); | |
| 604 | - } | |
| 605 | - | |
| 606 | - if ( '' !== settings.hover_animation ) { | |
| 607 | - view.addRenderAttribute( 'button', 'class', 'elementor-animation-' + settings.hover_animation ); | |
| 608 | - } | |
| 609 | - | |
| 610 | - view.addRenderAttribute( 'icon', 'class', 'elementor-button-icon' ); | |
| 611 | 478 | view.addRenderAttribute( 'text', 'class', 'elementor-button-text' ); |
| 612 | 479 | view.addInlineEditingAttributes( 'text', 'none' ); |
| 613 | 480 | var iconHTML = elementor.helpers.renderIcon( view, settings.selected_icon, { 'aria-hidden': true }, 'i' , 'object' ), |
| 614 | 481 | migrated = elementor.helpers.isIconMigrated( settings, 'selected_icon' ); |
| 615 | 482 | #> |
| 616 | - <# if ( ! optimized_markup ) { #> | |
| 617 | - <div {{{ view.getRenderAttributeString( 'wrapper' ) }}}> | |
| 618 | - <# } #> | |
| 619 | - <a {{{ view.getRenderAttributeString( 'button' ) }}}> | |
| 483 | + <div class="elementor-button-wrapper"> | |
| 484 | + <a id="{{ settings.button_css_id }}" class="elementor-button elementor-size-{{ settings.size }} elementor-animation-{{ settings.hover_animation }}" href="{{ settings.link.url }}" role="button"> | |
| 620 | 485 | <span class="elementor-button-content-wrapper"> |
| 621 | 486 | <# if ( settings.icon || settings.selected_icon ) { #> |
| 622 | - <span {{{ view.getRenderAttributeString( 'icon' ) }}}> | |
| 487 | + <span class="elementor-button-icon elementor-align-icon-{{ settings.icon_align }}"> | |
| 623 | 488 | <# if ( ( migrated || ! settings.icon ) && iconHTML.rendered ) { #> |
| 624 | 489 | {{{ iconHTML.value }}} |
| 625 | 490 | <# } else { #> |
| 626 | 491 | <i class="{{ settings.icon }}" aria-hidden="true"></i> |
| @@ -626,16 +491,12 @@ | ||
| 626 | 491 | <i class="{{ settings.icon }}" aria-hidden="true"></i> |
| 627 | 492 | <# } #> |
| 628 | 493 | </span> |
| 629 | 494 | <# } #> |
| 630 | - <# if ( settings.text ) { #> | |
| 631 | - <span {{{ view.getRenderAttributeString( 'text' ) }}}>{{ settings.text }}</span> | |
| 632 | - <# } #> | |
| 495 | + <span {{{ view.getRenderAttributeString( 'text' ) }}}>{{{ settings.text }}}</span> | |
| 633 | 496 | </span> |
| 634 | 497 | </a> |
| 635 | - <# if ( ! optimized_markup ) { #> | |
| 636 | 498 | </div> |
| 637 | - <# } #> | |
| 638 | 499 | <?php |
| 639 | 500 | } |
| 640 | 501 | |
| 641 | 502 | /** |
| @@ -647,9 +508,9 @@ | ||
| 647 | 508 | * |
| 648 | 509 | * @since 3.4.0 |
| 649 | 510 | * @access protected |
| 650 | 511 | */ |
| 651 | - protected function render_text( ?Widget_Base $instance = null ) { | |
| 512 | + protected function render_text( Widget_Base $instance = null ) { | |
| 652 | 513 | // The default instance should be `$this` (a Button widget), unless the Trait is being used from outside of a widget (e.g. `Skin_Base`) which should pass an `$instance`. |
| 653 | 514 | if ( empty( $instance ) ) { |
| 654 | 515 | $instance = $this; |
| 655 | 516 | } |
| @@ -658,14 +519,24 @@ | ||
| 658 | 519 | |
| 659 | 520 | $migrated = isset( $settings['__fa4_migrated']['selected_icon'] ); |
| 660 | 521 | $is_new = empty( $settings['icon'] ) && Icons_Manager::is_migration_allowed(); |
| 661 | 522 | |
| 523 | + if ( ! $is_new && empty( $settings['icon_align'] ) ) { | |
| 524 | + // @todo: remove when deprecated | |
| 525 | + // added as bc in 2.6 | |
| 526 | + //old default | |
| 527 | + $settings['icon_align'] = $instance->get_settings( 'icon_align' ); | |
| 528 | + } | |
| 529 | + | |
| 662 | 530 | $instance->add_render_attribute( [ |
| 663 | 531 | 'content-wrapper' => [ |
| 664 | 532 | 'class' => 'elementor-button-content-wrapper', |
| 665 | 533 | ], |
| 666 | - 'icon' => [ | |
| 667 | - 'class' => 'elementor-button-icon', | |
| 534 | + 'icon-align' => [ | |
| 535 | + 'class' => [ | |
| 536 | + 'elementor-button-icon', | |
| 537 | + 'elementor-align-icon-' . $settings['icon_align'], | |
| 538 | + ], | |
| 668 | 539 | ], |
| 669 | 540 | 'text' => [ |
| 670 | 541 | 'class' => 'elementor-button-text', |
| 671 | 542 | ], |
| @@ -671,13 +542,13 @@ | ||
| 671 | 542 | ], |
| 672 | 543 | ] ); |
| 673 | 544 | |
| 674 | 545 | // TODO: replace the protected with public |
| 675 | - // $instance->add_inline_editing_attributes( 'text', 'none' ); | |
| 546 | + //$instance->add_inline_editing_attributes( 'text', 'none' ); | |
| 676 | 547 | ?> |
| 677 | 548 | <span <?php $instance->print_render_attribute_string( 'content-wrapper' ); ?>> |
| 678 | 549 | <?php if ( ! empty( $settings['icon'] ) || ! empty( $settings['selected_icon']['value'] ) ) : ?> |
| 679 | - <span <?php $instance->print_render_attribute_string( 'icon' ); ?>> | |
| 550 | + <span <?php $instance->print_render_attribute_string( 'icon-align' ); ?>> | |
| 680 | 551 | <?php if ( $is_new || $migrated ) : |
| 681 | 552 | Icons_Manager::render_icon( $settings['selected_icon'], [ 'aria-hidden' => 'true' ] ); |
| 682 | 553 | else : ?> |
| 683 | 554 | <i class="<?php echo esc_attr( $settings['icon'] ); ?>" aria-hidden="true"></i> |
| @@ -683,11 +554,9 @@ | ||
| 683 | 554 | <i class="<?php echo esc_attr( $settings['icon'] ); ?>" aria-hidden="true"></i> |
| 684 | 555 | <?php endif; ?> |
| 685 | 556 | </span> |
| 686 | 557 | <?php endif; ?> |
| 687 | - <?php if ( ! empty( $settings['text'] ) ) : ?> | |
| 688 | - <span <?php $instance->print_render_attribute_string( 'text' ); ?>><?php echo wp_kses_post( $settings['text'] ); ?></span> | |
| 689 | - <?php endif; ?> | |
| 558 | + <span <?php $instance->print_render_attribute_string( 'text' ); ?>><?php $this->print_unescaped_setting( 'text' ); ?></span> | |
| 690 | 559 | </span> |
| 691 | 560 | <?php |
| 692 | 561 | } |
| 693 | 562 | |