PluginProbe
Booking Calendar / 10.1.3
Booking Calendar v10.1.3
11.8.3 11.8.2 11.8.1 11.8 11.7 11.6.1 11.6 11.5 11.4.3 11.4.2 11.4.1 11.4 11.3 11.2.1 11.2 11.1 11.0 10.15.7 10.15.6 10.1.3 10.10 10.10.1 10.10.2 10.11 10.11.2 All 203 releases
booking / core / lib / wpdev-booking-widget.php

wpdev-booking-widget.php in Booking Calendar 10.1.3, at core/lib/wpdev-booking-widget.php

178 lines 9.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // BookingWidget Class
4 class BookingWidget extends WP_Widget {
5 /** constructor */
6 function __construct() {
7 parent::__construct(false, $name = 'Booking Calendar');
8 }
9
10 /** @see WP_Widget::widget */
11 function widget($args, $instance) {
12 extract( $args );
13
14 $booking_widget_title = __('Booking Calendar', 'booking'); //FixIn: 6.1.1.11
15 $booking_widget_show = 'booking_form';
16 $booking_widget_type = 1;
17 $booking_widget_calendar_count = 1;
18 $booking_widget_last_field = '';
19
20
21 if ( isset( $instance['booking_widget_title'] ) ) //FixIn: 6.1.1.11
22 $booking_widget_title = apply_filters('widget_title', $instance['booking_widget_title']);
23 if (function_exists('icl_translate'))
24 $booking_widget_title = icl_translate( 'wpml_custom', 'wpbc_custom_widget_booking_title1', $booking_widget_title);
25
26 if ( isset( $instance['booking_widget_show'] ) ) //FixIn: 6.1.1.11
27 $booking_widget_show = $instance['booking_widget_show'];
28 if ( isset( $instance['booking_widget_type'] ) ) //FixIn: 6.1.1.11
29 $booking_widget_type = $instance['booking_widget_type'];
30 if (empty($booking_widget_type)) $booking_widget_type=1;
31 if ( isset( $instance['booking_widget_calendar_count'] ) ) //FixIn: 6.1.1.11
32 $booking_widget_calendar_count = $instance['booking_widget_calendar_count'];
33 if ( isset( $instance['booking_widget_last_field'] ) ) //FixIn: 6.1.1.11
34 $booking_widget_last_field = $instance['booking_widget_last_field'];
35
36
37
38 echo $before_widget;
39 if (isset($_GET['booking_hash'])) {
40 _e('You need to use special shortcode [bookingedit] for booking editing.' ,'booking');
41 echo $after_widget;
42 return;
43 }
44
45 if ($booking_widget_title != '') echo $before_title . htmlspecialchars_decode($booking_widget_title) . $after_title;
46
47 echo "<div class='widget_wpdev_booking wpdevelop months_num_in_row_1'>"; //FixIn: 8.4.2.3
48 if ($booking_widget_show == 'booking_form') {
49 // do_action('wpdev_bk_add_form', $booking_widget_type , $booking_widget_calendar_count);
50 $my_booking_form_name = apply_bk_filter('wpbc_get_default_custom_form', 'standard', $booking_widget_type);
51 make_bk_action('wpdevbk_add_form', $booking_widget_type , $booking_widget_calendar_count, true, $my_booking_form_name );
52
53 } else {
54 echo "<div class='wpbc_only_calendar wpbc_container'>"; //FixIn: 8.0.1.2
55 echo "<div id='calendar_booking_unselectable" . $booking_widget_type . "'></div>"; //FixIn: 6.1.1.13
56 do_action( 'wpdev_bk_add_calendar', $booking_widget_type, $booking_widget_calendar_count );
57 echo '</div>';
58 }
59
60 if ($booking_widget_last_field !== '') echo '<br/>' . htmlspecialchars_decode($booking_widget_last_field);
61 echo "</div>";
62
63 echo $after_widget;
64
65
66 }
67
68 /** @see WP_Widget::update */
69 function update($new_instance, $old_instance) {
70 $instance = $old_instance;
71
72 $instance['booking_widget_title'] = strip_tags($new_instance['booking_widget_title']);
73 $instance['booking_widget_show'] = strip_tags($new_instance['booking_widget_show']);
74 $instance['booking_widget_type'] = ( empty( $new_instance['booking_widget_type'] ) ? 1 : strip_tags( $new_instance['booking_widget_type'] ) );
75 $instance['booking_widget_calendar_count'] = strip_tags($new_instance['booking_widget_calendar_count']);
76 $instance['booking_widget_last_field'] = $new_instance['booking_widget_last_field'];
77 return $instance;
78 }
79
80 /** @see WP_Widget::form */
81 function form($instance) {
82 if ( isset($instance['booking_widget_title']) ) $booking_widget_title = esc_attr($instance['booking_widget_title']);
83 else $booking_widget_title = '';
84 if ( isset($instance['booking_widget_show']) ) $booking_widget_show = esc_attr($instance['booking_widget_show']);
85 else $booking_widget_show = '';
86 if ( ( class_exists('wpdev_bk_personal') ) && ( isset($instance['booking_widget_type']) ) ) {
87 $booking_widget_type = esc_attr($instance['booking_widget_type']);
88 } else $booking_widget_type=1;
89 if ( isset($instance['booking_widget_calendar_count']) ) $booking_widget_calendar_count = esc_attr($instance['booking_widget_calendar_count']);
90 else $booking_widget_calendar_count = 1;
91 if ( isset($instance['booking_widget_last_field']) ) $booking_widget_last_field = esc_attr($instance['booking_widget_last_field']);
92 else $booking_widget_last_field = '';
93 ?>
94
95 <p>
96 <label for="<?php echo $this->get_field_id('booking_widget_title'); ?>"><?php _e('Title' ,'booking'); ?>:</label><br/>
97 <input value="<?php echo $booking_widget_title; ?>"
98 name="<?php echo $this->get_field_name('booking_widget_title'); ?>"
99 id="<?php echo $this->get_field_id('booking_widget_title'); ?>"
100 type="text" class="widefat" style="width:100%;line-height: 1.5em;" />
101 </p>
102
103 <p>
104 <label for="<?php echo $this->get_field_id('booking_widget_show'); ?>"><?php _e('Show' ,'booking'); ?>:</label><br/>
105 <select
106 name="<?php echo $this->get_field_name('booking_widget_show'); ?>"
107 id="<?php echo $this->get_field_id('booking_widget_show'); ?>" style="width:100%;line-height: 1.5em;">
108 <option <?php if($booking_widget_show == 'booking_form') echo "selected"; ?> value="booking_form"><?php _e('Booking form with calendar' ,'booking'); ?></option>
109 <option <?php if($booking_widget_show == 'booking_calendar') echo "selected"; ?> value="booking_calendar"><?php _e('Only availability calendar' ,'booking'); ?></option>
110 </select>
111 </p>
112
113
114 <?php
115 if ( class_exists('wpdev_bk_personal')) {
116 $types_list = wpbc_get_br_as_objects(); ?>
117 <p>
118 <label for="<?php echo $this->get_field_id('booking_widget_type'); ?>"><?php _e('Booking resource' ,'booking'); ?>:</label><br/>
119 <!--input id="calendar_type" name="calendar_type" class="input" type="text" -->
120 <select
121 name="<?php echo $this->get_field_name('booking_widget_type'); ?>"
122 id="<?php echo $this->get_field_id('booking_widget_type'); ?>"
123 style="width:100%;line-height: 1.5em;">
124 <?php foreach ($types_list as $tl) { ?>
125 <option <?php if($booking_widget_type == $tl->id ) echo "selected"; ?>
126 style="<?php if (isset($tl->parent)) if ($tl->parent == 0 ) { echo 'font-weight:600;'; } else { echo 'font-size:11px;padding-left:20px;'; } ?>"
127 value="<?php echo $tl->id; ?>"><?php echo $tl->title; ?></option>
128 <?php } ?>
129 </select>
130
131 </p>
132 <?php } ?>
133
134 <p>
135 <label for="<?php echo $this->get_field_id('booking_widget_calendar_count'); ?>"><?php _e('Visible months' ,'booking'); ?>:</label><br/>
136
137 <select style="width:100%;line-height: 1.5em;"
138 name="<?php echo $this->get_field_name('booking_widget_calendar_count'); ?>"
139 id="<?php echo $this->get_field_id('booking_widget_calendar_count'); ?>"
140 >
141 <?php foreach ( array(1,2,3,4,5,6,7,8,9,10,11,12) as $tl) { ?>
142 <option <?php if($booking_widget_calendar_count == $tl ) echo "selected"; ?>
143 style="font-weight:600;"
144 value="<?php echo $tl; ?>"><?php echo $tl; ?></option>
145 <?php } ?>
146 </select>
147 </p>
148
149 <p>
150 <label for="<?php echo $this->get_field_id('booking_widget_last_field'); ?>"><?php _e('Footer' ,'booking'); ?>:</label><br/>
151 <input value="<?php echo $booking_widget_last_field; ?>"
152 name="<?php echo $this->get_field_name('booking_widget_last_field'); ?>"
153 id="<?php echo $this->get_field_id('booking_widget_last_field'); ?>"
154 type="text" style="width:100%;line-height: 1.5em;" /><br/>
155 <em style="font-size:11px;"><?php printf(__("Example: %sMake booking here%s" ,'booking'),"<code>&lt;a href='". get_site_url() ."'&gt;",'&lt;/a&gt;</code>'); ?></em>
156 </p>
157
158 <p style="font-size:10px;" >
159 <?php printf(__("%sImportant!!!%s Please note, if you show booking calendar (inserted into post/page) with widget at the same page, then the last will not be visible." ,'booking'),'<strong>','</strong>'); ?>
160
161 <?php if (!class_exists('wpdev_bk_personal')) { ?>
162
163 <em><?php printf(__("%sSeveral widgets are supported at %spaid versions%s." ,'booking'),'<span style="">','<a href="https://wpbookingcalendar.com/" target="_blank" style="text-decoration:none;color:#3A5670;">','</a>','</span>'); ?></em>
164
165 <?php
166 }
167 ?></p><?php
168 }
169
170 } // class BookingWidget
171
172 // register widget - New, since WordPress - 2.8
173 //add_action('widgets_init', create_function('', 'return register_widget("BookingWidget");'));
174 //FixIn: 8.1.3.18
175 function register_wpbc_widget() {
176 register_widget("BookingWidget");
177 }
178 add_action( 'widgets_init', 'register_wpbc_widget' );