PluginProbe
Booking Calendar / 11.8.3
Booking Calendar v11.8.3
11.8.3 11.8.2 11.8.1 11.8 11.7 11.6.1 11.6 11.5 11.4.3 11.4.2 11.4.1 11.4 11.3 11.2.1 11.2 11.1 11.0 10.15.7 10.15.6 10.1.3 10.10 10.10.1 10.10.2 10.11 10.11.2 All 203 releases
← All changes | includes/_functions/booking_data__parse.php +114 -118 11.6.111.8.3 View file →
@@ -363,19 +363,19 @@
363 363 * Example 4: $booking_form = wpbc_get__booking_form_fields__configuration( 1 , '' ); <- Load CUSTOM booking form, which is DEFAULT for RESOURCE
364 364 * Example 4: $booking_form = wpbc_get__booking_form_fields__configuration( 10 ); <- If resource ID = 10 belong to REGULAR User, then load booking form for this REGULAR USER
365 365 *
366 366 */
367 -function wpbc_get__booking_form_fields__configuration( $resource_id = 1, $form_name = 'standard' ) {
368 -
369 - $pair = wpbc_get__bfb_booking_form_pair__for_field_names_listing( $resource_id, $form_name, wpbc_get_request_form_context() );
370 -
371 - // Keep the complete BFB source intact. Languages use separate custom forms.
372 - $booking_form_configuration = isset( $pair['form'] ) ? (string) $pair['form'] : '';
373 -
374 - return $booking_form_configuration;
375 -}
367 +function wpbc_get__booking_form_fields__configuration( $resource_id = 1, $form_name = 'standard' ) {
376 368
369 + $pair = wpbc_get__bfb_booking_form_pair__for_field_names_listing( $resource_id, $form_name, wpbc_get_request_form_context() );
377 370
371 + // Keep the complete BFB source intact. Languages use separate custom forms.
372 + $booking_form_configuration = isset( $pair['form'] ) ? (string) $pair['form'] : '';
373 +
374 + return $booking_form_configuration;
375 +}
376 +
377 +
378 378 /**
379 379 * Load BFB preview payload from transient (for booking created inside preview iframe).
380 380 *
381 381 * @param array $ctx
@@ -466,19 +466,19 @@
466 466 }
467 467 }
468 468
469 469
470 - if ( 'standard' === $my_booking_form_name || '' === $my_booking_form_name ) {
471 - $resource_default_custom_form_name = apply_bk_filter( 'wpbc_get_default_custom_form', 'standard', $resource_id );
472 - if ( ! empty( $resource_default_custom_form_name ) ) {
473 - $my_booking_form_name = $resource_default_custom_form_name;
474 - }
475 - }
476 -
477 - $booking_form_show = WPBC_BFB_Booking_Data_Content_Resolver::maybe_override_booking_form_show_by_bfb( '', $resource_id, $my_booking_form_name, $form_data, $ctx );
478 -
479 - // Keep the complete BFB content template intact. Languages use separate custom forms.
480 - return $booking_form_show;
470 + if ( 'standard' === $my_booking_form_name || '' === $my_booking_form_name ) {
471 + $resource_default_custom_form_name = apply_bk_filter( 'wpbc_get_default_custom_form', 'standard', $resource_id );
472 + if ( ! empty( $resource_default_custom_form_name ) ) {
473 + $my_booking_form_name = $resource_default_custom_form_name;
474 + }
475 + }
476 +
477 + $booking_form_show = WPBC_BFB_Booking_Data_Content_Resolver::maybe_override_booking_form_show_by_bfb( '', $resource_id, $my_booking_form_name, $form_data, $ctx );
478 +
479 + // Keep the complete BFB content template intact. Languages use separate custom forms.
480 + return $booking_form_show;
481 481 }
482 482
483 483
484 484 // -------------------------------------------------------------------------------------------------------------
@@ -710,9 +710,9 @@
710 710
711 711 /**
712 712 * Get booking form pair (fields + show template) for listing/inspection purposes.
713 713 *
714 - * Uses BFB resolver and returns advanced_form + content_form.
714 + * Uses BFB resolver and returns advanced_form + content_form.
715 715 *
716 716 * @param int $resource_id
717 717 * @param string $form_name
718 718 * @param array $ctx
@@ -728,23 +728,23 @@
728 728 if ( '' === $form_name ) {
729 729 $form_name = 'standard';
730 730 }
731 731
732 - $bfb_pair = wpbc_get__bfb_booking_form_pair__for_field_names_listing( $resource_id, $form_name, $ctx );
733 - $pair = is_array( $bfb_pair ) ? $bfb_pair : array();
734 - $pair = wp_parse_args( $pair, array( 'form' => '', 'content' => '' ) );
732 + $bfb_pair = wpbc_get__bfb_booking_form_pair__for_field_names_listing( $resource_id, $form_name, $ctx );
733 + $pair = is_array( $bfb_pair ) ? $bfb_pair : array();
734 + $pair = wp_parse_args( $pair, array( 'form' => '', 'content' => '' ) );
735 735
736 - $pair['form'] = wpbc_bf__replace_custom_html_shortcodes( (string) $pair['form'] );
737 - $pair['content'] = wpbc_bf__replace_custom_html_shortcodes( (string) $pair['content'] );
738 -
739 - // Do not interpret inline [lang=LOCALE] markers as whole-form language blocks.
740 - return $pair;
741 -}
736 + $pair['form'] = wpbc_bf__replace_custom_html_shortcodes( (string) $pair['form'] );
737 + $pair['content'] = wpbc_bf__replace_custom_html_shortcodes( (string) $pair['content'] );
742 738
739 + // Do not interpret inline [lang=LOCALE] markers as whole-form language blocks.
740 + return $pair;
741 +}
742 +
743 743 /**
744 744 * Get arr of all fields names from all booking forms (including custom).
745 745 *
746 - * Load form names through BFB helpers and inspect each stored form pair.
746 + * Load form names through BFB helpers and inspect each stored form pair.
747 747 *
748 748 * @return array
749 749 */
750 750 function wpbc_get__in_all_forms__field_names_arr() {
@@ -750,101 +750,84 @@
750 750 function wpbc_get__in_all_forms__field_names_arr() {
751 751
752 752 $booking_form_fields_arr = array();
753 753
754 - $ctx = wpbc_get_request_form_context();
755 - $ctx['form_status'] = 'published';
756 -
757 - $form_names = array( 'standard' );
758 -
759 - if (
760 - class_exists( 'WPBC_FE_Custom_Form_Helper' )
761 - && method_exists( 'WPBC_FE_Custom_Form_Helper', 'get_custom_booking_forms_list' )
762 - ) {
763 - $owner_user_id = 0;
764 -
765 - if ( method_exists( 'WPBC_FE_Custom_Form_Helper', 'wpbc_mu__get_current__owner_user_id' ) ) {
766 - $owner_user_id = absint( WPBC_FE_Custom_Form_Helper::wpbc_mu__get_current__owner_user_id() );
767 - }
768 -
769 - $ctx['owner_user_id'] = $owner_user_id;
770 -
771 - $forms_list = WPBC_FE_Custom_Form_Helper::get_custom_booking_forms_list(
772 - array(
773 - 'include_standard' => false,
774 - 'owner_user_id' => $owner_user_id,
775 - 'statuses' => array( 'published' ),
776 - 'list_mode' => 'bfb',
777 - )
778 - );
779 -
780 - if ( is_array( $forms_list ) ) {
781 - foreach ( $forms_list as $form_data ) {
782 -
783 - if ( empty( $form_data['name'] ) ) {
784 - continue;
785 - }
786 -
787 - $form_name = sanitize_text_field( (string) $form_data['name'] );
788 -
789 - if ( ( '' !== $form_name ) && ( 'standard' !== $form_name ) ) {
790 - $form_names[] = $form_name;
791 - }
792 - }
793 - }
794 - }
795 -
796 - $form_names = array_values( array_unique( $form_names ) );
797 -
798 - foreach ( $form_names as $form_name ) {
799 -
800 - $pair = wpbc_get__booking_form_pair__for_field_names_listing(
801 - wpbc_get_default_resource(),
802 - $form_name,
803 - $ctx
804 - );
805 -
806 - $booking_form_fields_arr[] = array(
807 - 'name' => $form_name,
808 - 'form' => $pair['form'],
809 - 'content' => $pair['content'],
810 - );
811 - }
812 -
813 - // ---------------------------------------------------------------------
814 - // Common parser.
815 - // ---------------------------------------------------------------------
816 - foreach ( $booking_form_fields_arr as $form_key => $booking_form_element ) {
754 + $ctx = wpbc_get_request_form_context();
755 + $ctx['form_status'] = 'published';
817 756
818 - $booking_form = isset( $booking_form_element['form'] ) ? (string) $booking_form_element['form'] : '';
757 + $form_names = array( 'standard' );
819 758
820 - $types = 'text[*]?|email[*]?|time[*]?|textarea[*]?|select[*]?|selectbox[*]?|checkbox[*]?|radio|acceptance|captchac|captchar|file[*]?|quiz';
821 - $regex = '%\[\s*(' . $types . ')(\s+[a-zA-Z][0-9a-zA-Z:._-]*)([-0-9a-zA-Z:#_/|\s]*)?((?:\s*(?:"[^"]*"|\'[^\']*\'))*)?\s*\]%';
822 - $regex2 = '%\[\s*(country[*]?|starttime[*]?|endtime[*]?)(\s*[a-zA-Z]*[0-9a-zA-Z:._-]*)([-0-9a-zA-Z:#_/|\s]*)*((?:\s*(?:"[^"]*"|\'[^\']*\'))*)?\s*\]%';
759 + if (
760 + class_exists( 'WPBC_FE_Custom_Form_Helper' )
761 + && method_exists( 'WPBC_FE_Custom_Form_Helper', 'get_custom_booking_forms_list' )
762 + ) {
763 + $owner_user_id = 0;
823 764
824 - $fields_matches = array();
825 - $fields_matches2 = array();
765 + if ( method_exists( 'WPBC_FE_Custom_Form_Helper', 'wpbc_mu__get_current__owner_user_id' ) ) {
766 + $owner_user_id = absint( WPBC_FE_Custom_Form_Helper::wpbc_mu__get_current__owner_user_id() );
767 + }
826 768
827 - $fields_count = preg_match_all( $regex, $booking_form, $fields_matches );
828 - $fields_count2 = preg_match_all( $regex2, $booking_form, $fields_matches2 );
769 + $ctx['owner_user_id'] = $owner_user_id;
829 770
830 - foreach ( $fields_matches2 as $key => $value ) {
771 + $forms_list = WPBC_FE_Custom_Form_Helper::get_custom_booking_forms_list(
772 + array(
773 + 'include_standard' => false,
774 + 'owner_user_id' => $owner_user_id,
775 + 'statuses' => array( 'published' ),
776 + 'list_mode' => 'bfb',
777 + )
778 + );
831 779
832 - if ( 2 === (int) $key ) {
833 - $value = $fields_matches2[1];
834 - }
780 + if ( is_array( $forms_list ) ) {
781 + foreach ( $forms_list as $form_data ) {
835 782
836 - if ( ! isset( $fields_matches[ $key ] ) || ! is_array( $fields_matches[ $key ] ) ) {
837 - $fields_matches[ $key ] = array();
838 - }
783 + if ( empty( $form_data['name'] ) ) {
784 + continue;
785 + }
839 786
840 - foreach ( $value as $single_value ) {
841 - $fields_matches[ $key ][] = $single_value;
787 + $form_name = sanitize_text_field( (string) $form_data['name'] );
788 +
789 + if ( ( '' !== $form_name ) && ( 'standard' !== $form_name ) ) {
790 + $form_names[] = $form_name;
791 + }
842 792 }
843 793 }
794 + }
844 795
845 - $fields_count += $fields_count2;
796 + $form_names = array_values( array_unique( $form_names ) );
846 797
798 + foreach ( $form_names as $form_name ) {
799 +
800 + $pair = wpbc_get__booking_form_pair__for_field_names_listing(
801 + wpbc_get_default_resource(),
802 + $form_name,
803 + $ctx
804 + );
805 +
806 + $booking_form_fields_arr[] = array(
807 + 'name' => $form_name,
808 + 'form' => $pair['form'],
809 + 'content' => $pair['content'],
810 + );
811 + }
812 +
813 + // ---------------------------------------------------------------------
814 + // Common parser.
815 + // ---------------------------------------------------------------------
816 + foreach ( $booking_form_fields_arr as $form_key => $booking_form_element ) {
817 +
818 + $booking_form = isset( $booking_form_element['form'] ) ? (string) $booking_form_element['form'] : '';
819 +
820 + // Keep field-assignment inventories aligned with the shared shortcode parser. Builder choice fields can
821 + // contain named attributes such as default="1", which the former duplicate regex did not recognize.
822 + $parsed_booking_fields = '' !== trim( $booking_form ) ? wpbc_get_fields_from_booking_form( $booking_form ) : false;
823 + $fields_count = 0;
824 + $fields_matches = array_fill( 0, 5, array() );
825 +
826 + if ( false !== $parsed_booking_fields ) {
827 + list( $fields_count, $fields_matches ) = $parsed_booking_fields;
828 + }
829 +
847 830 $booking_form_fields_arr[ $form_key ]['num'] = $fields_count;
848 831 $booking_form_fields_arr[ $form_key ]['listing'] = array();
849 832
850 833 if ( ! isset( $fields_matches[1] ) ) {
@@ -1073,14 +1056,27 @@
1073 1056 $booking_form_show = str_replace( '[' . $type_name . ']', $value, $booking_form_show );
1074 1057 }
1075 1058 }
1076 1059
1077 - if (! isset($all_fields_array_without_types[ 'booking_resource_id' ])) $all_fields_array_without_types[ 'booking_resource_id' ] = $bktype;
1078 - if (! isset($all_fields_array_without_types[ 'resource_id' ])) $all_fields_array_without_types[ 'resource_id' ] = $bktype;
1079 - if (! isset($all_fields_array_without_types[ 'type_id' ])) $all_fields_array_without_types[ 'type_id' ] = $bktype;
1060 + if ( ! isset( $all_fields_array_without_types['booking_resource_id'] ) ) {
1061 + $all_fields_array_without_types['booking_resource_id'] = $bktype;
1062 + }
1063 + if ( ! isset( $all_fields_array_without_types['resource_id'] ) ) {
1064 + $all_fields_array_without_types['resource_id'] = $bktype;
1065 + }
1066 + if ( ! isset( $all_fields_array_without_types['type_id'] ) ) {
1067 + $all_fields_array_without_types['type_id'] = $bktype;
1068 + }
1080 1069
1081 - if (! isset($all_fields_array_without_types[ 'type' ])) $all_fields_array_without_types[ 'type' ] = $bktype;
1082 - if (! isset($all_fields_array_without_types[ 'resource' ])) $all_fields_array_without_types[ 'resource' ] = $bktype;
1070 + if ( ! isset( $all_fields_array_without_types['type'] ) ) {
1071 + $all_fields_array_without_types['type'] = $bktype;
1072 + }
1073 + if ( ! isset( $all_fields_array_without_types['resource'] ) ) {
1074 + $all_fields_array_without_types['resource'] = wpbc_get_resource_title( $bktype );
1075 + }
1076 + if ( ! isset( $all_fields_array_without_types['resource_title'] ) ) {
1077 + $all_fields_array_without_types['resource_title'] = wpbc_get_resource_title( $bktype );
1078 + }
1083 1079
1084 1080 foreach ($extended_params as $key_param=>$value_param) {
1085 1081 if (! isset($all_fields_array_without_types[ $key_param ])) $all_fields_array_without_types[ $key_param ] = $value_param;
1086 1082 }
@@ -1202,5 +1198,5 @@
1202 1198 }
1203 1199
1204 1200
1205 1201 return $replaced_form;
1206 -}
1202 +}