PluginProbe
Booking Calendar / 10.11.2
Booking Calendar v10.11.2
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 10.11.3 All 202 releases
booking / core / wpbc-activation.php

wpbc-activation.php in Booking Calendar 10.11.2, at core/wpbc-activation.php

1,615 lines 97.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @version 1.0
4 * @package Booking Calendar
5 * @subpackage Activation / Deactivation
6 * @category Functions
7 * @author wpdevelop
8 *
9 * @web-site https://wpbookingcalendar.com/
10 * @email info@wpbookingcalendar.com
11 * @modified 2016-03-17
12 */
13
14 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
15
16
17 /** Activation & Deactivation of Booking Calendar */
18 class WPBC_BookingInstall extends WPBC_Install {
19
20 /**
21 * Overload Booking Calendar option names and some other parameters
22 *
23 * //FixIn: 7.0.1.12
24 * Important! for correct loading of trasnaltions later, we must do not use here loacale of plugin. So here will be untranslated strings!!!
25 *
26 */
27 public function get_init_option_names() {
28
29 add_bk_action( 'wpdev_booking_activate_user', array( $this, 'wpbc_activate') ); // Hook for MU User activation
30
31 $links = array(
32 'option-version_num' => 'booking_version_num'
33 , 'option-is_delete_if_deactive' => 'booking_is_delete_if_deactive'
34 , 'option-activation_process' => 'booking_activation_process'
35 , 'transient-wpbc_activation_redirect' => '_booking_activation_redirect'
36 , 'message-delete_data' => '<strong>' . 'Warning!' . '</strong> '
37 . 'All booking data will be deleted when the plugin is deactivated.'
38 . '<br />'
39 . sprintf( 'If you want to save your booking data, please uncheck the %s"Delete booking data"%s at the'
40 , '<strong>', '</strong>')
41 . '<a href="' . esc_url( admin_url( add_query_arg( array( 'page' => 'wpbc-settings' ), 'admin.php' ) ) )
42 . '&scroll_to_section=wpbc_general_settings_uninstall_tab"> ' . 'settings page' . '.'
43 . ' </a>'
44 , 'link_settings' => '<a class="wpbc_plugins_links__settings" href="' . esc_url( admin_url( add_query_arg( array( 'page' => 'wpbc-settings' ), 'admin.php' ) ) )
45 . '">'. "Settings" .'</a>'
46 , 'link_whats_new' => '<a title="'. "Check new functionality in this plugin update." .'" href="'
47 . esc_url( admin_url( add_query_arg( array( 'page' => 'wpbc-about' ), 'index.php' ) ) )
48 .'">'. "What's New".'</a>'
49 , 'link_faq' => '<a title="FAQ" href="https://wpbookingcalendar.com/faq/">FAQ</a>'
50 , 'link_up' => '<a title="Check Pro functionality" href="https://wpbookingcalendar.com/features/#link_up" style="color: rgb(0, 163, 42);font-weight:700;">Get Pro</a>'
51 , 'link_upgrade' => '<a title="Upgrade to higher version" href="'
52 . esc_url( admin_url( add_query_arg( array( 'page' => 'wpbc-settings', 'tab' => 'upgrade' ), 'admin.php' ) ) )
53 . '" style="color: rgb(0, 163, 42);font-weight:700;">Get More</a>'
54 );
55
56 return $links;
57
58 }
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
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 }
84
85 }
86
87
88 // <editor-fold defaultstate="collapsed" desc=" Examples Data for Demos " >
89
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 }
464
465
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
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
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 // <editor-fold defaultstate="collapsed" desc=" Support & Maintence " >
585
586 /** Reindex DataBase to have "date key field" for be able to sort by dates. */
587 function wpbc_reindex_booking_db(){ global $wpdb;
588 $is_show_messages = false;
589 // if ( ( wpbc_is_settings_page('QUERY_STRING') ) && ( strpos($_SERVER[ 'QUERY_STRING' ],'reindex_sort_data=1') !== false ) )
590 // $is_show_messages = true;
591
592
593 if ($is_show_messages) {
594 // Hide all settings
595 // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedStylesheet
596 ?><style type="text/css" rel="stylesheet" >
597 #post_option .meta-box {
598 display:none;
599 }
600 #post_option .button-primary {
601 display:none;
602 }
603 #post_option .technical-booking-section {
604 display:block;
605 }
606 </style>
607 <?php
608 }
609
610 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
613 $wpdb->query( $simple_sql );
614 }
615
616 // Refill the sort date index.
617 if (wpbc_is_field_in_table_exists('booking','sort_date') != 0) {
618
619 $bookings_res = array();
620 if ( ! wpbc_is_this_wp_playground_db() ) { // FixIn: 10.0.0.1.
621 // 1. Select all bookings ID, where sort_date is NULL in wp_booking.
622 $sql = " SELECT booking_id as id FROM {$wpdb->prefix}booking as bk WHERE sort_date IS NULL";
623
624 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
625 $bookings_res = $wpdb->get_results( $sql );
626 }
627 if ( $is_show_messages ) {
628 /* translators: 1: ... */
629 echo esc_html( sprintf( __( '%1$s Found %2$s not indexed bookings %3$s', 'booking' ), ' ', count( $bookings_res ), '<br/>' ) );
630 }
631
632
633 if ( count( $bookings_res ) > 0 ) {
634 $id_string = '';
635 foreach ($bookings_res as $value) { $id_string .= $value->id . ','; }
636 $id_string = substr($id_string,0,-1);
637
638 //2. Select all (FIRST ??) booking_date, where booking_id = booking_id from #1 in wp_bookingdates
639 $sql = " SELECT booking_id as id, booking_date as date" ;
640 $sql .= " FROM {$wpdb->prefix}bookingdates as bdt" ;
641 $sql .= " WHERE booking_id IN ( ". $id_string ." ) GROUP BY bdt.booking_id ORDER BY bdt.booking_date " ;
642
643 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
644 $sort_date_array = $wpdb->get_results( $sql );
645
646 if ( $is_show_messages ) {
647 /* translators: 1: ... */
648 echo esc_html( sprintf( __( '%1$s Finish getting sort dates. %2$s', 'booking' ), ' ', '<br/>' ) );
649 }
650
651 //3. Insert that firtst date into the bookings in wp_booking
652 $ii=0;
653 foreach ($sort_date_array as $value) { $ii++;
654 $sql = "UPDATE {$wpdb->prefix}booking as bdt ";
655 $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
657 $wpdb->query( $sql );
658
659 if ( $is_show_messages ) {
660 /* translators: 1: ... */
661 echo esc_html( sprintf( __( 'Updated booking: %s', 'booking' ), $value->id . ' [' . $ii . ' / ' . count( $bookings_res ) . '] <br/>' ) );
662 }
663 }
664 }
665
666 }
667
668
669 }
670
671 // </editor-fold>
672
673
674
675 ////////////////////////////////////////////////////////////////////////////////
676 // A c t i v a t e & D e a c t i v a t e
677 ////////////////////////////////////////////////////////////////////////////////
678
679 /** Activation */
680 function wpbc_booking_activate() {
681
682 make_bk_action( 'wpbc_before_activation' );
683
684 wpbc_load_translation();
685
686 $version = wpbc_get_plugin_version_type();
687 $is_demo = wpbc_is_this_demo();
688
689 // -----------------------------------------------------------------------------------------------------------------
690 // Options
691 // -----------------------------------------------------------------------------------------------------------------
692 $default_options_to_add = wpbc_get_default_options();
693
694 make_bk_action( 'wpbc_before_activation__add_options', $default_options_to_add ); // FixIn: 9.6.2.11.
695
696 foreach ( $default_options_to_add as $default_option_name => $default_option_value ) {
697 add_bk_option( $default_option_name, $default_option_value );
698 }
699
700
701 // -----------------------------------------------------------------------------------------------------------------
702 // DB Tables
703 // -----------------------------------------------------------------------------------------------------------------
704 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
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, " . /**/
728
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 }
738
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 }
742
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 }
753
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 }
757
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 }
761
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 }
765
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 }
770
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 }
775
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 }
780
781
782
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 }
787
788 $is_insert_test_bookings = false;
789
790 // FixIn: 8.7.9.1.
791 if ( ! wpbc_is_table_exists( 'bookingdates' ) ) {
792 // Check if tables not exist yet.
793 $simple_sql = "CREATE TABLE {$wpdb->prefix}bookingdates (
794 booking_dates_id bigint(20) unsigned NOT NULL auto_increment,
795 booking_id bigint(20) unsigned NOT NULL,
796 booking_date datetime NOT NULL default '0000-00-00 00:00:00',
797 approved bigint(20) unsigned NOT NULL default 0,
798 PRIMARY KEY (booking_dates_id)
799 ) {$charset_collate}";
800
801 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
802 $wpdb->query( $simple_sql );
803
804 if ( ! class_exists( 'wpdev_bk_personal' ) ) {
805 $is_insert_test_bookings = true;
806 }
807 }
808
809 if ( 0 === wpbc_is_index_in_table_exists( 'bookingdates', 'booking_id_dates' ) ) {
810 // If we remove this index, so then its can significant impact to the speed of page loading at the Booking Listing and Timelines.
811 // Index for SPEED opening Booking Listing and Timeline with thousands of Bookings, otherwise, without this index, speed will be TOO SLOW...
812 $simple_sql = "CREATE UNIQUE INDEX booking_id_dates ON {$wpdb->prefix}bookingdates ( booking_id, booking_date);";
813 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
814 $wpdb->query( $simple_sql );
815 }
816
817
818 if ( count( $wp_queries ) > 0 ) {
819 foreach ( $wp_queries as $wp_q ) {
820 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
821 $wpdb->query( $wp_q );
822 }
823
824 if ( $is_insert_test_bookings ) {
825 // -- Test Booking #1 --
826 $wp_queries_sub = "INSERT INTO {$wpdb->prefix}booking ( form, modification_date ) VALUES (
827 'text^name1^John~text^secondname1^Smith~text^email1^example-free@wpbookingcalendar.com~text^phone1^458-77-77~textarea^details1^This is a test booking showing booking for several days.', NOW() );";
828 $wpdb->query( $wp_queries_sub ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
829
830 $temp_id = $wpdb->insert_id;
831 $wp_queries_sub = "INSERT INTO {$wpdb->prefix}bookingdates ( booking_id, booking_date ) VALUES
832 ( " . $temp_id . ", CURDATE()+ INTERVAL 2 day ),
833 ( " . $temp_id . ", CURDATE()+ INTERVAL 3 day ),
834 ( " . $temp_id . ", CURDATE()+ INTERVAL 4 day );";
835 $wpdb->query( $wp_queries_sub ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
836
837 // -- Test Booking #2 --
838 $is_appr = 1;
839 $start_time = '10:00';
840 $end_time = '10:30';
841 $wp_queries_sub = "INSERT INTO {$wpdb->prefix}booking ( form, modification_date, is_new ) VALUES (
842 'selectbox^rangetime1^".$start_time." - ".$end_time."~text^name1^Sophia~text^secondname1^Robinson~text^email1^example-free@wpbookingcalendar.com~text^phone1^458-77-77~textarea^details1^This is a test booking showing a one day time slot booking.', NOW(), 0 );";
843 $wpdb->query( $wp_queries_sub ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
844
845 $temp_id = $wpdb->insert_id;
846
847 $wp_queries_sub = "INSERT INTO {$wpdb->prefix}bookingdates ( booking_id, booking_date, approved ) VALUES
848 ( ". $temp_id .", CURDATE()+ INTERVAL \"5 " . $start_time. ":01\" DAY_SECOND ,". $is_appr." ),
849 ( ". $temp_id .", CURDATE()+ INTERVAL \"5 " . $end_time . ":02\" DAY_SECOND ,". $is_appr." );";
850 $wpdb->query( $wp_queries_sub ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
851 }
852 }
853
854 // FixIn: 9.2.3.3.
855 if ( wpbc_is_field_in_table_exists( 'booking', 'hash' ) == 0 ) { //HASH_EDIT
856
857 $simple_sql = "ALTER TABLE {$wpdb->prefix}booking ADD hash TEXT AFTER form";
858 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
859 $wpdb->query( $simple_sql );
860
861 // Update hash value only in last 100 bookings
862 $sql_check_table = "SELECT booking_id as id FROM {$wpdb->prefix}booking ORDER BY booking_id DESC LIMIT 0, 100";
863
864 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
865 $res = $wpdb->get_results( $sql_check_table );
866
867 foreach ( $res as $l ) {
868 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
869 $wpdb->query( "UPDATE {$wpdb->prefix}booking SET hash = MD5('" . time() . '_' . wp_rand( 1000, 1000000 ) . "') WHERE booking_id = " . $l->id );
870 }
871 }
872 }
873 make_bk_action( 'wpbc_activation_after_db_actions' ); // FixIn: 9.3.1.2.
874
875 // -----------------------------------------------------------------------------------------------------------------
876 // Other versions Activation
877 // -----------------------------------------------------------------------------------------------------------------
878 make_bk_action( 'wpbc_other_versions_activation' );
879
880
881 // -----------------------------------------------------------------------------------------------------------------
882 // Examples in demos
883 // -----------------------------------------------------------------------------------------------------------------
884 if ( $is_demo ) { wpbc_create_examples_4_demo(); }
885
886
887 // Fill Development server by initial bookings
888 if ( ( defined( 'WP_BK_BETA_DATA_FILL' ) )
889 && ( WP_BK_BETA_DATA_FILL > 0 )
890 ) {
891 if ( ( isset( $_SERVER['HTTP_HOST'] ) ) && ( ( 'beta' === $_SERVER['HTTP_HOST'] ) || ( 'freetest.wpbookingcalendar.com' === $_SERVER['HTTP_HOST'] ) ) ) {
892 $types_array = array();
893 for ( $i = 0; $i < WP_BK_BETA_DATA_FILL; $i++) {
894 foreach ( range(1, 12) as $types_el) {
895 $types_array[] = $types_el;
896 }
897 }
898 wpbc_create_examples_4_demo( $types_array );
899 }
900 }
901 //wpbc_set_default_initial_values();
902
903 // -----------------------------------------------------------------------------------------------------------------
904 wpbc_reindex_booking_db();
905
906 make_bk_action( 'wpbc_after_activation' );
907 }
908 add_bk_action( 'wpbc_activation', 'wpbc_booking_activate' );
909
910
911
912 // Deactivate
913 function wpbc_booking_deactivate() {
914
915 // -----------------------------------------------------------------------------------------------------------------
916 // Options
917 // -----------------------------------------------------------------------------------------------------------------
918 $default_options_to_add = wpbc_get_default_options();
919 foreach ( $default_options_to_add as $default_option_name => $default_option_value) {
920
921 delete_bk_option( $default_option_name );
922 }
923
924
925 // -----------------------------------------------------------------------------------------------------------------
926 // Widgets
927 // -----------------------------------------------------------------------------------------------------------------
928 delete_bk_option( 'widget_bookingwidget' );
929 delete_bk_option( 'widget_bookingsearchwidget' );
930 delete_bk_option( 'widget_bookingselectwidget' );
931 delete_bk_option( 'booking_activation_redirect_for_version' );
932
933
934 // -----------------------------------------------------------------------------------------------------------------
935 // DB Tables
936 // -----------------------------------------------------------------------------------------------------------------
937 global $wpdb;
938 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.SchemaChange
939 $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}booking" );
940 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.SchemaChange
941 $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}bookingdates" );
942
943 // Delete all users booking windows states.
944 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared,
945 if ( false === $wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key LIKE '%booking_%'" ) ) {
946 debuge_error('Error during deleting user meta at DB',__FILE__,__LINE__);
947 die();
948 }
949
950 // Delete or Drafts and Pending from demo sites
951 if ( wpbc_is_this_demo() ) { // Delete all temp posts at the demo sites: (post_status = pending || draft) && ( post_type = post ) && (post_author != 1)
952 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared,
953 $postss = $wpdb->get_results( "SELECT * FROM {$wpdb->posts} WHERE ( post_status = 'pending' OR post_status = 'draft' OR post_status = 'auto-draft' OR post_status = 'trash' OR post_status = 'inherit' ) AND ( post_type='post' OR post_type='revision') AND post_author != 1" );
954 foreach ( $postss as $pp ) {
955 wp_delete_post( $pp->ID, true );
956 }
957 }
958
959 ////////////////////////////////////////////////////////////////////////////
960 // Other versions Deactivation
961 ////////////////////////////////////////////////////////////////////////////
962 make_bk_action( 'wpbc_other_versions_deactivation' );
963 }
964 add_bk_action( 'wpbc_deactivation', 'wpbc_booking_deactivate' );
965
966
967 /**
968 * Default Options
969 *
970 * Exmaple of getting options for deleting in MU:
971 *
972 * $option_name = '';
973 * $is_get_multiuser_general_options = true;
974 * $options_for_delete = wpbc_get_default_options( $option_name, $is_get_multiuser_general_options );
975 */
976 function wpbc_get_default_options( $option_name = '', $is_get_multiuser_general_options = false ) {
977
978 $is_demo = wpbc_is_this_demo();
979 $blg_title = str_replace( array( '"', "'" ), '', get_option( 'blogname' ) );
980
981 $default_options = array();
982
983 // If this option here, then system get this option from "Super Admin" options configuration for "Regular" users.
984 $mu_option4delete = array();
985
986 // FixIn: 9.6.3.5.
987 $default_options['booking_setup_wizard_page_steps_is_done'] = '';
988 $mu_option4delete[]='booking_setup_wizard_page_steps_is_done';
989
990 $default_options['booking_admin_cal_count'] = ($is_demo) ? '3' : '2';
991 $mu_option4delete[]='booking_admin_cal_count'; // $multiuser_general_option[] = implode( '', array_keys( array_slice( $default_options, -1 ) ) );
992 $default_options['booking_skin'] = '/css/skins/24_9__light_square_1.css';
993 $mu_option4delete[]='booking_skin';
994 // FixIn: 9.6.3.5.
995 $default_options['booking_listing_default_view_mode'] = 'vm_booking_listing'; // 'vm_calendar'; // FixIn: 9.6.3.5.
996 $mu_option4delete[]='booking_listing_default_view_mode';
997
998 $default_options['booking_view_days_num'] = ( ( ! class_exists( 'wpdev_bk_personal' ) ) ? '90' : '30' );
999 $mu_option4delete[]='booking_view_days_num';
1000 // FixIn: 8.9.4.3.
1001 $default_options['booking_calendar_overview__day_mode__days_number_show'] = ( ( ! class_exists( 'wpdev_bk_personal' ) ) ? '7' : '7' );
1002 $mu_option4delete[]='booking_calendar_overview__day_mode__days_number_show';
1003 $default_options['booking_timeline__month_mode__days_number_show'] = ( ( ! class_exists( 'wpdev_bk_personal' ) ) ? '7' : '7' );
1004 $mu_option4delete[]='booking_timeline__month_mode__days_number_show';
1005 // FixIn: 8.6.1.13.
1006 $default_options['booking_max_monthes_in_calendar'] = '2y';
1007 $mu_option4delete[]='booking_max_monthes_in_calendar';
1008 $default_options['booking_client_cal_count'] = '1';
1009 $mu_option4delete[]='booking_client_cal_count';
1010 $default_options['booking_start_day_weeek'] = '0';
1011 $mu_option4delete[]='booking_start_day_weeek';
1012 $default_options['booking_title_after_reservation'] = ( ! class_exists( 'wpdev_bk_biz_s' ) )
1013 ? __( 'Your booking is received. We will confirm it soon. Many thanks!', 'booking' )
1014 : __( 'Your booking is received. Please proceed with payment to confirm it. Many thanks!', 'booking' );
1015 $mu_option4delete[]='booking_title_after_reservation';
1016 // $default_options['booking_title_after_reservation_time'] = '7000';
1017 //$mu_option4delete[]='booking_title_after_reservation_time';
1018 $default_options['booking_type_of_thank_you_message'] = 'message';
1019 $mu_option4delete[]='booking_type_of_thank_you_message';
1020 $default_options['booking_thank_you_page_URL'] = '/thank-you';
1021 $mu_option4delete[]='booking_thank_you_page_URL';
1022 $default_options['booking_is_use_autofill_4_logged_user'] = ($is_demo) ? 'On' : 'Off';
1023 $mu_option4delete[]='booking_is_use_autofill_4_logged_user';
1024 $default_options['booking_date_format'] = get_option( 'date_format' );
1025 $mu_option4delete[]='booking_date_format';
1026 $default_options['booking_time_format'] = get_option( 'time_format' ); //'H:i';
1027 $mu_option4delete[]='booking_time_format';
1028
1029 //FixIn:10.2.0.1 ------------------------------------------------------------------------------------------------
1030 // Confirmation section:
1031 $default_options['booking_confirmation_header_enabled'] = 'On';
1032 /* translators: 1: ... */
1033 $default_options['booking_confirmation_header'] = sprintf( __( 'Your booking id: %s', 'booking' ), '<strong>[booking_id]</strong>' );
1034 $mu_option4delete[] = 'booking_confirmation_header_enabled';
1035 $mu_option4delete[] = 'booking_confirmation_header';
1036
1037 $default_options['booking_confirmation__personal_info__header_enabled'] = 'On';
1038 $default_options['booking_confirmation__personal_info__title'] = __( 'Personal information', 'booking' );
1039 $default_options['booking_confirmation__personal_info__content'] = '[content]';
1040 $mu_option4delete[] = 'booking_confirmation__personal_info__header_enabled';
1041 $mu_option4delete[] = 'booking_confirmation__personal_info__title';
1042 $mu_option4delete[] = 'booking_confirmation__personal_info__content';
1043
1044 $default_options['booking_confirmation__booking_details__header_enabled'] = 'On';
1045 $default_options['booking_confirmation__booking_details__title'] = __( 'Booking details', 'booking' );
1046 $default_options['booking_confirmation__booking_details__content'] = ( class_exists( 'wpdev_bk_personal' ) )
1047 ? "<h4>[resource_title]</h4>[readable_dates][readable_times]\n[add_to_google_cal_button]"
1048 : "[readable_dates][readable_times]\n[add_to_google_cal_button]";
1049
1050 $mu_option4delete[] = 'booking_confirmation__booking_details__header_enabled';
1051 $mu_option4delete[] = 'booking_confirmation__booking_details__title';
1052 $mu_option4delete[] = 'booking_confirmation__booking_details__content';
1053 //FixIn:10.2.0.1 End --------------------------------------------------------------------------------------------
1054
1055 $default_options['booking_date_view_type'] = 'short';
1056 $mu_option4delete[]='booking_date_view_type';
1057 $default_options['booking_is_delete_if_deactive'] = ($is_demo) ? 'On' : 'Off';
1058 $mu_option4delete[]='booking_is_delete_if_deactive';
1059 $default_options['booking_dif_colors_approval_pending'] = 'On'; // Depricated
1060 $default_options['booking_is_use_hints_at_admin_panel'] = 'On';
1061 $mu_option4delete[]='booking_is_use_hints_at_admin_panel';
1062 $default_options['booking_is_load_js_css_on_specific_pages'] = 'Off';
1063 $mu_option4delete[]='booking_is_nonce_at_front_end'; // FixIn: 10.1.1.2.
1064 $default_options['booking_is_nonce_at_front_end'] = 'Off';
1065 // FixIn: 9.8.6.2.
1066 $mu_option4delete[]='booking_load_balancer_max_threads';
1067 $default_options['booking_load_balancer_max_threads'] = ( $is_demo ) ? '1' : '3';
1068
1069
1070 //FixIn: 7.2.1.15
1071 $mu_option4delete[]='booking_is_show_system_debug_log';
1072 $default_options['booking_is_show_system_debug_log'] = 'Off';
1073
1074
1075 $mu_option4delete[]='booking_is_load_js_css_on_specific_pages';
1076 $default_options['booking_pages_for_load_js_css'] = '';
1077 $mu_option4delete[]='booking_pages_for_load_js_css';
1078 $default_options['booking_type_of_day_selections'] = ( ( get_bk_option( 'booking_range_selection_is_active' ) == 'On' ) && ( ! $is_demo ) ) ? 'range' : 'multiple';
1079 $mu_option4delete[]='booking_type_of_day_selections';
1080
1081 // FixIn: 8.7.11.10.
1082 $default_options['booking_timeslot_picker'] = 'On';
1083 $mu_option4delete[]= 'booking_timeslot_picker';
1084 $default_options['booking_timeslot_picker_skin'] = '/css/time_picker_skins/light__24_8.css';
1085 $mu_option4delete[]= 'booking_timeslot_picker_skin';
1086
1087 $default_options['booking_timeslot_day_bg_as_available'] = 'Off'; //( ( class_exists( 'wpdev_bk_personal' ) ) ? 'Off' : 'On' ); // FixIn: 8.2.1.27.
1088 $mu_option4delete[]='booking_timeslot_day_bg_as_available';
1089
1090
1091 $default_options['booking_disable_timeslots_in_tooltip'] = 'Off'; //FixIn: 9.5.0.2.2
1092 $mu_option4delete[]='booking_disable_timeslots_in_tooltip';
1093
1094 $default_options['booking_highlight_timeslot_word'] = __( 'Booked Times:', 'booking' ); // FixIn: 9.4.3.1.
1095 $mu_option4delete[]='booking_highlight_timeslot_word';
1096
1097 $default_options['booking_form_is_using_bs_css'] = 'Off';
1098 $mu_option4delete[]='booking_form_is_using_bs_css';
1099 $default_options['booking_form_format_type'] = 'vertical';
1100 $mu_option4delete[]='booking_form_format_type';
1101
1102 // Does not exist in MU
1103 $default_options['booking_form_field_active1'] = 'On';
1104 $default_options['booking_form_field_required1'] = 'On';
1105 $default_options['booking_form_field_label1'] = 'First Name';
1106 $default_options['booking_form_field_active2'] = 'On';
1107 $default_options['booking_form_field_required2'] = 'On';
1108 $default_options['booking_form_field_label2'] = 'Last Name';
1109 $default_options['booking_form_field_active3'] = 'On';
1110 $default_options['booking_form_field_required3'] = 'On';
1111 $default_options['booking_form_field_label3'] = 'Email';
1112 $default_options['booking_form_field_active4'] = 'On';
1113 $default_options['booking_form_field_required4'] = 'Off';
1114 $default_options['booking_form_field_label4'] = 'Phone';
1115 $default_options['booking_form_field_active5'] = 'On';
1116 $default_options['booking_form_field_required5'] = 'Off';
1117 $default_options['booking_form_field_label5'] = 'Details';
1118 $default_options['booking_form_field_active6'] = 'Off';
1119 $default_options['booking_form_field_required6'] = 'Off';
1120 $default_options['booking_form_field_label6'] = 'Visitors';
1121 $default_options['booking_form_field_values6'] = "1\n2\n3\n4";
1122
1123
1124 $default_options['booking_is_days_always_available'] = 'Off';
1125 $mu_option4delete[]='booking_is_days_always_available';
1126
1127 // FixIn: 8.3.2.2.
1128 $default_options['booking_is_show_pending_days_as_available'] = 'Off';
1129 $mu_option4delete[]='booking_is_show_pending_days_as_available';
1130
1131 $default_options['booking_unavailable_days_num_from_today'] = '0';
1132 $mu_option4delete[]='booking_unavailable_days_num_from_today';
1133 $default_options['booking_unavailable_day0'] = 'Off';
1134 $mu_option4delete[]='booking_unavailable_day0';
1135 $default_options['booking_unavailable_day1'] = 'Off';
1136 $mu_option4delete[]='booking_unavailable_day1';
1137 $default_options['booking_unavailable_day2'] = 'Off';
1138 $mu_option4delete[]='booking_unavailable_day2';
1139 $default_options['booking_unavailable_day3'] = 'Off';
1140 $mu_option4delete[]='booking_unavailable_day3';
1141 $default_options['booking_unavailable_day4'] = 'Off';
1142 $mu_option4delete[]='booking_unavailable_day4';
1143 $default_options['booking_unavailable_day5'] = 'Off';
1144 $mu_option4delete[]='booking_unavailable_day5';
1145 $default_options['booking_unavailable_day6'] = 'Off';
1146 $mu_option4delete[]='booking_unavailable_day6';
1147 $default_options['booking_menu_position'] = ( $is_demo ) ? 'top' : 'top';
1148 $mu_option4delete[]='booking_menu_position';
1149 $default_options['booking_translation_load_from'] = 'wp.org';
1150 $mu_option4delete[]='booking_translation_load_from';
1151 $default_options['booking_user_role_booking'] = ( $is_demo ) ? 'subscriber' : 'editor';
1152 $mu_option4delete[]='booking_user_role_booking';
1153 $default_options['booking_user_role_availability'] = ( $is_demo ) ? 'subscriber' : 'editor'; // FixIn: 9.5.2.2.
1154 $mu_option4delete[]='booking_user_role_availability';
1155 $default_options['booking_user_role_addbooking'] = ( $is_demo ) ? 'subscriber' : 'editor';
1156 $mu_option4delete[]='booking_user_role_addbooking';
1157 $default_options['booking_user_role_resources'] = ( $is_demo ) ? 'subscriber' : 'editor';
1158 $mu_option4delete[]='booking_user_role_resources';
1159 $default_options['booking_user_role_settings'] = ( $is_demo ) ? 'subscriber' : 'administrator';
1160 $mu_option4delete[]='booking_user_role_settings';
1161 //FixIn: 9.8.15.2.6
1162 if ( class_exists( 'wpdev_bk_biz_m' ) ) {
1163 $default_options['booking_user_role_prices'] = ( $is_demo ) ? 'subscriber' : 'editor';
1164 $mu_option4delete[]='booking_user_role_prices';
1165 }
1166
1167 // New admin ///////////////////////////////////////////////////////////////
1168
1169 $default_options['booking_is_email_reservation_adress'] = 'On';
1170 $default_options['booking_email_reservation_adress'] = htmlspecialchars( '"Booking system" <' . get_option( 'admin_email' ) . '>' );
1171 $default_options['booking_email_reservation_from_adress'] = '[visitoremail]';
1172 $default_options['booking_email_reservation_subject'] = __( 'New booking', 'booking' );
1173 /* translators: 1: ... */
1174 $default_options['booking_email_reservation_content'] = htmlspecialchars( sprintf( __( 'You need to approve a new booking %1$s for: %2$s Person detail information:%3$s Currently a new booking is waiting for approval. Please visit the moderation panel%4$sThank you, %5$s', 'booking' ), '[bookingtype]', '[dates]<br/><br/>', '<br/> [content]<br/><br/>', ' [moderatelink]<br/><br/>', $blg_title . '<br/>[siteurl]' ) );
1175
1176 // New Visitor /////////////////////////////////////////////////////////////
1177
1178 $default_options['booking_is_email_newbookingbyperson_adress'] = 'Off';
1179 $default_options['booking_email_newbookingbyperson_adress'] = htmlspecialchars( '"Booking system" <' . get_option( 'admin_email' ) . '>' );
1180 $default_options['booking_email_newbookingbyperson_subject'] = __( 'New booking', 'booking' );
1181 if ( class_exists( 'wpdev_bk_personal' ) )
1182 /* translators: 1: ... */
1183 $default_options['booking_email_newbookingbyperson_content'] = htmlspecialchars( sprintf( __( 'Your reservation %1$s for: %2$s is processing now! We will send confirmation by email. %3$sYou can edit this booking at this page: %4$s Thank you, %5$s', 'booking' ), '[bookingtype]', '[dates]', '<br/><br/>[content]<br/><br/>', '[visitorbookingediturl]<br/><br/>', $blg_title . '<br/>[siteurl]' ) );
1184 else
1185 /* translators: 1: ... */
1186 $default_options['booking_email_newbookingbyperson_content'] = htmlspecialchars( sprintf( __( 'Your reservation %1$s for: %2$s is processing now! We will send confirmation by email. %3$s Thank you, %4$s', 'booking' ), '[bookingtype]', '[dates]', '<br/><br/>[content]<br/><br/>', $blg_title . '<br/>[siteurl]' ) );
1187
1188 // Approval ////////////////////////////////////////////////////////////////
1189
1190 $default_options['booking_is_email_approval_adress'] = 'On';
1191 $default_options['booking_is_email_approval_send_copy_to_admin'] = 'Off';
1192 $default_options['booking_email_approval_adress'] = htmlspecialchars( '"Booking system" <' . get_option( 'admin_email' ) . '>' );
1193 $default_options['booking_email_approval_subject'] = __( 'Your booking has been approved', 'booking' );
1194 if ( class_exists( 'wpdev_bk_personal' ) ) {
1195 /* translators: 1: ... */
1196 $default_options['booking_email_approval_content'] = htmlspecialchars( sprintf( __( 'Your reservation %1$s for: %2$s has been approved.%3$sYou can edit the booking on this page: %4$s Thank you, %5$s', 'booking' ), '[bookingtype]', '[dates]', '<br/><br/>[content]<br/><br/>', '[visitorbookingediturl]<br/><br/>', $blg_title . '<br/>[siteurl]' ) );
1197 } else {
1198 /* translators: 1: ... */
1199 $default_options['booking_email_approval_content'] = htmlspecialchars( sprintf( __( 'Your booking %1$s for: %2$s has been approved.%3$sThank you, %4$s', 'booking' ), '[bookingtype]', '[dates]', '<br/><br/>[content]<br/><br/>', $blg_title . '<br/>[siteurl]' ) );
1200 }
1201
1202 // Decline /////////////////////////////////////////////////////////////////
1203
1204 $default_options['booking_is_email_deny_adress'] = 'On';
1205 $default_options['booking_is_email_deny_send_copy_to_admin'] = 'Off';
1206 $default_options['booking_email_deny_adress'] = htmlspecialchars( '"Booking system" <' . get_option( 'admin_email' ) . '>' );
1207 $default_options['booking_email_deny_subject'] = __( 'Your booking has been declined', 'booking' );
1208 /* translators: 1: ... */
1209 $default_options['booking_email_deny_content'] = htmlspecialchars( sprintf( __( 'Your booking %1$s for: %2$s has been canceled. %3$sThank you, %4$s', 'booking' ), '[bookingtype]', '[dates]', '<br/>[denyreason]<br/><br/>[content]<br/><br/>', $blg_title . '<br/>[siteurl]' ) );
1210
1211 // -----------------------------------------------------------------------------------------------------------------
1212 $default_options['booking_widget_title'] = __( 'Booking form', 'booking' );
1213 $default_options['booking_widget_show'] = 'booking_form';
1214 $default_options['booking_widget_type'] = '1';
1215 $default_options['booking_widget_calendar_count'] = '1';
1216 $default_options['booking_widget_last_field'] = '';
1217
1218 $default_options['booking_wpdev_copyright_adminpanel'] = 'On';
1219 $mu_option4delete[]='booking_wpdev_copyright_adminpanel';
1220 $default_options['booking_is_show_powered_by_notice'] = 'On';
1221 $mu_option4delete[]='booking_is_show_powered_by_notice';
1222 $default_options['booking_form_theme'] = '';
1223 $mu_option4delete[]='booking_form_theme';
1224 $default_options['booking_is_use_captcha'] = 'Off';
1225 $mu_option4delete[]='booking_is_use_captcha';
1226 $default_options['booking_is_show_legend'] = 'On';
1227 $mu_option4delete[]='booking_is_show_legend';
1228 $default_options['booking_send_button_title'] = __( 'Send', 'booking' ); // FixIn: 8.8.1.14.
1229 $mu_option4delete[]='booking_send_button_title';
1230 $default_options['booking_legend_is_show_item_available'] = 'On';
1231 $mu_option4delete[]='booking_legend_is_show_item_available';
1232 $default_options['booking_legend_text_for_item_available'] = __( 'Available', 'booking' );
1233 $mu_option4delete[]='booking_legend_text_for_item_available';
1234 $default_options['booking_legend_is_show_item_pending'] = 'On';
1235 $mu_option4delete[]='booking_legend_is_show_item_pending';
1236 $default_options['booking_legend_text_for_item_pending'] = __( 'Pending', 'booking' );
1237 $mu_option4delete[]='booking_legend_text_for_item_pending';
1238 $default_options['booking_legend_is_show_item_approved'] = 'On';
1239 $mu_option4delete[]='booking_legend_is_show_item_approved';
1240 $default_options['booking_legend_text_for_item_approved'] = __( 'Booked', 'booking' );
1241 $mu_option4delete[]='booking_legend_text_for_item_approved';
1242 // FixIn: 9.9.0.5.
1243 $default_options['booking_legend_is_show_item_unavailable'] = 'Off';
1244 $mu_option4delete[]='booking_legend_is_show_item_unavailable';
1245 $default_options['booking_legend_text_for_item_unavailable'] = __( 'Unavailable', 'booking' );
1246 $mu_option4delete[]='booking_legend_text_for_item_unavailable';
1247
1248 // FixIn: 10.1.5.5.
1249 $default_options['booking_legend_is_show_item_partially'] = ( ( class_exists( 'wpdev_bk_personal' ) ) && ( ! class_exists( 'wpdev_bk_biz_s' ) ) ) ? 'Off' : 'On';
1250 $mu_option4delete[]='booking_legend_is_show_item_partially';
1251 $default_options['booking_legend_text_for_item_partially'] = __( 'Partially booked', 'booking' );
1252 $mu_option4delete[]='booking_legend_text_for_item_partially';
1253
1254 $default_options['booking_legend_is_show_numbers'] = 'On'; //FixIn:6.0.1.4 // FixIn: 8.1.3.8.
1255 $mu_option4delete[]='booking_legend_is_show_numbers';
1256 $default_options['booking_legend_is_vertical'] = 'Off'; // FixIn: 9.4.3.6.
1257 $mu_option4delete[]='booking_legend_is_vertical';
1258
1259 /*
1260 Import previous (old version) Email templates
1261 or get defult values from Email Classes, if the emails was not saved
1262 if the emails was saved, in this case - return empty array(), Useful for the Email Settings page to loading data from DB, during activation Mail API class.
1263 So if we get empty array for values, in this case, we need to get this optiosn from DB.
1264 */
1265 // Get NEW Email Templates default data or Import previous saved
1266 $emails_init = wpbc_import6_email__new_admin__get_fields_array_for_activation();
1267 $emails_init = array_merge( $emails_init, wpbc_import6_email__new_visitor__get_fields_array_for_activation() );
1268 $emails_init = array_merge( $emails_init, wpbc_import6_email__approved__get_fields_array_for_activation() );
1269 $emails_init = array_merge( $emails_init, wpbc_import6_email__deleted__get_fields_array_for_activation() );
1270 $emails_init = array_merge( $emails_init, wpbc_import6_email__deny__get_fields_array_for_activation() );
1271 $emails_init = array_merge( $emails_init, wpbc_import6_email__trash__get_fields_array_for_activation() );
1272 if ( class_exists( 'wpdev_bk_personal' ) )
1273 $emails_init = array_merge( $emails_init, wpbc_import6_email__modification__get_fields_array_for_activation() );
1274 if ( class_exists( 'wpdev_bk_biz_s' ) )
1275 $emails_init = array_merge( $emails_init, wpbc_import6_email__payment_request__get_fields_array_for_activation() );
1276 foreach ( $emails_init as $email_key_name => $email_values ) {
1277
1278 if ( ! empty( $email_values ) ) $default_options[ $email_key_name ] = $email_values;
1279 else $default_options[ $email_key_name ] = get_bk_option( $email_key_name );
1280 }
1281
1282
1283 $mu_option4delete[]='booking_gcal_auto_import_is_active'; // Creation in wpbc-gcal.php file
1284 $mu_option4delete[]='booking_gcal_auto_import_time';
1285 $mu_option4delete[]='booking_cron'; // Creation in wpbc-cron.php
1286
1287 // FixIn: 8.0.1.6.
1288 //$default_options['booking_form_structure_type'] = 'vertical';
1289 $default_options['booking_form_structure_type'] = 'form_right'; // FixIn: 10.3.0.6.
1290 $default_options['booking_menu_go_pro'] = 'show'; // show | hide
1291
1292 $default_options['booking_form_layout_width'] = '440';
1293 $default_options['booking_form_layout_width_px_pr'] = 'px';
1294 $default_options['booking_form_layout_max_cols'] = 1;
1295
1296 // -----------------------------------------------------------------------------------------------------------------
1297 // PS
1298 // -----------------------------------------------------------------------------------------------------------------
1299 if ( class_exists( 'wpdev_bk_personal' ) ) {
1300
1301 $default_options['booking_is_use_simple_booking_form'] = 'Off'; // FixIn: 8.1.1.12.
1302 $mu_option4delete[]='booking_is_use_simple_booking_form';
1303
1304 $default_options['booking_is_use_codehighlighter_booking_form'] = 'On'; // FixIn: 8.4.7.18.
1305 $mu_option4delete[]='booking_is_use_codehighlighter_booking_form';
1306
1307 $default_options['booking_form'] = str_replace( '\\n\\', '', wpbc_get_default_booking_form() );
1308 $default_options['booking_form_show'] = str_replace( '\\n\\', '', wpbc_get_default_booking_form_show() );
1309
1310 $default_options['booking_url_bookings_edit_by_visitors'] = site_url();
1311 $mu_option4delete[]='booking_url_bookings_edit_by_visitors';
1312
1313 $default_options['booking_url_bookings_listing_by_customer'] = site_url(); //FixIn: 8.1.3.5.1
1314 $mu_option4delete[]='booking_url_bookings_listing_by_customer';
1315
1316 $default_options['booking_default_booking_resource'] = ''; // All resources
1317 $mu_option4delete[]='booking_default_booking_resource';
1318 $default_options['booking_is_change_hash_after_approvement'] = 'On'; // FixIn: 10.10.1.1.
1319 $mu_option4delete[]='booking_is_change_hash_after_approvement';
1320 $default_options['booking_email_modification_adress'] = htmlspecialchars( '"Booking system" <' . get_option( 'admin_email' ) . '>' );
1321 $default_options['booking_email_modification_subject'] = __( 'The reservation has been modified', 'booking' );
1322 /* translators: 1: ... */
1323 $default_options['booking_email_modification_content'] = htmlspecialchars( sprintf( __( 'The reservation %1$s for: %2$s has been modified. %3$sYou can edit this booking on this page: %4$s Thank you, %5$s', 'booking' ), '[bookingtype]', '[dates]', '<br/><br/>[content]<br/><br/>', '[visitorbookingediturl]<br/><br/>', $blg_title . '<br/>[siteurl]' ) );
1324 $default_options['booking_is_email_modification_adress'] = 'On';
1325 $default_options['booking_is_email_modification_send_copy_to_admin'] = 'Off';
1326 $default_options['booking_resourses_num_per_page'] = '10';
1327 $mu_option4delete[]='booking_resourses_num_per_page';
1328 $default_options['booking_default_title_in_day_for_calendar_view_mode'] = '[id]: [name] [secondname]';
1329 $mu_option4delete[]='booking_default_title_in_day_for_calendar_view_mode';
1330
1331 // FixIn: 8.1.3.31.
1332 $default_options['booking_calendar_overview_start_time'] = '0';
1333 $mu_option4delete[]='booking_calendar_overview_start_time';
1334 $default_options['booking_calendar_overview_end_time'] = '24';
1335 $mu_option4delete[]='booking_calendar_overview_end_time';
1336
1337 $default_options['booking_default_title_in_day_for_timeline_front_end'] = '[name] [secondname]';
1338 $mu_option4delete[]='booking_default_title_in_day_for_timeline_front_end';
1339 $default_options['booking_is_show_popover_in_timeline_front_end'] = ($is_demo) ? 'On' : 'Off';
1340 $mu_option4delete[]='booking_is_show_popover_in_timeline_front_end';
1341 // FixIn: 9.6.3.5.
1342
1343 $default_options['booking_send_emails_off_addbooking'] = 'Off'; // FixIn: 8.4.5.4.
1344 $mu_option4delete[]='booking_send_emails_off_addbooking';
1345
1346 // FixIn: 9.6.3.5.
1347
1348 $default_options['booking_change_resource_skip_checking'] = 'Off'; // FixIn: 8.4.5.4.
1349 $mu_option4delete[]='booking_change_resource_skip_checking';
1350
1351 $default_options['booking_log_booking_actions'] = 'On'; // FixIn: 8.6.1.10.
1352 $mu_option4delete[]='booking_log_booking_actions';
1353
1354
1355 }
1356
1357 // FixIn: 8.5.1.1.
1358 // $default_options['booking_ics_force_import'] = 'Off'; // FixIn: 8.4.7.1.
1359 $default_options['booking_ics_force_trash_before_import'] = 'Off'; // FixIn: 8.4.7.12.
1360 //$mu_option4delete[]='booking_ics_force_trash_before_import'; // No need to delete ^
1361 $default_options['booking_ics_import_append_checkout_day'] = 'Off'; //FixIn: 9.6.2.7 // FixIn: 9.5.4.1.
1362 //$mu_option4delete[]='booking_ics_import_append_checkout_day'; // No need to delete ^
1363
1364 // FixIn: 9.8.15.8.
1365 $default_options['booking_condition_import_only_new'] = ( get_bk_option( 'booking_ics_force_import' ) === 'On' ) ? 'Off' : 'On';
1366 $default_options['booking_condition_import_if_available'] = 'Off';
1367
1368 // FixIn: 10.1.5.4.
1369 $default_options['booking_recurrent_time'] = ( class_exists( 'wpdev_bk_personal' ) ) ? 'Off' : 'On';
1370 $mu_option4delete[]='booking_recurrent_time';
1371
1372 $default_options['booking_calendar_allow_several_months_on_mobile'] = 'Off';
1373 $mu_option4delete[]='booking_calendar_allow_several_months_on_mobile';
1374
1375 // -----------------------------------------------------------------------------------------------------------------
1376 // BS
1377 // -----------------------------------------------------------------------------------------------------------------
1378 if ( class_exists( 'wpdev_bk_biz_s' ) ) {
1379
1380 //$mu_option4delete[]='booking_paypal_price_period'; // No need to delete, this option, because different users can have different settings. During init defined at ../booking/inc/gateways/page-gateways.php
1381
1382 $default_options['booking_gateways_order'] = 'stripe_v3,paypal_std_co,paypal,authorizenet,sage,redsys,bank_transfer,pay_cash,ipay88,ideal'; // Default Original Payment Gateways
1383 //$mu_option4delete[]='booking_gateways_order'; // No need to delete ^
1384
1385 // FixIn: 8.1.3.29.
1386 $default_options['booking_ics_import_add_change_over_time'] = 'On';
1387 //$mu_option4delete[]='booking_ics_import_add_change_over_time'; // No need to delete ^
1388
1389 // FixIn: 8.5.2.3.
1390 $default_options['booking_is_ics_export_only_approved'] = 'Off';
1391 //$mu_option4delete[]='booking_is_ics_export_only_approved'; // No need to delete ^
1392 $default_options['booking_is_ics_export_imported_bookings'] = ''; // FixIn: 8.8.3.19.
1393
1394
1395 $default_options['booking_auto_approve_new_bookings_is_active'] = 'Off';
1396 $mu_option4delete[]='booking_auto_approve_new_bookings_is_active';
1397
1398 // FixIn: 8.1.3.27.
1399 $default_options['booking_auto_approve_bookings_when_import'] = 'Off';
1400 $mu_option4delete[]='booking_auto_approve_bookings_when_import';
1401 $default_options['booking_auto_approve_bookings_when_zero_cost'] = 'Off';
1402 $mu_option4delete[]='booking_auto_approve_bookings_when_zero_cost';
1403 $default_options['booking_auto_approve_bookings_if_added_in_admin_panel'] = 'Off';
1404 $mu_option4delete[]='booking_auto_approve_bookings_if_added_in_admin_panel';
1405
1406 $default_options['booking_auto_cancel_pending_unpaid_bk_is_active'] = 'Off';
1407 $mu_option4delete[]='booking_auto_cancel_pending_unpaid_bk_is_active';
1408 $default_options['booking_auto_cancel_pending_unpaid_bk_time'] = '24';
1409 $mu_option4delete[]='booking_auto_cancel_pending_unpaid_bk_time';
1410 $default_options['booking_auto_cancel_pending_unpaid_bk_is_send_email'] = 'On';
1411 $mu_option4delete[]='booking_auto_cancel_pending_unpaid_bk_is_send_email';
1412 $default_options['booking_auto_cancel_pending_unpaid_bk_email_reason'] = __( 'This booking canceled because we did not receive payment and the administrator did not approve it.', 'booking' );
1413 $mu_option4delete[]='booking_auto_cancel_pending_unpaid_bk_email_reason';
1414 $default_options['booking_range_selection_type'] = 'fixed';
1415 $mu_option4delete[]='booking_range_selection_type';
1416 $default_options['booking_range_selection_days_count'] = '3';
1417 $mu_option4delete[]='booking_range_selection_days_count';
1418 $default_options['booking_range_selection_days_max_count_dynamic'] = 30;
1419 $mu_option4delete[]='booking_range_selection_days_max_count_dynamic';
1420 $default_options['booking_range_selection_days_specific_num_dynamic'] = '';
1421 $mu_option4delete[]='booking_range_selection_days_specific_num_dynamic';
1422 $default_options['booking_range_start_day'] = '-1';
1423 $mu_option4delete[]='booking_range_start_day';
1424 $default_options['booking_range_selection_days_count_dynamic'] = '1';
1425 $mu_option4delete[]='booking_range_selection_days_count_dynamic';
1426 $default_options['booking_range_start_day_dynamic'] = '-1';
1427 $mu_option4delete[]='booking_range_start_day_dynamic';
1428 $default_options['booking_range_selection_time_is_active'] = 'Off';
1429 $mu_option4delete[]='booking_range_selection_time_is_active';
1430 $default_options['booking_range_selection_start_time'] = '12:00';
1431 $mu_option4delete[]='booking_range_selection_start_time';
1432 $default_options['booking_range_selection_end_time'] = '10:00';
1433 $mu_option4delete[]='booking_range_selection_end_time';
1434 $default_options['booking_change_over_days_triangles'] = 'On'; // FixIn: 7.0.1.24.
1435
1436 $mu_option4delete[]='booking_last_checkout_day_available';
1437 $default_options['booking_last_checkout_day_available'] = 'Off'; // FixIn: 8.1.3.28.
1438
1439 $mu_option4delete[]='booking_change_over_days_triangles';
1440
1441 $mu_option4delete[]='booking_change_over__is_excerpt_on_pages';
1442 $default_options['booking_change_over__is_excerpt_on_pages'] = 'Off'; // FixIn: 8.9.4.10.
1443 $mu_option4delete[]='booking_change_over__excerpt_on_pages';
1444 $default_options['booking_change_over__excerpt_on_pages'] = ''; // FixIn: 8.9.4.10.
1445
1446
1447 $default_options['booking_email_payment_request_adress'] = htmlspecialchars( '"Booking system" <' . get_option( 'admin_email' ) . '>' );
1448 $default_options['booking_email_payment_request_subject'] = __( 'You need to make payment for this reservation', 'booking' );
1449 /* translators: 1: ... */
1450 $default_options['booking_email_payment_request_content'] = htmlspecialchars( sprintf( __( 'You need to make payment %1$s for reservation %2$s at %3$s. %4$s Please make payment on this page: %5$s Thank you, %6$s', 'booking' ), '[cost]', '[bookingtype]', '[dates]', '<br/><br/>[paymentreason]<br/><br/>[content]<br/><br/>', '[visitorbookingpayurl]<br/><br/>', $blg_title . '<br/>[siteurl]' ) );
1451 $default_options['booking_is_email_payment_request_adress'] = 'On';
1452 $default_options['booking_is_email_payment_request_send_copy_to_admin'] = 'Off';
1453 }
1454
1455
1456 // -----------------------------------------------------------------------------------------------------------------
1457 // BM
1458 // -----------------------------------------------------------------------------------------------------------------
1459 if ( class_exists( 'wpdev_bk_biz_m' ) ) {
1460
1461 // FixIn: 8.1.3.15.
1462 $default_options['booking_is_show_booked_data_in_tooltips'] = 'Off';
1463 $mu_option4delete[]='booking_is_show_booked_data_in_tooltips';
1464 $default_options['booking_booked_data_in_tooltips'] = '[name] [secondname]';
1465 $mu_option4delete[]='booking_booked_data_in_tooltips';
1466
1467 $default_options['booking_number_for_pre_checkin_date_hint'] = '14'; // FixIn: 10.0.0.31.
1468 $mu_option4delete[]='booking_number_for_pre_checkin_date_hint';
1469 $default_options['booking_available_days_num_from_today'] = '';
1470 $mu_option4delete[]='booking_available_days_num_from_today';
1471 $default_options['booking_unavailable_extra_in_out'] = '';
1472 $mu_option4delete[]='booking_unavailable_extra_in_out';
1473 $default_options['booking_unavailable_extra_minutes_in'] = '';
1474 $mu_option4delete[]='booking_unavailable_extra_minutes_in';
1475 $default_options['booking_unavailable_extra_minutes_out'] = '';
1476 $mu_option4delete[]='booking_unavailable_extra_minutes_out';
1477 $default_options['booking_unavailable_extra_days_in'] = '';
1478 $mu_option4delete[]='booking_unavailable_extra_days_in';
1479 $default_options['booking_unavailable_extra_days_out'] = '';
1480 $mu_option4delete[]='booking_unavailable_extra_days_out';
1481
1482 $default_options['booking_forms_extended'] = serialize( array() );
1483 $default_options['booking_advanced_costs_values'] = serialize( array() );
1484 $default_options['booking_is_resource_deposit_payment_active'] = 'On';
1485 $mu_option4delete[]='booking_is_resource_deposit_payment_active';
1486 $default_options['booking_advanced_costs_calc_fixed_cost_with_procents'] = 'Off';
1487 $default_options['booking_is_show_cost_in_tooltips'] = 'Off';
1488 $mu_option4delete[]='booking_is_show_cost_in_tooltips';
1489 $default_options['booking_highlight_cost_word'] = __( 'Cost: ', 'booking' );
1490 $mu_option4delete[]='booking_highlight_cost_word';
1491 $default_options['booking_is_show_cost_in_date_cell'] = 'Off';
1492 $mu_option4delete[]='booking_is_show_cost_in_date_cell';
1493 $default_options['booking_cost_in_date_cell_currency'] = '&#36;';
1494 $mu_option4delete[]='booking_cost_in_date_cell_currency';
1495 $default_options['booking_visitor_number_rate'] = '0'; //Depricated
1496 $default_options['booking_visitor_number_rate_type'] = '%'; //Depricated
1497 }
1498
1499
1500 // -----------------------------------------------------------------------------------------------------------------
1501 // BL
1502 // -----------------------------------------------------------------------------------------------------------------
1503 if ( class_exists( 'wpdev_bk_biz_l' ) ) {
1504
1505 // Get Key of Last added item to "$default_options" array
1506 // $multiuser_general_option[] = implode( '', array_keys( array_slice( $default_options, -1 ) ) );
1507
1508 $default_options['booking_check_out_available_for_parents'] = 'On';
1509 $mu_option4delete[]='booking_check_out_available_for_parents';
1510 $default_options['booking_check_in_available_for_parents'] = 'Off';
1511 $mu_option4delete[]='booking_check_in_available_for_parents';
1512 $default_options['booking_is_show_pending_days_as_available'] = 'Off';
1513 $mu_option4delete[]='booking_is_show_pending_days_as_available';
1514 $default_options['booking_auto_cancel_pending_bookings_for_approved_date'] = 'Off';
1515 $mu_option4delete[]='booking_auto_cancel_pending_bookings_for_approved_date';
1516
1517 $default_options['booking_quantity_control'] = ( get_bk_option( 'booking_is_use_visitors_number_for_availability') == 'On' ) ? 'On' : 'Off';
1518 $mu_option4delete[]='booking_quantity_control';
1519 $default_options['booking_capacity_field'] = ( get_bk_option( 'booking_is_use_visitors_number_for_availability') == 'On' ) ? 'select^visitors' : '';
1520 $mu_option4delete[]='booking_capacity_field';
1521
1522 $default_options['booking_is_show_availability_in_tooltips'] = 'On'; // FixIn: 8.1.3.8.
1523 $mu_option4delete[]='booking_is_show_availability_in_tooltips';
1524 $default_options['booking_highlight_availability_word'] = __( 'Available: ', 'booking' );
1525 $mu_option4delete[]='booking_highlight_availability_word';
1526
1527 $default_options['booking_is_show_availability_in_date_cell'] = 'Off'; // FixIn: 10.6.4.1.
1528 $mu_option4delete[]='booking_is_show_availability_in_date_cell';
1529 $default_options['booking_highlight_availability_word_in_date_cell'] = __( 'available', 'booking' );
1530 $mu_option4delete[]='booking_highlight_availability_word_in_date_cell';
1531
1532
1533 $default_options['booking_is_dissbale_booking_for_different_sub_resources'] = 'Off';
1534 $mu_option4delete[]='booking_is_dissbale_booking_for_different_sub_resources';
1535 // FixIn: 10.10.1.2 $default_options['booking_is_resource_no_update__during_editing'] = 'On'; // FixIn: 9.4.2.3.
1536 // FixIn: 10.10.1.2 $mu_option4delete[]='booking_is_resource_no_update__during_editing';
1537 $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.
1538 $mu_option4delete[]='booking_search_form_show';
1539 $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.
1540 $mu_option4delete[]='booking_found_search_item';
1541 $default_options['booking_cache_expiration'] = '2d';
1542 $mu_option4delete[]='booking_cache_expiration';
1543 $default_options['booking_search_results_order'] = 'prioritet'; // FixIn: 8.4.7.8.
1544 $mu_option4delete[]='booking_search_results_order';
1545 $default_options['booking_search_form_dates_format'] = 'yy-mm-dd'; // FixIn: 8.6.1.21.
1546 $mu_option4delete[]='booking_search_form_dates_format';
1547 $default_options['booking_search_results_days_select'] = 'Off'; // FixIn: 8.8.2.3.
1548 $mu_option4delete[]='booking_search_results_days_select';
1549 $default_options['booking_from_search_scroll_to_calendar'] = 'On'; // FixIn: 9.4.4.6.
1550 $mu_option4delete[]='booking_from_search_scroll_to_calendar';
1551
1552 $default_options['booking_search_from_auto_open_checkout_cal'] = 'On'; // FixIn: 10.0.0.39.
1553 $mu_option4delete[]='booking_search_from_auto_open_checkout_cal';
1554 $default_options['booking_search_from__search_header'] = '[result_count] ' . __('Result(s) Found','booking'); // FixIn: 10.0.0.41.
1555 $mu_option4delete[]='booking_search_from__search_header';
1556 $default_options['booking_search_from__search_header_advanced'] = __( 'Extended Search Results', 'booking' ); // FixIn: 10.0.0.41.
1557 $mu_option4delete[]='booking_search_from__search_header_advanced';
1558 $default_options['booking_search_from__search_nothing_found'] = __('Nothing Found','booking');
1559 $mu_option4delete[]='booking_search_from__search_nothing_found';
1560
1561 $default_options['booking_search_form__dates_required_enabled'] = 'Off';
1562 $mu_option4delete[]='booking_search_form__dates_required_enabled';
1563 $default_options['booking_search_form__dates_required_warning'] = __('Please select check-in and check-out dates to perform the search.','booking');
1564 $mu_option4delete[]='booking_search_form__dates_required_warning';
1565
1566
1567 // Updated during regeneration seacrh cache
1568 //$default_options['booking_cache_content']='';
1569 $mu_option4delete[]='booking_cache_content';
1570 //$default_options['booking_cache_created']=wpbc_datetime_localized( date ('Y-m-d H:i:s'), 'Y-m-d H:i:s' );
1571 $mu_option4delete[]='booking_cache_created';
1572 $mu_option4delete[]='booking_resources_search_options'; // FixIn: 10.0.0.18.
1573 }
1574
1575
1576 // -----------------------------------------------------------------------------------------------------------------
1577 // MU
1578 // -----------------------------------------------------------------------------------------------------------------
1579 if ( class_exists( 'wpdev_bk_multiuser' ) ) {
1580
1581 // FixIn: 8.1.3.19.
1582 $default_options['booking_is_custom_forms_for_regular_users'] = 'Off';
1583 $mu_option4delete[]='booking_is_custom_forms_for_regular_users';
1584
1585 // FixIn: 9.2.3.8.
1586 $default_options['booking_super_admin_receive_regular_user_payments'] = 'Off';
1587 $mu_option4delete[]='booking_super_admin_receive_regular_user_payments';
1588 }
1589
1590
1591 if ( ! $is_get_multiuser_general_options ) {
1592
1593 if ( ! empty( $option_name ) ) {
1594
1595 if (isset( $default_options[ $option_name ] ))
1596 return $default_options[ $option_name ]; // Return 1 option
1597 else
1598 return false; // Option does NOT exist
1599
1600 } else {
1601 return $default_options; // Return ALL
1602 }
1603
1604 } else
1605 return $mu_option4delete; // Get options for MU
1606 }
1607
1608
1609 // <editor-fold defaultstate="collapsed" desc=" Update Deprecated Options " >
1610 function wpbc_after_activation__update_deprecated_options() {
1611 update_bk_option( 'booking_form_is_using_bs_css', 'Off' );
1612 }
1613 add_bk_action( 'wpbc_after_activation', 'wpbc_after_activation__update_deprecated_options' );
1614 // </editor-fold>
1615