Skip to content

Commit

Permalink
button widget: added css id closes #4535
Browse files Browse the repository at this point in the history
  • Loading branch information
bainternet committed May 24, 2018
1 parent 2a52076 commit f42f355
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion includes/widgets/button.php
Expand Up @@ -248,6 +248,17 @@ protected function _register_controls() {
]
);

$this->add_control(
'button_css_id',
[
'label' => __( 'CSS ID', 'elementor' ),
'type' => Controls_Manager::TEXT,
'default' => '',
'title' => __( 'Add your custom id WITHOUT the Pound key. e.g: my-id', 'elementor' ),
'label_block' => false,
]
);

$this->end_controls_section();

$this->start_controls_section(
Expand Down Expand Up @@ -436,6 +447,10 @@ protected function render() {
$this->add_render_attribute( 'button', 'class', 'elementor-button' );
$this->add_render_attribute( 'button', 'role', 'button' );

if ( ! empty( $settings['button_css_id'] ) ) {
$this->add_render_attribute( 'button', 'id', $settings['button_css_id'] );
}

if ( ! empty( $settings['size'] ) ) {
$this->add_render_attribute( 'button', 'class', 'elementor-size-' . $settings['size'] );
}
Expand Down Expand Up @@ -469,7 +484,7 @@ protected function _content_template() {
view.addInlineEditingAttributes( 'text', 'none' );
#>
<div class="elementor-button-wrapper">
<a class="elementor-button elementor-size-{{ settings.size }} elementor-animation-{{ settings.hover_animation }}" href="{{ settings.link.url }}" role="button">
<a id="{{ settings.button_css_id }}" class="elementor-button elementor-size-{{ settings.size }} elementor-animation-{{ settings.hover_animation }}" href="{{ settings.link.url }}" role="button">
<span class="elementor-button-content-wrapper">
<# if ( settings.icon ) { #>
<span class="elementor-button-icon elementor-align-icon-{{ settings.icon_align }}">
Expand Down

0 comments on commit f42f355

Please sign in to comment.