Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
firepot
/
next_old
/
wp-content
/
plugins
/
cyarb-toolkit
/
widgets
:
button.php
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?php /** * Button Widget */ namespace Elementor; class Cyarb_Button extends Widget_Base { public function get_name() { return 'CyarbButton'; } public function get_title() { return __( 'Cyarb Button', 'cyarb-toolkit' ); } public function get_icon() { return 'eicon-handle'; } public function get_categories() { return [ 'cyarb-elements' ]; } protected function register_controls() { $this->start_controls_section( 'cyarb_Button', [ 'label' => __( 'Cyarb Button', 'cyarb-toolkit' ), 'tab' => Controls_Manager::TAB_CONTENT, ] ); $this->add_control( 'button_text', [ 'label' => __( 'Button Text', 'cyarb-toolkit' ), 'type' => Controls_Manager::TEXT, 'default' => __('Get In Touch', 'cyarb-toolkit'), ] ); $this->add_control( 'button_link', [ 'label' => __( 'Button Link', 'cyarb-toolkit' ), 'type' => Controls_Manager::URL, ] ); $this->add_control( 'button_alignment', [ 'label' => __( 'Button Alignment', 'cyarb-toolkit' ), 'type' => Controls_Manager::SELECT, 'options' => [ 'text-start' => __( 'Left', 'cyarb-toolkit' ), 'text-center' => __( 'Center', 'cyarb-toolkit' ), 'text-end' => __( 'Right', 'cyarb-toolkit' ), ], 'default' => 'text-start', ] ); $this->end_controls_section(); $this->start_controls_section( 'Button_style', [ 'label' => __( 'Style', 'cyarb-toolkit' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_control( 'btn_text_color', [ 'label' => __( 'Button Text Color', 'cyarb-toolkit' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .default-btn' => 'color: {{VALUE}}', ], ] ); $this->add_control( 'btn_bg_color', [ 'label' => __( 'Button Background Color', 'cyarb-toolkit' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .default-btn' => 'background: {{VALUE}}', ], ] ); $this->add_control( 'btn_hover_text_color', [ 'label' => __( 'Button Hover Text Color', 'cyarb-toolkit' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .default-btn:hover' => 'color: {{VALUE}}', ], ] ); $this->add_control( 'btn_hbg_color', [ 'label' => __( 'Button Hover Background Color', 'cyarb-toolkit' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .default-btn:before, .default-btn::after' => 'background-color: {{VALUE}}', ], ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'btn_typography', 'label' => __( 'Button Typography', 'cyarb-toolkit' ), 'selector' => '{{WRAPPER}} .default-btn', ] ); $this->add_responsive_control( 'border_radius', [ 'label' => esc_html__( 'Border Radius', 'cyarb-toolkit' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ], 'selectors' => [ '{{WRAPPER}} .default-btn' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->add_responsive_control( 'text_padding', [ 'label' => esc_html__( 'Padding', 'cyarb-toolkit' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ], 'selectors' => [ '{{WRAPPER}} .default-btn' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], 'separator' => 'before', ] ); $this->end_controls_section(); } protected function render() { $settings = $this->get_settings_for_display(); if ( ! empty( $settings['button_link']['url'] ) ) { $this->add_link_attributes( 'button_link', $settings['button_link'] ); } if( $settings['button_text'] != '' ): ?> <div class="cyarb-button <?php echo esc_attr($settings['button_alignment']); ?>"> <a <?php echo $this->get_render_attribute_string( 'button_link' ); ?> class="default-btn"> <span> <?php echo esc_html( $settings['button_text'] ); ?></span> </a> </div> <?php endif; ?> <?php } } Plugin::instance()->widgets_manager->register( new Cyarb_Button );