D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
aramrprl
/
greytechnologies.info
/
wp-content
/
plugins
/
techbiz-core
/
addons
/
widgets
/
Filename :
button.php
back
Copy
<?php use \Elementor\Widget_Base; use \Elementor\Controls_Manager; use \Elementor\Group_Control_Typography; use \Elementor\Group_Control_Border; use \Elementor\Group_Control_Box_Shadow; /** * * Button Widget . * */ class Techbiz_Button extends Widget_Base { public function get_name() { return 'techbizbutton'; } public function get_title() { return __( 'Button', 'techbiz' ); } public function get_icon() { return 'eicon-code'; } public function get_categories() { return [ 'techbiz' ]; } protected function register_controls() { $this->start_controls_section( 'button_section', [ 'label' => __( 'Button', 'techbiz' ), 'tab' => Controls_Manager::TAB_CONTENT, ] ); $this->add_control( 'button_style', [ 'label' => __( 'Button Style', 'techbiz' ), 'type' => Controls_Manager::SELECT, 'default' => '1', 'options' => [ '1' => __( 'Style One', 'techbiz' ), '2' => __( 'Style Two', 'techbiz' ), '3' => __( 'Style Three', 'techbiz' ), ], ] ); $this->add_control( 'button_text', [ 'label' => __( 'Button Text', 'techbiz' ), 'type' => Controls_Manager::TEXTAREA, 'default' => __( 'Button Text', 'techbiz' ) ] ); $this->add_control( 'button_icon_class', [ 'label' => __( 'Button Icon Class', 'techbiz' ), 'type' => Controls_Manager::TEXTAREA, 'default' => __( 'fas fa-chevron-right', 'techbiz' ), ] ); $this->add_control( 'button_link', [ 'label' => __( 'Link', 'techbiz' ), 'type' => Controls_Manager::URL, 'placeholder' => __( 'https://your-link.com', 'techbiz' ), 'show_external' => true, 'default' => [ 'url' => '#', 'is_external' => false, 'nofollow' => false, ], ] ); $this->add_responsive_control( 'button_align', [ 'label' => __( 'Alignment', 'techbiz' ), 'type' => Controls_Manager::CHOOSE, 'options' => [ 'left' => [ 'title' => __( 'Left', 'techbiz' ), 'icon' => 'eicon-text-align-left', ], 'center' => [ 'title' => __( 'Center', 'techbiz' ), 'icon' => 'eicon-text-align-center', ], 'right' => [ 'title' => __( 'Right', 'techbiz' ), 'icon' => 'eicon-text-align-right', ], ], 'default' => 'left', 'toggle' => true, 'selectors' => [ '{{WRAPPER}} .btn-wrapper' => 'text-align: {{VALUE}}', ], ] ); $this->end_controls_section(); $this->start_controls_section( 'button_style_section', [ 'label' => __( 'Button Style', 'techbiz' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_control( 'button_color', [ 'label' => __( 'Button Color', 'techbiz' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .btn-wrapper a' => 'color: {{VALUE}}', ], ] ); $this->add_control( 'button_color_hover', [ 'label' => __( 'Button Color Hover', 'techbiz' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .btn-wrapper a:hover' => 'color: {{VALUE}}', ], ] ); $this->add_control( 'button_bg_color', [ 'label' => __( 'Button Background Color', 'techbiz' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .btn-wrapper a,{{WRAPPER}} .vs-btn.style3::before' => 'background-color: {{VALUE}}', ], 'condition' => [ 'button_style' => '1' ], ] ); $this->add_control( 'button_bg_color_two', [ 'label' => __( 'Button Background Color', 'techbiz' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .vs-btn.style3::before' => 'background-color: {{VALUE}}', ], 'condition' => [ 'button_style' => '2' ] ] ); $this->add_control( 'button_bg_color_hover', [ 'label' => __( 'Button Background Hover Color', 'techbiz' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .btn-wrapper a:hover,{{WRAPPER}} .vs-btn:after' => 'background-color: {{VALUE}}', ], 'condition' => [ 'button_style' => '1' ], ] ); $this->add_control( 'button_bg_hover_color_two', [ 'label' => __( 'Button Background Hover Color', 'techbiz' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .vs-btn.style3::after' => 'background-color: {{VALUE}}', ], 'condition' => [ 'button_style' => '2' ] ] ); $this->add_group_control( Group_Control_Border::get_type(), [ 'name' => 'border', 'label' => __( 'Border', 'techbiz' ), 'selector' => '{{WRAPPER}} .btn-wrapper a', ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'button_typography', 'label' => __( 'Button Typography', 'techbiz' ), 'selector' => '{{WRAPPER}} .btn-wrapper a', ] ); $this->add_responsive_control( 'button_margin', [ 'label' => __( 'Button Margin', 'techbiz' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', '%', 'em' ], 'selectors' => [ '{{WRAPPER}} .btn-wrapper a' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ] ] ); $this->add_responsive_control( 'button_padding', [ 'label' => __( 'Button Padding', 'techbiz' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', '%', 'em' ], 'selectors' => [ '{{WRAPPER}} .btn-wrapper a' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ] ] ); $this->add_responsive_control( 'button_border_radius', [ 'label' => __( 'Button Border Radius', 'techbiz' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', '%', 'em' ], 'selectors' => [ '{{WRAPPER}} .btn-wrapper a' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ] ] ); $this->add_group_control( Group_Control_Box_Shadow::get_type(), [ 'name' => 'box_shadow', 'label' => __( 'Box Shadow', 'techbiz' ), 'selector' => '{{WRAPPER}} .btn-wrapper a', ] ); $this->end_controls_section(); } protected function render() { $settings = $this->get_settings_for_display(); $this->add_render_attribute( 'wrapper','class', 'btn-wrapper'); $this->add_render_attribute( 'wrapper','class', esc_attr( $settings['button_align'] ) ); if( $settings['button_style'] == '1' ){ $this->add_render_attribute( 'button', 'class', 'vs-btn' ); }elseif( $settings['button_style'] == '2' ){ $this->add_render_attribute( 'button', 'class', 'vs-btn style3' ); } if( ! empty( $settings['button_link']['url'] ) ) { $this->add_render_attribute( 'button', 'href', esc_url( $settings['button_link']['url'] ) ); } if( ! empty( $settings['button_link']['nofollow'] ) ) { $this->add_render_attribute( 'button', 'rel', 'nofollow' ); } if( ! empty( $settings['button_link']['is_external'] ) ) { $this->add_render_attribute( 'button', 'target', '_blank' ); } echo '<!-- Button -->'; echo '<div '.$this->get_render_attribute_string('wrapper').'>'; if( ! empty( $settings['button_text'] ) ) { echo '<a '.$this->get_render_attribute_string('button').'>'; echo esc_html( $settings['button_text'] ); if( ! empty( $settings['button_icon_class'] ) ){ echo '<i class="'.esc_attr( $settings['button_icon_class'] ).'"></i>'; } echo '</a>'; } echo '</div>'; echo '<!-- End Button -->'; } }