1: <?php
2: /**
3: * Elementor Property Features 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_Features Class
17: *
18: * @since 3.6.0
19: */
20: class EPL_Elementor_Property_Features 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-features';
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__( 'Feature List', '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-bullet-list';
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', 'features', 'amenities', 'epl' );
71: }
72:
73: /**
74: * Register widget controls.
75: * @since 3.6.0 New: Elementor widgets (beta).
76: */
77: protected function register_controls() {
78:
79: $this->start_controls_section(
80: 'section_content',
81: array(
82: 'label' => esc_html__( 'Content', 'easy-property-listings' ),
83: 'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
84: )
85: );
86:
87: $this->add_control(
88: 'show_title',
89: array(
90: 'label' => esc_html__( 'Show Title', 'easy-property-listings' ),
91: 'description' => esc_html__( 'The features list already includes its own heading; enable this only for an additional custom title.', 'easy-property-listings' ),
92: 'type' => \Elementor\Controls_Manager::SWITCHER,
93: 'label_on' => esc_html__( 'Yes', 'easy-property-listings' ),
94: 'label_off' => esc_html__( 'No', 'easy-property-listings' ),
95: 'return_value' => 'yes',
96: 'default' => '',
97: )
98: );
99:
100: $this->add_control(
101: 'title_text',
102: array(
103: 'label' => esc_html__( 'Title', 'easy-property-listings' ),
104: 'type' => \Elementor\Controls_Manager::TEXT,
105: 'default' => esc_html__( 'Features', 'easy-property-listings' ),
106: 'condition' => array(
107: 'show_title' => 'yes',
108: ),
109: )
110: );
111:
112: $this->end_controls_section();
113:
114: // Style Section.
115: $this->start_controls_section(
116: 'section_style',
117: array(
118: 'label' => esc_html__( 'Style', 'easy-property-listings' ),
119: 'tab' => \Elementor\Controls_Manager::TAB_STYLE,
120: )
121: );
122:
123: $this->add_control(
124: 'text_color',
125: array(
126: 'label' => esc_html__( 'Color', 'easy-property-listings' ),
127: 'type' => \Elementor\Controls_Manager::COLOR,
128: 'selectors' => array(
129: '{{WRAPPER}} .epl-property-features' => 'color: {{VALUE}};',
130: ),
131: )
132: );
133:
134: $this->add_group_control(
135: \Elementor\Group_Control_Typography::get_type(),
136: array(
137: 'name' => 'typography',
138: 'selector' => '{{WRAPPER}} .epl-property-features',
139: )
140: );
141:
142: $this->end_controls_section();
143: }
144:
145: /**
146: * Render widget output.
147: * @since 3.6.0 New: Elementor widgets (beta).
148: */
149: protected function render() {
150: $property = EPL_Elementor::setup_listing_context();
151: $is_editor = \Elementor\Plugin::$instance->editor->is_edit_mode();
152:
153: if ( ! $property ) {
154: if ( $is_editor ) {
155: echo '<div class="epl-elementor-placeholder">' . esc_html__( 'Property Features - No listings found.', 'easy-property-listings' ) . '</div>';
156: }
157: EPL_Elementor::restore_listing_context();
158: return;
159: }
160:
161: $settings = $this->get_settings_for_display();
162:
163: echo '<div class="epl-property-features">';
164:
165: if ( 'yes' === $settings['show_title'] && ! empty( $settings['title_text'] ) ) {
166: echo '<h5 class="epl-features-title">' . esc_html( $settings['title_text'] ) . '</h5>';
167: }
168:
169: do_action( 'epl_property_features' );
170:
171: echo '</div>';
172:
173: EPL_Elementor::restore_listing_context();
174: }
175: }
176: