| 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 is_dynamic_content(): bool { |
| 81 |
return false; |
| 82 |
} |
| 83 |
|
| 84 |
/** |
| 85 |
* Get widget upsale data. |
| 86 |
* |
| 87 |
* Retrieve the widget promotion data. |
| 88 |
* |
| 89 |
* @since 3.19.0 |
| 90 |
* @access protected |
| 91 |
* |
| 92 |
* @return array Widget promotion data. |
| 93 |
*/ |
| 94 |
protected function get_upsale_data() { |
| 95 |
return [ |
| 96 |
'condition' => ! Utils::has_pro(), |
| 97 |
'image' => esc_url( ELEMENTOR_ASSETS_URL . 'images/go-pro.svg' ), |
| 98 |
'image_alt' => esc_attr__( 'Upgrade', 'elementor' ), |
| 99 |
'title' => esc_html__( 'Convert visitors into customers', 'elementor' ), |
| 100 |
'description' => esc_html__( 'Get the Call to Action widget and grow your toolbox with Elementor Pro.', 'elementor' ), |
| 101 |
'upgrade_url' => esc_url( 'https://go.elementor.com/go-pro-button-widget/' ), |
| 102 |
'upgrade_text' => esc_html__( 'Upgrade Now', 'elementor' ), |
| 103 |
]; |
| 104 |
} |
| 105 |
|
| 106 |
protected function register_controls() { |
| 107 |
$this->start_controls_section( |
| 108 |
'section_button', |
| 109 |
[ |
| 110 |
'label' => esc_html__( 'Button', 'elementor' ), |
| 111 |
] |
| 112 |
); |
| 113 |
|
| 114 |
$this->register_button_content_controls(); |
| 115 |
|
| 116 |
$this->end_controls_section(); |
| 117 |
|
| 118 |
$this->start_controls_section( |
| 119 |
'section_style', |
| 120 |
[ |
| 121 |
'label' => esc_html__( 'Button', 'elementor' ), |
| 122 |
'tab' => Controls_Manager::TAB_STYLE, |
| 123 |
] |
| 124 |
); |
| 125 |
|
| 126 |
$this->register_button_style_controls(); |
| 127 |
|
| 128 |
$this->end_controls_section(); |
| 129 |
} |
| 130 |
|
| 131 |
/** |
| 132 |
* Render button widget output on the frontend. |
| 133 |
* |
| 134 |
* Written in PHP and used to generate the final HTML. |
| 135 |
* |
| 136 |
* @since 1.0.0 |
| 137 |
* @access protected |
| 138 |
*/ |
| 139 |
protected function render() { |
| 140 |
$this->render_button(); |
| 141 |
} |
| 142 |
} |
| 143 |
|