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

wpbc-create-pages.php in Booking Calendar 10.1.3, at includes/publish/wpbc-create-pages.php

622 lines 26.7 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 Create pages Functions
6 * @category Functions
7 *
8 * @author wpdevelop
9 * @link https://wpbookingcalendar.com/
10 * @email info@wpbookingcalendar.com
11 *
12 * @modified 2023-05-10
13 */
14
15 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
16
17
18 /**
19 * Create page for Booking Calendar
20 *
21 * @param array $page_params = array(
22 'post_content' => '[bookingedit]',
23 'post_name' => 'wpbc-booking-edit',
24 'post_title' => esc_html__('Booking edit','booking')
25 )
26 *
27 * @return false|int - ID of the page.
28 */
29 function wpbc_create_page( $page_params = array() ){ //FixIn: 9.6.2.10
30
31 global $wp_rewrite;
32 if ( is_null( $wp_rewrite ) ) { //FixIn: 9.7.1.1
33 return false;
34 }
35
36 // Create post object
37 $defaults = array(
38 //'menu_order' => 0, // The order the post should be displayed in. Default 0. If new post is a page, it sets the order in which it should appear in the tabs.
39 //'pinged' => '', // Space or carriage return-separated list of URLs that have been pinged. Default empty.
40 //'post_author' => get_current_user_id(), // The user ID number of the author. The ID of the user who added the post. Default is the current user ID.
41 //'post_category' => array(), // Array of category IDs. Defaults to value of the 'default_category' option. post_category no longer exists, try wp_set_post_terms() for setting a post's categories
42 //'post_date' => [ Y-m-d H:i:s ] // The date of the post. Default is the current time. The time post was made.
43 //'post_date_gmt' => [ Y-m-d H:i:s ] // The time post was made, in GMT.
44 //'post_excerpt' => '' //The post excerpt. Default empty. For all your post excerpt needs.
45 //'post_parent' => 0, // Set this for the post it belongs to, if any. Default 0. Sets the parent of the new post.
46 //'post_password' => '', //The password to access the post. Default empty. password for post?
47 //'tags_input' => '', // Array of tag names, slugs, or IDs. Default empty. [ '<tag>, <tag>, <...>' ] //For tags.
48 //'to_ping' => '', // Space or carriage return-separated list of URLs to ping. Default empty. Space or carriage return-separated list of URLs to ping. Default empty.
49 //'tax_input' => '', // Default empty. [ array( 'taxonomy_name' => array( 'term', 'term2', 'term3' ) ) ] // support for custom taxonomies.
50 'ID' => 0, // The post ID. If equal to something other than 0, the post with that ID will be updated. Default 0.
51 'post_type' => 'page', // The post type. Default 'post'. [ 'post' | 'page' | 'link' | 'nav_menu_item' | 'custom_post_type' ] //You may want to insert a regular post, page, link, a menu item or some custom post type
52 'post_status' => 'publish', // [ 'draft' | 'publish' | 'pending'| 'future' | 'private' | 'custom_registered_status' ] // The post status. Default 'draft'. Set the status of the new post.
53 'comment_status' => 'closed', // [ 'closed' | 'open' ] // 'closed' means no comments.
54 'ping_status' => 'closed', // [ 'closed' | 'open' ] // 'closed' means pingbacks or trackbacks turned off
55 'post_content' => '[bookingedit]', // The post content. Default empty. The full text of the post.
56 'post_name' => 'wpbc-booking-edit', // sanitize_title( $post_title ), -- By default, converts accent characters to ASCII characters and further limits the output to alphanumeric characters, underscore (_) and dash (-) // The post name. Default is the sanitized post title when creating a new post. The name (slug) for your post
57 'post_title' => esc_html__('Booking edit','booking') // The post title. Default empty. The title of your post.
58 );
59
60
61 $my_post = wp_parse_args( $page_params, $defaults );
62
63
64 $post_id = wp_insert_post( $my_post ); // Insert the post into the database
65
66 if ( ( ! is_wp_error( $post_id ) ) && ( ! empty( $post_id ) ) ) {
67
68 // Success
69
70 // $post = get_post( $post_id );
71 // $post_url = get_permalink( $post_id );
72
73 } else {
74 if ( is_wp_error( $post_id ) ) {
75 // Error // __( 'Sorry, the post could not be created.' )
76 }
77 if ( ! $post_id ) {
78 // Error // __( 'Sorry, the post could not be created.' )
79 }
80 $post_id = false;
81 }
82
83 return $post_id;
84 }
85
86
87 /**
88 * Is shortcode or some text exist in specific page
89 *
90 * @param string $relative_url relative URL of the page, if we have absolute url, then get it using: wpbc_make_link_relative( 'https://...' );
91 * @param string $shortcode_to_add shortcode to check '[booking'
92 *
93 * @return bool
94 */
95 function wpbc_is_shortcode_exist_in_page( $relative_url, $shortcode_to_add ) {
96
97 if ( ! empty( $relative_url ) ) {
98
99 $post_obj = get_page_by_path( $relative_url );
100
101 if ( ! empty( $post_obj ) ) {
102 if ( false !== strpos( $post_obj->post_content, $shortcode_to_add ) ) {
103 return true;
104 }
105 }
106 }
107
108 return false;
109 }
110
111
112 /**
113 * Add shortcode, if it does not exist yet, to the page
114 *
115 * @param string $relative_url relative URL of the page, if we have absolute url, then get it using: wpbc_make_link_relative( 'https://...' );
116 * @param string $shortcode_to_add shortcode '[bookingedit]'
117 *
118 * @return bool
119 */
120 function wpbc_add_shortcode_to_exist_page( $relative_url, $shortcode_to_add ) {
121
122 if ( ! empty( $relative_url ) ) {
123
124 $post_obj = get_page_by_path( $relative_url );
125
126 if ( ! empty( $post_obj ) ) {
127 if ( false === strpos( $post_obj->post_content, $shortcode_to_add ) ) { // No such shortcode in this page. So we need to Add it.
128
129 $my_post = array(
130 'ID' => $post_obj->ID,
131 'post_content' => $post_obj->post_content . "\r\n" . $shortcode_to_add
132 );
133 wp_update_post( $my_post ); // Update the post into the database
134
135 return true;
136 }
137 }
138 }
139
140 return false;
141 }
142
143
144 // ---------------------------------------------------------------------------------------------------------------------
145
146 /**
147 * Create new page or add to existing page the shortcode
148 *
149 * @param array $params
150 *
151 * @return array success: [ 'result' => true, 'relative_url' => $relative_post_url, 'message' => __( 'Booking form shortcode embedded into the page.', 'booking' ) ]
152 * failed: [ 'result' => false, 'message' => __( 'We can not embed booking form shortcode into the page.', 'booking' ) ]
153 *
154 * Example:
155 * $result_arr = wpbc_add_shortcode_into_page( array(
156 * 'shortcode' => '[booking resource_id=1]',
157 * 'post_title' => 'Booking Form'
158 * ) );
159 */
160 function wpbc_add_shortcode_into_page( $params = array() ) {
161
162 $defaults = array(
163 'page_post_name' => '', // 'wpbc-booking',
164 'post_title' => esc_html( __( 'Booking Form', 'booking' ) ),
165 'shortcode' => '[booking resource_id=1]',
166 'check_exist_shortcode' => '[booking', // can be an array: array( '[booking resource_id=1]', '[booking type=1]', '[booking]' )
167 'page_id' => 0,
168 'resource_id' => 0 // Optional
169 );
170 $params = wp_parse_args( $params, $defaults );
171
172 if ( empty( $params['page_post_name'] ) ) {
173 $params['page_post_name'] = sanitize_title( $params['post_title'] ); // Get slug for the page
174 }
175
176
177 global $wp_rewrite;
178 if ( is_null( $wp_rewrite ) ) {
179 return array( 'result' => false, 'message' => 'Sorry, we are unable to insert the shortcode into the page. The reason is that wp_rewrite is not initialized.' );
180 }
181 // -----------------------------------------------------------------------------------------------------------------
182
183 $params['page_id'] = intval( $params['page_id'] );
184 if ( ! empty( $params['page_id'] ) ) {
185 $wp_post = get_post( $params['page_id'] );
186 } else {
187 $wp_post = get_page_by_path( $params['page_post_name'] );
188 }
189
190 $relative_post_url = '';
191
192 $post_title = '';
193 $post_url = '';
194 if ( ! empty( $wp_post ) ) {
195 $post_title = $wp_post->post_title;
196 $post_url = get_permalink( $wp_post->ID );
197 }
198
199 if ( empty( $wp_post ) ) { // No default page. Create it.
200
201 $page_params = array(
202 'post_title' => $params['post_title'],
203 'post_content' => $params['shortcode'],
204 'post_name' => $params['page_post_name']
205 );
206 $post_id = wpbc_create_page( $page_params );
207
208 if ( ! empty( $post_id ) ) {
209
210 $new_post = get_post( $post_id );
211 if ( ! empty( $new_post ) ) {
212 $post_title = $new_post->post_title;
213 $post_url = get_permalink( $new_post->ID );
214 }
215
216 $relative_post_url = wpbc_make_link_relative( get_permalink( $post_id ) );
217
218 // Scroll to the booking form.
219 if ( ! empty( $params['resource_id'] ) ) {
220 $post_url .= '#bklnk' . $params['resource_id'];
221 }
222
223 return array( 'result' => true,
224 'relative_url' => $relative_post_url,
225 'message' => __( 'A new page has been created.', 'booking' ) . ' ' . sprintf( __( 'The booking form shortcode %s has been embedded into the page %s', 'booking' )
226 , "<code class='wpbc_inserted_shortcode_view'>{$params['shortcode']}</code>"
227 , "<a class='wpbc_open_page_as_new_tab' href='" . esc_url( $post_url ) . "'>{$post_title}</a>"
228 . " <a target='_blank' class='wpbc_open_page_as_new_tab tooltip_top wpbc-bi-arrow-up-right-square' href='" . esc_url( $post_url ) . "' title='" . esc_attr( __( 'Open in new window', 'booking' ) ) . "'></a>"
229 )
230 );
231 }
232
233 } else {
234 $relative_post_url = wpbc_make_link_relative( get_permalink( $wp_post->ID ) ); // Page already exist, so we need to update the
235 }
236
237 // Check if the shortcode in the page
238 $is_shortcode_already_in_page = false;
239 if ( is_array( $params['check_exist_shortcode'] ) ) {
240 foreach ( $params['check_exist_shortcode'] as $check_shortcode ) {
241 $is_shortcode_already_in_page = wpbc_is_shortcode_exist_in_page( $relative_post_url, $check_shortcode );
242 if ( $is_shortcode_already_in_page ) {
243 break;
244 }
245 }
246 } else {
247 $is_shortcode_already_in_page = wpbc_is_shortcode_exist_in_page( $relative_post_url, $params['check_exist_shortcode'] );
248 }
249
250 // Scroll to the booking form.
251 if ( ! empty( $params['resource_id'] ) ) {
252 $post_url .= '#bklnk' . $params['resource_id'];
253 }
254
255 // Check if existing page has our shortcode. We are checking for 'booking' because it can be '[booking]' or '[booking type=1]' ...
256 if (
257 ( ! $is_shortcode_already_in_page )
258 && ( ! wpbc_is_shortcode_exist_in_page( $relative_post_url, $params['shortcode'] ) )
259 ) {
260 $is_sh_added = wpbc_add_shortcode_to_exist_page( $relative_post_url, $params['shortcode'] );
261
262 if ( $is_sh_added ) {
263 return array( 'result' => true,
264 'relative_url' => $relative_post_url,
265 'message' => sprintf( __( 'The booking form shortcode %s has been embedded into the page %s', 'booking' )
266 , "<code class='wpbc_inserted_shortcode_view'>{$params['shortcode']}</code>"
267 , "<a class='wpbc_open_page_as_new_tab' href='" . esc_url( $post_url ) . "'>{$post_title}</a>"
268 . " <a target='_blank' class='wpbc_open_page_as_new_tab tooltip_top wpbc-bi-arrow-up-right-square' href='" . esc_url( $post_url ) . "' title='" . esc_attr( __( 'Open in new window', 'booking' ) ) . "'></a>"
269
270 )
271 );
272
273 } else {
274 return array( 'result' => false,
275 'message' => sprintf( __( 'We are unable to embed the booking form shortcode %s into the page %s.', 'booking' )
276 , "<code class='wpbc_inserted_shortcode_view'>{$params['shortcode']}</code>"
277 , "<a class='wpbc_open_page_as_new_tab' href='" . esc_url( $post_url ) . "'>{$post_title}</a>"
278 . " <a target='_blank' class='wpbc_open_page_as_new_tab tooltip_top wpbc-bi-arrow-up-right-square' href='" . esc_url( $post_url ) . "' title='" . esc_attr( __( 'Open in new window', 'booking' ) ) . "'></a>"
279 )
280 );
281 }
282 } else {
283
284 return array( 'result' => false,
285 'message' => sprintf( __( 'The Booking Calendar shortcode %s is already present on this page %s.', 'booking' )
286 , "<code class='wpbc_inserted_shortcode_view'>{$params['shortcode']}</code>"
287 , "<a class='wpbc_open_page_as_new_tab' href='" . esc_url( $post_url ) . "'>{$post_title}</a>"
288 . " <a target='_blank' class='wpbc_open_page_as_new_tab tooltip_top wpbc-bi-arrow-up-right-square' href='" . esc_url( $post_url ) . "' title='" . esc_attr( __( 'Open in new window', 'booking' ) ) . "'></a>"
289 )
290 );
291
292 }
293
294 }
295
296
297 // ---------------------------------------------------------------------------------------------------------------------
298 // ---------------------------------------------------------------------------------------------------------------------
299 // ---------------------------------------------------------------------------------------------------------------------
300
301
302 /**
303 * Create new starter page with booking form
304 *
305 * @param $default_options_to_add - array from function wpbc_get_default_options(), which passed only from 'wpbc_before_activation__add_options'. Here we skip this option.
306 *
307 * @return void
308 */
309 function wpbc_create_page_with_booking_form( $default_options_to_add = array() ) { //FixIn: 9.6.2.11
310
311 global $wp_rewrite;
312 if ( is_null( $wp_rewrite ) ) { //FixIn: 9.7.1.1
313
314 // Maybe it was not init, yet
315 if ( ! has_action( 'init', 'wpbc_create_page_with_booking_form' ) ) {
316 add_action( 'init', 'wpbc_create_page_with_booking_form', 99 ); // <- priority to load it last
317 }
318 return false;
319 }
320
321 // -----------------------------------------------------------------------------------------------------------------
322
323 $wp_post = get_page_by_path( 'wpbc-booking' );
324
325 $post_url = '';
326
327 if ( empty( $wp_post ) ) { // No default page. Create it.
328
329 $page_params = array(
330 'post_title' => esc_html( __( 'Booking Form', 'booking' ) ),
331 'post_content' => '[booking resource_id=1]',
332 'post_name' => 'wpbc-booking'
333 );
334 $post_id = wpbc_create_page( $page_params );
335
336 if ( ! empty( $post_id ) ) {
337 $post_url = wpbc_make_link_relative( get_permalink( $post_id ) );
338 }
339
340 } else {
341 $post_url = wpbc_make_link_relative( get_permalink( $wp_post->ID ) ); // Page already exist, so we need to update the
342 }
343
344 // -----------------------------------------------------------------------------------------------------------------
345
346 // Check if existing page has our shortcode. We are checking for 'booking' because it can be '[booking]' or '[booking type=1]' ...
347 if ( ! wpbc_is_shortcode_exist_in_page( $post_url, '[booking' ) ) {
348 $is_sh_added = wpbc_add_shortcode_to_exist_page( $post_url, '[booking resource_id=1]' );
349 }
350
351 }
352 add_bk_action( 'wpbc_before_activation__add_options', 'wpbc_create_page_with_booking_form' );
353
354 // ---------------------------------------------------------------------------------------------------------------------
355
356
357 /**
358 * Create new page and get URL of this page
359 *
360 * @param $default_options_to_add
361 *
362 * @return void
363 */
364 function wpbc_create_page_thank_you( $default_options_to_add ) { //FixIn: 9.6.2.11
365
366 global $wp_rewrite;
367 if ( is_null( $wp_rewrite ) ) { //FixIn: 9.7.1.1
368
369 // Maybe it was not init, yet
370 if ( ! has_action( 'init', 'wpbc_create_page_thank_you' ) ) {
371 add_action( 'init', 'wpbc_create_page_thank_you', 99 ); // <- priority to load it last
372 }
373 return false;
374 }
375
376 // -----------------------------------------------------------------------------------------------------------------
377
378 $thank_you_page_url = get_bk_option( 'booking_thank_you_page_URL' );
379
380 if ( ( empty( $thank_you_page_url ) ) // If No 'Thank you' page in Settings, or it's set as Empty.
381 || (
382 ( '/thank-you' == wpbc_make_link_relative( get_bk_option( 'booking_thank_you_page_URL' ) ) )
383 && ( empty( get_page_by_path( 'thank-you' ) ) ) //FixIn: 9.9.0.27
384 )
385 || ( '/' == wpbc_make_link_relative( get_bk_option( 'booking_thank_you_page_URL' ) ) )
386 ){
387 $wp_post = get_page_by_path( 'wpbc-booking-received' );
388
389 $post_url = '';
390
391 if ( empty( $wp_post ) ) { // No default page. Create it.
392
393 $page_params = array(
394 'post_title' => esc_html( __( 'Booking Received', 'booking' ) ),
395 'post_content' => esc_html( __( 'Thank you for your booking. Your booking has been successfully received.', 'booking' ) )
396 . "\r\n" . ' [booking_confirm]',
397 'post_name' => 'wpbc-booking-received'
398 );
399 $post_id = wpbc_create_page( $page_params );
400
401 if ( ! empty( $post_id ) ) {
402 $post_url = wpbc_make_link_relative( get_permalink( $post_id ) );
403 }
404
405 } else {
406 $post_url = wpbc_make_link_relative( get_permalink( $wp_post->ID ) ); // Page already exist, so we need to update the
407 }
408
409 if ( ! empty( $post_url ) ) {
410 update_bk_option( 'booking_thank_you_page_URL', $post_url );
411 }
412 }
413
414 // -----------------------------------------------------------------------------------------------------------------
415
416 // Check if existing page has our shortcode
417 $relative_url = wpbc_make_link_relative( get_bk_option( 'booking_thank_you_page_URL' ) );
418 $is_sh_added = wpbc_add_shortcode_to_exist_page( $relative_url, '[booking_confirm]' );
419
420 }
421 add_bk_action( 'wpbc_before_activation__add_options', 'wpbc_create_page_thank_you' );
422
423
424
425 /**
426 * Create pages for [bookingedit] and [bookingcustomerlisting] shortcodes,
427 *
428 * if previously was not defined options
429 * 'booking_url_bookings_edit_by_visitors' and 'booking_url_bookings_listing_by_customer'
430 * to some pages different from homepage.
431 *
432 * @return void
433 */
434 function wpbc_create_page_bookingedit(){ //FixIn: 9.6.2.10
435
436 global $wp_rewrite;
437 if ( is_null( $wp_rewrite ) ) { //FixIn: 9.7.1.1
438 // Maybe it was not init, yet
439 if ( ! has_action( 'init', 'wpbc_create_page_bookingedit' ) ) {
440 add_action( 'init', 'wpbc_create_page_bookingedit', 99 ); // <- priority to load it last
441 }
442 return false;
443 }
444
445 // Booking Edit page - set default page and URL ---------------------------------------------------------------
446 $url_booking_edit = get_bk_option( 'booking_url_bookings_edit_by_visitors' );
447 if (
448 ( site_url() == $url_booking_edit )
449 && ( empty( get_page_by_path( 'wpbc-my-booking' ) ) )
450 ){
451 $page_params = array(
452 'post_content' => '[bookingedit]', // The post content
453 'post_name' => 'wpbc-my-booking', // sanitize_title( $post_title )
454 'post_title' => esc_html__( 'My Booking', 'booking' ) // Title
455 );
456
457 $post_id = wpbc_create_page( $page_params );
458
459 if ( ! empty( $post_id ) ) {
460 $post_url = get_permalink( $post_id );
461 update_bk_option( 'booking_url_bookings_edit_by_visitors', $post_url );
462 }
463 } else if (
464 (
465 ( site_url() == $url_booking_edit )
466 || ( empty( $url_booking_edit ) )
467 )
468 && ( ! empty( get_page_by_path( 'wpbc-my-booking' ) ) )
469 ){
470 $wp_post = get_page_by_path( 'wpbc-my-booking' );
471 if ( ! empty( $wp_post ) ) {
472 update_bk_option( 'booking_url_bookings_edit_by_visitors', get_permalink( $wp_post->ID ) );
473 }
474 }
475
476 // -----------------------------------------------------------------------------------------------------------------
477 // Check if existing page has our shortcode
478 // -----------------------------------------------------------------------------------------------------------------
479 $booking_edit_relative_url = wpbc_make_link_relative( get_bk_option( 'booking_url_bookings_edit_by_visitors' ) );
480 $is_added = wpbc_add_shortcode_to_exist_page( $booking_edit_relative_url, '[bookingedit]' );
481
482
483 // =================================================================================================================
484 // =================================================================================================================
485 // =================================================================================================================
486
487
488 // Booking Listing page - set default page and URL ---------------------------------------------------------------
489 $url_booking_edit = get_bk_option( 'booking_url_bookings_listing_by_customer' );
490 if (
491 ( site_url() == $url_booking_edit )
492 && ( empty( get_page_by_path( 'wpbc-my-bookings-listing' ) ) )
493 ){
494
495 $page_params = array(
496 'post_content' => '[bookingcustomerlisting]', // The post content
497 'post_name' => 'wpbc-my-bookings-listing', // sanitize_title( $post_title )
498 'post_title' => esc_html__( 'My Bookings Listing', 'booking' ) // Title
499 );
500
501 $post_id = wpbc_create_page( $page_params );
502
503 if ( ! empty( $post_id ) ) {
504 $post_url = get_permalink( $post_id );
505 update_bk_option( 'booking_url_bookings_listing_by_customer', $post_url );
506 }
507 } else if (
508 (
509 ( site_url() == $url_booking_edit )
510 || ( empty( $url_booking_edit ) )
511 )
512 && ( ! empty( get_page_by_path( 'wpbc-my-bookings-listing' ) ) )
513 ){
514 $wp_post = get_page_by_path( 'wpbc-my-bookings-listing' );
515 if ( ! empty( $wp_post ) ){
516 update_bk_option( 'booking_url_bookings_listing_by_customer', get_permalink( $wp_post->ID ) );
517 }
518 }
519
520
521 // -----------------------------------------------------------------------------------------------------------------
522 // Check if existing page has our shortcode
523 // -----------------------------------------------------------------------------------------------------------------
524 $booking_listing_relative_url = wpbc_make_link_relative( get_bk_option( 'booking_url_bookings_listing_by_customer' ) );
525 $is_added = wpbc_add_shortcode_to_exist_page( $booking_listing_relative_url, '[bookingcustomerlisting]' );
526
527 }
528
529
530 function wpbc_create_page_booking_payment_status(){ //FixIn: 9.6.2.13
531
532 global $wp_rewrite;
533 if ( is_null( $wp_rewrite ) ) { //FixIn: 9.7.1.1
534 return false;
535 }
536
537 // Successful Payment page options ---------------------------------------------------------------------------------
538
539 $post_url_relative = false;
540 $slug = 'wpbc-booking-payment-successful';
541 if ( empty( get_page_by_path( $slug ) ) ) {
542 // Create page
543 $page_params = array(
544 'post_title' => esc_html( __( 'Booking Payment Confirmation', 'booking' ) ),
545 'post_content' => esc_html( __( 'Thank you for your booking. Your payment for the booking has been successfully received.', 'booking' ) ),
546 'post_name' => $slug
547 );
548
549 $post_id = wpbc_create_page( $page_params );
550
551 if ( ! empty( $post_id ) ) {
552 $post_url = get_permalink( $post_id );
553 $post_url_relative = str_replace( site_url(), '', $post_url );
554 }
555 }
556 if ( ! empty( $post_url_relative ) ) {
557
558 //$post_url_relative = wpbc_make_link_absolute( $post_url_relative );
559
560 $payment_systems = array(
561 'booking_stripe_v3_order_successful',
562 'booking_paypal_return_url',
563 'booking_authorizenet_order_successful',
564 'booking_sage_order_successful',
565 'booking_ideal_return_url',
566 'booking_ipay88_return_url'
567 );
568
569 foreach ( $payment_systems as $payment_system ) {
570
571 if (
572 ( false === get_bk_option( $payment_system ) )
573 || ( '/successful' == wpbc_make_link_relative( get_bk_option( $payment_system ) ) )
574 ) {
575 update_bk_option( $payment_system, wpbc_make_link_relative( $post_url_relative ) );
576 }
577 }
578 }
579
580 // Failed Payment page options -------------------------------------------------------------------------------------
581
582 $post_url_relative = false;
583 $slug = 'wpbc-booking-payment-failed';
584 if ( empty( get_page_by_path( $slug ) ) ) {
585 // Create page
586 $page_params = array(
587 'post_title' => esc_html( __( 'Booking Payment Failed', 'booking' ) ),
588 'post_content' => esc_html( __( 'Payment Unsuccessful. Please contact us for assistance.', 'booking' ) ),
589 'post_name' => $slug
590 );
591
592 $post_id = wpbc_create_page( $page_params );
593
594 if ( ! empty( $post_id ) ) {
595 $post_url = get_permalink( $post_id );
596 $post_url_relative = str_replace( site_url(), '', $post_url );
597 }
598 }
599 if ( ! empty( $post_url_relative ) ) {
600
601 //$post_url_relative = wpbc_make_link_absolute( $post_url_relative );
602
603 $payment_systems = array(
604 'booking_stripe_v3_order_failed',
605 'booking_paypal_cancel_return_url',
606 'booking_authorizenet_order_failed',
607 'booking_sage_order_failed',
608 'booking_ideal_cancel_return_url',
609 'booking_ipay88_cancel_return_url'
610 );
611
612 foreach ( $payment_systems as $payment_system ) {
613
614 if (
615 ( false === get_bk_option( $payment_system ) )
616 || ( '/failed' == wpbc_make_link_relative( get_bk_option( $payment_system ) ) )
617 ) {
618 update_bk_option( $payment_system, wpbc_make_link_relative( $post_url_relative ) );
619 }
620 }
621 }
622 }