start_controls_section( 'content_section', [ 'label' => __( 'Content', 'admore-widgets-suite' ), 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, ] ); $this->add_control( 'text', [ 'label' => __( 'Text', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::TEXT, 'default' => __( 'Click Here', 'admore-widgets-suite' ), 'dynamic' => [ 'active' => true ], ] ); $this->add_control( 'link', [ 'label' => __( 'Link', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::URL, 'dynamic' => [ 'active' => true ], ] ); $this->add_control( 'icon', [ 'label' => __( 'Icon', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::ICONS, ] ); $this->add_control( 'icon_position', [ 'label' => __( 'Icon Position', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => 'before', 'options' => [ 'before' => __( 'Before Text', 'admore-widgets-suite' ), 'after' => __( 'After Text', 'admore-widgets-suite' ), ], 'condition' => [ 'icon[value]!' => '' ], ] ); $this->add_responsive_control( 'icon_gap', [ 'label' => __( 'Icon Spacing', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SLIDER, 'size_units' => [ 'px' ], 'range' => [ 'px' => [ 'min' => 0, 'max' => 40 ] ], 'default' => [ 'size' => 8 ], 'selectors' => [ '{{WRAPPER}} .eppro-btn.icon-before .eppro-btn-icon' => 'margin-right: {{SIZE}}{{UNIT}};', '{{WRAPPER}} .eppro-btn.icon-after .eppro-btn-icon' => 'margin-left: {{SIZE}}{{UNIT}};', ], 'condition' => [ 'icon[value]!' => '' ], ] ); $this->add_control( 'btn_preset', [ 'label' => __( 'Button Style', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => 'solid', 'options' => [ 'solid' => __( 'Solid', 'admore-widgets-suite' ), 'outline' => __( 'Outline', 'admore-widgets-suite' ), 'ghost' => __( 'Ghost (Text Only)', 'admore-widgets-suite' ), ], ] ); $this->add_control( 'btn_size', [ 'label' => __( 'Size', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => 'md', 'options' => [ 'xs' => __( 'Extra Small', 'admore-widgets-suite' ), 'sm' => __( 'Small', 'admore-widgets-suite' ), 'md' => __( 'Medium', 'admore-widgets-suite' ), 'lg' => __( 'Large', 'admore-widgets-suite' ), 'xl' => __( 'Extra Large', 'admore-widgets-suite' ), ], ] ); $this->add_control( 'btn_css_id', [ 'label' => __( 'Button ID', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::TEXT, 'description' => __( 'Set a custom CSS ID for the button element.', 'admore-widgets-suite' ), 'ai' => [ 'active' => false ], ] ); $this->add_control( 'icon_hover_animation', [ 'label' => __( 'Icon Hover Effect', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => 'none', 'options' => [ 'none' => __( 'None', 'admore-widgets-suite' ), 'slide-right'=> __( 'Slide Right', 'admore-widgets-suite' ), 'grow' => __( 'Grow', 'admore-widgets-suite' ), 'spin' => __( 'Spin', 'admore-widgets-suite' ), 'bounce' => __( 'Bounce', 'admore-widgets-suite' ), ], 'condition' => [ 'icon[value]!' => '' ], ] ); $this->add_responsive_control( 'min_width', [ 'label' => __( 'Min Width', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SLIDER, 'size_units' => [ 'px', '%' ], 'range' => [ 'px' => [ 'min' => 0, 'max' => 600 ] ], 'selectors' => [ '{{WRAPPER}} .eppro-btn' => 'min-width: {{SIZE}}{{UNIT}};' ], ] ); $this->add_control( 'alignment', [ 'label' => __( 'Alignment', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::CHOOSE, 'options' => [ 'left' => [ 'title' => __( 'Left', 'admore-widgets-suite' ), 'icon' => 'eicon-text-align-left' ], 'center' => [ 'title' => __( 'Center', 'admore-widgets-suite' ), 'icon' => 'eicon-text-align-center' ], 'right' => [ 'title' => __( 'Right', 'admore-widgets-suite' ), 'icon' => 'eicon-text-align-right' ], ], 'default' => 'center', ] ); $this->add_control( 'full_width', [ 'label' => __( 'Full Width', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SWITCHER, 'return_value' => 'yes', 'selectors' => [ '{{WRAPPER}} .eppro-btn' => 'width:100%;justify-content:center;' ], ] ); $this->add_control( 'sub_label', [ 'label' => __( 'Sub Label', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::TEXT, 'default' => '', 'placeholder' => __( 'e.g. No credit card required', 'admore-widgets-suite' ), 'separator' => 'before', 'dynamic' => [ 'active' => true ], ] ); $this->add_control( 'scroll_to', [ 'label' => __( 'Scroll To Section ID', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::TEXT, 'placeholder' => '#section-id', 'description' => __( 'Enter a section ID to smooth-scroll on click (overrides the Link above).', 'admore-widgets-suite' ), ] ); $this->add_control( 'tooltip_text', [ 'label' => __( 'Tooltip Text', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::TEXT, 'placeholder' => __( 'Tooltip on hover', 'admore-widgets-suite' ), 'dynamic' => [ 'active' => true ], ] ); $this->end_controls_section(); /* ================= STYLE ================= */ $this->start_controls_section( 'style_section', [ 'label' => __( 'Button Style', 'admore-widgets-suite' ), 'tab' => \Elementor\Controls_Manager::TAB_STYLE, ] ); $this->add_group_control( \Elementor\Group_Control_Typography::get_type(), [ 'name'=>'typography', 'selector'=>'{{WRAPPER}} .eppro-btn' ] ); $this->add_responsive_control( 'padding', [ 'label' => __( 'Padding', 'admore-widgets-suite' ), 'type'=>\Elementor\Controls_Manager::DIMENSIONS, 'selectors'=>[ '{{WRAPPER}} .eppro-btn'=>'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' ] ] ); $this->start_controls_tabs('style_tabs'); /* NORMAL */ $this->start_controls_tab( 'normal_tab', [ 'label' => __( 'Normal', 'admore-widgets-suite' ) ] ); $this->add_control( 'text_color', [ 'label' => __( 'Text Color', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .eppro-btn' => 'color: {{VALUE}};' ], ] ); $this->add_control( 'icon_color', [ 'label' => __( 'Icon Color', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .eppro-btn .eppro-btn-icon i' => 'color: {{VALUE}};', '{{WRAPPER}} .eppro-btn .eppro-btn-icon svg' => 'fill: {{VALUE}};', ], 'condition' => [ 'icon[value]!' => '' ], ] ); $this->add_group_control( \Elementor\Group_Control_Background::get_type(), [ 'name' => 'background', 'selector' => '{{WRAPPER}} .eppro-btn' ] ); $this->end_controls_tab(); /* HOVER */ $this->start_controls_tab( 'hover_tab', [ 'label' => __( 'Hover', 'admore-widgets-suite' ) ] ); $this->add_control( 'hover_text_color', [ 'label' => __( 'Text Color', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .eppro-btn:hover' => 'color: {{VALUE}};' ], ] ); $this->add_control( 'hover_icon_color', [ 'label' => __( 'Icon Color', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .eppro-btn:hover .eppro-btn-icon i' => 'color: {{VALUE}};', '{{WRAPPER}} .eppro-btn:hover .eppro-btn-icon svg' => 'fill: {{VALUE}};', ], 'condition' => [ 'icon[value]!' => '' ], ] ); $this->add_group_control( \Elementor\Group_Control_Background::get_type(), [ 'name' => 'hover_background', 'selector' => '{{WRAPPER}} .eppro-btn:hover' ] ); $this->end_controls_tab(); $this->end_controls_tabs(); $this->add_group_control( \Elementor\Group_Control_Border::get_type(), [ 'name'=>'border', 'selector'=>'{{WRAPPER}} .eppro-btn' ] ); $this->add_responsive_control( 'border_radius', [ 'label' => __( 'Border Radius', 'admore-widgets-suite' ), 'type'=>\Elementor\Controls_Manager::DIMENSIONS, 'selectors'=>[ '{{WRAPPER}} .eppro-btn'=>'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' ] ] ); $this->add_group_control( \Elementor\Group_Control_Box_Shadow::get_type(), [ 'name'=>'box_shadow', 'selector'=>'{{WRAPPER}} .eppro-btn' ] ); $this->add_group_control( \Elementor\Group_Control_Box_Shadow::get_type(), [ 'name' => 'hover_box_shadow', 'label' => __( 'Box Shadow', 'admore-widgets-suite' ), 'selector' => '{{WRAPPER}} .eppro-btn:hover', ] ); $this->add_control( 'hover_border_color', [ 'label' => __( 'Border Color', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .eppro-btn:hover' => 'border-color: {{VALUE}};' ], ] ); $this->add_control( 'hover_translate', [ 'label' => __( 'Lift on Hover (px)', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SLIDER, 'size_units' => [ 'px' ], 'range' => [ 'px' => [ 'min' => 0, 'max' => 20 ] ], 'default' => [ 'size' => 2 ], 'selectors' => [ '{{WRAPPER}} .eppro-btn' => '--eppro-btn-lift: -{{SIZE}}{{UNIT}};', '{{WRAPPER}} .eppro-btn:hover' => 'transform: translateY(var(--eppro-btn-lift, 0)) scale(var(--eppro-btn-scale, 1));', ], ] ); $this->add_control( 'hover_scale', [ 'label' => __( 'Hover Scale', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SLIDER, 'range' => [ 'px' => [ 'min' => 0.9, 'max' => 1.3, 'step' => 0.01 ] ], 'selectors' => [ '{{WRAPPER}} .eppro-btn' => '--eppro-btn-scale: {{SIZE}};', '{{WRAPPER}} .eppro-btn:hover' => 'transform: translateY(var(--eppro-btn-lift, 0)) scale(var(--eppro-btn-scale, 1));', ], ] ); $this->add_responsive_control( 'icon_size', [ 'label' => __( 'Icon Size', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SLIDER, 'range' => [ 'px' => [ 'min' => 10, 'max' => 100 ] ], 'selectors' => [ '{{WRAPPER}} .eppro-btn i' => 'font-size: {{SIZE}}{{UNIT}};', '{{WRAPPER}} .eppro-btn svg' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};', ], ] ); $this->add_responsive_control( 'icon_spacing', [ 'label' => __( 'Icon Spacing', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SLIDER, 'size_units' => [ 'px' ], 'range' => [ 'px' => [ 'min' => 0, 'max' => 30 ] ], 'default' => [ 'size' => 8 ], 'selectors' => [ '{{WRAPPER}} .eppro-btn .eppro-btn-icon' => 'gap: {{SIZE}}{{UNIT}};' ], 'condition' => [ 'icon[value]!' => '' ], ] ); $this->add_control( 'hover_animation', [ 'label' => __( 'Hover Animation', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => 'none', 'options' => [ 'none' => __( 'None', 'admore-widgets-suite' ), 'pulse' => __( 'Pulse', 'admore-widgets-suite' ), 'swing' => __( 'Swing', 'admore-widgets-suite' ), 'bounce' => __( 'Bounce', 'admore-widgets-suite' ), 'shake' => __( 'Shake', 'admore-widgets-suite' ), 'tada' => __( 'Tada', 'admore-widgets-suite' ), ], 'separator' => 'before', ] ); $this->add_control( 'hover_fill', [ 'label' => __( 'Fill Slide Effect', 'admore-widgets-suite' ), 'description' => __( 'Background color slides in from a direction on hover (uses ::before pseudo-element).', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => 'none', 'options' => [ 'none' => __( 'None', 'admore-widgets-suite' ), 'left' => __( 'Slide from Left', 'admore-widgets-suite' ), 'right' => __( 'Slide from Right', 'admore-widgets-suite' ), 'top' => __( 'Slide from Top', 'admore-widgets-suite' ), 'bottom' => __( 'Slide from Bottom', 'admore-widgets-suite' ), 'center' => __( 'Expand from Center', 'admore-widgets-suite' ), ], 'prefix_class' => 'eppro-btn--fill-', ] ); $this->add_control( 'hover_fill_color', [ 'label' => __( 'Fill Color', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::COLOR, 'default' => '#5b21b6', 'selectors' => [ '{{WRAPPER}} .eppro-btn::before' => 'background-color: {{VALUE}};' ], 'condition' => [ 'hover_fill!' => 'none' ], ] ); $this->add_control( 'transition_duration', [ 'label' => __( 'Transition Duration (ms)', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SLIDER, 'size_units' => [ 'ms' ], 'range' => [ 'ms' => [ 'min' => 0, 'max' => 1000, 'step' => 50 ] ], 'default' => [ 'size' => 250, 'unit' => 'ms' ], 'selectors' => [ '{{WRAPPER}} .eppro-btn' => 'transition-duration: {{SIZE}}ms;' ], 'separator' => 'before', ] ); $this->add_group_control( \Elementor\Group_Control_Text_Shadow::get_type(), [ 'name' => 'text_shadow', 'selector' => '{{WRAPPER}} .eppro-btn', 'separator' => 'before', ] ); $this->add_group_control( \Elementor\Group_Control_Text_Shadow::get_type(), [ 'name' => 'hover_text_shadow', 'label' => __( 'Text Shadow (Hover)', 'admore-widgets-suite' ), 'selector' => '{{WRAPPER}} .eppro-btn:hover', ] ); $this->end_controls_section(); // Entrance animation — inherited from base $this->eppro_register_entrance_animation_controls(); } protected function render() { $settings = $this->get_settings_for_display(); $link_url = $settings['link']['url'] ?? ''; $alignment = sanitize_key( $settings['alignment'] ?? 'left' ); $preset = sanitize_key( $settings['btn_preset'] ?? 'solid' ); $animation = sanitize_key( $settings['hover_animation'] ?? 'none' ); $this->add_render_attribute( 'wrapper', 'class', [ 'eppro-btn-wrapper', 'align-' . $alignment ] ); $btn_size = sanitize_key( $settings['btn_size'] ?? 'md' ); $icon_anim = sanitize_key( $settings['icon_hover_animation'] ?? 'none' ); $btn_classes = [ 'eppro-btn', 'preset-' . $preset, 'eppro-btn-size-' . $btn_size ]; if ( 'none' !== $animation ) { $btn_classes[] = 'eppro-hover-anim-' . $animation; } if ( 'none' !== $icon_anim ) { $btn_classes[] = 'eppro-icon-anim-' . $icon_anim; } $this->add_render_attribute( 'button', 'class', $btn_classes ); $scroll_to = trim( $settings['scroll_to'] ?? '' ); $tooltip = trim( $settings['tooltip_text'] ?? '' ); if ( $scroll_to ) { $anchor = ltrim( $scroll_to, '#' ); $this->add_render_attribute( 'button', 'href', '#' . esc_attr( $anchor ) ); $this->add_render_attribute( 'button', 'data-eppro-scroll', esc_attr( $anchor ) ); } else { $this->add_render_attribute( 'button', 'href', esc_url( $link_url ) ); } if ( $tooltip ) { $this->add_render_attribute( 'button', 'title', esc_attr( $tooltip ) ); $this->add_render_attribute( 'button', 'data-eppro-tooltip', esc_attr( $tooltip ) ); } if ( ! empty( $settings['btn_css_id'] ) ) { $this->add_render_attribute( 'button', 'id', sanitize_html_class( $settings['btn_css_id'] ) ); } $rel_parts = []; if ( ! empty( $settings['link']['is_external'] ) ) { $this->add_render_attribute( 'button', 'target', '_blank' ); $rel_parts[] = 'noopener'; $rel_parts[] = 'noreferrer'; } if ( ! empty( $settings['link']['nofollow'] ) ) { $rel_parts[] = 'nofollow'; } if ( $rel_parts ) { $this->add_render_attribute( 'button', 'rel', implode( ' ', $rel_parts ) ); } $icon_pos = $settings['icon_position'] ?? 'before'; $has_icon = ! empty( $settings['icon']['value'] ); $sub_label = trim( $settings['sub_label'] ?? '' ); if ( $has_icon ) { $this->add_render_attribute( 'button', 'class', 'icon-' . $icon_pos ); } if ( $sub_label ) { $this->add_render_attribute( 'button', 'class', 'has-sub' ); } echo '