PluginProbe
Booking Calendar / 10.10
Booking Calendar v10.10
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.10, at core/wpbc-activation.php

1,620 lines 98.2 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 // 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 (
791 booking_dates_id bigint(20) unsigned NOT NULL auto_increment,
792 booking_id bigint(20) unsigned NOT NULL,
793 booking_date datetime NOT NULL default '0000-00-00 00:00:00',
794 approved bigint(20) unsigned NOT NULL default 0,
795 PRIMARY KEY (booking_dates_id)
796 ) {$charset_collate}";
797
798 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
799 $wpdb->query( $simple_sql );
800
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 }
806
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
832 $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 }
841
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 }
855
856 // FixIn: 9.2.3.3.
857 if ( wpbc_is_field_in_table_exists( 'booking', 'hash' ) == 0 ) { //HASH_EDIT
858
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 );
862
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";
865
866 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
867 $res = $wpdb->get_results( $sql_check_table );
868
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 }
873 }
874 }
875 make_bk_action( 'wpbc_activation_after_db_actions' ); // FixIn: 9.3.1.2.
876
877 // -----------------------------------------------------------------------------------------------------------------
878 // Other versions Activation
879 // -----------------------------------------------------------------------------------------------------------------
880 make_bk_action( 'wpbc_other_versions_activation' );
881
882
883 // -----------------------------------------------------------------------------------------------------------------
884 // Examples in demos
885 // -----------------------------------------------------------------------------------------------------------------
886 if ( $is_demo ) { wpbc_create_examples_4_demo(); }
887
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();
904
905 // -----------------------------------------------------------------------------------------------------------------
906 wpbc_reindex_booking_db();
907
908 make_bk_action( 'wpbc_after_activation' );
909 }
910 add_bk_action( 'wpbc_activation', 'wpbc_booking_activate' );
911
912
913
914 // Deactivate
915 function wpbc_booking_deactivate() {
916
917 // -----------------------------------------------------------------------------------------------------------------
918 // Options
919 // -----------------------------------------------------------------------------------------------------------------
920 $default_options_to_add = wpbc_get_default_options();
921 foreach ( $default_options_to_add as $default_option_name => $default_option_value) {
922
923 delete_bk_option( $default_option_name );
924 }
925
926
927 // -----------------------------------------------------------------------------------------------------------------
928 // Widgets
929 // -----------------------------------------------------------------------------------------------------------------
930 delete_bk_option( 'widget_bookingwidget' );
931 delete_bk_option( 'widget_bookingsearchwidget' );
932 delete_bk_option( 'widget_bookingselectwidget' );
933 delete_bk_option( 'booking_activation_redirect_for_version' );
934
935
936 // -----------------------------------------------------------------------------------------------------------------
937 // DB Tables
938 // -----------------------------------------------------------------------------------------------------------------
939 global $wpdb;
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}booking" );
942 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.SchemaChange
943 $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}bookingdates" );
944
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_%'" ) ) {
948 debuge_error('Error during deleting user meta at DB',__FILE__,__LINE__);
949 die();
950 }
951
952 // Delete or Drafts and Pending from demo sites
953 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,
955 $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 foreach ( $postss as $pp ) {
957 wp_delete_post( $pp->ID, true );
958 }
959 }
960
961 ////////////////////////////////////////////////////////////////////////////
962 // Other versions Deactivation
963 ////////////////////////////////////////////////////////////////////////////
964 make_bk_action( 'wpbc_other_versions_deactivation' );
965 }
966 add_bk_action( 'wpbc_deactivation', 'wpbc_booking_deactivate' );
967
968
969 /**
970 * Default Options
971 *
972 * Exmaple of getting options for deleting in MU:
973 *
974 * $option_name = '';
975 * $is_get_multiuser_general_options = true;
976 * $options_for_delete = wpbc_get_default_options( $option_name, $is_get_multiuser_general_options );
977 */
978 function wpbc_get_default_options( $option_name = '', $is_get_multiuser_general_options = false ) {
979
980 $is_demo = wpbc_is_this_demo();
981 $blg_title = str_replace( array( '"', "'" ), '', get_option( 'blogname' ) );
982
983 $default_options = array();
984
985 // If this option here, then system get this option from "Super Admin" options configuration for "Regular" users.
986 $mu_option4delete = array();
987
988 // FixIn: 9.6.3.5.
989 $default_options['booking_setup_wizard_page_steps_is_done'] = '';
990 $mu_option4delete[]='booking_setup_wizard_page_steps_is_done';
991
992 $default_options['booking_admin_cal_count'] = ($is_demo) ? '3' : '2';
993 $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';
995 $mu_option4delete[]='booking_skin';
996 // FixIn: 9.6.3.5.
997 $default_options['booking_listing_default_view_mode'] = 'vm_booking_listing'; // 'vm_calendar'; // FixIn: 9.6.3.5.
998 $mu_option4delete[]='booking_listing_default_view_mode';
999
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 $default_options['booking_view_days_num'] = ( ( ! class_exists( 'wpdev_bk_personal' ) ) ? '90' : '30' );
1004 $mu_option4delete[]='booking_view_days_num';
1005 // FixIn: 8.9.4.3.
1006 $default_options['booking_calendar_overview__day_mode__days_number_show'] = ( ( ! class_exists( 'wpdev_bk_personal' ) ) ? '7' : '7' );
1007 $mu_option4delete[]='booking_calendar_overview__day_mode__days_number_show';
1008 $default_options['booking_timeline__month_mode__days_number_show'] = ( ( ! class_exists( 'wpdev_bk_personal' ) ) ? '7' : '7' );
1009 $mu_option4delete[]='booking_timeline__month_mode__days_number_show';
1010 // FixIn: 8.6.1.13.
1011 $default_options['booking_max_monthes_in_calendar'] = '2y';
1012 $mu_option4delete[]='booking_max_monthes_in_calendar';
1013 $default_options['booking_client_cal_count'] = '1';
1014 $mu_option4delete[]='booking_client_cal_count';
1015 $default_options['booking_start_day_weeek'] = '0';
1016 $mu_option4delete[]='booking_start_day_weeek';
1017 $default_options['booking_title_after_reservation'] = ( ! class_exists( 'wpdev_bk_biz_s' ) )
1018 ? __( 'Your booking is received. We will confirm it soon. Many thanks!', 'booking' )
1019 : __( 'Your booking is received. Please proceed with payment to confirm it. Many thanks!', 'booking' );
1020 $mu_option4delete[]='booking_title_after_reservation';
1021 // $default_options['booking_title_after_reservation_time'] = '7000';
1022 //$mu_option4delete[]='booking_title_after_reservation_time';
1023 $default_options['booking_type_of_thank_you_message'] = 'message';
1024 $mu_option4delete[]='booking_type_of_thank_you_message';
1025 $default_options['booking_thank_you_page_URL'] = '/thank-you';
1026 $mu_option4delete[]='booking_thank_you_page_URL';
1027 $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' );
1030 $mu_option4delete[]='booking_date_format';
1031 $default_options['booking_time_format'] = get_option( 'time_format' ); //'H:i';
1032 $mu_option4delete[]='booking_time_format';
1033
1034 //FixIn:10.2.0.1 ------------------------------------------------------------------------------------------------
1035 // Confirmation section:
1036 $default_options['booking_confirmation_header_enabled'] = 'On';
1037 /* translators: 1: ... */
1038 $default_options['booking_confirmation_header'] = sprintf( __( 'Your booking id: %s', 'booking' ), '<strong>[booking_id]</strong>' );
1039 $mu_option4delete[] = 'booking_confirmation_header_enabled';
1040 $mu_option4delete[] = 'booking_confirmation_header';
1041
1042 $default_options['booking_confirmation__personal_info__header_enabled'] = 'On';
1043 $default_options['booking_confirmation__personal_info__title'] = __( 'Personal information', 'booking' );
1044 $default_options['booking_confirmation__personal_info__content'] = '[content]';
1045 $mu_option4delete[] = 'booking_confirmation__personal_info__header_enabled';
1046 $mu_option4delete[] = 'booking_confirmation__personal_info__title';
1047 $mu_option4delete[] = 'booking_confirmation__personal_info__content';
1048
1049 $default_options['booking_confirmation__booking_details__header_enabled'] = 'On';
1050 $default_options['booking_confirmation__booking_details__title'] = __( 'Booking details', 'booking' );
1051 $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]"
1053 : "[readable_dates][readable_times]\n[add_to_google_cal_button]";
1054
1055 $mu_option4delete[] = 'booking_confirmation__booking_details__header_enabled';
1056 $mu_option4delete[] = 'booking_confirmation__booking_details__title';
1057 $mu_option4delete[] = 'booking_confirmation__booking_details__content';
1058 //FixIn:10.2.0.1 End --------------------------------------------------------------------------------------------
1059
1060 $default_options['booking_date_view_type'] = 'short';
1061 $mu_option4delete[]='booking_date_view_type';
1062 $default_options['booking_is_delete_if_deactive'] = ($is_demo) ? 'On' : 'Off';
1063 $mu_option4delete[]='booking_is_delete_if_deactive';
1064 $default_options['booking_dif_colors_approval_pending'] = 'On'; // Depricated
1065 $default_options['booking_is_use_hints_at_admin_panel'] = 'On';
1066 $mu_option4delete[]='booking_is_use_hints_at_admin_panel';
1067 $default_options['booking_is_load_js_css_on_specific_pages'] = 'Off';
1068 $mu_option4delete[]='booking_is_nonce_at_front_end'; // FixIn: 10.1.1.2.
1069 $default_options['booking_is_nonce_at_front_end'] = 'Off';
1070 // FixIn: 9.8.6.2.
1071 $mu_option4delete[]='booking_load_balancer_max_threads';
1072 $default_options['booking_load_balancer_max_threads'] = ( $is_demo ) ? '1' : '3';
1073
1074
1075 //FixIn: 7.2.1.15
1076 $mu_option4delete[]='booking_is_show_system_debug_log';
1077 $default_options['booking_is_show_system_debug_log'] = 'Off';
1078
1079
1080 $mu_option4delete[]='booking_is_load_js_css_on_specific_pages';
1081 $default_options['booking_pages_for_load_js_css'] = '';
1082 $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';
1084 $mu_option4delete[]='booking_type_of_day_selections';
1085
1086 // FixIn: 8.7.11.10.
1087 $default_options['booking_timeslot_picker'] = 'On';
1088 $mu_option4delete[]= 'booking_timeslot_picker';
1089 $default_options['booking_timeslot_picker_skin'] = '/css/time_picker_skins/light__24_8.css';
1090 $mu_option4delete[]= 'booking_timeslot_picker_skin';
1091
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 $default_options['booking_disable_timeslots_in_tooltip'] = 'Off'; //FixIn: 9.5.0.2.2
1097 $mu_option4delete[]='booking_disable_timeslots_in_tooltip';
1098
1099 $default_options['booking_highlight_timeslot_word'] = __( 'Booked Times:', 'booking' ); // FixIn: 9.4.3.1.
1100 $mu_option4delete[]='booking_highlight_timeslot_word';
1101
1102 $default_options['booking_form_is_using_bs_css'] = 'Off';
1103 $mu_option4delete[]='booking_form_is_using_bs_css';
1104 $default_options['booking_form_format_type'] = 'vertical';
1105 $mu_option4delete[]='booking_form_format_type';
1106
1107 // Does not exist in MU
1108 $default_options['booking_form_field_active1'] = 'On';
1109 $default_options['booking_form_field_required1'] = 'On';
1110 $default_options['booking_form_field_label1'] = 'First Name';
1111 $default_options['booking_form_field_active2'] = 'On';
1112 $default_options['booking_form_field_required2'] = 'On';
1113 $default_options['booking_form_field_label2'] = 'Last Name';
1114 $default_options['booking_form_field_active3'] = 'On';
1115 $default_options['booking_form_field_required3'] = 'On';
1116 $default_options['booking_form_field_label3'] = 'Email';
1117 $default_options['booking_form_field_active4'] = 'On';
1118 $default_options['booking_form_field_required4'] = 'Off';
1119 $default_options['booking_form_field_label4'] = 'Phone';
1120 $default_options['booking_form_field_active5'] = 'On';
1121 $default_options['booking_form_field_required5'] = 'Off';
1122 $default_options['booking_form_field_label5'] = 'Details';
1123 $default_options['booking_form_field_active6'] = 'Off';
1124 $default_options['booking_form_field_required6'] = 'Off';
1125 $default_options['booking_form_field_label6'] = 'Visitors';
1126 $default_options['booking_form_field_values6'] = "1\n2\n3\n4";
1127
1128
1129 $default_options['booking_is_days_always_available'] = 'Off';
1130 $mu_option4delete[]='booking_is_days_always_available';
1131
1132 // FixIn: 8.3.2.2.
1133 $default_options['booking_is_show_pending_days_as_available'] = 'Off';
1134 $mu_option4delete[]='booking_is_show_pending_days_as_available';
1135
1136 $default_options['booking_unavailable_days_num_from_today'] = '0';
1137 $mu_option4delete[]='booking_unavailable_days_num_from_today';
1138 $default_options['booking_unavailable_day0'] = 'Off';
1139 $mu_option4delete[]='booking_unavailable_day0';
1140 $default_options['booking_unavailable_day1'] = 'Off';
1141 $mu_option4delete[]='booking_unavailable_day1';
1142 $default_options['booking_unavailable_day2'] = 'Off';
1143 $mu_option4delete[]='booking_unavailable_day2';
1144 $default_options['booking_unavailable_day3'] = 'Off';
1145 $mu_option4delete[]='booking_unavailable_day3';
1146 $default_options['booking_unavailable_day4'] = 'Off';
1147 $mu_option4delete[]='booking_unavailable_day4';
1148 $default_options['booking_unavailable_day5'] = 'Off';
1149 $mu_option4delete[]='booking_unavailable_day5';
1150 $default_options['booking_unavailable_day6'] = 'Off';
1151 $mu_option4delete[]='booking_unavailable_day6';
1152 $default_options['booking_menu_position'] = ( $is_demo ) ? 'top' : 'top';
1153 $mu_option4delete[]='booking_menu_position';
1154 $default_options['booking_translation_load_from'] = 'wp.org';
1155 $mu_option4delete[]='booking_translation_load_from';
1156 $default_options['booking_user_role_booking'] = ( $is_demo ) ? 'subscriber' : 'editor';
1157 $mu_option4delete[]='booking_user_role_booking';
1158 $default_options['booking_user_role_availability'] = ( $is_demo ) ? 'subscriber' : 'editor'; // FixIn: 9.5.2.2.
1159 $mu_option4delete[]='booking_user_role_availability';
1160 $default_options['booking_user_role_addbooking'] = ( $is_demo ) ? 'subscriber' : 'editor';
1161 $mu_option4delete[]='booking_user_role_addbooking';
1162 $default_options['booking_user_role_resources'] = ( $is_demo ) ? 'subscriber' : 'editor';
1163 $mu_option4delete[]='booking_user_role_resources';
1164 $default_options['booking_user_role_settings'] = ( $is_demo ) ? 'subscriber' : 'administrator';
1165 $mu_option4delete[]='booking_user_role_settings';
1166 //FixIn: 9.8.15.2.6
1167 if ( class_exists( 'wpdev_bk_biz_m' ) ) {
1168 $default_options['booking_user_role_prices'] = ( $is_demo ) ? 'subscriber' : 'editor';
1169 $mu_option4delete[]='booking_user_role_prices';
1170 }
1171
1172 // New admin ///////////////////////////////////////////////////////////////
1173
1174 $default_options['booking_is_email_reservation_adress'] = 'On';
1175 $default_options['booking_email_reservation_adress'] = htmlspecialchars( '"Booking system" <' . get_option( 'admin_email' ) . '>' );
1176 $default_options['booking_email_reservation_from_adress'] = '[visitoremail]';
1177 $default_options['booking_email_reservation_subject'] = __( 'New booking', 'booking' );
1178 /* translators: 1: ... */
1179 $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]' ) );
1180
1181 // New Visitor /////////////////////////////////////////////////////////////
1182
1183 $default_options['booking_is_email_newbookingbyperson_adress'] = 'Off';
1184 $default_options['booking_email_newbookingbyperson_adress'] = htmlspecialchars( '"Booking system" <' . get_option( 'admin_email' ) . '>' );
1185 $default_options['booking_email_newbookingbyperson_subject'] = __( 'New booking', 'booking' );
1186 if ( class_exists( 'wpdev_bk_personal' ) )
1187 /* translators: 1: ... */
1188 $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]' ) );
1189 else
1190 /* translators: 1: ... */
1191 $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]' ) );
1192
1193 // Approval ////////////////////////////////////////////////////////////////
1194
1195 $default_options['booking_is_email_approval_adress'] = 'On';
1196 $default_options['booking_is_email_approval_send_copy_to_admin'] = 'Off';
1197 $default_options['booking_email_approval_adress'] = htmlspecialchars( '"Booking system" <' . get_option( 'admin_email' ) . '>' );
1198 $default_options['booking_email_approval_subject'] = __( 'Your booking has been approved', 'booking' );
1199 if ( class_exists( 'wpdev_bk_personal' ) ) {
1200 /* translators: 1: ... */
1201 $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]' ) );
1202 } else {
1203 /* translators: 1: ... */
1204 $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]' ) );
1205 }
1206
1207 // Decline /////////////////////////////////////////////////////////////////
1208
1209 $default_options['booking_is_email_deny_adress'] = 'On';
1210 $default_options['booking_is_email_deny_send_copy_to_admin'] = 'Off';
1211 $default_options['booking_email_deny_adress'] = htmlspecialchars( '"Booking system" <' . get_option( 'admin_email' ) . '>' );
1212 $default_options['booking_email_deny_subject'] = __( 'Your booking has been declined', 'booking' );
1213 /* translators: 1: ... */
1214 $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]' ) );
1215
1216 // -----------------------------------------------------------------------------------------------------------------
1217 $default_options['booking_widget_title'] = __( 'Booking form', 'booking' );
1218 $default_options['booking_widget_show'] = 'booking_form';
1219 $default_options['booking_widget_type'] = '1';
1220 $default_options['booking_widget_calendar_count'] = '1';
1221 $default_options['booking_widget_last_field'] = '';
1222
1223 $default_options['booking_wpdev_copyright_adminpanel'] = 'On';
1224 $mu_option4delete[]='booking_wpdev_copyright_adminpanel';
1225 $default_options['booking_is_show_powered_by_notice'] = 'On';
1226 $mu_option4delete[]='booking_is_show_powered_by_notice';
1227 $default_options['booking_form_theme'] = '';
1228 $mu_option4delete[]='booking_form_theme';
1229 $default_options['booking_is_use_captcha'] = 'Off';
1230 $mu_option4delete[]='booking_is_use_captcha';
1231 $default_options['booking_is_show_legend'] = 'On';
1232 $mu_option4delete[]='booking_is_show_legend';
1233 $default_options['booking_send_button_title'] = __( 'Send', 'booking' ); // FixIn: 8.8.1.14.
1234 $mu_option4delete[]='booking_send_button_title';
1235 $default_options['booking_legend_is_show_item_available'] = 'On';
1236 $mu_option4delete[]='booking_legend_is_show_item_available';
1237 $default_options['booking_legend_text_for_item_available'] = __( 'Available', 'booking' );
1238 $mu_option4delete[]='booking_legend_text_for_item_available';
1239 $default_options['booking_legend_is_show_item_pending'] = 'On';
1240 $mu_option4delete[]='booking_legend_is_show_item_pending';
1241 $default_options['booking_legend_text_for_item_pending'] = __( 'Pending', 'booking' );
1242 $mu_option4delete[]='booking_legend_text_for_item_pending';
1243 $default_options['booking_legend_is_show_item_approved'] = 'On';
1244 $mu_option4delete[]='booking_legend_is_show_item_approved';
1245 $default_options['booking_legend_text_for_item_approved'] = __( 'Booked', 'booking' );
1246 $mu_option4delete[]='booking_legend_text_for_item_approved';
1247 // FixIn: 9.9.0.5.
1248 $default_options['booking_legend_is_show_item_unavailable'] = 'Off';
1249 $mu_option4delete[]='booking_legend_is_show_item_unavailable';
1250 $default_options['booking_legend_text_for_item_unavailable'] = __( 'Unavailable', 'booking' );
1251 $mu_option4delete[]='booking_legend_text_for_item_unavailable';
1252
1253 // FixIn: 10.1.5.5.
1254 $default_options['booking_legend_is_show_item_partially'] = ( ( class_exists( 'wpdev_bk_personal' ) ) && ( ! class_exists( 'wpdev_bk_biz_s' ) ) ) ? 'Off' : 'On';
1255 $mu_option4delete[]='booking_legend_is_show_item_partially';
1256 $default_options['booking_legend_text_for_item_partially'] = __( 'Partially booked', 'booking' );
1257 $mu_option4delete[]='booking_legend_text_for_item_partially';
1258
1259 $default_options['booking_legend_is_show_numbers'] = 'On'; //FixIn:6.0.1.4 // FixIn: 8.1.3.8.
1260 $mu_option4delete[]='booking_legend_is_show_numbers';
1261 $default_options['booking_legend_is_vertical'] = 'Off'; // FixIn: 9.4.3.6.
1262 $mu_option4delete[]='booking_legend_is_vertical';
1263
1264 /*
1265 Import previous (old version) Email templates
1266 or get defult values from Email Classes, if the emails was not saved
1267 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.
1268 So if we get empty array for values, in this case, we need to get this optiosn from DB.
1269 */
1270 // Get NEW Email Templates default data or Import previous saved
1271 $emails_init = wpbc_import6_email__new_admin__get_fields_array_for_activation();
1272 $emails_init = array_merge( $emails_init, wpbc_import6_email__new_visitor__get_fields_array_for_activation() );
1273 $emails_init = array_merge( $emails_init, wpbc_import6_email__approved__get_fields_array_for_activation() );
1274 $emails_init = array_merge( $emails_init, wpbc_import6_email__deleted__get_fields_array_for_activation() );
1275 $emails_init = array_merge( $emails_init, wpbc_import6_email__deny__get_fields_array_for_activation() );
1276 $emails_init = array_merge( $emails_init, wpbc_import6_email__trash__get_fields_array_for_activation() );
1277 if ( class_exists( 'wpdev_bk_personal' ) )
1278 $emails_init = array_merge( $emails_init, wpbc_import6_email__modification__get_fields_array_for_activation() );
1279 if ( class_exists( 'wpdev_bk_biz_s' ) )
1280 $emails_init = array_merge( $emails_init, wpbc_import6_email__payment_request__get_fields_array_for_activation() );
1281 foreach ( $emails_init as $email_key_name => $email_values ) {
1282
1283 if ( ! empty( $email_values ) ) $default_options[ $email_key_name ] = $email_values;
1284 else $default_options[ $email_key_name ] = get_bk_option( $email_key_name );
1285 }
1286
1287
1288 $mu_option4delete[]='booking_gcal_auto_import_is_active'; // Creation in wpbc-gcal.php file
1289 $mu_option4delete[]='booking_gcal_auto_import_time';
1290 $mu_option4delete[]='booking_cron'; // Creation in wpbc-cron.php
1291
1292 // FixIn: 8.0.1.6.
1293 //$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
1296
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;
1300
1301 // -----------------------------------------------------------------------------------------------------------------
1302 // PS
1303 // -----------------------------------------------------------------------------------------------------------------
1304 if ( class_exists( 'wpdev_bk_personal' ) ) {
1305
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
1309 $default_options['booking_is_use_codehighlighter_booking_form'] = 'On'; // FixIn: 8.4.7.18.
1310 $mu_option4delete[]='booking_is_use_codehighlighter_booking_form';
1311
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 $default_options['booking_url_bookings_edit_by_visitors'] = site_url();
1316 $mu_option4delete[]='booking_url_bookings_edit_by_visitors';
1317
1318 $default_options['booking_url_bookings_listing_by_customer'] = site_url(); //FixIn: 8.1.3.5.1
1319 $mu_option4delete[]='booking_url_bookings_listing_by_customer';
1320
1321 $default_options['booking_default_booking_resource'] = ''; // All resources
1322 $mu_option4delete[]='booking_default_booking_resource';
1323 $default_options['booking_is_change_hash_after_approvement'] = 'Off';
1324 $mu_option4delete[]='booking_is_change_hash_after_approvement';
1325 $default_options['booking_email_modification_adress'] = htmlspecialchars( '"Booking system" <' . get_option( 'admin_email' ) . '>' );
1326 $default_options['booking_email_modification_subject'] = __( 'The reservation has been modified', 'booking' );
1327 /* translators: 1: ... */
1328 $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]' ) );
1329 $default_options['booking_is_email_modification_adress'] = 'On';
1330 $default_options['booking_is_email_modification_send_copy_to_admin'] = 'Off';
1331 $default_options['booking_resourses_num_per_page'] = '10';
1332 $mu_option4delete[]='booking_resourses_num_per_page';
1333 $default_options['booking_default_title_in_day_for_calendar_view_mode'] = '[id]: [name] [secondname]';
1334 $mu_option4delete[]='booking_default_title_in_day_for_calendar_view_mode';
1335
1336 // FixIn: 8.1.3.31.
1337 $default_options['booking_calendar_overview_start_time'] = '0';
1338 $mu_option4delete[]='booking_calendar_overview_start_time';
1339 $default_options['booking_calendar_overview_end_time'] = '24';
1340 $mu_option4delete[]='booking_calendar_overview_end_time';
1341
1342 $default_options['booking_default_title_in_day_for_timeline_front_end'] = '[name] [secondname]';
1343 $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';
1345 $mu_option4delete[]='booking_is_show_popover_in_timeline_front_end';
1346 // FixIn: 9.6.3.5.
1347
1348 $default_options['booking_send_emails_off_addbooking'] = 'Off'; // FixIn: 8.4.5.4.
1349 $mu_option4delete[]='booking_send_emails_off_addbooking';
1350
1351 // FixIn: 9.6.3.5.
1352
1353 $default_options['booking_change_resource_skip_checking'] = 'Off'; // FixIn: 8.4.5.4.
1354 $mu_option4delete[]='booking_change_resource_skip_checking';
1355
1356 $default_options['booking_log_booking_actions'] = 'On'; // FixIn: 8.6.1.10.
1357 $mu_option4delete[]='booking_log_booking_actions';
1358
1359
1360 }
1361
1362 // FixIn: 8.5.1.1.
1363 // $default_options['booking_ics_force_import'] = 'Off'; // FixIn: 8.4.7.1.
1364 $default_options['booking_ics_force_trash_before_import'] = 'Off'; // FixIn: 8.4.7.12.
1365 //$mu_option4delete[]='booking_ics_force_trash_before_import'; // No need to delete ^
1366 $default_options['booking_ics_import_append_checkout_day'] = 'Off'; //FixIn: 9.6.2.7 // FixIn: 9.5.4.1.
1367 //$mu_option4delete[]='booking_ics_import_append_checkout_day'; // No need to delete ^
1368
1369 // FixIn: 9.8.15.8.
1370 $default_options['booking_condition_import_only_new'] = ( get_bk_option( 'booking_ics_force_import' ) === 'On' ) ? 'Off' : 'On';
1371 $default_options['booking_condition_import_if_available'] = 'Off';
1372
1373 // FixIn: 10.1.5.4.
1374 $default_options['booking_recurrent_time'] = ( class_exists( 'wpdev_bk_personal' ) ) ? 'Off' : 'On';
1375 $mu_option4delete[]='booking_recurrent_time';
1376
1377 $default_options['booking_calendar_allow_several_months_on_mobile'] = 'Off';
1378 $mu_option4delete[]='booking_calendar_allow_several_months_on_mobile';
1379
1380 // -----------------------------------------------------------------------------------------------------------------
1381 // BS
1382 // -----------------------------------------------------------------------------------------------------------------
1383 if ( class_exists( 'wpdev_bk_biz_s' ) ) {
1384
1385 //$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
1386
1387 $default_options['booking_gateways_order'] = 'stripe_v3,paypal_std_co,paypal,authorizenet,sage,redsys,bank_transfer,pay_cash,ipay88,ideal'; // Default Original Payment Gateways
1388 //$mu_option4delete[]='booking_gateways_order'; // No need to delete ^
1389
1390 // FixIn: 8.1.3.29.
1391 $default_options['booking_ics_import_add_change_over_time'] = 'On';
1392 //$mu_option4delete[]='booking_ics_import_add_change_over_time'; // No need to delete ^
1393
1394 // FixIn: 8.5.2.3.
1395 $default_options['booking_is_ics_export_only_approved'] = 'Off';
1396 //$mu_option4delete[]='booking_is_ics_export_only_approved'; // No need to delete ^
1397 $default_options['booking_is_ics_export_imported_bookings'] = ''; // FixIn: 8.8.3.19.
1398
1399
1400 $default_options['booking_auto_approve_new_bookings_is_active'] = 'Off';
1401 $mu_option4delete[]='booking_auto_approve_new_bookings_is_active';
1402
1403 // FixIn: 8.1.3.27.
1404 $default_options['booking_auto_approve_bookings_when_import'] = 'Off';
1405 $mu_option4delete[]='booking_auto_approve_bookings_when_import';
1406 $default_options['booking_auto_approve_bookings_when_zero_cost'] = 'Off';
1407 $mu_option4delete[]='booking_auto_approve_bookings_when_zero_cost';
1408 $default_options['booking_auto_approve_bookings_if_added_in_admin_panel'] = 'Off';
1409 $mu_option4delete[]='booking_auto_approve_bookings_if_added_in_admin_panel';
1410
1411 $default_options['booking_auto_cancel_pending_unpaid_bk_is_active'] = 'Off';
1412 $mu_option4delete[]='booking_auto_cancel_pending_unpaid_bk_is_active';
1413 $default_options['booking_auto_cancel_pending_unpaid_bk_time'] = '24';
1414 $mu_option4delete[]='booking_auto_cancel_pending_unpaid_bk_time';
1415 $default_options['booking_auto_cancel_pending_unpaid_bk_is_send_email'] = 'On';
1416 $mu_option4delete[]='booking_auto_cancel_pending_unpaid_bk_is_send_email';
1417 $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 $mu_option4delete[]='booking_auto_cancel_pending_unpaid_bk_email_reason';
1419 $default_options['booking_range_selection_type'] = 'fixed';
1420 $mu_option4delete[]='booking_range_selection_type';
1421 $default_options['booking_range_selection_days_count'] = '3';
1422 $mu_option4delete[]='booking_range_selection_days_count';
1423 $default_options['booking_range_selection_days_max_count_dynamic'] = 30;
1424 $mu_option4delete[]='booking_range_selection_days_max_count_dynamic';
1425 $default_options['booking_range_selection_days_specific_num_dynamic'] = '';
1426 $mu_option4delete[]='booking_range_selection_days_specific_num_dynamic';
1427 $default_options['booking_range_start_day'] = '-1';
1428 $mu_option4delete[]='booking_range_start_day';
1429 $default_options['booking_range_selection_days_count_dynamic'] = '1';
1430 $mu_option4delete[]='booking_range_selection_days_count_dynamic';
1431 $default_options['booking_range_start_day_dynamic'] = '-1';
1432 $mu_option4delete[]='booking_range_start_day_dynamic';
1433 $default_options['booking_range_selection_time_is_active'] = 'Off';
1434 $mu_option4delete[]='booking_range_selection_time_is_active';
1435 $default_options['booking_range_selection_start_time'] = '12:00';
1436 $mu_option4delete[]='booking_range_selection_start_time';
1437 $default_options['booking_range_selection_end_time'] = '10:00';
1438 $mu_option4delete[]='booking_range_selection_end_time';
1439 $default_options['booking_change_over_days_triangles'] = 'On'; // FixIn: 7.0.1.24.
1440
1441 $mu_option4delete[]='booking_last_checkout_day_available';
1442 $default_options['booking_last_checkout_day_available'] = 'Off'; // FixIn: 8.1.3.28.
1443
1444 $mu_option4delete[]='booking_change_over_days_triangles';
1445
1446 $mu_option4delete[]='booking_change_over__is_excerpt_on_pages';
1447 $default_options['booking_change_over__is_excerpt_on_pages'] = 'Off'; // FixIn: 8.9.4.10.
1448 $mu_option4delete[]='booking_change_over__excerpt_on_pages';
1449 $default_options['booking_change_over__excerpt_on_pages'] = ''; // FixIn: 8.9.4.10.
1450
1451
1452 $default_options['booking_email_payment_request_adress'] = htmlspecialchars( '"Booking system" <' . get_option( 'admin_email' ) . '>' );
1453 $default_options['booking_email_payment_request_subject'] = __( 'You need to make payment for this reservation', 'booking' );
1454 /* translators: 1: ... */
1455 $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]' ) );
1456 $default_options['booking_is_email_payment_request_adress'] = 'On';
1457 $default_options['booking_is_email_payment_request_send_copy_to_admin'] = 'Off';
1458 }
1459
1460
1461 // -----------------------------------------------------------------------------------------------------------------
1462 // BM
1463 // -----------------------------------------------------------------------------------------------------------------
1464 if ( class_exists( 'wpdev_bk_biz_m' ) ) {
1465
1466 // FixIn: 8.1.3.15.
1467 $default_options['booking_is_show_booked_data_in_tooltips'] = 'Off';
1468 $mu_option4delete[]='booking_is_show_booked_data_in_tooltips';
1469 $default_options['booking_booked_data_in_tooltips'] = '[name] [secondname]';
1470 $mu_option4delete[]='booking_booked_data_in_tooltips';
1471
1472 $default_options['booking_number_for_pre_checkin_date_hint'] = '14'; // FixIn: 10.0.0.31.
1473 $mu_option4delete[]='booking_number_for_pre_checkin_date_hint';
1474 $default_options['booking_available_days_num_from_today'] = '';
1475 $mu_option4delete[]='booking_available_days_num_from_today';
1476 $default_options['booking_unavailable_extra_in_out'] = '';
1477 $mu_option4delete[]='booking_unavailable_extra_in_out';
1478 $default_options['booking_unavailable_extra_minutes_in'] = '';
1479 $mu_option4delete[]='booking_unavailable_extra_minutes_in';
1480 $default_options['booking_unavailable_extra_minutes_out'] = '';
1481 $mu_option4delete[]='booking_unavailable_extra_minutes_out';
1482 $default_options['booking_unavailable_extra_days_in'] = '';
1483 $mu_option4delete[]='booking_unavailable_extra_days_in';
1484 $default_options['booking_unavailable_extra_days_out'] = '';
1485 $mu_option4delete[]='booking_unavailable_extra_days_out';
1486
1487 $default_options['booking_forms_extended'] = serialize( array() );
1488 $default_options['booking_advanced_costs_values'] = serialize( array() );
1489 $default_options['booking_is_resource_deposit_payment_active'] = 'On';
1490 $mu_option4delete[]='booking_is_resource_deposit_payment_active';
1491 $default_options['booking_advanced_costs_calc_fixed_cost_with_procents'] = 'Off';
1492 $default_options['booking_is_show_cost_in_tooltips'] = 'Off';
1493 $mu_option4delete[]='booking_is_show_cost_in_tooltips';
1494 $default_options['booking_highlight_cost_word'] = __( 'Cost: ', 'booking' );
1495 $mu_option4delete[]='booking_highlight_cost_word';
1496 $default_options['booking_is_show_cost_in_date_cell'] = 'Off';
1497 $mu_option4delete[]='booking_is_show_cost_in_date_cell';
1498 $default_options['booking_cost_in_date_cell_currency'] = '&#36;';
1499 $mu_option4delete[]='booking_cost_in_date_cell_currency';
1500 $default_options['booking_visitor_number_rate'] = '0'; //Depricated
1501 $default_options['booking_visitor_number_rate_type'] = '%'; //Depricated
1502 }
1503
1504
1505 // -----------------------------------------------------------------------------------------------------------------
1506 // BL
1507 // -----------------------------------------------------------------------------------------------------------------
1508 if ( class_exists( 'wpdev_bk_biz_l' ) ) {
1509
1510 // Get Key of Last added item to "$default_options" array
1511 // $multiuser_general_option[] = implode( '', array_keys( array_slice( $default_options, -1 ) ) );
1512
1513 $default_options['booking_check_out_available_for_parents'] = 'On';
1514 $mu_option4delete[]='booking_check_out_available_for_parents';
1515 $default_options['booking_check_in_available_for_parents'] = 'Off';
1516 $mu_option4delete[]='booking_check_in_available_for_parents';
1517 $default_options['booking_is_show_pending_days_as_available'] = 'Off';
1518 $mu_option4delete[]='booking_is_show_pending_days_as_available';
1519 $default_options['booking_auto_cancel_pending_bookings_for_approved_date'] = 'Off';
1520 $mu_option4delete[]='booking_auto_cancel_pending_bookings_for_approved_date';
1521
1522 $default_options['booking_quantity_control'] = ( get_bk_option( 'booking_is_use_visitors_number_for_availability') == 'On' ) ? 'On' : 'Off';
1523 $mu_option4delete[]='booking_quantity_control';
1524 $default_options['booking_capacity_field'] = ( get_bk_option( 'booking_is_use_visitors_number_for_availability') == 'On' ) ? 'select^visitors' : '';
1525 $mu_option4delete[]='booking_capacity_field';
1526
1527 $default_options['booking_is_show_availability_in_tooltips'] = 'On'; // FixIn: 8.1.3.8.
1528 $mu_option4delete[]='booking_is_show_availability_in_tooltips';
1529 $default_options['booking_highlight_availability_word'] = __( 'Available: ', 'booking' );
1530 $mu_option4delete[]='booking_highlight_availability_word';
1531
1532 $default_options['booking_is_show_availability_in_date_cell'] = 'Off'; // FixIn: 10.6.4.1.
1533 $mu_option4delete[]='booking_is_show_availability_in_date_cell';
1534 $default_options['booking_highlight_availability_word_in_date_cell'] = __( 'available', 'booking' );
1535 $mu_option4delete[]='booking_highlight_availability_word_in_date_cell';
1536
1537
1538 $default_options['booking_is_dissbale_booking_for_different_sub_resources'] = 'Off';
1539 $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';
1542 $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 $mu_option4delete[]='booking_search_form_show';
1544 $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 $mu_option4delete[]='booking_found_search_item';
1546 $default_options['booking_cache_expiration'] = '2d';
1547 $mu_option4delete[]='booking_cache_expiration';
1548 $default_options['booking_search_results_order'] = 'prioritet'; // FixIn: 8.4.7.8.
1549 $mu_option4delete[]='booking_search_results_order';
1550 $default_options['booking_search_form_dates_format'] = 'yy-mm-dd'; // FixIn: 8.6.1.21.
1551 $mu_option4delete[]='booking_search_form_dates_format';
1552 $default_options['booking_search_results_days_select'] = 'Off'; // FixIn: 8.8.2.3.
1553 $mu_option4delete[]='booking_search_results_days_select';
1554 $default_options['booking_from_search_scroll_to_calendar'] = 'On'; // FixIn: 9.4.4.6.
1555 $mu_option4delete[]='booking_from_search_scroll_to_calendar';
1556
1557 $default_options['booking_search_from_auto_open_checkout_cal'] = 'On'; // FixIn: 10.0.0.39.
1558 $mu_option4delete[]='booking_search_from_auto_open_checkout_cal';
1559 $default_options['booking_search_from__search_header'] = '[result_count] ' . __('Result(s) Found','booking'); // FixIn: 10.0.0.41.
1560 $mu_option4delete[]='booking_search_from__search_header';
1561 $default_options['booking_search_from__search_header_advanced'] = __( 'Extended Search Results', 'booking' ); // FixIn: 10.0.0.41.
1562 $mu_option4delete[]='booking_search_from__search_header_advanced';
1563 $default_options['booking_search_from__search_nothing_found'] = __('Nothing Found','booking');
1564 $mu_option4delete[]='booking_search_from__search_nothing_found';
1565
1566 $default_options['booking_search_form__dates_required_enabled'] = 'Off';
1567 $mu_option4delete[]='booking_search_form__dates_required_enabled';
1568 $default_options['booking_search_form__dates_required_warning'] = __('Please select check-in and check-out dates to perform the search.','booking');
1569 $mu_option4delete[]='booking_search_form__dates_required_warning';
1570
1571
1572 // Updated during regeneration seacrh cache
1573 //$default_options['booking_cache_content']='';
1574 $mu_option4delete[]='booking_cache_content';
1575 //$default_options['booking_cache_created']=wpbc_datetime_localized( date ('Y-m-d H:i:s'), 'Y-m-d H:i:s' );
1576 $mu_option4delete[]='booking_cache_created';
1577 $mu_option4delete[]='booking_resources_search_options'; // FixIn: 10.0.0.18.
1578 }
1579
1580
1581 // -----------------------------------------------------------------------------------------------------------------
1582 // MU
1583 // -----------------------------------------------------------------------------------------------------------------
1584 if ( class_exists( 'wpdev_bk_multiuser' ) ) {
1585
1586 // FixIn: 8.1.3.19.
1587 $default_options['booking_is_custom_forms_for_regular_users'] = 'Off';
1588 $mu_option4delete[]='booking_is_custom_forms_for_regular_users';
1589
1590 // FixIn: 9.2.3.8.
1591 $default_options['booking_super_admin_receive_regular_user_payments'] = 'Off';
1592 $mu_option4delete[]='booking_super_admin_receive_regular_user_payments';
1593 }
1594
1595
1596 if ( ! $is_get_multiuser_general_options ) {
1597
1598 if ( ! empty( $option_name ) ) {
1599
1600 if (isset( $default_options[ $option_name ] ))
1601 return $default_options[ $option_name ]; // Return 1 option
1602 else
1603 return false; // Option does NOT exist
1604
1605 } else {
1606 return $default_options; // Return ALL
1607 }
1608
1609 } else
1610 return $mu_option4delete; // Get options for MU
1611 }
1612
1613
1614 // <editor-fold defaultstate="collapsed" desc=" Update Deprecated Options " >
1615 function wpbc_after_activation__update_deprecated_options() {
1616 update_bk_option( 'booking_form_is_using_bs_css', 'Off' );
1617 }
1618 add_bk_action( 'wpbc_after_activation', 'wpbc_after_activation__update_deprecated_options' );
1619 // </editor-fold>
1620