| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly //FixIn: 9.8.0.4 | |
| 3 | +if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly // FixIn: 9.8.0.4. | |
| 4 | 4 | |
| 5 | 5 | // --------------------------------------------------------------------------------------------------------------------- |
| 6 | 6 | // == Confirmation Page |
| 7 | 7 | // --------------------------------------------------------------------------------------------------------------------- |
| @@ -26,9 +26,9 @@ | ||
| 26 | 26 | $search = array( '‘', '’', '“', '”', '—' ); |
| 27 | 27 | $replace = array( "'", "'", '"', '"', '-' ); |
| 28 | 28 | $content_utf2 = str_replace($search, $replace, $content_utf); |
| 29 | 29 | |
| 30 | - $content_utf2 = strip_tags( $content_utf2 ); | |
| 30 | + $content_utf2 = wp_strip_all_tags( $content_utf2 ); | |
| 31 | 31 | |
| 32 | 32 | $content_json = json_decode( $content_utf2 ); |
| 33 | 33 | debuge($content_json); |
| 34 | 34 | |
| @@ -34,12 +34,12 @@ | ||
| 34 | 34 | |
| 35 | 35 | die; |
| 36 | 36 | |
| 37 | 37 | |
| 38 | - $content_str = json_encode( $content_json ); | |
| 38 | + $content_str = wp_json_encode( $content_json ); | |
| 39 | 39 | $content_str = str_replace(',', ",\n", $content_str); |
| 40 | 40 | |
| 41 | - $return = json_encode( $attr ) . '<p><pre>' . $content_str . '</pre></p>' . $tag; | |
| 41 | + $return = wp_json_encode( $attr ) . '<p><pre>' . $content_str . '</pre></p>' . $tag; | |
| 42 | 42 | |
| 43 | 43 | $return .= '<hr/>'; |
| 44 | 44 | |
| 45 | 45 | return $return ; |
| @@ -64,9 +64,9 @@ | ||
| 64 | 64 | } |
| 65 | 65 | add_action( 'init', 'wpbc_init_shortcode__wpbc_booking_confirmation', 9999 ); // <- priority to load it last |
| 66 | 66 | |
| 67 | 67 | |
| 68 | - /** | |
| 68 | +/** | |
| 69 | 69 | * Universal shortcode worker |
| 70 | 70 | * |
| 71 | 71 | * @param array $attr |
| 72 | 72 | * @param string|null $content |
| @@ -73,9 +73,9 @@ | ||
| 73 | 73 | * @param string $tag |
| 74 | 74 | * |
| 75 | 75 | * @return string |
| 76 | 76 | */ |
| 77 | - function wpbc_shortcode__booking_confirmation( $attr = array(), $content = null, $tag = '' ) { | |
| 77 | +function wpbc_shortcode__booking_confirmation( $attr = array(), $content = null, $tag = '' ) { | |
| 78 | 78 | |
| 79 | 79 | // ob_start(); |
| 80 | 80 | |
| 81 | 81 | $atts = array_change_key_case( (array) $attr, CASE_LOWER ); // Changes the case of all keys in an array |
| @@ -90,27 +90,26 @@ | ||
| 90 | 90 | */ |
| 91 | 91 | |
| 92 | 92 | $return = ''; |
| 93 | 93 | |
| 94 | - switch ( $attr['mode'] ) { | |
| 94 | + switch ( $attr['mode'] ) { | |
| 95 | 95 | |
| 96 | - case 'booking_confirm': | |
| 96 | + case 'booking_confirm': | |
| 97 | + $return .= wpbc_do_shortcode__booking_confirm( $attr ); | |
| 98 | + break; | |
| 97 | 99 | |
| 98 | - $return .= wpbc_do_shortcode__booking_confirm( $attr ); | |
| 99 | - break; | |
| 100 | + default: | |
| 101 | + $return = '<p style="font-size:9px;">Invalid shortcode configuration: <strong>[' . esc_html( $tag ) . ' ... ]</strong>. ' . // FixIn: 10.11.2.1. | |
| 102 | + /* translators: 1: ... */ | |
| 103 | + sprintf( __( 'Find more in the %1$sFAQ%2$s', 'booking' ), '<a href="https://wpbookingcalendar.com/faq/">', '</a>.' ) . | |
| 104 | + '</p>'; | |
| 105 | + } | |
| 100 | 106 | |
| 101 | - default: | |
| 102 | - $return = '<p style="font-size:9px;">' | |
| 103 | - . 'Invalid shortcode configuration: <strong>[' . $tag . ' ... ]</strong> with the following parameters: ' . json_encode( $attr ) . '. ' | |
| 104 | - . sprintf( __( 'Find more in the %sFAQ%s', 'booking' ), '<a href="https://wpbookingcalendar.com/faq/">', '</a>.' ) | |
| 105 | - . '</p>'; | |
| 106 | - } | |
| 107 | - | |
| 108 | 107 | // $possible_output = ob_get_clean(); |
| 109 | 108 | // $return .= $possible_output; |
| 110 | 109 | |
| 111 | - return $return ; | |
| 112 | - } | |
| 110 | + return $return ; | |
| 111 | +} | |
| 113 | 112 | |
| 114 | 113 | |
| 115 | 114 | |
| 116 | 115 | function wpbc_do_shortcode__booking_confirm( $attr ){ |
| @@ -115,9 +114,9 @@ | ||
| 115 | 114 | |
| 116 | 115 | function wpbc_do_shortcode__booking_confirm( $attr ){ |
| 117 | 116 | |
| 118 | 117 | if ( wpbc_is_on_edit_page() ) { |
| 119 | - return wpbc_get_preview_for_shortcode( 'booking_confirm', array() ); //FixIn: 9.9.0.39 | |
| 118 | + return wpbc_get_preview_for_shortcode( 'booking_confirm', array() ); // FixIn: 9.9.0.39. | |
| 120 | 119 | } |
| 121 | 120 | |
| 122 | 121 | ob_start(); |
| 123 | 122 | |
| @@ -136,10 +135,10 @@ | ||
| 136 | 135 | $resource_id = intval( $booking_resource_id__arr['resource_id'] ); |
| 137 | 136 | |
| 138 | 137 | if ( empty( $booking_id ) ) { |
| 139 | 138 | |
| 140 | - return '<strong>' . __('Oops!' ,'booking') . '</strong> ' | |
| 141 | - . __('We could not find your booking. The link you used may be incorrect or has expired. If you need assistance, please contact our support team.' ,'booking'); | |
| 139 | + return '<div class="wpbc_after_booking_thank_you_section"><div class="wpbc_ty__container"><div class="wpbc_ty__header"><strong>' . esc_html__('Oops!' ,'booking') . '</strong> ' | |
| 140 | + . __('We could not find your booking. The link you used may be incorrect or has expired. If you need assistance, please contact our support team.' ,'booking') . '</div></div></div>'; | |
| 142 | 141 | } else { |
| 143 | 142 | |
| 144 | 143 | |
| 145 | 144 | // DB Booking Details |
| @@ -173,9 +172,9 @@ | ||
| 173 | 172 | * $bookings_obj = array( $booking_data ); |
| 174 | 173 | * $booking_dates_obj = wpbc_ajx_get__booking_dates_obj__sql( $bookings_obj ); |
| 175 | 174 | * |
| 176 | 175 | * // 4. Include dates into bookings (Wide and Short dates view) |
| 177 | - * $bookings_with_dates = wpbc_ajx_include_bookingdates_in_bookings( $bookings_obj, $booking_dates_obj ); | |
| 176 | + * $bookings_with_dates = wpbc_ajx_include_bookingdates_in_the_bookings( $bookings_obj, $booking_dates_obj ); | |
| 178 | 177 | * |
| 179 | 178 | * // 5. Parse forms |
| 180 | 179 | * $parsed_bookings = wpbc_ajx_parse_bookings( $bookings_with_dates, $resources_arr ); ?? |
| 181 | 180 | * |
| @@ -241,9 +240,10 @@ | ||
| 241 | 240 | $payment_params['is_duplicate_booking'] = 0; // => 0 0 | 1 |
| 242 | 241 | $payment_params['is_from_admin_panel'] = false; // => false true | false |
| 243 | 242 | $payment_params['is_show_payment_form'] = 1; // => 1 0 | 1 |
| 244 | 243 | |
| 245 | - //FixIn: 9.9.0.35 | |
| 244 | + // FixIn: 9.9.0.35. | |
| 245 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing | |
| 246 | 246 | if ( ( ! empty( $_GET['is_show_payment_form'] ) ) && ( 'Off' === $_GET['is_show_payment_form'] ) ) { |
| 247 | 247 | $payment_params['is_show_payment_form'] = 0; |
| 248 | 248 | } |
| 249 | 249 | |
| @@ -250,8 +250,9 @@ | ||
| 250 | 250 | $payment_params['costs_arr'] = array( |
| 251 | 251 | 'total_cost' => $params_arr['payment_cost'], |
| 252 | 252 | 'deposit_cost' => $params_arr['payment_cost'] |
| 253 | 253 | ); |
| 254 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing | |
| 254 | 255 | if ( ( ! empty( $_GET['booking_pay'] ) ) && ( 1 == intval( $_GET['booking_pay'] ) ) ) { |
| 255 | 256 | $payment_params['booking_payment_form_in_request_only'] = 1; |
| 256 | 257 | $params_arr['booking_payment_form_in_request_only'] = 1; |
| 257 | 258 | } |
| @@ -295,14 +296,21 @@ | ||
| 295 | 296 | $json_arr = array(); |
| 296 | 297 | $json_arr['ajx_confirmation'] = $confirmation_arr; |
| 297 | 298 | $json_arr['resource_id'] = $resource_id; |
| 298 | 299 | |
| 299 | - $return_str = '<div class="wpbc_container ">' | |
| 300 | + /* | |
| 301 | + * Keep redirected confirmation/payment output in the same styling scope | |
| 302 | + * as payment forms shown directly after an AJAX booking. Gateway buttons | |
| 303 | + * use the shared .wpbc_button_light styles scoped by | |
| 304 | + * .wpbc_container_booking_form. | |
| 305 | + */ | |
| 306 | + $return_str = '<div class="wpbc_container wpbc_container_booking_form">' | |
| 300 | 307 | . '<div id="booking_form' . $resource_id . '"></div>' |
| 301 | - . '<script type="text/javascript"> ' . wpbc_jq_ready_start() //FixIn: 10.1.3.7 | |
| 308 | + . '<script type="text/javascript"> ' . wpbc_jq_ready_start() // FixIn: 10.1.3.7. | |
| 302 | 309 | . ' wpbc_show_thank_you_message_after_booking(' .wp_json_encode( $json_arr ) . '); ' |
| 310 | + //. ' wpbc_show_thank_you_message_after_booking(' . str_replace( array( "\n", '\\n', '\n' ), ' ', wp_json_encode( $json_arr ) ) . '); ' | |
| 303 | 311 | . ' setTimeout( function (){ wpbc_do_scroll( "#wpbc_scroll_point_' . intval( $resource_id ) . '", 10 ); }, 500 ); ' |
| 304 | - . wpbc_jq_ready_end() . '</script>' //FixIn: 10.1.3.7 | |
| 312 | + . wpbc_jq_ready_end() . '</script>' // FixIn: 10.1.3.7. | |
| 305 | 313 | . '</div>'; |
| 306 | 314 | } |
| 307 | 315 | |
| 308 | 316 | |
| @@ -310,5 +318,5 @@ | ||
| 310 | 318 | |
| 311 | 319 | $return_str .= $possible_output; |
| 312 | 320 | |
| 313 | 321 | return $return_str; // return '<pre>' . var_export($confirmation_arr, true) . '</pre>'; |
| 314 | -} | |
| 322 | +} | |