1: <?php
2: /**
3: * Elementor Property Buttons Widget
4: *
5: * @package EPL
6: * @subpackage PageBuilders/Elementor/Widgets/Elements
7: * @since 3.6.0
8: */
9:
10: // Exit if accessed directly.
11: if ( ! defined( 'ABSPATH' ) ) {
12: exit;
13: }
14:
15: /**
16: * EPL_Elementor_Property_Buttons Class
17: *
18: * @since 3.6.0
19: */
20: class EPL_Elementor_Property_Buttons extends \Elementor\Widget_Base {
21: use EPL_Elementor_Dynamic_Widget;
22:
23: /**
24: * Get widget name.
25: *
26: * @return string
27: * @since 3.6.0 New: Elementor widgets (beta).
28: */
29: public function get_name() {
30: return 'epl-property-buttons';
31: }
32:
33: /**
34: * Get widget title.
35: *
36: * @return string
37: * @since 3.6.0 New: Elementor widgets (beta).
38: */
39: public function get_title() {
40: return esc_html__( 'Buttons', 'easy-property-listings' );
41: }
42:
43: /**
44: * Get widget icon.
45: *
46: * @return string
47: * @since 3.6.0 New: Elementor widgets (beta).
48: */
49: public function get_icon() {
50: return 'eicon-button';
51: }
52:
53: /**
54: * Get widget categories.
55: *
56: * @return array
57: * @since 3.6.0 New: Elementor widgets (beta).
58: */
59: public function get_categories() {
60: return array( 'epl-elements' );
61: }
62:
63: /**
64: * Get widget keywords.
65: *
66: * @return array
67: * @since 3.6.0 New: Elementor widgets (beta).
68: */
69: public function get_keywords() {
70: return array( 'property', 'buttons', 'enquire', 'download', 'epl' );
71: }
72:
73: /**
74: * Register widget controls.
75: * @since 3.6.0 New: Elementor widgets (beta).
76: */
77: protected function register_controls() {
78: // Style Section.
79: $this->start_controls_section(
80: 'section_style',
81: array(
82: 'label' => esc_html__( 'Style', 'easy-property-listings' ),
83: 'tab' => \Elementor\Controls_Manager::TAB_STYLE,
84: )
85: );
86:
87: $this->add_responsive_control(
88: 'margin',
89: array(
90: 'label' => esc_html__( 'Margin', 'easy-property-listings' ),
91: 'type' => \Elementor\Controls_Manager::DIMENSIONS,
92: 'size_units' => array( 'px', '%', 'em' ),
93: 'selectors' => array(
94: '{{WRAPPER}} .epl-property-buttons' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
95: ),
96: )
97: );
98:
99: $this->add_responsive_control(
100: 'align',
101: array(
102: 'label' => esc_html__( 'Alignment', 'easy-property-listings' ),
103: 'type' => \Elementor\Controls_Manager::CHOOSE,
104: 'options' => array(
105: 'left' => array(
106: 'title' => esc_html__( 'Left', 'easy-property-listings' ),
107: 'icon' => 'eicon-text-align-left',
108: ),
109: 'center' => array(
110: 'title' => esc_html__( 'Center', 'easy-property-listings' ),
111: 'icon' => 'eicon-text-align-center',
112: ),
113: 'right' => array(
114: 'title' => esc_html__( 'Right', 'easy-property-listings' ),
115: 'icon' => 'eicon-text-align-right',
116: ),
117: ),
118: 'selectors' => array(
119: '{{WRAPPER}} .epl-property-buttons' => 'text-align: {{VALUE}};',
120: ),
121: )
122: );
123:
124: $this->end_controls_section();
125: }
126:
127: /**
128: * Render widget output.
129: * @since 3.6.0 New: Elementor widgets (beta).
130: */
131: protected function render() {
132: $property = EPL_Elementor::setup_listing_context();
133: $is_editor = \Elementor\Plugin::$instance->editor->is_edit_mode();
134:
135: if ( ! $property ) {
136: if ( $is_editor ) {
137: echo '<div class="epl-elementor-placeholder">' . esc_html__( 'Property Buttons - No listings found.', 'easy-property-listings' ) . '</div>';
138: }
139: EPL_Elementor::restore_listing_context();
140: return;
141: }
142:
143: echo '<div class="epl-property-buttons">';
144: do_action( 'epl_buttons_single_property' );
145: echo '</div>';
146:
147: EPL_Elementor::restore_listing_context();
148: }
149: }
150: