PluginProbe
Booking Calendar / 11.8.3
Booking Calendar v11.8.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
← All changes | core/wpbc-activation.php +521 -717 10.1111.8.3 View file →
@@ -13,8 +13,59 @@
13 13
14 14 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
15 15
16 16
17 +/**
18 + * Evaluate whether the current activation starts from a genuinely empty install.
19 + *
20 + * Both signals are required. A missing version option by itself is not reliable,
21 + * because older installations or interrupted upgrades can still have Booking
22 + * Calendar tables. A missing table by itself is also insufficient when stored
23 + * installation metadata remains.
24 + *
25 + * @param mixed $stored_version Stored Booking Calendar version, or false when absent.
26 + * @param bool $booking_table_exists Whether the canonical booking table exists.
27 + *
28 + * @return bool True only when neither installation signal exists.
29 + */
30 +function wpbc_is_plugin_initial_install_state( $stored_version, $booking_table_exists ) {
31 +
32 + return ( false === $stored_version ) && ! (bool) $booking_table_exists;
33 +}
34 +
35 +
36 +/**
37 + * Check whether the active activation request is a genuine first installation.
38 + *
39 + * The result is cached before activation creates tables or saves
40 + * `booking_version_num`, allowing later activation callbacks to consume the same
41 + * immutable request-scoped decision. For later administration requests, use the
42 + * persisted first-install marker owned by the Setup Wizard instead.
43 + *
44 + * @return bool True during a genuine first-install activation; otherwise false.
45 + */
46 +function wpbc_is_plugin_initial_install() {
47 +
48 + static $is_initial_install = null;
49 +
50 + if ( null !== $is_initial_install ) {
51 + return $is_initial_install;
52 + }
53 +
54 + if ( ! function_exists( 'wpbc_is_table_exists' ) ) {
55 + $is_initial_install = false;
56 + return $is_initial_install;
57 + }
58 +
59 + $is_initial_install = wpbc_is_plugin_initial_install_state(
60 + get_option( 'booking_version_num', false ),
61 + wpbc_is_table_exists( 'booking' )
62 + );
63 +
64 + return $is_initial_install;
65 +}
66 +
67 +
17 68 /** Activation & Deactivation of Booking Calendar */
18 69 class WPBC_BookingInstall extends WPBC_Install {
19 70
20 71 /**
@@ -55,533 +106,43 @@
55 106
56 107 return $links;
57 108
58 109 }
59 -
60 - /** Check if was updated from lower to high version */
61 - public function is_update_from_lower_to_high_version() {
62 -
63 - $is_make_activation = false;
64 110
65 - // Check conditions for different version about Upgrade
66 - if ( ( class_exists( 'wpdev_bk_personal' ) ) && ( ! wpbc_is_table_exists( 'bookingtypes' ) ) ) {
67 - $is_make_activation = true;
68 - }
69 - if ( ( ! $is_make_activation ) && ( class_exists( 'wpdev_bk_biz_s' ) ) && ( wpbc_is_field_in_table_exists( 'booking', 'pay_request' ) == 0 ) ) {
70 - $is_make_activation = true;
71 - }
72 - // FixIn: 9.9.0.13.
73 - if ( ( ! $is_make_activation ) && ( class_exists( 'wpdev_bk_biz_m' ) ) && ( ! wpbc_is_table_exists( 'booking_seasons' ) ) ) {
74 - $is_make_activation = true;
75 - }
76 - if ( ( ! $is_make_activation ) && ( class_exists( 'wpdev_bk_biz_l' ) ) && ( ! wpbc_is_table_exists( 'booking_coupons' ) ) ) {
77 - $is_make_activation = true;
78 - }
79 - if ( ( ! $is_make_activation ) && ( class_exists( 'wpdev_bk_multiuser' ) ) && ( wpbc_is_field_in_table_exists( 'booking_coupons', 'users' ) == 0 ) ) {
80 - $is_make_activation = true;
81 - }
82 - return $is_make_activation;
83 - }
111 + /** Check if was updated from lower to high version */
112 + public function is_update_from_lower_to_high_version() {
84 113
85 -}
114 + $is_make_activation = false;
86 115
116 + // Check conditions for different version about Upgrade
117 + if ( ( class_exists( 'wpdev_bk_personal' ) ) && ( ! wpbc_is_table_exists( 'bookingtypes' ) ) ) {
118 + $is_make_activation = true;
119 + }
120 + if ( ( ! $is_make_activation ) && ( class_exists( 'wpdev_bk_biz_s' ) ) && ( wpbc_is_field_in_table_exists( 'booking', 'pay_request' ) == 0 ) ) {
121 + $is_make_activation = true;
122 + }
123 + // FixIn: 9.9.0.13.
124 + if ( ( ! $is_make_activation ) && ( class_exists( 'wpdev_bk_biz_m' ) ) && ( ! wpbc_is_table_exists( 'booking_seasons' ) ) ) {
125 + $is_make_activation = true;
126 + }
127 + if ( ( ! $is_make_activation ) && ( class_exists( 'wpdev_bk_biz_m' ) ) && ( wpbc_is_field_in_table_exists( 'booking_seasons', 'season_color' ) == 0 ) ) {
128 + $is_make_activation = true;
129 + }
130 + if ( ( ! $is_make_activation ) && ( class_exists( 'wpdev_bk_biz_l' ) ) && ( ! wpbc_is_table_exists( 'booking_coupons' ) ) ) {
131 + $is_make_activation = true;
132 + }
133 + if ( ( ! $is_make_activation ) && ( class_exists( 'wpdev_bk_multiuser' ) ) && ( wpbc_is_field_in_table_exists( 'booking_coupons', 'users' ) == 0 ) ) {
134 + $is_make_activation = true;
135 + }
87 136
88 -// <editor-fold defaultstate="collapsed" desc=" Examples Data for Demos " >
137 + return $is_make_activation;
138 + }
89 139
90 -function wpbc_create_examples_4_demo( $my_bk_types = array() ){
91 -
92 - global $wpdb;
93 - $version = wpbc_get_plugin_version_type();
94 -
95 - if (class_exists('wpdev_bk_multiuser')) {
96 -
97 - if ( empty( $my_bk_types ) ) {
98 - $my_bk_types = array( 13, 14, 15, 16, 17 ); // The booking resources with these IDs are exist in the Demo sites
99 - } else {
100 - shuffle( $my_bk_types );
101 - }
102 -
103 - // Get NUMBER of Bookings.
104 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
105 - $bookings_count = $wpdb->get_results( "SELECT COUNT(*) as count FROM {$wpdb->prefix}booking as bk WHERE bk.trash != 1" );
106 -
107 - if (count($bookings_count)>0) $bookings_count = $bookings_count[0]->count ;
108 - if ($bookings_count>=20) return;
109 -
110 - if ( ( ( defined( 'WP_BK_BETA_DATA_FILL_AS' ) ) && ( 'BL' === WP_BK_BETA_DATA_FILL_AS ) ) && ( isset( $_SERVER['HTTP_HOST'] ) ) && ( 'beta' === $_SERVER['HTTP_HOST'] ) ) {
111 - update_bk_option( 'booking_range_selection_time_is_active', 'On' );
112 - update_bk_option( 'booking_range_selection_start_time', '14:00' );
113 - update_bk_option( 'booking_range_selection_end_time', '12:00' );
114 -
115 - update_bk_option( 'booking_is_delete_if_deactive', 'On');
116 - }
117 -
118 - $max_num_bookings = 5; // How many bookings exist per resource
119 - foreach ($my_bk_types as $resource_id) { // Loop all resources
120 - $bk_type = $resource_id; // Booking Resource
121 -
122 - if ( ( ( defined( 'WP_BK_BETA_DATA_FILL_AS' ) ) && ( 'BL' === WP_BK_BETA_DATA_FILL_AS ) ) && ( isset( $_SERVER['HTTP_HOST'] ) ) && ( 'beta' === $_SERVER['HTTP_HOST'] ) ) {
123 - $min_days = 3;
124 - $max_days = 7;
125 - } else {
126 - $min_days = 1; // FixIn: 10.0.0.51.
127 - $max_days = 1; // FixIn: 10.0.0.51.
128 - }
129 -
130 - $evry_one = $max_days + wp_rand( 1, 5 ); // Multiplier of interval between 2 dates of different bookings
131 - $days_start_shift = wp_rand( $max_days, ( 3 * $max_days ) );//(ceil($max_num_bookings/2)) * $max_days; // How long far ago we are start bookings
132 -
133 - // Fill Development server by initial bookings
134 - if ( ( ( defined( 'WP_BK_BETA_DATA_FILL' ) ) && ( WP_BK_BETA_DATA_FILL > 0 ) ) && ( isset( $_SERVER['HTTP_HOST'] ) ) && ( 'beta' === $_SERVER['HTTP_HOST'] ) ) {
135 - $evry_one = $min_days + wp_rand( 1, 7 );//3*$max_days+wp_rand(1,7); // Multiplier of interval between 2 dates of different bookings
136 - $days_start_shift = wp_rand( 2 * $max_days, ( 5 * $max_days ) ); //wp_rand(2*$max_days,(5*$max_days));//(ceil($max_num_bookings/2)) * $max_days; // How long far ago we are start bookings
137 - }
138 -
139 - for ( $i = 0; $i < $max_num_bookings; $i ++ ) {
140 -
141 - $is_appr = wp_rand(0,1); // Pending | Approved
142 - $num_days = wp_rand($min_days,$max_days); // Max Number of Dates for specific booking
143 -
144 - $second_name = wpbc_get_initial_values_4_demo('second_name');
145 - $city = wpbc_get_initial_values_4_demo('city');
146 - if ( ( ( defined( 'WP_BK_BETA_DATA_FILL_AS' ) ) && ( 'BL' === WP_BK_BETA_DATA_FILL_AS ) ) && ( isset( $_SERVER['HTTP_HOST'] ) ) && ( 'beta' === $_SERVER['HTTP_HOST'] ) ) {
147 - $start_time = '14:00';
148 - $end_time = '12:00';
149 - } else {
150 - $range_time = wpbc_get_initial_values_4_demo( 'rangetime' ); // FixIn: 10.0.0.51.
151 - $start_time = $range_time[0]; // FixIn: 10.0.0.51.
152 - $end_time = $range_time[1]; // FixIn: 10.0.0.51.
153 - }
154 -
155 - $form = '';
156 - $form .= 'selectbox-one^rangetime'.$bk_type.'^'.$start_time.' - '.$end_time.'~';
157 - $form .= 'text^name'.$bk_type.'^'.wpbc_get_initial_values_4_demo('name').'~';
158 - $form .= 'text^secondname'.$bk_type.'^'.$second_name.'~';
159 - $form .= 'text^email'.$bk_type.'^'.$second_name.'.example@wpbookingcalendar.com~';
160 - $form .= 'text^address'.$bk_type.'^'.wpbc_get_initial_values_4_demo('adress').'~';
161 - $form .= 'text^city'.$bk_type.'^'.$city[0].'~';
162 - $form .= 'text^postcode'.$bk_type.'^'.wpbc_get_initial_values_4_demo('postcode').'~';
163 - $form .= 'text^country'.$bk_type.'^'.$city[1].'~';
164 - $form .= 'text^phone'.$bk_type.'^'.wpbc_get_initial_values_4_demo('phone').'~';
165 - $form .= 'selectbox-one^visitors'.$bk_type.'^1~';
166 - //$form .= 'checkbox^children'.$bk_type.'[]^0~';
167 - $form .= 'textarea^details'.$bk_type.'^'.wpbc_get_initial_values_4_demo('info').'~';
168 - $form .= 'coupon^coupon'.$bk_type.'^ ';
169 -
170 -
171 - $wp_bk_querie = "INSERT INTO {$wpdb->prefix}booking ( form, booking_type, cost, hash, modification_date ) VALUES
172 - ( '".$form."', ".$bk_type .", ".wp_rand(0,1000).", MD5('". time() . '_' . wp_rand(1000,1000000)."'), NOW() ) ;";
173 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
174 - $wpdb->query( $wp_bk_querie );
175 - $temp_id = $wpdb->insert_id;
176 -
177 - $wp_queries_sub = "INSERT INTO {$wpdb->prefix}bookingdates (
178 - booking_id,
179 - booking_date,
180 - approved
181 - ) VALUES ";
182 - for ($d_num = 0; $d_num < $num_days; $d_num++) {
183 - $my_interval = ( $i*$evry_one + $d_num);
184 -
185 - if ( ( ( defined( 'WP_BK_BETA_DATA_FILL_AS' ) ) && ( 'BL' === WP_BK_BETA_DATA_FILL_AS ) ) && ( isset( $_SERVER['HTTP_HOST'] ) ) && ( 'beta' === $_SERVER['HTTP_HOST'] ) ) {
186 -
187 - if ( 'On' !== get_bk_option( 'booking_range_selection_time_is_active' ) ) {
188 - $wp_queries_sub .= "( " . $temp_id . ", DATE_ADD(CURDATE(), INTERVAL -" . $days_start_shift . " day) + INTERVAL " . $my_interval . " day ," . $is_appr . " ),";
189 - } else {
190 - if ( $d_num == 0 ) { // Check In
191 - $wp_queries_sub .= "( " . $temp_id . ", DATE_ADD(CURDATE(), INTERVAL -" . $days_start_shift . " day) + INTERVAL \"" . $my_interval . " " . $start_time . ":01\" DAY_SECOND ," . $is_appr . " ),";
192 - } elseif ( $d_num == ( $num_days - 1 ) ) { // Check Out
193 - $wp_queries_sub .= "( " . $temp_id . ", DATE_ADD(CURDATE(), INTERVAL -" . $days_start_shift . " day) + INTERVAL \"" . $my_interval . " " . $end_time . ":02\" DAY_SECOND ," . $is_appr . " ),";
194 - } else {
195 - $wp_queries_sub .= "( " . $temp_id . ", DATE_ADD(CURDATE(), INTERVAL -" . $days_start_shift . " day) + INTERVAL " . $my_interval . " day ," . $is_appr . " ),";
196 - }
197 - }
198 - } else {
199 - $wp_queries_sub .= "( " . $temp_id . ", DATE_ADD(CURDATE(), INTERVAL -" . $days_start_shift . " DAY) + INTERVAL \"" . $my_interval . " " . $start_time . ":01\" DAY_SECOND ," . $is_appr . " ),"; // FixIn: 10.0.0.51.
200 - $wp_queries_sub .= "( " . $temp_id . ", DATE_ADD(CURDATE(), INTERVAL -" . $days_start_shift . " DAY) + INTERVAL \"" . $my_interval . " " . $end_time . ":02\" DAY_SECOND ," . $is_appr . " ),"; // FixIn: 10.0.0.51.
201 - }
202 - }
203 - $wp_queries_sub = substr($wp_queries_sub,0,-1) . ";";
204 -
205 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
206 - $wpdb->query( $wp_queries_sub );
207 - }
208 - }
209 - } else if ( $version == 'free' ) {
210 - if (empty($my_bk_types)) $my_bk_types=array(1,1);
211 - else shuffle($my_bk_types);
212 -
213 - for ($i = 0; $i < count($my_bk_types); $i++) {
214 -
215 - $bk_type = 1;
216 - $is_appr = wp_rand( 0, 1 );
217 - $evry_one = 2;
218 - if ( ( isset( $_SERVER['HTTP_HOST'] ) ) && ( ( 'beta' === $_SERVER['HTTP_HOST'] ) || ( 'freetest.wpbookingcalendar.com' === $_SERVER['HTTP_HOST'] ) ) ) {
219 - $evry_one = wp_rand( 1, 21 );
220 - $num_days = wp_rand( 1, 10 );
221 - $days_start_shift = - 1 * wp_rand( 0, 28 );
222 - }
223 -
224 -
225 - $second_name = wpbc_get_initial_values_4_demo('second_name');
226 - $form = '';
227 - $form .= 'text^name'.$bk_type.'^'.wpbc_get_initial_values_4_demo('name').'~';
228 - $form .= 'text^secondname'.$bk_type.'^'.$second_name.'~';
229 - $form .= 'text^email'.$bk_type.'^'.$second_name.'.example@wpbookingcalendar.com~';
230 - $form .= 'text^phone'.$bk_type.'^'.wpbc_get_initial_values_4_demo('phone').'~';
231 - $form .= 'textarea^details'.$bk_type.'^'.wpbc_get_initial_values_4_demo('info');
232 -
233 - $wp_bk_querie = "INSERT INTO {$wpdb->prefix}booking ( form, modification_date ) VALUES ( '".$form."', NOW() ) ;";
234 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
235 - $wpdb->query( $wp_bk_querie );
236 - $temp_id = $wpdb->insert_id;
237 - $wp_queries_sub = "INSERT INTO {$wpdb->prefix}bookingdates (
238 - booking_id,
239 - booking_date,
240 - approved
241 - ) VALUES ";
242 -
243 - if ( ( 'beta' === $_SERVER['HTTP_HOST'] ) || ( 'freetest.wpbookingcalendar.com' === $_SERVER['HTTP_HOST'] ) ) {
244 - for ($d_num = 0; $d_num < $num_days; $d_num++) {
245 - $wp_queries_sub .= "( ". $temp_id .", CURDATE()+ INTERVAL ".($days_start_shift + 2*($i+1)*$evry_one + $d_num)." day ,". $is_appr." ),";
246 - }
247 - $wp_queries_sub = substr($wp_queries_sub,0,-1) . ";";
248 - } else {
249 - $wp_queries_sub .= "( ". $temp_id .", CURDATE()+ INTERVAL ".(2*($i+1)*$evry_one+2)." day ,". $is_appr." ),
250 - ( ". $temp_id .", CURDATE()+ INTERVAL ".(2*($i+1)*$evry_one+3)." day ,". $is_appr." ),
251 - ( ". $temp_id .", CURDATE()+ INTERVAL ".(2*($i+1)*$evry_one+4)." day ,". $is_appr." );";
252 - }
253 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
254 - $wpdb->query( $wp_queries_sub );
255 - }
256 - } else if ( $version == 'personal' ) {
257 - $max_num_bookings = 8; // How many bookings exist
258 - for ($i = 0; $i < $max_num_bookings; $i++) {
259 -
260 - $bk_type = wp_rand(1,4); // Booking Resource
261 - $min_days = 1;
262 - $max_days = 7;
263 - $is_appr = wp_rand(0,1); // Pending | Approved
264 - $evry_one = $max_days; // Multiplier of interval between 2 dates of different bookings
265 - $num_days = wp_rand($min_days,$max_days); // Max Number of Dates for specific booking
266 - $days_start_shift = -1 * (ceil($max_num_bookings/2)) * $max_days; // How long far ago we are start bookings
267 -
268 - $second_name = wpbc_get_initial_values_4_demo('second_name');
269 - $form = '';
270 - $form .= 'text^name'.$bk_type.'^'.wpbc_get_initial_values_4_demo('name').'~';
271 - $form .= 'text^secondname'.$bk_type.'^'.$second_name.'~';
272 - $form .= 'text^email'.$bk_type.'^'.$second_name.'.example@wpbookingcalendar.com~';
273 - $form .= 'text^phone'.$bk_type.'^'.wpbc_get_initial_values_4_demo('phone').'~';
274 - $form .= 'selectbox-one^visitors'.$bk_type.'^'.wp_rand(1,4).'~';
275 - $form .= 'selectbox-one^children'.$bk_type.'^'.wp_rand(0,3).'~';
276 - $form .= 'textarea^details'.$bk_type.'^'.wpbc_get_initial_values_4_demo('info');
277 -
278 - $wp_bk_querie = "INSERT INTO {$wpdb->prefix}booking ( form, booking_type, hash, modification_date ) VALUES
279 - ( '".$form."', ".$bk_type .", MD5('". time() . '_' . wp_rand(1000,1000000)."'), NOW() ) ;";
280 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
281 - $wpdb->query( $wp_bk_querie );
282 - $temp_id = $wpdb->insert_id;
283 -
284 - $wp_queries_sub = "INSERT INTO {$wpdb->prefix}bookingdates (
285 - booking_id,
286 - booking_date,
287 - approved
288 - ) VALUES ";
289 - for ($d_num = 0; $d_num < $num_days; $d_num++) {
290 - $wp_queries_sub .= "( ". $temp_id .", CURDATE()+ INTERVAL ".($days_start_shift + $i*$evry_one + $d_num)." day ,". $is_appr." ),";
291 - }
292 - $wp_queries_sub = substr($wp_queries_sub,0,-1) . ";";
293 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
294 - $wpdb->query( $wp_queries_sub );
295 - }
296 - } else if ( $version == 'biz_s' ) {
297 - $max_num_bookings = 8; // How many bookings exist
298 - for ($i = 0; $i < $max_num_bookings; $i++) {
299 -
300 - $bk_type = wp_rand(1,4); // Booking Resource
301 - $min_days = 1;
302 - $max_days = 1;
303 - $is_appr = wp_rand(0,1); // Pending | Approved
304 - $evry_one = $max_days; // Multiplier of interval between 2 dates of different bookings
305 - $num_days = wp_rand($min_days,$max_days); // Max Number of Dates for specific booking
306 - $days_start_shift = (ceil($max_num_bookings/4)) * $max_days; // How long far ago we are start bookings
307 -
308 - $second_name = wpbc_get_initial_values_4_demo('second_name');
309 - $city = wpbc_get_initial_values_4_demo('city');
310 - $range_time = wpbc_get_initial_values_4_demo('rangetime');
311 - $start_time = $range_time[0];
312 - $end_time = $range_time[1];
313 -
314 - $form = '';
315 - $form .= 'selectbox-one^rangetime'.$bk_type.'^'.$start_time.' - '.$end_time.'~';
316 - $form .= 'text^name'.$bk_type.'^'.wpbc_get_initial_values_4_demo('name').'~';
317 - $form .= 'text^secondname'.$bk_type.'^'.$second_name.'~';
318 - $form .= 'text^email'.$bk_type.'^'.$second_name.'.example@wpbookingcalendar.com~';
319 - $form .= 'text^address'.$bk_type.'^'.wpbc_get_initial_values_4_demo('adress').'~';
320 - $form .= 'text^city'.$bk_type.'^'.$city[0].'~';
321 - $form .= 'text^postcode'.$bk_type.'^'.wpbc_get_initial_values_4_demo('postcode').'~';
322 - $form .= 'text^country'.$bk_type.'^'.$city[1].'~';
323 - $form .= 'text^phone'.$bk_type.'^'.wpbc_get_initial_values_4_demo('phone').'~';
324 - $form .= 'selectbox-one^visitors'.$bk_type.'^'.wp_rand(1,4).'~';
325 - $form .= 'checkbox^children'.$bk_type.'[]^'.wp_rand(0,3).'~';
326 - $form .= 'textarea^details'.$bk_type.'^'.wpbc_get_initial_values_4_demo('info');
327 -
328 - $wp_bk_querie = "INSERT INTO {$wpdb->prefix}booking ( form, booking_type, cost, hash, modification_date ) VALUES
329 - ( '".$form."', ".$bk_type .", ".wp_rand(0,1000).", MD5('". time() . '_' . wp_rand(1000,1000000)."'), NOW() ) ;";
330 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
331 - $wpdb->query( $wp_bk_querie );
332 - $temp_id = $wpdb->insert_id;
333 -
334 - $wp_queries_sub = "INSERT INTO {$wpdb->prefix}bookingdates (
335 - booking_id,
336 - booking_date,
337 - approved
338 - ) VALUES ";
339 - for ($d_num = 0; $d_num < $num_days; $d_num++) {
340 - $my_interval = ( $i*$evry_one + $d_num);
341 -// $wp_queries_sub .= "( ". $temp_id .", CURDATE()+ INTERVAL \"".($days_start_shift + $i*$evry_one + $d_num)." ".$start_time.":01\" DAY_SECOND ,". $is_appr." ),";
342 -// $wp_queries_sub .= "( ". $temp_id .", CURDATE()+ INTERVAL \"".($days_start_shift + $i*$evry_one + $d_num)." ".$end_time .":02\" DAY_SECOND ,". $is_appr." ),";
343 - $wp_queries_sub .= "( ". $temp_id .", DATE_ADD(CURDATE(), INTERVAL -".$days_start_shift." DAY) + INTERVAL \"".$my_interval." ".$start_time.":01\" DAY_SECOND ,". $is_appr." ),";
344 - $wp_queries_sub .= "( ". $temp_id .", DATE_ADD(CURDATE(), INTERVAL -".$days_start_shift." DAY) + INTERVAL \"".$my_interval." ".$end_time.":02\" DAY_SECOND ,". $is_appr." ),";
345 - }
346 - $wp_queries_sub = substr($wp_queries_sub,0,-1) . ";";
347 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
348 - $wpdb->query( $wp_queries_sub );
349 - }
350 - } else if ( $version == 'biz_m' ) {
351 - $max_num_bookings = 8; // How many bookings exist
352 - for ($i = 0; $i < $max_num_bookings; $i++) {
353 -
354 - $bk_type = wp_rand(1,4); // Booking Resource
355 - $min_days = 3;
356 - $max_days = 7;
357 - $is_appr = wp_rand(0,1); // Pending | Approved
358 - $evry_one = $max_days; // Multiplier of interval between 2 dates of different bookings
359 - $num_days = wp_rand($min_days,$max_days); // Max Number of Dates for specific booking
360 - $days_start_shift = (ceil($max_num_bookings/2)) * $max_days; // How long far ago we are start bookings
361 -
362 - $second_name = wpbc_get_initial_values_4_demo('second_name');
363 - $city = wpbc_get_initial_values_4_demo('city');
364 - $start_time = '14:00';
365 - $end_time = '12:00';
366 -
367 - $form = '';
368 - $form .= 'text^name'.$bk_type.'^'.wpbc_get_initial_values_4_demo('name').'~';
369 - $form .= 'text^secondname'.$bk_type.'^'.$second_name.'~';
370 - $form .= 'text^email'.$bk_type.'^'.$second_name.'.example@wpbookingcalendar.com~';
371 - $form .= 'text^address'.$bk_type.'^'.wpbc_get_initial_values_4_demo('adress').'~';
372 - $form .= 'text^city'.$bk_type.'^'.$city[0].'~';
373 - $form .= 'text^postcode'.$bk_type.'^'.wpbc_get_initial_values_4_demo('postcode').'~';
374 - $form .= 'text^country'.$bk_type.'^'.$city[1].'~';
375 - $form .= 'text^phone'.$bk_type.'^'.wpbc_get_initial_values_4_demo('phone').'~';
376 - $form .= 'selectbox-one^visitors'.$bk_type.'^'.wp_rand(1,4).'~';
377 - $form .= 'checkbox^children'.$bk_type.'[]^'.wp_rand(0,3).'~';
378 - $form .= 'textarea^details'.$bk_type.'^'.wpbc_get_initial_values_4_demo('info').'~';
379 - $form .= 'text^starttime'.$bk_type.'^'.$start_time.'~';
380 - $form .= 'text^endtime'.$bk_type.'^'.$end_time;
381 -
382 - $wp_bk_querie = "INSERT INTO {$wpdb->prefix}booking ( form, booking_type, cost, hash, modification_date ) VALUES
383 - ( '".$form."', ".$bk_type .", ".wp_rand(0,1000).", MD5('". time() . '_' . wp_rand(1000,1000000)."'), NOW() ) ;";
384 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
385 - $wpdb->query( $wp_bk_querie );
386 - $temp_id = $wpdb->insert_id;
387 -
388 - $wp_queries_sub = "INSERT INTO {$wpdb->prefix}bookingdates (
389 - booking_id,
390 - booking_date,
391 - approved
392 - ) VALUES ";
393 - for ($d_num = 0; $d_num < $num_days; $d_num++) {
394 - $my_interval = ( $i*$evry_one + $d_num);
395 - if ($d_num == 0) { // Check In
396 - $wp_queries_sub .= "( ". $temp_id .", DATE_ADD(CURDATE(), INTERVAL -".$days_start_shift." day) + INTERVAL \"".$my_interval." ".$start_time.":01\" DAY_SECOND ,". $is_appr." ),";
397 - } elseif ($d_num == ($num_days-1) ) { // Check Out
398 - $wp_queries_sub .= "( ". $temp_id .", DATE_ADD(CURDATE(), INTERVAL -".$days_start_shift." day) + INTERVAL \"".$my_interval." ".$end_time.":02\" DAY_SECOND ,". $is_appr." ),";
399 - } else {
400 - $wp_queries_sub .= "( ". $temp_id .", DATE_ADD(CURDATE(), INTERVAL -".$days_start_shift." day) + INTERVAL ".$my_interval." day ,". $is_appr." ),";
401 - }
402 - }
403 - $wp_queries_sub = substr($wp_queries_sub,0,-1) . ";";
404 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
405 - $wpdb->query( $wp_queries_sub );
406 - }
407 -
408 - } else if ( $version == 'biz_l' ) {
409 - $max_num_bookings = 12; // How many bookings exist
410 - for ($res_groups = 0; $res_groups < 2; $res_groups++)
411 - for ($i = 0; $i < $max_num_bookings; $i++) {
412 - if($res_groups)
413 - $bk_type = wp_rand(1,6); // Booking Resource
414 - else $bk_type = wp_rand(7,12); // Booking Resource
415 - $min_days = 2;
416 - $max_days = 7;
417 - $is_appr = wp_rand(0,1); // Pending | Approved
418 - $evry_one = $max_days; // Multiplier of interval between 2 dates of different bookings
419 - $num_days = wp_rand($min_days,$max_days); // Max Number of Dates for specific booking
420 - $days_start_shift = (ceil($max_num_bookings/2)) * $max_days; // How long far ago we are start bookings
421 -
422 - $second_name = wpbc_get_initial_values_4_demo('second_name');
423 - $city = wpbc_get_initial_values_4_demo('city');
424 - $start_time = '14:00';
425 - $end_time = '12:00';
426 -
427 -
428 - $form = '';
429 - $form .= 'text^name'.$bk_type.'^'.wpbc_get_initial_values_4_demo('name').'~';
430 - $form .= 'text^secondname'.$bk_type.'^'.$second_name.'~';
431 - $form .= 'text^email'.$bk_type.'^'.$second_name.'.example@wpbookingcalendar.com~';
432 - $form .= 'text^address'.$bk_type.'^'.wpbc_get_initial_values_4_demo('adress').'~';
433 - $form .= 'text^city'.$bk_type.'^'.$city[0].'~';
434 - $form .= 'text^postcode'.$bk_type.'^'.wpbc_get_initial_values_4_demo('postcode').'~';
435 - $form .= 'text^country'.$bk_type.'^'.$city[1].'~';
436 - $form .= 'text^phone'.$bk_type.'^'.wpbc_get_initial_values_4_demo('phone').'~';
437 - $form .= 'selectbox-one^visitors'.$bk_type.'^1~';
438 - //$form .= 'checkbox^children'.$bk_type.'[]^0~';
439 - $form .= 'textarea^details'.$bk_type.'^'.wpbc_get_initial_values_4_demo('info').'~';
440 - $form .= 'coupon^coupon'.$bk_type.'^ ';
441 -
442 - $wp_bk_querie = "INSERT INTO {$wpdb->prefix}booking ( form, booking_type, cost, hash, modification_date ) VALUES
443 - ( '".$form."', ".$bk_type .", ".wp_rand(0,1000).", MD5('". time() . '_' . wp_rand(1000,1000000)."'), NOW() ) ;";
444 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
445 - $wpdb->query( $wp_bk_querie );
446 - $temp_id = $wpdb->insert_id;
447 -
448 - $wp_queries_sub = "INSERT INTO {$wpdb->prefix}bookingdates (
449 - booking_id,
450 - booking_date,
451 - approved
452 - ) VALUES ";
453 - for ($d_num = 0; $d_num < $num_days; $d_num++) {
454 - $my_interval = ( $i*$evry_one + $d_num);
455 -
456 - $wp_queries_sub .= "( ". $temp_id .", DATE_ADD(CURDATE(), INTERVAL -".$days_start_shift." day) + INTERVAL ".$my_interval." day ,". $is_appr." ),";
457 - }
458 - $wp_queries_sub = substr($wp_queries_sub,0,-1) . ";";
459 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
460 - $wpdb->query( $wp_queries_sub );
461 - }
462 - }
463 140 }
464 141
465 142
466 -function wpbc_get_initial_values_4_demo( $type ) {
467 - $names = array('Jacob', 'Michael', 'Daniel', 'Anthony', 'William', 'Emma', 'Sophia', 'Kamila', 'Isabella', 'Jack', 'Daniel', 'Matthew',
468 - 'Olivia', 'Emily', 'Grace', 'Jessica', 'Joshua', 'Harry', 'Thomas', 'Oliver', 'Jack' );
469 - $second_names = array( 'Smith', 'Johnson', 'Widams', 'Brown', 'Jones', 'Miller', 'Davis', 'Garcia', 'Rodriguez', 'Wilyson', 'Gonzalez', 'Gomez',
470 - 'Taylor', 'Bron', 'Wilson', 'Davies', 'Robinson', 'Evans', 'Walker', 'Jackson', 'Clarke' );
471 - $city = array( 'New York', 'Los Angeles', 'Chicago', 'Houston', 'Phoenix', 'San Antonio', 'San Diego', 'San Jose', 'Detroit',
472 - 'San Francisco', 'Jacksonville', 'Austin',
473 - 'London', 'Birmingham', 'Leeds', 'Glasgow', 'Sheffield', 'Bradford', 'Edinburgh', 'Liverpool', 'Manchester' );
474 - $adress = array('30 Mortensen Avenue', '144 Hitchcock Rd', '222 Lincoln Ave', '200 Lincoln Ave', '65 West Alisal St',
475 - '426 Work St', '65 West Alisal Street', '159 Main St', '305 Jonoton Avenue', '423 Caiptown Rd', '34 Linoro Ave',
476 - '50 Voro Ave', '15 East St', '226 Middle St', '35 West Town Street', '59 Other St', '50 Merci Ave', '15 Dolof St',
477 - '226 Gordon St', '35 Sero Street', '59 Exit St' );
478 - $country = array( 'US' ,'US' ,'US' ,'US' ,'US' ,'US' ,'US' ,'US' ,'US' ,'US' ,'US' ,'US' ,'UK','UK','UK','UK','UK','UK','UK','UK','UK' );
479 143
480 - $range_times = array( array("10:00","12:00"), array("12:00","14:00"), array("14:00","16:00"), array("16:00","18:00"), array("18:00","20:00") );
481 144
482 - switch ($type) {
483 - case 'rangetime':
484 - return $range_times[ wp_rand(0 , (count($range_times)-1) ) ] ;
485 - break;
486 - case 'name':
487 - return $names[ wp_rand(0 , (count($names)-1) ) ] ;
488 - break;
489 - case 'second_name':
490 - return $second_names[ wp_rand(0 , (count($second_names)-1) ) ] ;
491 - break;
492 - case 'adress':
493 - return $adress[ wp_rand(0 , (count($adress)-1) ) ] ;
494 - break;
495 - case 'city':
496 - $city_num = wp_rand(0 , (count($city)-1) ) ;
497 - return array( $city[$city_num], $country[$city_num]) ;
498 - break;
499 - case 'postcode':
500 - return (wp_rand(0,9).wp_rand(0,9).wp_rand(0,9).wp_rand(0,9).wp_rand(0,9));
501 - break;
502 - case 'phone':
503 - return (wp_rand(0,9).wp_rand(0,9).wp_rand(0,9).'-'.wp_rand(0,9).wp_rand(0,9).'-'.wp_rand(0,9).wp_rand(0,9)) ;
504 - break;
505 - case 'starttime':
506 - return ('0'.wp_rand(0,9) . ':' .wp_rand(1,3).'0' );
507 - break;
508 - case 'endtime':
509 - return (wp_rand(12,23) . ':' .wp_rand(1,3).'0' );
510 - break;
511 - case 'visitors':
512 - return wp_rand(1,4);
513 - break;
514 - default:
515 - return '';
516 - break;
517 - }
518 -
519 -}
520 -
521 -
522 -function wpbc_set_default_initial_values( $evry_one = 1 ) {
523 - global $wpdb;
524 - $names = array( 'Jacob', 'Michael', 'Daniel', 'Anthony', 'William', 'Emma', 'Sophia', 'Kamila', 'Isabella', 'Jack', 'Daniel', 'Matthew',
525 - 'Olivia', 'Emily', 'Grace', 'Jessica', 'Joshua', 'Harry', 'Thomas', 'Oliver', 'Jack' );
526 - $second_names = array( 'Smith', 'Johnson', 'Widams', 'Brown', 'Jones', 'Miller', 'Davis', 'Garcia', 'Rodriguez', 'Wilyson', 'Gonzalez', 'Gomez',
527 - 'Taylor', 'Bron', 'Wilson', 'Davies', 'Robinson', 'Evans', 'Walker', 'Jackson', 'Clarke' );
528 - $city = array( 'New York', 'Los Angeles', 'Chicago', 'Houston', 'Phoenix', 'San Antonio', 'San Diego', 'San Jose', 'Detroit',
529 - 'San Francisco', 'Jacksonville', 'Austin',
530 - 'London', 'Birmingham', 'Leeds', 'Glasgow', 'Sheffield', 'Bradford', 'Edinburgh', 'Liverpool', 'Manchester' );
531 - $adress = array( '30 Mortensen Avenue', '144 Hitchcock Rd', '222 Lincoln Ave', '200 Lincoln Ave', '65 West Alisal St',
532 - '426 Work St', '65 West Alisal Street', '159 Main St', '305 Jonoton Avenue', '423 Caiptown Rd', '34 Linoro Ave',
533 - '50 Voro Ave', '15 East St', '226 Middle St', '35 West Town Street', '59 Other St', '50 Merci Ave', '15 Dolof St',
534 - '226 Gordon St', '35 Sero Street', '59 Exit St' );
535 - $country = array( 'US' ,'US' ,'US' ,'US' ,'US' ,'US' ,'US' ,'US' ,'US' ,'US' ,'US' ,'US' ,'UK','UK','UK','UK','UK','UK','UK','UK','UK' );
536 - $info = array( ' ' ,' ' ,' ' ,' ' ,' ' ,' ' ,' ' ,' ' ,' ' ,' ' ,' ' ,' ' ,' ',' ',' ',' ',' ',' ',' ',' ',' ' );
537 -
538 - for ($i = 0; $i < count($names); $i++) {
539 - if ( ($i % $evry_one) !==0 ) {
540 - continue;
541 - }
542 - $bk_type = wp_rand(1,4);
543 - $is_appr = wp_rand(0,1);
544 -
545 - $start_time = '0'.wp_rand(0,9) . ':' .wp_rand(1,3).'0' ;
546 - $end_time = wp_rand(12,23) . ':' .wp_rand(1,3).'0' ;
547 -
548 - $form = 'text^starttime'.$bk_type.'^'.$start_time.'~';
549 - $form .='text^endtime'.$bk_type.'^'.$end_time.'~';
550 - $form .='text^name'.$bk_type.'^'.$names[$i].'~';
551 - $form .='text^secondname'.$bk_type.'^'.$second_names[$i].'~';
552 - $form .='text^email'.$bk_type.'^'.$second_names[$i].'.example@wpbookingcalendar.com~';
553 - $form .='text^address'.$bk_type.'^'.$adress[$i].'~';
554 - $form .='text^city'.$bk_type.'^'.$city[$i].'~';
555 - $form .='text^postcode'.$bk_type.'^'.wp_rand(0,9).wp_rand(0,9).wp_rand(0,9).wp_rand(0,9).wp_rand(0,9).'~';
556 - $form .='text^country'.$bk_type.'^'.$country[$i].'~';
557 - $form .='text^phone'.$bk_type.'^'.wp_rand(0,9).wp_rand(0,9).wp_rand(0,9).'-'.wp_rand(0,9).wp_rand(0,9).'-'.wp_rand(0,9).wp_rand(0,9).'~';
558 - $form .='selectbox-one^visitors'.$bk_type.'^'.wp_rand(0,9).'~';
559 - $form .='checkbox^children'.$bk_type.'[]^false~';
560 - $form .='textarea^details'.$bk_type.'^'.$info[$i];
561 -
562 - $wp_bk_querie = "INSERT INTO {$wpdb->prefix}booking ( form, booking_type, cost, hash ) VALUES
563 - ( '".$form."', ".$bk_type .", ".wp_rand(0,1000).", MD5('". time() . '_' . wp_rand(1000,1000000)."') ) ;";
564 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
565 - $wpdb->query( $wp_bk_querie );
566 -
567 - $temp_id = $wpdb->insert_id;
568 - $wp_queries_sub = "INSERT INTO {$wpdb->prefix}bookingdates (
569 - booking_id,
570 - booking_date,
571 - approved
572 - ) VALUES
573 - ( ". $temp_id .", CURDATE()+ INTERVAL \"".(2*($i+1)*$evry_one+2)." ".$start_time.":01"."\" DAY_SECOND ,". $is_appr." ),
574 - ( ". $temp_id .", CURDATE()+ INTERVAL ".(2*($i+1)*$evry_one+3)." day ,". $is_appr." ),
575 - ( ". $temp_id .", CURDATE()+ INTERVAL \"".(2*($i+1)*$evry_one+4)." ".$end_time.":02"."\" DAY_SECOND ,". $is_appr." );";
576 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
577 - $wpdb->query( $wp_queries_sub );
578 - }
579 -}
580 -
581 -// </editor-fold>
582 -
583 -
584 145 // <editor-fold defaultstate="collapsed" desc=" Support & Maintence " >
585 146
586 147 /** Reindex DataBase to have "date key field" for be able to sort by dates. */
587 148 function wpbc_reindex_booking_db(){ global $wpdb;
@@ -607,10 +168,10 @@
607 168 <?php
608 169 }
609 170
610 171 if (wpbc_is_field_in_table_exists('booking','sort_date') == 0) {
611 - $simple_sql = "ALTER TABLE {$wpdb->prefix}booking ADD sort_date datetime AFTER booking_id";
612 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
172 + $simple_sql = "ALTER TABLE {$wpdb->prefix}booking ADD COLUMN sort_date datetime"; // FixIn: 10.12.1.5.
173 + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter
613 174 $wpdb->query( $simple_sql );
614 175 }
615 176
616 177 // Refill the sort date index.
@@ -616,15 +177,15 @@
616 177 // Refill the sort date index.
617 178 if (wpbc_is_field_in_table_exists('booking','sort_date') != 0) {
618 179
619 180 $bookings_res = array();
620 - if ( ! wpbc_is_this_wp_playground_db() ) { // FixIn: 10.0.0.1.
181 +
621 182 // 1. Select all bookings ID, where sort_date is NULL in wp_booking.
622 183 $sql = " SELECT booking_id as id FROM {$wpdb->prefix}booking as bk WHERE sort_date IS NULL";
623 184
624 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
185 + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
625 186 $bookings_res = $wpdb->get_results( $sql );
626 - }
187 +
627 188 if ( $is_show_messages ) {
628 189 /* translators: 1: ... */
629 190 echo esc_html( sprintf( __( '%1$s Found %2$s not indexed bookings %3$s', 'booking' ), ' ', count( $bookings_res ), '<br/>' ) );
630 191 }
@@ -639,9 +200,9 @@
639 200 $sql = " SELECT booking_id as id, booking_date as date" ;
640 201 $sql .= " FROM {$wpdb->prefix}bookingdates as bdt" ;
641 202 $sql .= " WHERE booking_id IN ( ". $id_string ." ) GROUP BY bdt.booking_id ORDER BY bdt.booking_date " ;
642 203
643 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
204 + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter
644 205 $sort_date_array = $wpdb->get_results( $sql );
645 206
646 207 if ( $is_show_messages ) {
647 208 /* translators: 1: ... */
@@ -650,11 +211,11 @@
650 211
651 212 //3. Insert that firtst date into the bookings in wp_booking
652 213 $ii=0;
653 214 foreach ($sort_date_array as $value) { $ii++;
654 - $sql = "UPDATE {$wpdb->prefix}booking as bdt ";
215 + $sql = "UPDATE {$wpdb->prefix}booking ";
655 216 $sql .= " SET sort_date = '".$value->date. "' WHERE booking_id = ". $value->id . " ";
656 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
217 + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter
657 218 $wpdb->query( $sql );
658 219
659 220 if ( $is_show_messages ) {
660 221 /* translators: 1: ... */
@@ -676,13 +237,17 @@
676 237 // A c t i v a t e & D e a c t i v a t e
677 238 ////////////////////////////////////////////////////////////////////////////////
678 239
679 240 /** Activation */
680 -function wpbc_booking_activate() {
681 -
241 +function wpbc_booking_activate() {
242 +
243 + wpbc_load_translation();
244 +
245 + $is_new_install = wpbc_is_plugin_initial_install();
246 +
682 247 make_bk_action( 'wpbc_before_activation' );
683 248
684 - wpbc_load_translation();
249 +
685 250
686 251 $version = wpbc_get_plugin_version_type();
687 252 $is_demo = wpbc_is_this_demo();
688 253
@@ -688,10 +253,20 @@
688 253
689 254 // -----------------------------------------------------------------------------------------------------------------
690 255 // Options
691 256 // -----------------------------------------------------------------------------------------------------------------
692 - $default_options_to_add = wpbc_get_default_options();
693 -
257 + $default_options_to_add = wpbc_get_default_options();
258 + // Existing installations retain their saved value; add_bk_option() never overwrites it during upgrades.
259 + if ( $is_new_install ) {
260 + $default_options_to_add['booking_form_accent_enabled'] = 'On';
261 + $default_options_to_add['booking_setup_wizard_initial_install'] = 'On';
262 + $default_options_to_add['booking_setup_wizard_first_run_prompt'] = 'On';
263 + $default_options_to_add['booking_setup_wizard_booking_pages_prompt'] = 'On';
264 + if ( ! class_exists( 'wpdev_bk_personal' ) ) {
265 + $default_options_to_add['booking_resources_catalog_default_view'] = 'publishing';
266 + }
267 + }
268 + // TODO: for Import / Export options, we can use this function to get all option_names and then just get the real values from the wp_options table.
694 269 make_bk_action( 'wpbc_before_activation__add_options', $default_options_to_add ); // FixIn: 9.6.2.11.
695 270
696 271 foreach ( $default_options_to_add as $default_option_name => $default_option_value ) {
697 272 add_bk_option( $default_option_name, $default_option_value );
@@ -701,94 +276,145 @@
701 276 // -----------------------------------------------------------------------------------------------------------------
702 277 // DB Tables
703 278 // -----------------------------------------------------------------------------------------------------------------
704 279 if ( true ){
705 - global $wpdb;
706 - $charset_collate = '';
707 - //if ( $wpdb->has_cap( 'collation' ) ) {
708 - if ( ! empty($wpdb->charset) ) $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
709 - if ( ! empty($wpdb->collate) ) $charset_collate .= " COLLATE $wpdb->collate";
710 - //}
711 280
712 - $wp_queries = array();
713 - if ( ! wpbc_is_table_exists('booking') ) { // Check if tables not exist yet
714 -// FixIn: 10.0.0.1.
715 - $simple_sql = "CREATE TABLE {$wpdb->prefix}booking (
716 - booking_id bigint(20) unsigned NOT NULL auto_increment, " .
717 - /*
718 - " booking_options TEXT,
719 - trash bigint(10) NOT NULL default 0,
720 - is_new bigint(10) NOT NULL default 1,
721 - sort_date datetime,
722 - modification_date datetime,
723 - creation_date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
724 - status varchar(200) NOT NULL default '',
725 - sync_gid varchar(200) NOT NULL default '',
726 - is_trash datetime,
727 - hash TEXT, " . /**/
281 + global $wpdb;
728 282
729 - " form text ,
730 - booking_type bigint(10) NOT NULL default 1,
731 - PRIMARY KEY (booking_id)
732 - ) {$charset_collate};";
733 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
734 - $wpdb->query( $simple_sql );
735 - } elseif (wpbc_is_field_in_table_exists('booking','form') == 0) {
736 - $wp_queries[] = "ALTER TABLE {$wpdb->prefix}booking ADD form TEXT AFTER booking_id";
737 - }
283 + // ----------------------------------------------------------------------------
284 + // Charset / Collation
285 + // ----------------------------------------------------------------------------
286 + $charset_collate = '';
287 + if ( ! empty( $wpdb->charset ) ) {
288 + $charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}";
289 + }
290 + if ( ! empty( $wpdb->collate ) ) {
291 + $charset_collate .= " COLLATE {$wpdb->collate}";
292 + }
738 293
739 - if (wpbc_is_field_in_table_exists('booking','modification_date') == 0) {
740 - $wp_queries[] = "ALTER TABLE {$wpdb->prefix}booking ADD modification_date datetime AFTER booking_id";
741 - }
294 + // ----------------------------------------------------------------------------
295 + // Table name
296 + // ----------------------------------------------------------------------------
297 + $table_name = $wpdb->prefix . 'booking';
742 298
743 - // FixIn: 9.2.3.3.
744 - if ( wpbc_is_field_in_table_exists( 'booking', 'creation_date' ) == 0 ) {
745 - $wp_queries[] = "ALTER TABLE {$wpdb->prefix}booking ADD creation_date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP AFTER modification_date";
746 - /**
747 - *
748 - // Can be only one 'TIMESTAMP' field at some servers.
749 - // ADD re_create_date TIMESTAMP NOT NULL DEFAULT 0 AFTER rules_id
750 - //$wp_queries[] = "ALTER TABLE {$wpdb->prefix}booking ADD creation_date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP AFTER booking_id";
751 - */
752 - }
299 + // ----------------------------------------------------------------------------
300 + // Queries queue for upgrades only
301 + // ----------------------------------------------------------------------------
302 + $wp_queries = array();
753 303
754 - if (wpbc_is_field_in_table_exists('booking','sort_date') == 0) {
755 - $wp_queries[] = "ALTER TABLE {$wpdb->prefix}booking ADD sort_date datetime AFTER booking_id";
756 - }
304 + // ----------------------------------------------------------------------------
305 + // 1) First install: CREATE booking TABLE.
306 + // ----------------------------------------------------------------------------
307 + if ( ! wpbc_is_table_exists( 'booking' ) ) {
757 308
758 - if (wpbc_is_field_in_table_exists('booking','status') == 0) {
759 - $wp_queries[] = "ALTER TABLE {$wpdb->prefix}booking ADD status varchar(200) NOT NULL default '' AFTER booking_id";
760 - }
309 + $create_sql = "CREATE TABLE {$table_name} (
310 + booking_id bigint(20) unsigned NOT NULL auto_increment,
311 + booking_type bigint(10) NOT NULL default 1,
761 312
762 - if (wpbc_is_field_in_table_exists('booking','is_new') == 0) {
763 - $wp_queries[] = "ALTER TABLE {$wpdb->prefix}booking ADD is_new bigint(10) NOT NULL default 1 AFTER booking_id";
764 - }
313 + form TEXT,
314 + hash TEXT,
315 + booking_options TEXT,
316 + status varchar(200) NOT NULL default '',
317 +
318 + is_new bigint(10) NOT NULL default 1,
319 + sync_gid varchar(200) NOT NULL default '',
320 + trash bigint(10) NOT NULL default 0,
321 + is_trash datetime,
322 +
323 + sort_date datetime,
324 + modification_date datetime,
325 + creation_date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
326 +
327 + PRIMARY KEY (booking_id)
328 + ) {$charset_collate};";
765 329
766 - // Version: 5.2 - Google ID of the booking for Sync functionality
767 - if (wpbc_is_field_in_table_exists('booking','sync_gid') == 0) {
768 - $wp_queries[] = "ALTER TABLE {$wpdb->prefix}booking ADD sync_gid varchar(200) NOT NULL default '' AFTER booking_id";
769 - }
330 + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter
331 + $wpdb->query( $create_sql );
770 332
771 - // FixIn: 9.2.3.5.
772 - if (wpbc_is_field_in_table_exists('booking','is_trash') == 0) {
773 - $wp_queries[] = "ALTER TABLE {$wpdb->prefix}booking ADD is_trash datetime AFTER booking_id";
774 - }
333 + // ----------------------------------------------------------------------------
334 + // 2) Upgrade path: only add missing columns (your current logic)
335 + // ----------------------------------------------------------------------------
336 + } else {
775 337
776 - // FixIn: 6.1.1.10.
777 - if (wpbc_is_field_in_table_exists('booking','trash') == 0) {
778 - $wp_queries[] = "ALTER TABLE {$wpdb->prefix}booking ADD trash bigint(10) NOT NULL default 0 AFTER booking_id";
779 - }
338 + if ( wpbc_is_field_in_table_exists( 'booking', 'form' ) == 0 ) {
339 + $wp_queries[] = "ALTER TABLE {$table_name} ADD COLUMN form TEXT";
340 + }
780 341
342 + if ( wpbc_is_field_in_table_exists( 'booking', 'modification_date' ) == 0 ) {
343 + $wp_queries[] = "ALTER TABLE {$table_name} ADD COLUMN modification_date datetime";
344 + }
781 345
346 + // FixIn: 9.2.3.3.
347 + if ( wpbc_is_field_in_table_exists( 'booking', 'creation_date' ) == 0 ) {
348 + $wp_queries[] = "ALTER TABLE {$table_name} ADD COLUMN creation_date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";
349 + }
782 350
783 - // FixIn: 9.1.2.12.
784 - if ( wpbc_is_field_in_table_exists( 'booking', 'booking_options' ) == 0 ) {
785 - $wp_queries[] = "ALTER TABLE {$wpdb->prefix}booking ADD booking_options TEXT AFTER booking_id";
786 - }
351 + if ( wpbc_is_field_in_table_exists( 'booking', 'sort_date' ) == 0 ) {
352 + $wp_queries[] = "ALTER TABLE {$table_name} ADD COLUMN sort_date datetime";
353 + }
787 354
355 + if ( wpbc_is_field_in_table_exists( 'booking', 'status' ) == 0 ) {
356 + $wp_queries[] = "ALTER TABLE {$table_name} ADD COLUMN status varchar(200) NOT NULL default ''";
357 + }
358 +
359 + if ( wpbc_is_field_in_table_exists( 'booking', 'is_new' ) == 0 ) {
360 + $wp_queries[] = "ALTER TABLE {$table_name} ADD COLUMN is_new bigint(10) NOT NULL default 1";
361 + }
362 +
363 + // Version: 5.2 - Google ID for Sync
364 + if ( wpbc_is_field_in_table_exists( 'booking', 'sync_gid' ) == 0 ) {
365 + $wp_queries[] = "ALTER TABLE {$table_name} ADD COLUMN sync_gid varchar(200) NOT NULL default ''";
366 + }
367 +
368 + // FixIn: 9.2.3.5.
369 + if ( wpbc_is_field_in_table_exists( 'booking', 'is_trash' ) == 0 ) {
370 + $wp_queries[] = "ALTER TABLE {$table_name} ADD COLUMN is_trash datetime";
371 + }
372 +
373 + // FixIn: 6.1.1.10.
374 + if ( wpbc_is_field_in_table_exists( 'booking', 'trash' ) == 0 ) {
375 + $wp_queries[] = "ALTER TABLE {$table_name} ADD COLUMN trash bigint(10) NOT NULL default 0";
376 + }
377 +
378 + // FixIn: 9.1.2.12.
379 + if ( wpbc_is_field_in_table_exists( 'booking', 'booking_options' ) == 0 ) {
380 + $wp_queries[] = "ALTER TABLE {$table_name} ADD COLUMN booking_options TEXT";
381 + }
382 +
383 + if ( wpbc_is_field_in_table_exists( 'booking', 'hash' ) == 0 ) {
384 + $wp_queries[] = "ALTER TABLE {$table_name} ADD COLUMN hash TEXT";
385 +
386 + // Update hash value only in last 100 bookings.
387 + $sql_check_table = "SELECT booking_id as id FROM {$wpdb->prefix}booking ORDER BY booking_id DESC LIMIT 0, 100";
388 +
389 + $res = $wpdb->get_results( $sql_check_table ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter
390 + foreach ( $res as $l ) {
391 + $wp_queries[] = $wpdb->prepare(
392 + "UPDATE {$wpdb->prefix}booking SET hash = %s WHERE booking_id = %d",
393 + wpbc_hash__generate_booking_hash(),
394 + $l->id
395 + ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
396 + }
397 + }
398 + }
399 +
400 + // ----------------------------------------------------------------------------
401 + // Execute queued upgrade queries (only runs on upgrades, not new install)
402 + // ----------------------------------------------------------------------------
403 + if ( ! empty( $wp_queries ) ) {
404 + foreach ( $wp_queries as $sql ) {
405 + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter
406 + $wpdb->query( $sql );
407 + }
408 + }
409 +
410 +
788 411 $is_insert_test_bookings = false;
789 412
790 - // FixIn: 8.7.9.1.
413 + // ----------------------------------------------------------------------------
414 + // 2. Install: CREATE bookingdate TABLE.
415 + // ----------------------------------------------------------------------------
416 +
791 417 if ( ! wpbc_is_table_exists( 'bookingdates' ) ) {
792 418 // Check if tables not exist yet.
793 419 $simple_sql = "CREATE TABLE {$wpdb->prefix}bookingdates (
794 420 booking_dates_id bigint(20) unsigned NOT NULL auto_increment,
@@ -797,9 +423,9 @@
797 423 approved bigint(20) unsigned NOT NULL default 0,
798 424 PRIMARY KEY (booking_dates_id)
799 425 ) {$charset_collate}";
800 426
801 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
427 + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter
802 428 $wpdb->query( $simple_sql );
803 429
804 430 if ( ! class_exists( 'wpdev_bk_personal' ) ) {
805 431 $is_insert_test_bookings = true;
@@ -809,108 +435,170 @@
809 435 if ( 0 === wpbc_is_index_in_table_exists( 'bookingdates', 'booking_id_dates' ) ) {
810 436 // If we remove this index, so then its can significant impact to the speed of page loading at the Booking Listing and Timelines.
811 437 // Index for SPEED opening Booking Listing and Timeline with thousands of Bookings, otherwise, without this index, speed will be TOO SLOW...
812 438 $simple_sql = "CREATE UNIQUE INDEX booking_id_dates ON {$wpdb->prefix}bookingdates ( booking_id, booking_date);";
813 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
439 + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter
814 440 $wpdb->query( $simple_sql );
815 441 }
816 442
443 + // ----------------------------------------------------------------------------
444 + // 3. Insert test bookings.
445 + // ----------------------------------------------------------------------------
817 446
818 - if ( count( $wp_queries ) > 0 ) {
819 - foreach ( $wp_queries as $wp_q ) {
820 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
821 - $wpdb->query( $wp_q );
822 - }
447 + if ( $is_insert_test_bookings ) {
448 + // -- Test Booking #1 --
449 + $is_appr = 1;
450 + $wp_queries_sub = "INSERT INTO {$wpdb->prefix}booking ( form, modification_date ) VALUES (
451 + 'text^firstname1^John~text^secondname1^Smith~text^email1^example-free@wpbookingcalendar.com~text^phone1^458-77-77~textarea^details1^This is a test booking showing booking for several days.', " . wpbc_sql_date_math_expr_explicit('', 'now') . " );";
452 + $wpdb->query( $wp_queries_sub ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter
823 453
824 - if ( $is_insert_test_bookings ) {
825 - // -- Test Booking #1 --
826 - $wp_queries_sub = "INSERT INTO {$wpdb->prefix}booking ( form, modification_date ) VALUES (
827 - 'text^name1^John~text^secondname1^Smith~text^email1^example-free@wpbookingcalendar.com~text^phone1^458-77-77~textarea^details1^This is a test booking showing booking for several days.', NOW() );";
828 - $wpdb->query( $wp_queries_sub ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
454 + $temp_id = $wpdb->insert_id;
455 + $wp_queries_sub = "INSERT INTO {$wpdb->prefix}bookingdates ( booking_id, booking_date, approved ) VALUES
456 + ( " . $temp_id . ", " . wpbc_sql_date_math_expr_explicit( "+ INTERVAL 2 DAY", 'curdate' ) . " ," . $is_appr . " ),
457 + ( " . $temp_id . ", " . wpbc_sql_date_math_expr_explicit( "+ INTERVAL 3 DAY", 'curdate' ) . " ," . $is_appr . " ),
458 + ( " . $temp_id . ", " . wpbc_sql_date_math_expr_explicit( "+ INTERVAL 4 DAY", 'curdate' ) . " ," . $is_appr . " );";
459 + $wpdb->query( $wp_queries_sub ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter
829 460
830 - $temp_id = $wpdb->insert_id;
831 - $wp_queries_sub = "INSERT INTO {$wpdb->prefix}bookingdates ( booking_id, booking_date ) VALUES
832 - ( " . $temp_id . ", CURDATE()+ INTERVAL 2 day ),
833 - ( " . $temp_id . ", CURDATE()+ INTERVAL 3 day ),
834 - ( " . $temp_id . ", CURDATE()+ INTERVAL 4 day );";
835 - $wpdb->query( $wp_queries_sub ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
461 + // -- Test Booking #2 --
462 + $is_appr = 0;
463 + $wp_queries_sub = "INSERT INTO {$wpdb->prefix}booking ( form, modification_date ) VALUES (
464 + 'text^firstname1^Emma~text^secondname1^Robinson~text^email1^example-free@wpbookingcalendar.com~text^phone1^999-77-77~textarea^details1^This is a test booking showing booking for several days.', " . wpbc_sql_date_math_expr_explicit('', 'now') . " );";
465 + $wpdb->query( $wp_queries_sub ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter
836 466
837 - // -- Test Booking #2 --
838 - $is_appr = 1;
839 - $start_time = '10:00';
840 - $end_time = '10:30';
841 - $wp_queries_sub = "INSERT INTO {$wpdb->prefix}booking ( form, modification_date, is_new ) VALUES (
842 - 'selectbox^rangetime1^".$start_time." - ".$end_time."~text^name1^Sophia~text^secondname1^Robinson~text^email1^example-free@wpbookingcalendar.com~text^phone1^458-77-77~textarea^details1^This is a test booking showing a one day time slot booking.', NOW(), 0 );";
843 - $wpdb->query( $wp_queries_sub ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
467 + $temp_id = $wpdb->insert_id;
468 + $wp_queries_sub = "INSERT INTO {$wpdb->prefix}bookingdates ( booking_id, booking_date, approved ) VALUES
469 + ( " . $temp_id . ", " . wpbc_sql_date_math_expr_explicit( "+ INTERVAL 28 DAY", 'curdate' ) . " ," . $is_appr . " ),
470 + ( " . $temp_id . ", " . wpbc_sql_date_math_expr_explicit( "+ INTERVAL 29 DAY", 'curdate' ) . " ," . $is_appr . " ),
471 + ( " . $temp_id . ", " . wpbc_sql_date_math_expr_explicit( "+ INTERVAL 30 DAY", 'curdate' ) . " ," . $is_appr . " );";
472 + $wpdb->query( $wp_queries_sub ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter
844 473
845 - $temp_id = $wpdb->insert_id;
846 474
847 - $wp_queries_sub = "INSERT INTO {$wpdb->prefix}bookingdates ( booking_id, booking_date, approved ) VALUES
848 - ( ". $temp_id .", CURDATE()+ INTERVAL \"5 " . $start_time. ":01\" DAY_SECOND ,". $is_appr." ),
849 - ( ". $temp_id .", CURDATE()+ INTERVAL \"5 " . $end_time . ":02\" DAY_SECOND ,". $is_appr." );";
850 - $wpdb->query( $wp_queries_sub ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
851 - }
852 - }
475 + // -- Test Booking #3 --
476 + $is_appr = 1;
477 + $start_time = '10:00';
478 + $end_time = '10:30';
479 + $wp_queries_sub = "INSERT INTO {$wpdb->prefix}booking ( form, modification_date, is_new ) VALUES (
480 + 'selectbox^rangetime1^".$start_time." - ".$end_time."~text^firstname1^Sophia~text^secondname1^Robinson~text^email1^example-free@wpbookingcalendar.com~text^phone1^458-77-77~textarea^details1^This is a test booking showing a one day time slot booking.', " . wpbc_sql_date_math_expr_explicit('', 'now') . ", 0 );";
481 + $wpdb->query( $wp_queries_sub ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter
853 482
854 - // FixIn: 9.2.3.3.
855 - if ( wpbc_is_field_in_table_exists( 'booking', 'hash' ) == 0 ) { //HASH_EDIT
483 + $temp_id = $wpdb->insert_id;
856 484
857 - $simple_sql = "ALTER TABLE {$wpdb->prefix}booking ADD hash TEXT AFTER form";
858 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
859 - $wpdb->query( $simple_sql );
485 + $start_time_arr = explode( ':', $start_time );
486 + $end_time_arr = explode( ':', $end_time );
487 + $wp_queries_sub = "INSERT INTO {$wpdb->prefix}bookingdates ( booking_id, booking_date, approved ) VALUES
488 + ( " . $temp_id . ", " . wpbc_sql_date_math_expr_explicit( "+ INTERVAL '" . ( ( 8 * 24 ) + intval( $start_time_arr[0] ) ) . ':' . $start_time_arr[1] . ":01' HOUR_SECOND", 'curdate' ) . " ," . $is_appr . " ),
489 + ( " . $temp_id . ", " . wpbc_sql_date_math_expr_explicit( "+ INTERVAL '" . ( ( 8 * 24 ) + intval( $end_time_arr[0] ) ) . ':' . $end_time_arr[1] . ":02' HOUR_SECOND", 'curdate' ) . " ," . $is_appr . " );";
490 + $wpdb->query( $wp_queries_sub ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter
491 + }
492 + }
860 493
861 - // Update hash value only in last 100 bookings
862 - $sql_check_table = "SELECT booking_id as id FROM {$wpdb->prefix}booking ORDER BY booking_id DESC LIMIT 0, 100";
494 + make_bk_action( 'wpbc_free_version_activation' );
863 495
864 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
865 - $res = $wpdb->get_results( $sql_check_table );
496 + do_action( 'wpbc_free_version_activation' );
866 497
867 - foreach ( $res as $l ) {
868 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
869 - $wpdb->query( "UPDATE {$wpdb->prefix}booking SET hash = MD5('" . time() . '_' . wp_rand( 1000, 1000000 ) . "') WHERE booking_id = " . $l->id );
870 - }
871 - }
872 - }
873 - make_bk_action( 'wpbc_activation_after_db_actions' ); // FixIn: 9.3.1.2.
874 -
875 498 // -----------------------------------------------------------------------------------------------------------------
876 - // Other versions Activation
499 + // Other versions Activation
877 500 // -----------------------------------------------------------------------------------------------------------------
878 - make_bk_action( 'wpbc_other_versions_activation' );
501 + make_bk_action( 'wpbc_other_versions_activation' );
879 502
880 -
881 - // -----------------------------------------------------------------------------------------------------------------
882 - // Examples in demos
883 - // -----------------------------------------------------------------------------------------------------------------
884 - if ( $is_demo ) { wpbc_create_examples_4_demo(); }
503 + do_action( 'wpbc_pro_versions_activation' );
885 504
886 -
887 - // Fill Development server by initial bookings
888 - if ( ( defined( 'WP_BK_BETA_DATA_FILL' ) )
889 - && ( WP_BK_BETA_DATA_FILL > 0 )
890 - ) {
891 - if ( ( isset( $_SERVER['HTTP_HOST'] ) ) && ( ( 'beta' === $_SERVER['HTTP_HOST'] ) || ( 'freetest.wpbookingcalendar.com' === $_SERVER['HTTP_HOST'] ) ) ) {
892 - $types_array = array();
893 - for ( $i = 0; $i < WP_BK_BETA_DATA_FILL; $i++) {
894 - foreach ( range(1, 12) as $types_el) {
895 - $types_array[] = $types_el;
896 - }
897 - }
898 - wpbc_create_examples_4_demo( $types_array );
899 - }
900 - }
901 - //wpbc_set_default_initial_values();
505 + wpbc_reindex_booking_db();
902 506
903 - // -----------------------------------------------------------------------------------------------------------------
904 - wpbc_reindex_booking_db();
507 + make_bk_action( 'wpbc_after_activation' );
905 508
906 - make_bk_action( 'wpbc_after_activation' );
509 + do_action( 'wpbc_after_activation' );
907 510 }
908 511 add_bk_action( 'wpbc_activation', 'wpbc_booking_activate' );
909 512
910 513
514 +/**
515 + * Determine whether the commercial registration data must survive full data removal.
516 + *
517 + * Demo sites need to retain the validated commercial registration payload so that
518 + * resetting demo booking data does not expose the order-number registration form.
519 + * Requiring both the established demo check and the official domain prevents this
520 + * exception from changing cleanup behavior on customer, local, or beta websites.
521 + *
522 + * @return bool True when registration data must be preserved; otherwise false.
523 + */
524 +function wpbc_deactivation__should_preserve_registration_data() {
911 525
912 -// Deactivate
526 + if ( ! function_exists( 'wpbc_is_this_demo' ) || ! wpbc_is_this_demo() ) {
527 + return false;
528 + }
529 +
530 + $site_host = wp_parse_url( home_url( '/' ), PHP_URL_HOST );
531 +
532 + if ( ! is_string( $site_host ) || '' === $site_host ) {
533 + return false;
534 + }
535 +
536 + $site_host = strtolower( rtrim( $site_host, '.' ) );
537 + $official_demo_host = 'wpbookingcalendar.com';
538 + $official_demo_suffix = '.' . $official_demo_host;
539 +
540 + if ( $official_demo_host === $site_host ) {
541 + return true;
542 + }
543 +
544 + return strlen( $site_host ) > strlen( $official_demo_suffix )
545 + && $official_demo_suffix === substr( $site_host, -strlen( $official_demo_suffix ) );
546 +}
547 +
548 +
549 +/**
550 + * Delete every site option and transient owned by Booking Calendar.
551 + *
552 + * The historical deactivation path deletes options returned by
553 + * wpbc_get_default_options(). Runtime modules also create version markers,
554 + * setup state, caches, and transients outside that registry. This final pass
555 + * runs after all module callbacks so those callbacks can still read their
556 + * settings while removing tables and other data.
557 + *
558 + * @return void
559 + */
560 +function wpbc_deactivation__delete_all_plugin_options() {
561 +
562 + global $wpdb;
563 +
564 + $option_name_patterns = array(
565 + $wpdb->esc_like( 'booking_' ) . '%',
566 + $wpdb->esc_like( 'wpbc_' ) . '%',
567 + $wpdb->esc_like( '_transient_' ) . '%' . $wpdb->esc_like( 'booking_' ) . '%',
568 + $wpdb->esc_like( '_transient_' ) . '%' . $wpdb->esc_like( 'wpbc_' ) . '%',
569 + $wpdb->esc_like( '_site_transient_' ) . '%' . $wpdb->esc_like( 'booking_' ) . '%',
570 + $wpdb->esc_like( '_site_transient_' ) . '%' . $wpdb->esc_like( 'wpbc_' ) . '%',
571 + );
572 +
573 + $sql = $wpdb->prepare(
574 + "SELECT option_name
575 + FROM {$wpdb->options}
576 + WHERE option_name LIKE %s
577 + OR option_name LIKE %s
578 + OR option_name LIKE %s
579 + OR option_name LIKE %s
580 + OR option_name LIKE %s
581 + OR option_name LIKE %s",
582 + $option_name_patterns
583 + );
584 +
585 + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
586 + $option_names = $wpdb->get_col( $sql );
587 + $option_names = is_array( $option_names ) ? array_unique( $option_names ) : array();
588 +
589 + if ( ! wpbc_deactivation__should_preserve_registration_data() ) {
590 + $option_names[] = 'bk_version_data';
591 + }
592 +
593 + foreach ( $option_names as $option_name ) {
594 + delete_option( $option_name );
595 + }
596 +}
597 +
598 +
599 +
600 +// Deactivate.
913 601 function wpbc_booking_deactivate() {
914 602
915 603 // -----------------------------------------------------------------------------------------------------------------
916 604 // Options
@@ -929,21 +617,27 @@
929 617 delete_bk_option( 'widget_bookingsearchwidget' );
930 618 delete_bk_option( 'widget_bookingselectwidget' );
931 619 delete_bk_option( 'booking_activation_redirect_for_version' );
932 620
933 -
934 621 // -----------------------------------------------------------------------------------------------------------------
935 622 // DB Tables
936 623 // -----------------------------------------------------------------------------------------------------------------
937 624 global $wpdb;
938 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.SchemaChange
625 + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter, WordPress.DB.DirectDatabaseQuery.SchemaChange
939 626 $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}booking" );
940 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.SchemaChange
627 + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter, WordPress.DB.DirectDatabaseQuery.SchemaChange
941 628 $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}bookingdates" );
942 629
943 - // Delete all users booking windows states.
944 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared,
945 - if ( false === $wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key LIKE '%booking_%'" ) ) {
630 + // Delete all Booking Calendar user options, listing state, and dismissed notices.
631 + $booking_meta_pattern = '%' . $wpdb->esc_like( 'booking_' ) . '%';
632 + $wpbc_meta_pattern = '%' . $wpdb->esc_like( 'wpbc_' ) . '%';
633 + $user_meta_delete_sql = $wpdb->prepare(
634 + "DELETE FROM {$wpdb->usermeta} WHERE meta_key LIKE %s OR meta_key LIKE %s",
635 + $booking_meta_pattern,
636 + $wpbc_meta_pattern
637 + );
638 + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter
639 + if ( false === $wpdb->query( $user_meta_delete_sql ) ) {
946 640 debuge_error('Error during deleting user meta at DB',__FILE__,__LINE__);
947 641 die();
948 642 }
949 643
@@ -948,19 +642,21 @@
948 642 }
949 643
950 644 // Delete or Drafts and Pending from demo sites
951 645 if ( wpbc_is_this_demo() ) { // Delete all temp posts at the demo sites: (post_status = pending || draft) && ( post_type = post ) && (post_author != 1)
952 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared,
646 + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter,
953 647 $postss = $wpdb->get_results( "SELECT * FROM {$wpdb->posts} WHERE ( post_status = 'pending' OR post_status = 'draft' OR post_status = 'auto-draft' OR post_status = 'trash' OR post_status = 'inherit' ) AND ( post_type='post' OR post_type='revision') AND post_author != 1" );
954 648 foreach ( $postss as $pp ) {
955 649 wp_delete_post( $pp->ID, true );
956 650 }
957 651 }
958 -
652 + make_bk_action( 'wpbc_free_version_deactivation' );
959 653 ////////////////////////////////////////////////////////////////////////////
960 654 // Other versions Deactivation
961 655 ////////////////////////////////////////////////////////////////////////////
962 656 make_bk_action( 'wpbc_other_versions_deactivation' );
657 +
658 + wpbc_deactivation__delete_all_plugin_options();
963 659 }
964 660 add_bk_action( 'wpbc_deactivation', 'wpbc_booking_deactivate' );
965 661
966 662
@@ -974,10 +670,11 @@
974 670 * $options_for_delete = wpbc_get_default_options( $option_name, $is_get_multiuser_general_options );
975 671 */
976 672 function wpbc_get_default_options( $option_name = '', $is_get_multiuser_general_options = false ) {
977 673
978 - $is_demo = wpbc_is_this_demo();
979 - $blg_title = str_replace( array( '"', "'" ), '', get_option( 'blogname' ) );
674 + $is_demo = wpbc_is_this_demo();
675 + $is_free_version = ! class_exists( 'wpdev_bk_personal' );
676 + $blg_title = str_replace( array( '"', "'" ), '', get_option( 'blogname' ) );
980 677
981 678 $default_options = array();
982 679
983 680 // If this option here, then system get this option from "Super Admin" options configuration for "Regular" users.
@@ -985,16 +682,26 @@
985 682
986 683 // FixIn: 9.6.3.5.
987 684 $default_options['booking_setup_wizard_page_steps_is_done'] = '';
988 685 $mu_option4delete[]='booking_setup_wizard_page_steps_is_done';
686 + $default_options['booking_setup_wizard_initial_install'] = 'Off';
687 + $mu_option4delete[] = 'booking_setup_wizard_initial_install';
688 + $default_options['booking_setup_wizard_first_run_prompt'] = 'Off';
689 + $mu_option4delete[] = 'booking_setup_wizard_first_run_prompt';
690 + $default_options['booking_setup_wizard_booking_pages_prompt'] = 'Off';
691 + $mu_option4delete[] = 'booking_setup_wizard_booking_pages_prompt';
989 692
990 693 $default_options['booking_admin_cal_count'] = ($is_demo) ? '3' : '2';
991 694 $mu_option4delete[]='booking_admin_cal_count'; // $multiuser_general_option[] = implode( '', array_keys( array_slice( $default_options, -1 ) ) );
992 - $default_options['booking_skin'] = '/css/skins/24_9__light_square_1.css';
695 + $default_options['booking_skin'] = '/css/skins/25_5__square_1.css'; // FixIn: 10.11.4.2.
993 696 $mu_option4delete[]='booking_skin';
994 697 // FixIn: 9.6.3.5.
995 698 $default_options['booking_listing_default_view_mode'] = 'vm_booking_listing'; // 'vm_calendar'; // FixIn: 9.6.3.5.
996 699 $mu_option4delete[]='booking_listing_default_view_mode';
700 + $default_options['booking_admin_edit_booking_mode'] = 'popup';
701 + $mu_option4delete[]='booking_admin_edit_booking_mode';
702 + $default_options['booking_resources_catalog_default_view'] = '';
703 + $mu_option4delete[] = 'booking_resources_catalog_default_view';
997 704
998 705 $default_options['booking_view_days_num'] = ( ( ! class_exists( 'wpdev_bk_personal' ) ) ? '90' : '30' );
999 706 $mu_option4delete[]='booking_view_days_num';
1000 707 // FixIn: 8.9.4.3.
@@ -1017,12 +724,17 @@
1017 724 //$mu_option4delete[]='booking_title_after_reservation_time';
1018 725 $default_options['booking_type_of_thank_you_message'] = 'message';
1019 726 $mu_option4delete[]='booking_type_of_thank_you_message';
1020 727 $default_options['booking_thank_you_page_URL'] = '/thank-you';
1021 - $mu_option4delete[]='booking_thank_you_page_URL';
728 + $mu_option4delete[]='booking_thank_you_page_URL';
1022 729 $default_options['booking_is_use_autofill_4_logged_user'] = ($is_demo) ? 'On' : 'Off';
1023 - $mu_option4delete[]='booking_is_use_autofill_4_logged_user';
1024 - $default_options['booking_date_format'] = get_option( 'date_format' );
730 + $mu_option4delete[]='booking_is_use_autofill_4_logged_user';
731 +
732 + // FixIn: 10.13.1.5.
733 + $default_options['booking_is_use_phone_validation'] = 'Off';
734 + $mu_option4delete[]='booking_is_use_phone_validation';
735 + $wordpress_date_format = get_option( 'date_format' );
736 + $default_options['booking_date_format'] = ( 'F j, Y' === $wordpress_date_format ) ? 'j M Y' : $wordpress_date_format;
1025 737 $mu_option4delete[]='booking_date_format';
1026 738 $default_options['booking_time_format'] = get_option( 'time_format' ); //'H:i';
1027 739 $mu_option4delete[]='booking_time_format';
1028 740
@@ -1043,9 +755,9 @@
1043 755
1044 756 $default_options['booking_confirmation__booking_details__header_enabled'] = 'On';
1045 757 $default_options['booking_confirmation__booking_details__title'] = __( 'Booking details', 'booking' );
1046 758 $default_options['booking_confirmation__booking_details__content'] = ( class_exists( 'wpdev_bk_personal' ) )
1047 - ? "<h4>[resource_title]</h4>[readable_dates][readable_times]\n[add_to_google_cal_button]"
759 + ? "<h4>[resource_title]</h4>[readable_dates][readable_times]\n[add_to_google_cal_button]\n" . '<a href="[visitorbookingediturl]">Edit Booking</a> | <a href="[visitorbookingcancelurl]">Cancel Booking</a>'
1048 760 : "[readable_dates][readable_times]\n[add_to_google_cal_button]";
1049 761
1050 762 $mu_option4delete[] = 'booking_confirmation__booking_details__header_enabled';
1051 763 $mu_option4delete[] = 'booking_confirmation__booking_details__title';
@@ -1074,21 +786,19 @@
1074 786
1075 787 $mu_option4delete[]='booking_is_load_js_css_on_specific_pages';
1076 788 $default_options['booking_pages_for_load_js_css'] = '';
1077 789 $mu_option4delete[]='booking_pages_for_load_js_css';
1078 - $default_options['booking_type_of_day_selections'] = ( ( get_bk_option( 'booking_range_selection_is_active' ) == 'On' ) && ( ! $is_demo ) ) ? 'range' : 'multiple';
790 + $default_options['booking_type_of_day_selections'] = $is_free_version
791 + ? 'range'
792 + : ( ( get_bk_option( 'booking_range_selection_is_active' ) == 'On' ) && ( ! $is_demo ) ? 'range' : 'multiple' );
1079 793 $mu_option4delete[]='booking_type_of_day_selections';
1080 794
1081 795 // FixIn: 8.7.11.10.
1082 796 $default_options['booking_timeslot_picker'] = 'On';
1083 797 $mu_option4delete[]= 'booking_timeslot_picker';
1084 - $default_options['booking_timeslot_picker_skin'] = '/css/time_picker_skins/light__24_8.css';
798 + $default_options['booking_timeslot_picker_skin'] = '/css/time_picker_skins/form_style.css';
1085 799 $mu_option4delete[]= 'booking_timeslot_picker_skin';
1086 800
1087 - $default_options['booking_timeslot_day_bg_as_available'] = 'Off'; //( ( class_exists( 'wpdev_bk_personal' ) ) ? 'Off' : 'On' ); // FixIn: 8.2.1.27.
1088 - $mu_option4delete[]='booking_timeslot_day_bg_as_available';
1089 -
1090 -
1091 801 $default_options['booking_disable_timeslots_in_tooltip'] = 'Off'; //FixIn: 9.5.0.2.2
1092 802 $mu_option4delete[]='booking_disable_timeslots_in_tooltip';
1093 803
1094 804 $default_options['booking_highlight_timeslot_word'] = __( 'Booked Times:', 'booking' ); // FixIn: 9.4.3.1.
@@ -1143,25 +853,40 @@
1143 853 $default_options['booking_unavailable_day5'] = 'Off';
1144 854 $mu_option4delete[]='booking_unavailable_day5';
1145 855 $default_options['booking_unavailable_day6'] = 'Off';
1146 856 $mu_option4delete[]='booking_unavailable_day6';
857 +
858 + // Working Time defaults. Keep disabled by default on fresh activation/reinstall.
859 + $default_options['booking_working_time_enabled'] = 'Off';
860 + $mu_option4delete[]='booking_working_time_enabled';
861 + $default_options['booking_working_time_rules'] = function_exists( 'wpbc_working_time__get_default_settings' ) ? wpbc_working_time__get_default_settings() : array(
862 + 'enabled' => 'Off',
863 + 'default' => array(
864 + 'weekdays' => array(),
865 + ),
866 + 'resources' => array(),
867 + );
868 + $mu_option4delete[]='booking_working_time_rules';
869 +
1147 870 $default_options['booking_menu_position'] = ( $is_demo ) ? 'top' : 'top';
1148 871 $mu_option4delete[]='booking_menu_position';
1149 872 $default_options['booking_translation_load_from'] = 'wp.org';
1150 873 $mu_option4delete[]='booking_translation_load_from';
1151 - $default_options['booking_user_role_booking'] = ( $is_demo ) ? 'subscriber' : 'editor';
874 +
875 + // FixIn: 10.14.12.1.
876 + $default_options['booking_user_role_booking'] = 'editor';
1152 877 $mu_option4delete[]='booking_user_role_booking';
1153 - $default_options['booking_user_role_availability'] = ( $is_demo ) ? 'subscriber' : 'editor'; // FixIn: 9.5.2.2.
878 + $default_options['booking_user_role_availability'] = 'editor';
1154 879 $mu_option4delete[]='booking_user_role_availability';
1155 - $default_options['booking_user_role_addbooking'] = ( $is_demo ) ? 'subscriber' : 'editor';
880 + $default_options['booking_user_role_addbooking'] = 'editor';
1156 881 $mu_option4delete[]='booking_user_role_addbooking';
1157 - $default_options['booking_user_role_resources'] = ( $is_demo ) ? 'subscriber' : 'editor';
882 + $default_options['booking_user_role_resources'] = 'editor';
1158 883 $mu_option4delete[]='booking_user_role_resources';
1159 - $default_options['booking_user_role_settings'] = ( $is_demo ) ? 'subscriber' : 'administrator';
884 + $default_options['booking_user_role_settings'] = 'editor';
1160 885 $mu_option4delete[]='booking_user_role_settings';
1161 886 //FixIn: 9.8.15.2.6
1162 887 if ( class_exists( 'wpdev_bk_biz_m' ) ) {
1163 - $default_options['booking_user_role_prices'] = ( $is_demo ) ? 'subscriber' : 'editor';
888 + $default_options['booking_user_role_prices'] = 'editor';
1164 889 $mu_option4delete[]='booking_user_role_prices';
1165 890 }
1166 891
1167 892 // New admin ///////////////////////////////////////////////////////////////
@@ -1216,15 +941,83 @@
1216 941 $default_options['booking_widget_last_field'] = '';
1217 942
1218 943 $default_options['booking_wpdev_copyright_adminpanel'] = 'On';
1219 944 $mu_option4delete[]='booking_wpdev_copyright_adminpanel';
1220 - $default_options['booking_is_show_powered_by_notice'] = 'On';
945 + $default_options['booking_is_show_powered_by_notice'] = ( WPBC_IS_PLAYGROUND ) ? 'Off' : 'On';
1221 946 $mu_option4delete[]='booking_is_show_powered_by_notice';
1222 947 $default_options['booking_form_theme'] = '';
1223 948 $mu_option4delete[]='booking_form_theme';
1224 - $default_options['booking_is_use_captcha'] = 'Off';
949 + $default_options['booking_form_style'] = 'light_bordered';
950 + $mu_option4delete[]='booking_form_style';
951 + $default_options['booking_form_accent_enabled'] = 'Off';
952 + $mu_option4delete[]='booking_form_accent_enabled';
953 + $default_options['booking_form_accent_color'] = WPBC_DEFAULT_FORM_ACCENT_COLOR;
954 + $mu_option4delete[]='booking_form_accent_color';
955 + $default_options['booking_form_appearance_preset'] = 'bordered';
956 + $mu_option4delete[]='booking_form_appearance_preset';
957 + $default_options['booking_form_appearance_background_color'] = '#ffffff';
958 + $mu_option4delete[]='booking_form_appearance_background_color';
959 + $default_options['booking_form_appearance_border_color'] = '#cccccc';
960 + $mu_option4delete[]='booking_form_appearance_border_color';
961 + $default_options['booking_form_appearance_border_width'] = '1px';
962 + $mu_option4delete[]='booking_form_appearance_border_width';
963 + $default_options['booking_form_appearance_border_radius'] = '2px';
964 + $mu_option4delete[]='booking_form_appearance_border_radius';
965 + $default_options['booking_form_appearance_padding'] = '10px 30px';
966 + $mu_option4delete[]='booking_form_appearance_padding';
967 + $default_options['booking_form_custom_background_color'] = '#ffffff';
968 + $mu_option4delete[]='booking_form_custom_background_color';
969 + $default_options['booking_form_custom_border_color'] = '#cccccc';
970 + $mu_option4delete[]='booking_form_custom_border_color';
971 + $default_options['booking_form_custom_border_width'] = '1px';
972 + $mu_option4delete[]='booking_form_custom_border_width';
973 + $default_options['booking_form_custom_border_radius'] = '2px';
974 + $mu_option4delete[]='booking_form_custom_border_radius';
975 + $default_options['booking_form_custom_padding_vertical'] = '10px';
976 + $mu_option4delete[]='booking_form_custom_padding_vertical';
977 + $default_options['booking_form_custom_padding_horizontal'] = '30px';
978 + $mu_option4delete[]='booking_form_custom_padding_horizontal';
979 + $default_options['booking_form_custom_text_color'] = '#1d2327';
980 + $mu_option4delete[]='booking_form_custom_text_color';
981 + $default_options['booking_form_custom_field_background_color'] = '#ffffff';
982 + $mu_option4delete[]='booking_form_custom_field_background_color';
983 + $default_options['booking_form_custom_field_text_color'] = '#3c434a';
984 + $mu_option4delete[]='booking_form_custom_field_text_color';
985 + $default_options['booking_form_custom_field_border_color'] = '#cccccc';
986 + $mu_option4delete[]='booking_form_custom_field_border_color';
987 + $default_options['booking_form_custom_button_background_color'] = '#066aab';
988 + $mu_option4delete[]='booking_form_custom_button_background_color';
989 + $default_options['booking_form_custom_button_text_color'] = '#ffffff';
990 + $mu_option4delete[]='booking_form_custom_button_text_color';
991 + $default_options['booking_form_custom_button_border_color'] = '#066aab';
992 + $mu_option4delete[]='booking_form_custom_button_border_color';
993 + $default_options['booking_form_custom_button_hover_background_color'] = '#055589';
994 + $mu_option4delete[]='booking_form_custom_button_hover_background_color';
995 + $default_options['booking_form_custom_button_hover_text_color'] = '#ffffff';
996 + $mu_option4delete[]='booking_form_custom_button_hover_text_color';
997 + $default_options['booking_form_custom_button_hover_border_color'] = '#055589';
998 + $mu_option4delete[]='booking_form_custom_button_hover_border_color';
999 + $default_options['booking_form_custom_secondary_button_background_color'] = '#fdfdfd';
1000 + $mu_option4delete[]='booking_form_custom_secondary_button_background_color';
1001 + $default_options['booking_form_custom_secondary_button_text_color'] = '#444444';
1002 + $mu_option4delete[]='booking_form_custom_secondary_button_text_color';
1003 + $default_options['booking_form_custom_secondary_button_border_color'] = '#eeeeee';
1004 + $mu_option4delete[]='booking_form_custom_secondary_button_border_color';
1005 + $default_options['booking_form_custom_secondary_button_hover_background_color'] = '#fdfdfd';
1006 + $mu_option4delete[]='booking_form_custom_secondary_button_hover_background_color';
1007 + $default_options['booking_form_custom_secondary_button_hover_text_color'] = '#444444';
1008 + $mu_option4delete[]='booking_form_custom_secondary_button_hover_text_color';
1009 + $default_options['booking_form_custom_secondary_button_hover_border_color'] = '#4d91cd';
1010 + $mu_option4delete[]='booking_form_custom_secondary_button_hover_border_color';
1011 + $default_options['booking_form_custom_button_border_width'] = '1px';
1012 + $mu_option4delete[]='booking_form_custom_button_border_width';
1013 + $default_options['booking_form_custom_button_border_radius'] = '3px';
1014 + $mu_option4delete[]='booking_form_custom_button_border_radius';
1015 + $default_options['booking_is_use_captcha'] = 'Off';
1225 1016 $mu_option4delete[]='booking_is_use_captcha';
1226 - $default_options['booking_is_show_legend'] = 'On';
1017 + $default_options['booking_frontend_messages'] = array( 'version' => 1, 'messages' => array(), 'enabled' => array() );
1018 + $mu_option4delete[]='booking_frontend_messages';
1019 + $default_options['booking_is_show_legend'] = 'On';
1227 1020 $mu_option4delete[]='booking_is_show_legend';
1228 1021 $default_options['booking_send_button_title'] = __( 'Send', 'booking' ); // FixIn: 8.8.1.14.
1229 1022 $mu_option4delete[]='booking_send_button_title';
1230 1023 $default_options['booking_legend_is_show_item_available'] = 'On';
@@ -1270,8 +1063,10 @@
1270 1063 $emails_init = array_merge( $emails_init, wpbc_import6_email__deny__get_fields_array_for_activation() );
1271 1064 $emails_init = array_merge( $emails_init, wpbc_import6_email__trash__get_fields_array_for_activation() );
1272 1065 if ( class_exists( 'wpdev_bk_personal' ) )
1273 1066 $emails_init = array_merge( $emails_init, wpbc_import6_email__modification__get_fields_array_for_activation() );
1067 + if ( class_exists( 'wpdev_bk_personal' ) && function_exists( 'wpbc_customer_verification_email_get_initial_values' ) )
1068 + $emails_init = array_merge( $emails_init, wpbc_customer_verification_email_get_initial_values() );
1274 1069 if ( class_exists( 'wpdev_bk_biz_s' ) )
1275 1070 $emails_init = array_merge( $emails_init, wpbc_import6_email__payment_request__get_fields_array_for_activation() );
1276 1071 foreach ( $emails_init as $email_key_name => $email_values ) {
1277 1072
@@ -1285,29 +1080,31 @@
1285 1080 $mu_option4delete[]='booking_cron'; // Creation in wpbc-cron.php
1286 1081
1287 1082 // FixIn: 8.0.1.6.
1288 1083 //$default_options['booking_form_structure_type'] = 'vertical';
1289 - $default_options['booking_form_structure_type'] = 'form_right'; // FixIn: 10.3.0.6.
1290 - $default_options['booking_menu_go_pro'] = 'show'; // show | hide
1084 + // $default_options['booking_form_structure_type'] = 'form_right'; // FixIn: 10.3.0.6.
1085 + $default_options['booking_form_structure_type'] = 'wizard_services_a'; // FixIn: 10.11.4.3.
1086 + $default_options['booking_menu_go_pro'] = ( WPBC_IS_PLAYGROUND ) ? 'hide' : 'show'; // show | hide
1291 1087
1292 - $default_options['booking_form_layout_width'] = '440';
1293 - $default_options['booking_form_layout_width_px_pr'] = 'px';
1294 - $default_options['booking_form_layout_max_cols'] = 1;
1088 +// $default_options['booking_form_layout_width'] = '440';
1089 +// $default_options['booking_form_layout_width_px_pr'] = 'px';
1090 +// $default_options['booking_form_layout_max_cols'] = 1;
1295 1091
1092 + // FixIn: 10.11.4.3.
1093 + $default_options['booking_form_layout_width'] = '100';
1094 + $default_options['booking_form_layout_width_px_pr'] = '%';
1095 + $default_options['booking_form_layout_max_cols'] = 2;
1096 +
1097 +
1296 1098 // -----------------------------------------------------------------------------------------------------------------
1297 1099 // PS
1298 1100 // -----------------------------------------------------------------------------------------------------------------
1299 1101 if ( class_exists( 'wpdev_bk_personal' ) ) {
1300 1102
1301 - $default_options['booking_is_use_simple_booking_form'] = 'Off'; // FixIn: 8.1.1.12.
1302 - $mu_option4delete[]='booking_is_use_simple_booking_form';
1303 1103
1304 1104 $default_options['booking_is_use_codehighlighter_booking_form'] = 'On'; // FixIn: 8.4.7.18.
1305 1105 $mu_option4delete[]='booking_is_use_codehighlighter_booking_form';
1306 1106
1307 - $default_options['booking_form'] = str_replace( '\\n\\', '', wpbc_get_default_booking_form() );
1308 - $default_options['booking_form_show'] = str_replace( '\\n\\', '', wpbc_get_default_booking_form_show() );
1309 -
1310 1107 $default_options['booking_url_bookings_edit_by_visitors'] = site_url();
1311 1108 $mu_option4delete[]='booking_url_bookings_edit_by_visitors';
1312 1109
1313 1110 $default_options['booking_url_bookings_listing_by_customer'] = site_url(); //FixIn: 8.1.3.5.1
@@ -1335,9 +1132,10 @@
1335 1132 $mu_option4delete[]='booking_calendar_overview_end_time';
1336 1133
1337 1134 $default_options['booking_default_title_in_day_for_timeline_front_end'] = '[name] [secondname]';
1338 1135 $mu_option4delete[]='booking_default_title_in_day_for_timeline_front_end';
1339 - $default_options['booking_is_show_popover_in_timeline_front_end'] = ($is_demo) ? 'On' : 'Off';
1136 + // FixIn: 10.14.10.1.
1137 + $default_options['booking_is_show_popover_in_timeline_front_end'] = 'Off';
1340 1138 $mu_option4delete[]='booking_is_show_popover_in_timeline_front_end';
1341 1139 // FixIn: 9.6.3.5.
1342 1140
1343 1141 $default_options['booking_send_emails_off_addbooking'] = 'Off'; // FixIn: 8.4.5.4.
@@ -1360,8 +1158,11 @@
1360 1158 //$mu_option4delete[]='booking_ics_force_trash_before_import'; // No need to delete ^
1361 1159 $default_options['booking_ics_import_append_checkout_day'] = 'Off'; //FixIn: 9.6.2.7 // FixIn: 9.5.4.1.
1362 1160 //$mu_option4delete[]='booking_ics_import_append_checkout_day'; // No need to delete ^
1363 1161
1162 + $default_options['booking_ics_import_append_extra_checkout_day'] = 'Off';
1163 + //$mu_option4delete[]='booking_ics_import_append_extra_checkout_day'; // No need to delete ^
1164 +
1364 1165 // FixIn: 9.8.15.8.
1365 1166 $default_options['booking_condition_import_only_new'] = ( get_bk_option( 'booking_ics_force_import' ) === 'On' ) ? 'Off' : 'On';
1366 1167 $default_options['booking_condition_import_if_available'] = 'Off';
1367 1168
@@ -1410,9 +1211,11 @@
1410 1211 $default_options['booking_auto_cancel_pending_unpaid_bk_is_send_email'] = 'On';
1411 1212 $mu_option4delete[]='booking_auto_cancel_pending_unpaid_bk_is_send_email';
1412 1213 $default_options['booking_auto_cancel_pending_unpaid_bk_email_reason'] = __( 'This booking canceled because we did not receive payment and the administrator did not approve it.', 'booking' );
1413 1214 $mu_option4delete[]='booking_auto_cancel_pending_unpaid_bk_email_reason';
1414 - $default_options['booking_range_selection_type'] = 'fixed';
1215 + // Start every edition with the unrestricted two-click range.
1216 + // Business Small+ users can opt into a fixed one-click range later.
1217 + $default_options['booking_range_selection_type'] = 'dynamic';
1415 1218 $mu_option4delete[]='booking_range_selection_type';
1416 1219 $default_options['booking_range_selection_days_count'] = '3';
1417 1220 $mu_option4delete[]='booking_range_selection_days_count';
1418 1221 $default_options['booking_range_selection_days_max_count_dynamic'] = 30;
@@ -1441,8 +1244,10 @@
1441 1244 $mu_option4delete[]='booking_change_over__is_excerpt_on_pages';
1442 1245 $default_options['booking_change_over__is_excerpt_on_pages'] = 'Off'; // FixIn: 8.9.4.10.
1443 1246 $mu_option4delete[]='booking_change_over__excerpt_on_pages';
1444 1247 $default_options['booking_change_over__excerpt_on_pages'] = ''; // FixIn: 8.9.4.10.
1248 + $mu_option4delete[]='booking_change_over__excerpt_bk_resources';
1249 + $default_options['booking_change_over__excerpt_bk_resources'] = ''; // FixIn: 10.16.4.1.
1445 1250
1446 1251
1447 1252 $default_options['booking_email_payment_request_adress'] = htmlspecialchars( '"Booking system" <' . get_option( 'admin_email' ) . '>' );
1448 1253 $default_options['booking_email_payment_request_subject'] = __( 'You need to make payment for this reservation', 'booking' );
@@ -1478,9 +1283,8 @@
1478 1283 $mu_option4delete[]='booking_unavailable_extra_days_in';
1479 1284 $default_options['booking_unavailable_extra_days_out'] = '';
1480 1285 $mu_option4delete[]='booking_unavailable_extra_days_out';
1481 1286
1482 - $default_options['booking_forms_extended'] = serialize( array() );
1483 1287 $default_options['booking_advanced_costs_values'] = serialize( array() );
1484 1288 $default_options['booking_is_resource_deposit_payment_active'] = 'On';
1485 1289 $mu_option4delete[]='booking_is_resource_deposit_payment_active';
1486 1290 $default_options['booking_advanced_costs_calc_fixed_cost_with_procents'] = 'Off';