__('Extra Small'), 'sm' => __('Small'), 'md' => __('Medium'), 'lg' => __('Large'), 'xl' => __('Extra Large'), ]; } /** * Register button widget controls. * * Adds different input fields to allow the user to change and customize the widget settings. * * @since 1.0.0 * @access protected */ protected function _registerControls() { $this->startControlsSection( 'section_button', [ 'label' => __('Button'), ] ); $this->addControl( 'button_type', [ 'label' => __('Type'), 'type' => ControlsManager::SELECT, 'default' => '', 'options' => [ '' => __('Default'), 'info' => __('Info'), 'success' => __('Success'), 'warning' => __('Warning'), 'danger' => __('Danger'), ], 'prefix_class' => 'elementor-button-', ] ); $this->addControl( 'text', [ 'label' => __('Text'), 'type' => ControlsManager::TEXT, 'dynamic' => [ 'active' => true, ], 'default' => __('Click here'), 'placeholder' => __('Click here'), ] ); $this->addControl( 'link', [ 'label' => __('Link'), 'type' => ControlsManager::URL, 'dynamic' => [ 'active' => true, ], 'placeholder' => __('https://your-link.com'), 'default' => [ 'url' => '#', ], ] ); $this->addResponsiveControl( 'align', [ 'label' => __('Alignment'), 'type' => ControlsManager::CHOOSE, 'options' => [ 'left' => [ 'title' => __('Left'), 'icon' => 'fa fa-align-left', ], 'center' => [ 'title' => __('Center'), 'icon' => 'fa fa-align-center', ], 'right' => [ 'title' => __('Right'), 'icon' => 'fa fa-align-right', ], 'justify' => [ 'title' => __('Justified'), 'icon' => 'fa fa-align-justify', ], ], 'prefix_class' => 'elementor%s-align-', 'default' => '', ] ); $this->addControl( 'size', [ 'label' => __('Size'), 'type' => ControlsManager::SELECT, 'default' => 'sm', 'options' => self::getButtonSizes(), 'style_transfer' => true, ] ); $this->addControl( 'icon', [ 'label' => __('Icon'), 'type' => ControlsManager::ICON, 'label_block' => true, 'default' => '', ] ); $this->addControl( 'icon_align', [ 'label' => __('Icon Position'), 'type' => ControlsManager::SELECT, 'default' => 'left', 'options' => [ 'left' => __('Before'), 'right' => __('After'), ], 'condition' => [ 'icon!' => '', ], ] ); $this->addControl( 'icon_indent', [ 'label' => __('Icon Spacing'), 'type' => ControlsManager::SLIDER, 'range' => [ 'px' => [ 'max' => 50, ], ], 'selectors' => [ '{{WRAPPER}} .elementor-button-content-wrapper' => 'gap: {{SIZE}}{{UNIT}}', '{{WRAPPER}} .elementor-button-text' => 'flex-grow: min(0, {{SIZE}})', ], 'condition' => [ 'icon!' => '', ], ] ); $this->addControl( 'view', [ 'label' => __('View'), 'type' => ControlsManager::HIDDEN, 'default' => 'traditional', ] ); $this->addControl( 'button_css_id', [ 'label' => __('Button ID'), 'type' => ControlsManager::TEXT, 'dynamic' => [ 'active' => true, ], 'default' => '', 'title' => __('Add your custom id WITHOUT the Pound key. e.g: my-id'), 'label_block' => false, 'description' => __( 'Please make sure the ID is unique and not used elsewhere on the page this form is displayed. ' . 'This field allows A-z 0-9 & underscore chars without spaces.' ), 'separator' => 'before', ] ); $this->endControlsSection(); $this->startControlsSection( 'section_style', [ 'label' => __('Button'), 'tab' => ControlsManager::TAB_STYLE, ] ); $this->addGroupControl( GroupControlTypography::getType(), [ 'name' => 'typography', 'scheme' => SchemeTypography::TYPOGRAPHY_4, 'selector' => '{{WRAPPER}} a.elementor-button', ] ); $this->addGroupControl( GroupControlTextShadow::getType(), [ 'name' => 'text_shadow', 'selector' => '{{WRAPPER}} .elementor-button', ] ); $this->startControlsTabs('tabs_button_style'); $this->startControlsTab( 'tab_button_normal', [ 'label' => __('Normal'), ] ); $this->addControl( 'button_text_color', [ 'label' => __('Text Color'), 'type' => ControlsManager::COLOR, 'default' => '', 'selectors' => [ '{{WRAPPER}} a.elementor-button:not(#e)' => 'color: {{VALUE}};', ], ] ); $this->addControl( 'background_color', [ 'label' => __('Background Color'), 'type' => ControlsManager::COLOR, 'scheme' => [ 'type' => SchemeColor::getType(), 'value' => SchemeColor::COLOR_4, ], 'selectors' => [ '{{WRAPPER}} a.elementor-button' => 'background-color: {{VALUE}};', ], ] ); $this->endControlsTab(); $this->startControlsTab( 'tab_button_hover', [ 'label' => __('Hover'), ] ); $this->addControl( 'hover_color', [ 'label' => __('Text Color'), 'type' => ControlsManager::COLOR, 'selectors' => [ '{{WRAPPER}} a.elementor-button:not(#e):hover, {{WRAPPER}} a.elementor-button:not(#e):focus' => 'color: {{VALUE}};', ], ] ); $this->addControl( 'button_background_hover_color', [ 'label' => __('Background Color'), 'type' => ControlsManager::COLOR, 'selectors' => [ '{{WRAPPER}} a.elementor-button:hover, {{WRAPPER}} a.elementor-button:focus' => 'background-color: {{VALUE}};', ], ] ); $this->addControl( 'button_hover_border_color', [ 'label' => __('Border Color'), 'type' => ControlsManager::COLOR, 'condition' => [ 'border_border!' => '', ], 'selectors' => [ '{{WRAPPER}} a.elementor-button:hover, {{WRAPPER}} a.elementor-button:focus' => 'border-color: {{VALUE}};', ], ] ); $this->addControl( 'hover_animation', [ 'label' => __('Hover Animation'), 'type' => ControlsManager::HOVER_ANIMATION, ] ); $this->endControlsTab(); $this->endControlsTabs(); $this->addGroupControl( GroupControlBorder::getType(), [ 'name' => 'border', 'selector' => '{{WRAPPER}} .elementor-button', 'separator' => 'before', ] ); $this->addControl( 'border_radius', [ 'label' => __('Border Radius'), 'type' => ControlsManager::DIMENSIONS, 'size_units' => ['px', '%'], 'selectors' => [ '{{WRAPPER}} a.elementor-button' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->addGroupControl( GroupControlBoxShadow::getType(), [ 'name' => 'button_box_shadow', 'selector' => '{{WRAPPER}} .elementor-button', ] ); $this->addResponsiveControl( 'text_padding', [ 'label' => __('Padding'), 'type' => ControlsManager::DIMENSIONS, 'size_units' => ['px', 'em', '%'], 'selectors' => [ '{{WRAPPER}} a.elementor-button' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], 'separator' => 'before', ] ); $this->endControlsSection(); } /** * Render button widget output on the frontend. * * Written in PHP and used to generate the final HTML. * * @since 1.0.0 * @access protected */ protected function render() { $settings = $this->getSettingsForDisplay(); if (!empty($settings['link']['url'])) { $this->addRenderAttribute('button', 'href', $settings['link']['url']); $this->addRenderAttribute('button', 'class', 'elementor-button-link'); if ($settings['link']['is_external']) { $this->addRenderAttribute('button', 'target', '_blank'); } if ($settings['link']['nofollow']) { $this->addRenderAttribute('button', 'rel', 'nofollow'); } } $this->addRenderAttribute([ 'button' => [ 'class' => 'elementor-button', 'role' => 'button', ], 'text' => [ 'class' => 'elementor-button-text', ], ]); if (!empty($settings['button_css_id'])) { $this->addRenderAttribute('button', 'id', $settings['button_css_id']); } if (!empty($settings['size'])) { $this->addRenderAttribute('button', 'class', 'elementor-size-' . $settings['size']); } if ($settings['hover_animation']) { $this->addRenderAttribute('button', 'class', 'elementor-animation-' . $settings['hover_animation']); } $this->addInlineEditingAttributes('text', 'none'); ?>
getRenderAttributeString('button') ?>> getRenderAttributeString('text') ?>>
<# view.addRenderAttribute( 'button', { 'class': [ 'elementor-button', 'elementor-size-' + settings.size, 'elementor-animation-' + settings.hover_animation ], 'href': settings.link.url } ); view.addRenderAttribute( 'text', 'class', 'elementor-button-text' ); view.addInlineEditingAttributes( 'text', 'none' ); #>
<# if ( settings.icon ) { #> <# } #> {{{ settings.text }}}