| 1 |
<?php |
| 2 |
namespace Elementor; |
| 3 |
|
| 4 |
use Elementor\Includes\Widgets\Traits\Button_Trait; |
| 5 |
|
| 6 |
if ( ! defined( 'ABSPATH' ) ) { |
| 7 |
exit; // Exit if accessed directly. |
| 8 |
} |
| 9 |
|
| 10 |
/** |
| 11 |
* Elementor button widget. |
| 12 |
* |
| 13 |
* Elementor widget that displays a button with the ability to control every |
| 14 |
* aspect of the button design. |
| 15 |
* |
| 16 |
* @since 1.0.0 |
| 17 |
*/ |
| 18 |
class Widget_Button extends Widget_Base { |
| 19 |
|
| 20 |
use Button_Trait; |
| 21 |
|
| 22 |
/** |
| 23 |
* Get widget name. |
| 24 |
* |
| 25 |
* Retrieve button widget name. |
| 26 |
* |
| 27 |
* @since 1.0.0 |
| 28 |
* @access public |
| 29 |
* |
| 30 |
* @return string Widget name. |
| 31 |
*/ |
| 32 |
public function get_name() { |
| 33 |
return 'button'; |
| 34 |
} |
| 35 |
|
| 36 |
/** |
| 37 |
* Get widget title. |
| 38 |
* |
| 39 |
* Retrieve button widget title. |
| 40 |
* |
| 41 |
* @since 1.0.0 |
| 42 |
* @access public |
| 43 |
* |
| 44 |
* @return string Widget title. |
| 45 |
*/ |
| 46 |
public function get_title() { |
| 47 |
return esc_html__( 'Button', 'elementor' ); |
| 48 |
} |
| 49 |
|
| 50 |
/** |
| 51 |
* Get widget icon. |
| 52 |
* |
| 53 |
* Retrieve button widget icon. |
| 54 |
* |
| 55 |
* @since 1.0.0 |
| 56 |
* @access public |
| 57 |
* |
| 58 |
* @return string Widget icon. |
| 59 |
*/ |
| 60 |
public function get_icon() { |
| 61 |
return 'eicon-button'; |
| 62 |
} |
| 63 |
|
| 64 |
/** |
| 65 |
* Get widget categories. |
| 66 |
* |
| 67 |
* Retrieve the list of categories the button widget belongs to. |
| 68 |
* |
| 69 |
* Used to determine where to display the widget in the editor. |
| 70 |
* |
| 71 |
* @since 2.0.0 |
| 72 |
* @access public |
| 73 |
* |
| 74 |
* @return array Widget categories. |
| 75 |
*/ |
| 76 |
public function get_categories() { |
| 77 |
return [ 'basic' ]; |
| 78 |
} |
| 79 |
|
| 80 |
protected function register_controls() { |
| 81 |
$this->start_controls_section( |
| 82 |
'section_button', |
| 83 |
[ |
| 84 |
'label' => esc_html__( 'Button', 'elementor' ), |
| 85 |
] |
| 86 |
); |
| 87 |
|
| 88 |
$this->register_button_content_controls(); |
| 89 |
|
| 90 |
$this->end_controls_section(); |
| 91 |
|
| 92 |
$this->start_controls_section( |
| 93 |
'section_style', |
| 94 |
[ |
| 95 |
'label' => esc_html__( 'Button', 'elementor' ), |
| 96 |
'tab' => Controls_Manager::TAB_STYLE, |
| 97 |
] |
| 98 |
); |
| 99 |
|
| 100 |
$this->register_button_style_controls(); |
| 101 |
|
| 102 |
$this->end_controls_section(); |
| 103 |
} |
| 104 |
|
| 105 |
/** |
| 106 |
* Render button widget output on the frontend. |
| 107 |
* |
| 108 |
* Written in PHP and used to generate the final HTML. |
| 109 |
* |
| 110 |
* @since 1.0.0 |
| 111 |
* @access protected |
| 112 |
*/ |
| 113 |
protected function render() { |
| 114 |
$this->render_button(); |
| 115 |
} |
| 116 |
} |
| 117 |
|