PluginProbe
Commerce7 for WordPress / trunk
Commerce7 for WordPress vtrunk
1.8.1 1.8.0 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.1.0 1.1.1 1.1.3 1.2.0 1.2.1 1.2.2 1.2.3 1.2.5 1.2.6 1.3.0 1.3.1 1.3.2 1.3.4 1.3.5 1.4.0 1.4.1 All 37 releases
wp-commerce7 / includes / elementor / elementor-reservation.php

elementor-reservation.php in Commerce7 for WordPress trunk, at includes/elementor/elementor-reservation.php

307 lines 9.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Elementor widget: Reservation Form
4 *
5 * Created Date: Wednesday September 2nd 2020
6 * Author: Michael Bourne
7 * -----
8 * Last Modified: Wednesday, February 11th 2026, 8:26:26 pm
9 * Modified By: Michael Bourne
10 * -----
11 * Copyright (c) 2020 URSA6
12 *
13 * @package wp-commerce7
14 * @author Michael Bourne
15 * @license GPL3
16 * @link https://ursa6.com
17 * @since 1.0.8
18 */
19
20 if ( ! defined( 'ABSPATH' ) ) {
21 return;
22 }
23
24
25 /**
26 * Widget class
27 */
28 class C7WP_Elementor_Reservation extends \Elementor\Widget_Base {
29
30
31 /**
32 * Get widget name.
33 *
34 * Retrieve Commerce7 widget name.
35 *
36 * @since 1.0.0
37 * @access public
38 *
39 * @return string Widget name.
40 */
41 public function get_name() {
42 return 'commerce7-reservation';
43 }
44
45 /**
46 * Get widget title.
47 *
48 * Retrieve Commerce7 widget title.
49 *
50 * @since 1.0.0
51 * @access public
52 *
53 * @return string Widget title.
54 */
55 public function get_title() {
56 return __( 'Reservation Form', 'wp-commerce7' );
57 }
58
59 /**
60 * Get widget icon.
61 *
62 * Retrieve Commerce7 widget icon.
63 *
64 * @since 1.0.0
65 * @access public
66 *
67 * @return string Widget icon.
68 */
69 public function get_icon() {
70 return 'c7icon-c7sm';
71 }
72
73 /**
74 * Get widget categories.
75 *
76 * Retrieve the list of categories the widget belongs to.
77 *
78 * @since 1.0.0
79 * @access public
80 *
81 * @return array Widget categories.
82 */
83 public function get_categories() {
84 return array( 'commerce7' );
85 }
86
87 /**
88 * Retrieve widget keywords.
89 *
90 * @since 1.0.0
91 * @access public
92 *
93 * @return array Widget keywords.
94 */
95 public function get_keywords() {
96 return array( 'commerce7', 'reserve', 'reservation' );
97 }
98
99 /**
100 * Register widget controls.
101 *
102 * Adds different input fields to allow the user to change and customize the widget settings.
103 *
104 * @since 1.0.0
105 * @access protected
106 */
107 protected function register_controls() { // phpcs:ignore
108
109 $this->start_controls_section(
110 'content_section',
111 array(
112 'label' => __( 'Settings', 'wp-commerce7' ),
113 'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
114 )
115 );
116
117 $this->add_control(
118 'preview_notice',
119 array(
120 'type' => \Elementor\Controls_Manager::RAW_HTML,
121 'raw' => '<div style="background: #fff3cd; border: 1px solid #ffeaa7; padding: 10px; border-radius: 4px; margin-bottom: 15px;"><strong>Preview Notice:</strong> The preview shown in your editor is for example purposes only, it does not reflect the experience slug you provide nor is it interactive.</div>',
122 'content_classes' => 'elementor-panel-alert elementor-panel-alert-warning',
123 )
124 );
125
126 $this->add_control(
127 'data',
128 array(
129 'label' => __( 'Experience Slug', 'wp-commerce7' ),
130 'type' => \Elementor\Controls_Manager::TEXT,
131 'placeholder' => __( 'estate-tour', 'wp-commerce7' ),
132 )
133 );
134
135 $this->end_controls_section();
136 }
137
138 /**
139 * Render Commerce widget output on the frontend.
140 *
141 * Written in PHP and used to generate the final HTML.
142 *
143 * @since 1.0.0
144 * @access protected
145 */
146 protected function render() {
147
148 $settings = $this->get_settings_for_display();
149
150 $data = esc_attr( $settings['data'] );
151
152 // Show preview in Elementor editor, shortcode on frontend
153 if ( \Elementor\Plugin::$instance->editor->is_edit_mode() || \Elementor\Plugin::$instance->preview->is_preview_mode() ) {
154 $slugProvided = ! empty( $data );
155 ?>
156 <div class="c7-reservation-availability-placeholder" data-reservation-type-slug="<?php echo esc_attr( $data ); ?>">
157 <?php if ( $slugProvided ) : ?>
158 <section class="c7-reservation__search">
159 <form class="c7-form">
160 <div class="c7-form__group">
161 <div class="c7-form__field">
162 <label class="c7-required">Date</label>
163 <div class="c7-date-picker-input">
164 <input type="text" placeholder="MMM DD YYYY" value="" tabindex="-1" disabled>
165 <button type="button" class="c7-date-picker-toggle" tabindex="-1" disabled>
166 <span role="img">
167 <span class="dashicons dashicons-calendar-alt" aria-hidden="true"></span>
168 </span>
169 </button>
170 </div>
171 </div>
172 <div class="c7-form__field">
173 <label class="c7-required">Time</label>
174 <select tabindex="-1" disabled>
175 <option value=""></option>
176 <option value="10:00:00">10:00 am</option>
177 <option value="10:30:00">10:30 am</option>
178 <option value="11:00:00">11:00 am</option>
179 <option value="11:30:00">11:30 am</option>
180 <option value="12:00:00">12:00 pm</option>
181 <option value="12:30:00">12:30 pm</option>
182 <option value="13:00:00">1:00 pm</option>
183 <option value="13:30:00">1:30 pm</option>
184 <option value="14:00:00">2:00 pm</option>
185 <option value="14:30:00">2:30 pm</option>
186 <option value="15:00:00">3:00 pm</option>
187 <option value="15:30:00">3:30 pm</option>
188 <option value="16:00:00">4:00 pm</option>
189 </select>
190 </div>
191 <div class="c7-form__field">
192 <label class="c7-required">No of Guests</label>
193 <select tabindex="-1" disabled>
194 <option value=""></option>
195 <option value="1">1</option>
196 <option value="2">2</option>
197 <option value="3">3</option>
198 <option value="4">4</option>
199 <option value="5">5</option>
200 </select>
201 </div>
202 <button type="submit" class="c7-btn c7-btn--primary" tabindex="-1" disabled>
203 <span>Check Availability</span>
204 </button>
205 </div>
206 </form>
207 </section>
208 <?php else : ?>
209 <div class="c7-message c7-message--alert-error" role="presentation">
210 <svg aria-hidden="true" focusable="false" role="presentation" xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="#000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
211 <circle cx="12" cy="12" r="10"></circle>
212 <line x1="12" y1="8" x2="12" y2="12"></line>
213 <line x1="12" y1="16" x2="12.01" y2="16"></line>
214 </svg>
215 Please enter the single experience slug in the widget settings
216 </div>
217 <?php endif; ?>
218 </div>
219 <?php
220 } else {
221 // Frontend - show actual shortcode
222 echo do_shortcode( '[c7wp type="reservation" data="' . $data . '"]' );
223 }
224 }
225
226 /**
227 * Render widget output in the editor.
228 *
229 * Written as a Backbone JavaScript template and used to generate the live preview.
230 *
231 * @since 1.0.0
232 * @access protected
233 */
234 protected function content_template() {
235 ?>
236 <#
237 var slugProvided = settings.data && settings.data.length > 0;
238 #>
239 <div class="c7-reservation-availability-placeholder" data-reservation-type-slug="{{{ settings.data }}}">
240 <# if (slugProvided) { #>
241 <section class="c7-reservation__search">
242 <form class="c7-form">
243 <div class="c7-form__group">
244 <div class="c7-form__field">
245 <label class="c7-required">Date</label>
246 <div class="c7-date-picker-input">
247 <input type="text" placeholder="MMM DD YYYY" value="" tabindex="-1" disabled>
248 <button type="button" class="c7-date-picker-toggle" tabindex="-1" disabled>
249 <span role="img">
250 <span class="dashicons dashicons-calendar-alt" aria-hidden="true"></span>
251 </span>
252 </button>
253 </div>
254 </div>
255 <div class="c7-form__field">
256 <label class="c7-required">Time</label>
257 <select tabindex="-1" disabled>
258 <option value=""></option>
259 <option value="10:00:00">10:00 am</option>
260 <option value="10:30:00">10:30 am</option>
261 <option value="11:00:00">11:00 am</option>
262 <option value="11:30:00">11:30 am</option>
263 <option value="12:00:00">12:00 pm</option>
264 <option value="12:30:00">12:30 pm</option>
265 <option value="13:00:00">1:00 pm</option>
266 <option value="13:30:00">1:30 pm</option>
267 <option value="14:00:00">2:00 pm</option>
268 <option value="14:30:00">2:30 pm</option>
269 <option value="15:00:00">3:00 pm</option>
270 <option value="15:30:00">3:30 pm</option>
271 <option value="16:00:00">4:00 pm</option>
272 </select>
273 </div>
274 <div class="c7-form__field">
275 <label class="c7-required">No of Guests</label>
276 <select tabindex="-1" disabled>
277 <option value=""></option>
278 <option value="1">1</option>
279 <option value="2">2</option>
280 <option value="3">3</option>
281 <option value="4">4</option>
282 <option value="5">5</option>
283 </select>
284 </div>
285 <button type="submit" class="c7-btn c7-btn--primary" tabindex="-1" disabled>
286 <span>Check Availability</span>
287 </button>
288 </div>
289 </form>
290 </section>
291 <# } else { #>
292 <div class="c7-message c7-message--alert-error" role="presentation">
293 <svg aria-hidden="true" focusable="false" role="presentation" xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="#000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
294 <circle cx="12" cy="12" r="10"></circle>
295 <line x1="12" y1="8" x2="12" y2="12"></line>
296 <line x1="12" y1="16" x2="12.01" y2="16"></line>
297 </svg>
298 Please enter the single experience slug in the widget settings
299 </div>
300 <# } #>
301 </div>
302 <?php
303 }
304 public function render_plain_content( $instance = array() ) {}
305
306 }
307