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 +541 -742 10.1011.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,148 @@
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
788 - // FixIn: 8.7.9.1.
789 - if ( ! wpbc_is_table_exists('bookingdates') ) { // Check if tables not exist yet
790 - $simple_sql = "CREATE TABLE {$wpdb->prefix}bookingdates (
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 +
411 + $is_insert_test_bookings = false;
412 +
413 + // ----------------------------------------------------------------------------
414 + // 2. Install: CREATE bookingdate TABLE.
415 + // ----------------------------------------------------------------------------
416 +
417 + if ( ! wpbc_is_table_exists( 'bookingdates' ) ) {
418 + // Check if tables not exist yet.
419 + $simple_sql = "CREATE TABLE {$wpdb->prefix}bookingdates (
791 420 booking_dates_id bigint(20) unsigned NOT NULL auto_increment,
792 421 booking_id bigint(20) unsigned NOT NULL,
793 422 booking_date datetime NOT NULL default '0000-00-00 00:00:00',
794 423 approved bigint(20) unsigned NOT NULL default 0,
@@ -794,125 +423,182 @@
794 423 approved bigint(20) unsigned NOT NULL default 0,
795 424 PRIMARY KEY (booking_dates_id)
796 425 ) {$charset_collate}";
797 426
798 - // 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
799 428 $wpdb->query( $simple_sql );
800 429
801 - if( ! class_exists( 'wpdev_bk_personal' ) ) {
802 - $wp_queries[] = "INSERT INTO {$wpdb->prefix}booking ( form, modification_date ) VALUES (
803 - 'text^name1^Jony~text^secondname1^Smith~text^email1^example-free@wpbookingcalendar.com~text^phone1^458-77-77~textarea^details1^Reserve a room with sea view', NOW() );";
804 - }
805 - }
430 + if ( ! class_exists( 'wpdev_bk_personal' ) ) {
431 + $is_insert_test_bookings = true;
432 + }
433 + }
806 434
807 -
808 - // If we remove this index, so then its can significant impact to the speed of page loading at the Booking Listing and Timelines.
809 - /**
810 - (
811 - [0] => SELECT * FROM wp_booking as bk WHERE EXISTS (
812 - SELECT *
813 - FROM wp_bookingdates as dt
814 - WHERE bk.booking_id = dt.booking_id AND ( dt.booking_date >= '2016-11-01 00:00:00' ) AND ( dt.booking_date <= '2016-12-31 23:59:59' ) ) AND bk.trash = 0 AND ( ( bk.booking_type IN ( 14,15,16,17,18,20,21,22,23,1,2,3,4,5,26,6,7,8,9,10,11,12,24,25 ) ) ) ORDER BY booking_type DESC LIMIT 0, 100000
815 - [TIME] => 18.3653769493
816 - [2] => do_action('toplevel_page_wpbc'), call_user_func_array, WPBC_Admin_Menus->content, do_action('wpbc_page_structure_show'), call_user_func_array, WPBC_Page_Structure->content_structure, WPBC_Page_CalendarOverview->content, WPBC_Timeline->admin_init, wpbc_get_bookings_objects
817 - )
818 - (
819 - [0] => SELECT COUNT(*) as count FROM wp_booking as bk WHERE EXISTS (
820 - SELECT *
821 - FROM wp_bookingdates as dt
822 - WHERE bk.booking_id = dt.booking_id AND ( dt.booking_date >= '2016-11-01 00:00:00' ) AND ( dt.booking_date <= '2016-12-31 23:59:59' ) ) AND bk.trash = 0 AND ( ( bk.booking_type IN ( 14,15,16,17,18,20,21,22,23,1,2,3,4,5,26,6,7,8,9,10,11,12,24,25 ) ) )
823 - [TIME] => 18.0764019489
824 - [2] => do_action('toplevel_page_wpbc'), call_user_func_array, WPBC_Admin_Menus->content, do_action('wpbc_page_structure_show'), call_user_func_array, WPBC_Page_Structure->content_structure, WPBC_Page_CalendarOverview->content, WPBC_Timeline->admin_init, wpbc_get_bookings_objects
825 - )
826 - */
827 -
828 - // Index for SPEED opening Booking Listing and Timeline with thousands of Bookings, otherwise, without this index, speed will be TOO SLOW...
829 - if (wpbc_is_index_in_table_exists('bookingdates','booking_id_dates') == 0) {
830 - $simple_sql = "CREATE UNIQUE INDEX booking_id_dates ON {$wpdb->prefix}bookingdates ( booking_id, booking_date);";
831 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
435 + if ( 0 === wpbc_is_index_in_table_exists( 'bookingdates', 'booking_id_dates' ) ) {
436 + // If we remove this index, so then its can significant impact to the speed of page loading at the Booking Listing and Timelines.
437 + // Index for SPEED opening Booking Listing and Timeline with thousands of Bookings, otherwise, without this index, speed will be TOO SLOW...
438 + $simple_sql = "CREATE UNIQUE INDEX booking_id_dates ON {$wpdb->prefix}bookingdates ( booking_id, booking_date);";
439 + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter
832 440 $wpdb->query( $simple_sql );
833 - }
834 -
835 -
836 - if (count($wp_queries)>0) {
837 - foreach ( $wp_queries as $wp_q ) {
838 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
839 - $wpdb->query( $wp_q );
840 - }
441 + }
841 442
842 - if( ! class_exists( 'wpdev_bk_personal' ) ) {
843 - $temp_id = $wpdb->insert_id;
844 - $wp_queries_sub = "INSERT INTO {$wpdb->prefix}bookingdates (
845 - booking_id,
846 - booking_date
847 - ) VALUES
848 - ( ". $temp_id .", CURDATE()+ INTERVAL 2 day ),
849 - ( ". $temp_id .", CURDATE()+ INTERVAL 3 day ),
850 - ( ". $temp_id .", CURDATE()+ INTERVAL 4 day );";
851 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
852 - $wpdb->query( $wp_queries_sub );
853 - }
854 - }
443 + // ----------------------------------------------------------------------------
444 + // 3. Insert test bookings.
445 + // ----------------------------------------------------------------------------
855 446
856 - // FixIn: 9.2.3.3.
857 - if ( wpbc_is_field_in_table_exists( 'booking', 'hash' ) == 0 ) { //HASH_EDIT
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
858 453
859 - $simple_sql = "ALTER TABLE {$wpdb->prefix}booking ADD hash TEXT AFTER form";
860 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
861 - $wpdb->query( $simple_sql );
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
862 460
863 - // Update hash value only in last 100 bookings
864 - $sql_check_table = "SELECT booking_id as id FROM {$wpdb->prefix}booking ORDER BY booking_id DESC LIMIT 0, 100";
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
865 466
866 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
867 - $res = $wpdb->get_results( $sql_check_table );
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
868 473
869 - foreach ( $res as $l ) {
870 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
871 - $wpdb->query( "UPDATE {$wpdb->prefix}booking SET hash = MD5('" . time() . '_' . wp_rand( 1000, 1000000 ) . "') WHERE booking_id = " . $l->id );
872 - }
474 +
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
482 +
483 + $temp_id = $wpdb->insert_id;
484 +
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
873 491 }
874 492 }
875 - make_bk_action( 'wpbc_activation_after_db_actions' ); // FixIn: 9.3.1.2.
876 493
494 + make_bk_action( 'wpbc_free_version_activation' );
495 +
496 + do_action( 'wpbc_free_version_activation' );
497 +
877 498 // -----------------------------------------------------------------------------------------------------------------
878 - // Other versions Activation
499 + // Other versions Activation
879 500 // -----------------------------------------------------------------------------------------------------------------
880 - make_bk_action( 'wpbc_other_versions_activation' );
501 + make_bk_action( 'wpbc_other_versions_activation' );
881 502
882 -
883 - // -----------------------------------------------------------------------------------------------------------------
884 - // Examples in demos
885 - // -----------------------------------------------------------------------------------------------------------------
886 - if ( $is_demo ) { wpbc_create_examples_4_demo(); }
503 + do_action( 'wpbc_pro_versions_activation' );
887 504
888 -
889 - // Fill Development server by initial bookings
890 - if ( ( defined( 'WP_BK_BETA_DATA_FILL' ) )
891 - && ( WP_BK_BETA_DATA_FILL > 0 )
892 - ) {
893 - if ( ( isset( $_SERVER['HTTP_HOST'] ) ) && ( ( 'beta' === $_SERVER['HTTP_HOST'] ) || ( 'freetest.wpbookingcalendar.com' === $_SERVER['HTTP_HOST'] ) ) ) {
894 - $types_array = array();
895 - for ( $i = 0; $i < WP_BK_BETA_DATA_FILL; $i++) {
896 - foreach ( range(1, 12) as $types_el) {
897 - $types_array[] = $types_el;
898 - }
899 - }
900 - wpbc_create_examples_4_demo( $types_array );
901 - }
902 - }
903 - //wpbc_set_default_initial_values();
505 + wpbc_reindex_booking_db();
904 506
905 - // -----------------------------------------------------------------------------------------------------------------
906 - wpbc_reindex_booking_db();
507 + make_bk_action( 'wpbc_after_activation' );
907 508
908 - make_bk_action( 'wpbc_after_activation' );
509 + do_action( 'wpbc_after_activation' );
909 510 }
910 511 add_bk_action( 'wpbc_activation', 'wpbc_booking_activate' );
911 512
912 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() {
913 525
914 -// 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.
915 601 function wpbc_booking_deactivate() {
916 602
917 603 // -----------------------------------------------------------------------------------------------------------------
918 604 // Options
@@ -931,21 +617,27 @@
931 617 delete_bk_option( 'widget_bookingsearchwidget' );
932 618 delete_bk_option( 'widget_bookingselectwidget' );
933 619 delete_bk_option( 'booking_activation_redirect_for_version' );
934 620
935 -
936 621 // -----------------------------------------------------------------------------------------------------------------
937 622 // DB Tables
938 623 // -----------------------------------------------------------------------------------------------------------------
939 624 global $wpdb;
940 - // 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
941 626 $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}booking" );
942 - // 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
943 628 $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}bookingdates" );
944 629
945 - // Delete all users booking windows states.
946 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared,
947 - 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 ) ) {
948 640 debuge_error('Error during deleting user meta at DB',__FILE__,__LINE__);
949 641 die();
950 642 }
951 643
@@ -950,19 +642,21 @@
950 642 }
951 643
952 644 // Delete or Drafts and Pending from demo sites
953 645 if ( wpbc_is_this_demo() ) { // Delete all temp posts at the demo sites: (post_status = pending || draft) && ( post_type = post ) && (post_author != 1)
954 - // 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,
955 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" );
956 648 foreach ( $postss as $pp ) {
957 649 wp_delete_post( $pp->ID, true );
958 650 }
959 651 }
960 -
652 + make_bk_action( 'wpbc_free_version_deactivation' );
961 653 ////////////////////////////////////////////////////////////////////////////
962 654 // Other versions Deactivation
963 655 ////////////////////////////////////////////////////////////////////////////
964 656 make_bk_action( 'wpbc_other_versions_deactivation' );
657 +
658 + wpbc_deactivation__delete_all_plugin_options();
965 659 }
966 660 add_bk_action( 'wpbc_deactivation', 'wpbc_booking_deactivate' );
967 661
968 662
@@ -976,10 +670,11 @@
976 670 * $options_for_delete = wpbc_get_default_options( $option_name, $is_get_multiuser_general_options );
977 671 */
978 672 function wpbc_get_default_options( $option_name = '', $is_get_multiuser_general_options = false ) {
979 673
980 - $is_demo = wpbc_is_this_demo();
981 - $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' ) );
982 677
983 678 $default_options = array();
984 679
985 680 // If this option here, then system get this option from "Super Admin" options configuration for "Regular" users.
@@ -987,20 +682,27 @@
987 682
988 683 // FixIn: 9.6.3.5.
989 684 $default_options['booking_setup_wizard_page_steps_is_done'] = '';
990 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';
991 692
992 693 $default_options['booking_admin_cal_count'] = ($is_demo) ? '3' : '2';
993 694 $mu_option4delete[]='booking_admin_cal_count'; // $multiuser_general_option[] = implode( '', array_keys( array_slice( $default_options, -1 ) ) );
994 - $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.
995 696 $mu_option4delete[]='booking_skin';
996 697 // FixIn: 9.6.3.5.
997 698 $default_options['booking_listing_default_view_mode'] = 'vm_booking_listing'; // 'vm_calendar'; // FixIn: 9.6.3.5.
998 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';
999 704
1000 -// $default_options['booking_admin_panel_skin'] = 'modern_1'; // 'modern_1' //FixIn: 9.5.5.7 // FixIn: 10.1.1.3.
1001 -// $mu_option4delete[]='booking_admin_panel_skin';
1002 -
1003 705 $default_options['booking_view_days_num'] = ( ( ! class_exists( 'wpdev_bk_personal' ) ) ? '90' : '30' );
1004 706 $mu_option4delete[]='booking_view_days_num';
1005 707 // FixIn: 8.9.4.3.
1006 708 $default_options['booking_calendar_overview__day_mode__days_number_show'] = ( ( ! class_exists( 'wpdev_bk_personal' ) ) ? '7' : '7' );
@@ -1022,12 +724,17 @@
1022 724 //$mu_option4delete[]='booking_title_after_reservation_time';
1023 725 $default_options['booking_type_of_thank_you_message'] = 'message';
1024 726 $mu_option4delete[]='booking_type_of_thank_you_message';
1025 727 $default_options['booking_thank_you_page_URL'] = '/thank-you';
1026 - $mu_option4delete[]='booking_thank_you_page_URL';
728 + $mu_option4delete[]='booking_thank_you_page_URL';
1027 729 $default_options['booking_is_use_autofill_4_logged_user'] = ($is_demo) ? 'On' : 'Off';
1028 - $mu_option4delete[]='booking_is_use_autofill_4_logged_user';
1029 - $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;
1030 737 $mu_option4delete[]='booking_date_format';
1031 738 $default_options['booking_time_format'] = get_option( 'time_format' ); //'H:i';
1032 739 $mu_option4delete[]='booking_time_format';
1033 740
@@ -1048,9 +755,9 @@
1048 755
1049 756 $default_options['booking_confirmation__booking_details__header_enabled'] = 'On';
1050 757 $default_options['booking_confirmation__booking_details__title'] = __( 'Booking details', 'booking' );
1051 758 $default_options['booking_confirmation__booking_details__content'] = ( class_exists( 'wpdev_bk_personal' ) )
1052 - ? "<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>'
1053 760 : "[readable_dates][readable_times]\n[add_to_google_cal_button]";
1054 761
1055 762 $mu_option4delete[] = 'booking_confirmation__booking_details__header_enabled';
1056 763 $mu_option4delete[] = 'booking_confirmation__booking_details__title';
@@ -1079,21 +786,19 @@
1079 786
1080 787 $mu_option4delete[]='booking_is_load_js_css_on_specific_pages';
1081 788 $default_options['booking_pages_for_load_js_css'] = '';
1082 789 $mu_option4delete[]='booking_pages_for_load_js_css';
1083 - $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' );
1084 793 $mu_option4delete[]='booking_type_of_day_selections';
1085 794
1086 795 // FixIn: 8.7.11.10.
1087 796 $default_options['booking_timeslot_picker'] = 'On';
1088 797 $mu_option4delete[]= 'booking_timeslot_picker';
1089 - $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';
1090 799 $mu_option4delete[]= 'booking_timeslot_picker_skin';
1091 800
1092 - $default_options['booking_timeslot_day_bg_as_available'] = 'Off'; //( ( class_exists( 'wpdev_bk_personal' ) ) ? 'Off' : 'On' ); // FixIn: 8.2.1.27.
1093 - $mu_option4delete[]='booking_timeslot_day_bg_as_available';
1094 -
1095 -
1096 801 $default_options['booking_disable_timeslots_in_tooltip'] = 'Off'; //FixIn: 9.5.0.2.2
1097 802 $mu_option4delete[]='booking_disable_timeslots_in_tooltip';
1098 803
1099 804 $default_options['booking_highlight_timeslot_word'] = __( 'Booked Times:', 'booking' ); // FixIn: 9.4.3.1.
@@ -1148,25 +853,40 @@
1148 853 $default_options['booking_unavailable_day5'] = 'Off';
1149 854 $mu_option4delete[]='booking_unavailable_day5';
1150 855 $default_options['booking_unavailable_day6'] = 'Off';
1151 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 +
1152 870 $default_options['booking_menu_position'] = ( $is_demo ) ? 'top' : 'top';
1153 871 $mu_option4delete[]='booking_menu_position';
1154 872 $default_options['booking_translation_load_from'] = 'wp.org';
1155 873 $mu_option4delete[]='booking_translation_load_from';
1156 - $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';
1157 877 $mu_option4delete[]='booking_user_role_booking';
1158 - $default_options['booking_user_role_availability'] = ( $is_demo ) ? 'subscriber' : 'editor'; // FixIn: 9.5.2.2.
878 + $default_options['booking_user_role_availability'] = 'editor';
1159 879 $mu_option4delete[]='booking_user_role_availability';
1160 - $default_options['booking_user_role_addbooking'] = ( $is_demo ) ? 'subscriber' : 'editor';
880 + $default_options['booking_user_role_addbooking'] = 'editor';
1161 881 $mu_option4delete[]='booking_user_role_addbooking';
1162 - $default_options['booking_user_role_resources'] = ( $is_demo ) ? 'subscriber' : 'editor';
882 + $default_options['booking_user_role_resources'] = 'editor';
1163 883 $mu_option4delete[]='booking_user_role_resources';
1164 - $default_options['booking_user_role_settings'] = ( $is_demo ) ? 'subscriber' : 'administrator';
884 + $default_options['booking_user_role_settings'] = 'editor';
1165 885 $mu_option4delete[]='booking_user_role_settings';
1166 886 //FixIn: 9.8.15.2.6
1167 887 if ( class_exists( 'wpdev_bk_biz_m' ) ) {
1168 - $default_options['booking_user_role_prices'] = ( $is_demo ) ? 'subscriber' : 'editor';
888 + $default_options['booking_user_role_prices'] = 'editor';
1169 889 $mu_option4delete[]='booking_user_role_prices';
1170 890 }
1171 891
1172 892 // New admin ///////////////////////////////////////////////////////////////
@@ -1221,15 +941,83 @@
1221 941 $default_options['booking_widget_last_field'] = '';
1222 942
1223 943 $default_options['booking_wpdev_copyright_adminpanel'] = 'On';
1224 944 $mu_option4delete[]='booking_wpdev_copyright_adminpanel';
1225 - $default_options['booking_is_show_powered_by_notice'] = 'On';
945 + $default_options['booking_is_show_powered_by_notice'] = ( WPBC_IS_PLAYGROUND ) ? 'Off' : 'On';
1226 946 $mu_option4delete[]='booking_is_show_powered_by_notice';
1227 947 $default_options['booking_form_theme'] = '';
1228 948 $mu_option4delete[]='booking_form_theme';
1229 - $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';
1230 1016 $mu_option4delete[]='booking_is_use_captcha';
1231 - $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';
1232 1020 $mu_option4delete[]='booking_is_show_legend';
1233 1021 $default_options['booking_send_button_title'] = __( 'Send', 'booking' ); // FixIn: 8.8.1.14.
1234 1022 $mu_option4delete[]='booking_send_button_title';
1235 1023 $default_options['booking_legend_is_show_item_available'] = 'On';
@@ -1275,8 +1063,10 @@
1275 1063 $emails_init = array_merge( $emails_init, wpbc_import6_email__deny__get_fields_array_for_activation() );
1276 1064 $emails_init = array_merge( $emails_init, wpbc_import6_email__trash__get_fields_array_for_activation() );
1277 1065 if ( class_exists( 'wpdev_bk_personal' ) )
1278 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() );
1279 1069 if ( class_exists( 'wpdev_bk_biz_s' ) )
1280 1070 $emails_init = array_merge( $emails_init, wpbc_import6_email__payment_request__get_fields_array_for_activation() );
1281 1071 foreach ( $emails_init as $email_key_name => $email_values ) {
1282 1072
@@ -1290,29 +1080,31 @@
1290 1080 $mu_option4delete[]='booking_cron'; // Creation in wpbc-cron.php
1291 1081
1292 1082 // FixIn: 8.0.1.6.
1293 1083 //$default_options['booking_form_structure_type'] = 'vertical';
1294 - $default_options['booking_form_structure_type'] = 'form_right'; // FixIn: 10.3.0.6.
1295 - $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
1296 1087
1297 - $default_options['booking_form_layout_width'] = '440';
1298 - $default_options['booking_form_layout_width_px_pr'] = 'px';
1299 - $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;
1300 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 +
1301 1098 // -----------------------------------------------------------------------------------------------------------------
1302 1099 // PS
1303 1100 // -----------------------------------------------------------------------------------------------------------------
1304 1101 if ( class_exists( 'wpdev_bk_personal' ) ) {
1305 1102
1306 - $default_options['booking_is_use_simple_booking_form'] = 'Off'; // FixIn: 8.1.1.12.
1307 - $mu_option4delete[]='booking_is_use_simple_booking_form';
1308 1103
1309 1104 $default_options['booking_is_use_codehighlighter_booking_form'] = 'On'; // FixIn: 8.4.7.18.
1310 1105 $mu_option4delete[]='booking_is_use_codehighlighter_booking_form';
1311 1106
1312 - $default_options['booking_form'] = str_replace( '\\n\\', '', wpbc_get_default_booking_form() );
1313 - $default_options['booking_form_show'] = str_replace( '\\n\\', '', wpbc_get_default_booking_form_show() );
1314 -
1315 1107 $default_options['booking_url_bookings_edit_by_visitors'] = site_url();
1316 1108 $mu_option4delete[]='booking_url_bookings_edit_by_visitors';
1317 1109
1318 1110 $default_options['booking_url_bookings_listing_by_customer'] = site_url(); //FixIn: 8.1.3.5.1
@@ -1319,9 +1111,9 @@
1319 1111 $mu_option4delete[]='booking_url_bookings_listing_by_customer';
1320 1112
1321 1113 $default_options['booking_default_booking_resource'] = ''; // All resources
1322 1114 $mu_option4delete[]='booking_default_booking_resource';
1323 - $default_options['booking_is_change_hash_after_approvement'] = 'Off';
1115 + $default_options['booking_is_change_hash_after_approvement'] = 'On'; // FixIn: 10.10.1.1.
1324 1116 $mu_option4delete[]='booking_is_change_hash_after_approvement';
1325 1117 $default_options['booking_email_modification_adress'] = htmlspecialchars( '"Booking system" <' . get_option( 'admin_email' ) . '>' );
1326 1118 $default_options['booking_email_modification_subject'] = __( 'The reservation has been modified', 'booking' );
1327 1119 /* translators: 1: ... */
@@ -1340,9 +1132,10 @@
1340 1132 $mu_option4delete[]='booking_calendar_overview_end_time';
1341 1133
1342 1134 $default_options['booking_default_title_in_day_for_timeline_front_end'] = '[name] [secondname]';
1343 1135 $mu_option4delete[]='booking_default_title_in_day_for_timeline_front_end';
1344 - $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';
1345 1138 $mu_option4delete[]='booking_is_show_popover_in_timeline_front_end';
1346 1139 // FixIn: 9.6.3.5.
1347 1140
1348 1141 $default_options['booking_send_emails_off_addbooking'] = 'Off'; // FixIn: 8.4.5.4.
@@ -1365,8 +1158,11 @@
1365 1158 //$mu_option4delete[]='booking_ics_force_trash_before_import'; // No need to delete ^
1366 1159 $default_options['booking_ics_import_append_checkout_day'] = 'Off'; //FixIn: 9.6.2.7 // FixIn: 9.5.4.1.
1367 1160 //$mu_option4delete[]='booking_ics_import_append_checkout_day'; // No need to delete ^
1368 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 +
1369 1165 // FixIn: 9.8.15.8.
1370 1166 $default_options['booking_condition_import_only_new'] = ( get_bk_option( 'booking_ics_force_import' ) === 'On' ) ? 'Off' : 'On';
1371 1167 $default_options['booking_condition_import_if_available'] = 'Off';
1372 1168
@@ -1415,9 +1211,11 @@
1415 1211 $default_options['booking_auto_cancel_pending_unpaid_bk_is_send_email'] = 'On';
1416 1212 $mu_option4delete[]='booking_auto_cancel_pending_unpaid_bk_is_send_email';
1417 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' );
1418 1214 $mu_option4delete[]='booking_auto_cancel_pending_unpaid_bk_email_reason';
1419 - $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';
1420 1218 $mu_option4delete[]='booking_range_selection_type';
1421 1219 $default_options['booking_range_selection_days_count'] = '3';
1422 1220 $mu_option4delete[]='booking_range_selection_days_count';
1423 1221 $default_options['booking_range_selection_days_max_count_dynamic'] = 30;
@@ -1446,8 +1244,10 @@
1446 1244 $mu_option4delete[]='booking_change_over__is_excerpt_on_pages';
1447 1245 $default_options['booking_change_over__is_excerpt_on_pages'] = 'Off'; // FixIn: 8.9.4.10.
1448 1246 $mu_option4delete[]='booking_change_over__excerpt_on_pages';
1449 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.
1450 1250
1451 1251
1452 1252 $default_options['booking_email_payment_request_adress'] = htmlspecialchars( '"Booking system" <' . get_option( 'admin_email' ) . '>' );
1453 1253 $default_options['booking_email_payment_request_subject'] = __( 'You need to make payment for this reservation', 'booking' );
@@ -1483,9 +1283,8 @@
1483 1283 $mu_option4delete[]='booking_unavailable_extra_days_in';
1484 1284 $default_options['booking_unavailable_extra_days_out'] = '';
1485 1285 $mu_option4delete[]='booking_unavailable_extra_days_out';
1486 1286
1487 - $default_options['booking_forms_extended'] = serialize( array() );
1488 1287 $default_options['booking_advanced_costs_values'] = serialize( array() );
1489 1288 $default_options['booking_is_resource_deposit_payment_active'] = 'On';
1490 1289 $mu_option4delete[]='booking_is_resource_deposit_payment_active';
1491 1290 $default_options['booking_advanced_costs_calc_fixed_cost_with_procents'] = 'Off';
@@ -1536,10 +1335,10 @@
1536 1335
1537 1336
1538 1337 $default_options['booking_is_dissbale_booking_for_different_sub_resources'] = 'Off';
1539 1338 $mu_option4delete[]='booking_is_dissbale_booking_for_different_sub_resources';
1540 - $default_options['booking_is_resource_no_update__during_editing'] = 'On'; // FixIn: 9.4.2.3.
1541 - $mu_option4delete[]='booking_is_resource_no_update__during_editing';
1339 +// FixIn: 10.10.1.2 $default_options['booking_is_resource_no_update__during_editing'] = 'On'; // FixIn: 9.4.2.3.
1340 +// FixIn: 10.10.1.2 $mu_option4delete[]='booking_is_resource_no_update__during_editing';
1542 1341 $default_options['booking_search_form_show'] = str_replace( '\\n\\r', "\n", wpbc_get_default_search_form_template( 'standard_search_form' ) ); //FixIn:6.1.0.1 // FixIn: 8.5.2.11.
1543 1342 $mu_option4delete[]='booking_search_form_show';
1544 1343 $default_options['booking_found_search_item'] = str_replace( '\\n\\r', "\n", wpbc_get_default_search_results_template( 'advanced_search_results' ) ); //FixIn:6.1.0.1 // FixIn: 8.5.2.11.
1545 1344 $mu_option4delete[]='booking_found_search_item';