| @@ -1,4 +1,4 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * @version 1.0 |
| 4 | 4 | * @package Booking Calendar |
| @@ -365,36 +365,13 @@ | ||
| 365 | 365 | * |
| 366 | 366 | */ |
| 367 | 367 | function wpbc_get__booking_form_fields__configuration( $resource_id = 1, $form_name = 'standard' ) { |
| 368 | 368 | |
| 369 | - if ( ! class_exists( 'wpdev_bk_personal' ) ) { | |
| 370 | - $booking_form_configuration = wpbc_simple_form__get_booking_form__as_shortcodes(); | |
| 371 | - } else { | |
| 372 | - $booking_form_configuration = get_bk_option( 'booking_form' ); | |
| 369 | + $pair = wpbc_get__bfb_booking_form_pair__for_field_names_listing( $resource_id, $form_name, wpbc_get_request_form_context() ); | |
| 373 | 370 | |
| 374 | - if ( class_exists( 'wpdev_bk_biz_m' ) ) { | |
| 371 | + // Keep the complete BFB source intact. Languages use separate custom forms. | |
| 372 | + $booking_form_configuration = isset( $pair['form'] ) ? (string) $pair['form'] : ''; | |
| 375 | 373 | |
| 376 | - if ( $form_name != 'standard' ) { | |
| 377 | - | |
| 378 | - $booking_form_configuration = apply_bk_filter( 'wpdev_get_booking_form', $booking_form_configuration, $form_name ); | |
| 379 | - } | |
| 380 | - | |
| 381 | - // Get default Custom Form for resource, if $form_name == '' wpbc_get__booking_form_fields__configuration(1,'') | |
| 382 | - if ( empty( $form_name ) ) { | |
| 383 | - | |
| 384 | - $resource_default_custom_form_name = apply_bk_filter( 'wpbc_get_default_custom_form', 'standard', $resource_id ); | |
| 385 | - | |
| 386 | - $booking_form_configuration = apply_bk_filter( 'wpdev_get_booking_form', $booking_form_configuration, $resource_default_custom_form_name ); | |
| 387 | - } | |
| 388 | - | |
| 389 | - //MU :: if resource of "Regular User" - then GET STANDARD user form ( if ( get_bk_option( 'booking_is_custom_forms_for_regular_users' ) !== 'On' ) ) | |
| 390 | - $booking_form_configuration = apply_bk_filter( 'wpbc_multiuser_get_booking_form_fields_configuration_of_regular_user', $booking_form_configuration, $resource_id, $form_name ); // FixIn: 8.1.3.19. | |
| 391 | - } | |
| 392 | - } | |
| 393 | - | |
| 394 | - // Language | |
| 395 | - $booking_form_configuration = wpbc_lang( $booking_form_configuration ); | |
| 396 | - | |
| 397 | 374 | return $booking_form_configuration; |
| 398 | 375 | } |
| 399 | 376 | |
| 400 | 377 | |
| @@ -489,66 +466,18 @@ | ||
| 489 | 466 | } |
| 490 | 467 | } |
| 491 | 468 | |
| 492 | 469 | |
| 493 | - if ( ! class_exists( 'wpdev_bk_personal' ) ) { | |
| 494 | - | |
| 495 | - $booking_form_show = wpbc_simple_form__get_form_show__as_shortcodes(); | |
| 496 | - $booking_form_show = wpbc_bf__replace_custom_html_shortcodes( $booking_form_show ); | |
| 497 | - | |
| 498 | - // Try BFB (if available) even in this branch (safe no-op if not loaded). | |
| 499 | - $booking_form_show = WPBC_BFB_Booking_Data_Content_Resolver::maybe_override_booking_form_show_by_bfb( $booking_form_show, $resource_id, $my_booking_form_name, $form_data, $ctx ); | |
| 500 | - | |
| 501 | - } else { | |
| 502 | - | |
| 503 | - $booking_form_show = get_bk_option( 'booking_form_show' ); | |
| 504 | - $booking_form_show = wpbc_bf__replace_custom_html_shortcodes( $booking_form_show ); | |
| 505 | - | |
| 506 | - if ( class_exists( 'wpdev_bk_biz_m' ) ) { | |
| 507 | - | |
| 508 | - if ( false !== strpos( $form_data, 'wpbc_custom_booking_form' . $resource_id . '^' ) ) { // FixIn: 9.4.3.12. | |
| 509 | - | |
| 510 | - $custom_booking_form_name = substr( | |
| 511 | - $form_data, | |
| 512 | - strpos( $form_data, 'wpbc_custom_booking_form' . $resource_id . '^' ) + strlen( 'wpbc_custom_booking_form' . $resource_id . '^' ) | |
| 513 | - ); | |
| 514 | - | |
| 515 | - if ( false !== strpos( $custom_booking_form_name, '~' ) ) { | |
| 516 | - $custom_booking_form_name = substr( $custom_booking_form_name, 0, strpos( $custom_booking_form_name, '~' ) ); | |
| 517 | - } | |
| 518 | - | |
| 519 | - $booking_form_show = apply_bk_filter( 'wpdev_get_booking_form_content', $booking_form_show, $custom_booking_form_name ); | |
| 520 | - $my_booking_form_name = $custom_booking_form_name; | |
| 521 | - | |
| 522 | - } else { | |
| 523 | - | |
| 524 | - // BM :: Get default Custom Form of Resource. | |
| 525 | - $my_booking_form_name = apply_bk_filter( 'wpbc_get_default_custom_form', 'standard', $resource_id ); | |
| 526 | - if ( ( $my_booking_form_name != 'standard' ) && ( ! empty( $my_booking_form_name ) ) ) { | |
| 527 | - $booking_form_show = apply_bk_filter( 'wpdev_get_booking_form_content', $booking_form_show, $my_booking_form_name ); | |
| 528 | - } | |
| 529 | - } | |
| 530 | - | |
| 531 | - // MU :: if resource of "Regular User" - then GET STANDARD user form. | |
| 532 | - $booking_form_show = apply_bk_filter( 'wpbc_multiuser_get_booking_form_show_of_regular_user', $booking_form_show, $resource_id, $my_booking_form_name ); // FixIn: 8.1.3.19. | |
| 533 | - | |
| 534 | - /** | |
| 535 | - * IMPORTANT: | |
| 536 | - * Try BFB DB "content_form" (resolver-driven) BEFORE MU regular-user override, | |
| 537 | - * so MU filter can still enforce standard form when required. | |
| 538 | - */ | |
| 539 | - $booking_form_show = WPBC_BFB_Booking_Data_Content_Resolver::maybe_override_booking_form_show_by_bfb( $booking_form_show, $resource_id, $my_booking_form_name, $form_data, $ctx ); | |
| 540 | - | |
| 541 | - } else { | |
| 542 | - | |
| 543 | - // Try BFB also for non-BM paid branches (safe). | |
| 544 | - $booking_form_show = WPBC_BFB_Booking_Data_Content_Resolver::maybe_override_booking_form_show_by_bfb( $booking_form_show, $resource_id, $my_booking_form_name, $form_data, $ctx ); | |
| 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; | |
| 545 | 474 | } |
| 546 | 475 | } |
| 547 | 476 | |
| 548 | - // Language. | |
| 549 | - $booking_form_show = wpbc_lang( $booking_form_show ); | |
| 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 ); | |
| 550 | 478 | |
| 479 | + // Keep the complete BFB content template intact. Languages use separate custom forms. | |
| 551 | 480 | return $booking_form_show; |
| 552 | 481 | } |
| 553 | 482 | |
| 554 | 483 | |
| @@ -781,10 +710,9 @@ | ||
| 781 | 710 | |
| 782 | 711 | /** |
| 783 | 712 | * Get booking form pair (fields + show template) for listing/inspection purposes. |
| 784 | 713 | * |
| 785 | - * - Legacy mode: returns legacy form + content. | |
| 786 | - * - BFB mode: uses resolver and returns advanced_form + content_form. | |
| 714 | + * Uses BFB resolver and returns advanced_form + content_form. | |
| 787 | 715 | * |
| 788 | 716 | * @param int $resource_id |
| 789 | 717 | * @param string $form_name |
| 790 | 718 | * @param array $ctx |
| @@ -800,79 +728,16 @@ | ||
| 800 | 728 | if ( '' === $form_name ) { |
| 801 | 729 | $form_name = 'standard'; |
| 802 | 730 | } |
| 803 | 731 | |
| 804 | - /** | |
| 805 | - * --------------------------------------------------------------------- | |
| 806 | - * Legacy baseline pair. | |
| 807 | - * --------------------------------------------------------------------- | |
| 808 | - */ | |
| 809 | - $pair = array( | |
| 810 | - 'form' => '', | |
| 811 | - 'content' => '', | |
| 812 | - ); | |
| 813 | - | |
| 814 | - // Legacy "fields" configuration. | |
| 815 | - $pair['form'] = wpbc_get__booking_form_fields__configuration( $resource_id, $form_name ); | |
| 816 | - $pair['form'] = wpbc_bf__replace_custom_html_shortcodes( $pair['form'] ); | |
| 817 | - | |
| 818 | - // Legacy "show/content" configuration. | |
| 819 | - if ( ! class_exists( 'wpdev_bk_personal' ) ) { | |
| 820 | - | |
| 821 | - $pair['content'] = wpbc_simple_form__get_form_show__as_shortcodes(); | |
| 822 | - $pair['content'] = wpbc_bf__replace_custom_html_shortcodes( $pair['content'] ); | |
| 823 | - | |
| 824 | - } else { | |
| 825 | - | |
| 826 | - $pair['content'] = get_bk_option( 'booking_form_show' ); | |
| 827 | - $pair['content'] = wpbc_bf__replace_custom_html_shortcodes( $pair['content'] ); | |
| 828 | - | |
| 829 | - if ( class_exists( 'wpdev_bk_biz_m' ) ) { | |
| 830 | - | |
| 831 | - $my_booking_form_name = $form_name; | |
| 832 | - | |
| 833 | - if ( empty( $my_booking_form_name ) ) { | |
| 834 | - $my_booking_form_name = apply_bk_filter( 'wpbc_get_default_custom_form', 'standard', $resource_id ); | |
| 835 | - } | |
| 836 | - | |
| 837 | - if ( ( 'standard' !== $my_booking_form_name ) && ( '' !== $my_booking_form_name ) ) { | |
| 838 | - $pair['content'] = apply_bk_filter( 'wpdev_get_booking_form_content', $pair['content'], $my_booking_form_name ); | |
| 839 | - } | |
| 840 | - | |
| 841 | - $pair['content'] = apply_bk_filter( | |
| 842 | - 'wpbc_multiuser_get_booking_form_show_of_regular_user', | |
| 843 | - $pair['content'], | |
| 844 | - $resource_id, | |
| 845 | - $my_booking_form_name | |
| 846 | - ); | |
| 847 | - } | |
| 848 | - } | |
| 849 | - | |
| 850 | - /** | |
| 851 | - * --------------------------------------------------------------------- | |
| 852 | - * BFB override. | |
| 853 | - * --------------------------------------------------------------------- | |
| 854 | - */ | |
| 855 | 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' => '' ) ); | |
| 856 | 735 | |
| 857 | - if ( ! empty( $bfb_pair ) ) { | |
| 858 | - | |
| 859 | - if ( isset( $bfb_pair['form'] ) && ( '' !== trim( (string) $bfb_pair['form'] ) ) ) { | |
| 860 | - $pair['form'] = (string) $bfb_pair['form']; | |
| 861 | - } | |
| 862 | - | |
| 863 | - if ( isset( $bfb_pair['content'] ) && ( '' !== trim( (string) $bfb_pair['content'] ) ) ) { | |
| 864 | - $pair['content'] = (string) $bfb_pair['content']; | |
| 865 | - } | |
| 866 | - } | |
| 867 | - | |
| 868 | 736 | $pair['form'] = wpbc_bf__replace_custom_html_shortcodes( (string) $pair['form'] ); |
| 869 | 737 | $pair['content'] = wpbc_bf__replace_custom_html_shortcodes( (string) $pair['content'] ); |
| 870 | 738 | |
| 871 | - $pair['form'] = wpbc_lang( (string) $pair['form'] ); | |
| 872 | - $pair['content'] = wpbc_lang( (string) $pair['content'] ); | |
| 873 | - | |
| 874 | - | |
| 739 | + // Do not interpret inline [lang=LOCALE] markers as whole-form language blocks. | |
| 875 | 740 | return $pair; |
| 876 | 741 | } |
| 877 | 742 | |
| 878 | 743 | /** |
| @@ -877,15 +742,10 @@ | ||
| 877 | 742 | |
| 878 | 743 | /** |
| 879 | 744 | * Get arr of all fields names from all booking forms (including custom). |
| 880 | 745 | * |
| 881 | - * Legacy mode: | |
| 882 | - * - Keep previous behavior exactly as before. | |
| 746 | + * Load form names through BFB helpers and inspect each stored form pair. | |
| 883 | 747 | * |
| 884 | - * BFB mode: | |
| 885 | - * - Load form names via helper. | |
| 886 | - * - Load each pair through BFB-aware resolver logic. | |
| 887 | - * | |
| 888 | 748 | * @return array |
| 889 | 749 | */ |
| 890 | 750 | function wpbc_get__in_all_forms__field_names_arr() { |
| 891 | 751 | |
| @@ -890,167 +750,84 @@ | ||
| 890 | 750 | function wpbc_get__in_all_forms__field_names_arr() { |
| 891 | 751 | |
| 892 | 752 | $booking_form_fields_arr = array(); |
| 893 | 753 | |
| 894 | - $is_bfb_enabled = ( | |
| 895 | - class_exists( 'WPBC_Frontend_Settings' ) | |
| 896 | - && method_exists( 'WPBC_Frontend_Settings', 'is_bfb_enabled' ) | |
| 897 | - && WPBC_Frontend_Settings::is_bfb_enabled( null ) | |
| 898 | - ); | |
| 754 | + $ctx = wpbc_get_request_form_context(); | |
| 755 | + $ctx['form_status'] = 'published'; | |
| 899 | 756 | |
| 900 | - // --------------------------------------------------------------------- | |
| 901 | - // Legacy mode: keep previous behavior exactly. | |
| 902 | - // --------------------------------------------------------------------- | |
| 903 | - if ( ! $is_bfb_enabled ) { | |
| 757 | + $form_names = array( 'standard' ); | |
| 904 | 758 | |
| 905 | - $booking_form_fields_arr[] = array( | |
| 906 | - 'name' => 'standard', | |
| 907 | - 'form' => wpbc_bf__replace_custom_html_shortcodes( get_bk_option( 'booking_form' ) ), | |
| 908 | - 'content' => wpbc_bf__replace_custom_html_shortcodes( get_bk_option( 'booking_form_show' ) ), | |
| 909 | - ); | |
| 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; | |
| 910 | 764 | |
| 911 | - $is_can = apply_bk_filter( 'multiuser_is_user_can_be_here', true, 'only_super_admin' ); | |
| 912 | - | |
| 913 | - if ( ( $is_can ) || ( get_bk_option( 'booking_is_custom_forms_for_regular_users' ) === 'On' ) ) { | |
| 914 | - | |
| 915 | - $booking_forms_extended = get_bk_option( 'booking_forms_extended' ); | |
| 916 | - $booking_forms_extended = maybe_unserialize( $booking_forms_extended ); | |
| 917 | - | |
| 918 | - if ( is_array( $booking_forms_extended ) ) { | |
| 919 | - foreach ( $booking_forms_extended as $form_extended ) { | |
| 920 | - if ( is_array( $form_extended ) ) { | |
| 921 | - $booking_form_fields_arr[] = $form_extended; | |
| 922 | - } | |
| 923 | - } | |
| 924 | - } | |
| 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() ); | |
| 925 | 767 | } |
| 926 | 768 | |
| 927 | - // --------------------------------------------------------------------- | |
| 928 | - // BFB mode: use new resolver-aware logic. | |
| 929 | - // --------------------------------------------------------------------- | |
| 930 | - } else { | |
| 769 | + $ctx['owner_user_id'] = $owner_user_id; | |
| 931 | 770 | |
| 932 | - $ctx = wpbc_get_request_form_context(); | |
| 933 | - $ctx['form_status'] = 'published'; | |
| 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 | + ); | |
| 934 | 779 | |
| 935 | - $form_names = array( 'standard' ); | |
| 780 | + if ( is_array( $forms_list ) ) { | |
| 781 | + foreach ( $forms_list as $form_data ) { | |
| 936 | 782 | |
| 937 | - if ( | |
| 938 | - class_exists( 'WPBC_FE_Custom_Form_Helper' ) | |
| 939 | - && method_exists( 'WPBC_FE_Custom_Form_Helper', 'get_custom_booking_forms_list' ) | |
| 940 | - ) { | |
| 941 | - $owner_user_id = 0; | |
| 942 | - | |
| 943 | - if ( method_exists( 'WPBC_FE_Custom_Form_Helper', 'wpbc_mu__get_current__owner_user_id' ) ) { | |
| 944 | - $owner_user_id = absint( WPBC_FE_Custom_Form_Helper::wpbc_mu__get_current__owner_user_id() ); | |
| 945 | - } | |
| 946 | - | |
| 947 | - $ctx['owner_user_id'] = $owner_user_id; | |
| 948 | - | |
| 949 | - $forms_list = WPBC_FE_Custom_Form_Helper::get_custom_booking_forms_list( | |
| 950 | - array( | |
| 951 | - 'include_standard' => false, | |
| 952 | - 'owner_user_id' => $owner_user_id, | |
| 953 | - 'statuses' => array( 'published' ), | |
| 954 | - 'list_mode' => 'auto', | |
| 955 | - ) | |
| 956 | - ); | |
| 957 | - | |
| 958 | - if ( is_array( $forms_list ) ) { | |
| 959 | - foreach ( $forms_list as $form_data ) { | |
| 960 | - | |
| 961 | - if ( empty( $form_data['name'] ) ) { | |
| 962 | - continue; | |
| 963 | - } | |
| 964 | - | |
| 965 | - $form_name = sanitize_text_field( (string) $form_data['name'] ); | |
| 966 | - | |
| 967 | - if ( ( '' !== $form_name ) && ( 'standard' !== $form_name ) ) { | |
| 968 | - $form_names[] = $form_name; | |
| 969 | - } | |
| 783 | + if ( empty( $form_data['name'] ) ) { | |
| 784 | + continue; | |
| 970 | 785 | } |
| 971 | - } | |
| 972 | - } else { | |
| 973 | 786 | |
| 974 | - // Fallback to legacy list only if helper is unavailable. | |
| 975 | - $is_can = apply_bk_filter( 'multiuser_is_user_can_be_here', true, 'only_super_admin' ); | |
| 787 | + $form_name = sanitize_text_field( (string) $form_data['name'] ); | |
| 976 | 788 | |
| 977 | - if ( ( $is_can ) || ( get_bk_option( 'booking_is_custom_forms_for_regular_users' ) === 'On' ) ) { | |
| 978 | - | |
| 979 | - $booking_forms_extended = get_bk_option( 'booking_forms_extended' ); | |
| 980 | - $booking_forms_extended = maybe_unserialize( $booking_forms_extended ); | |
| 981 | - | |
| 982 | - if ( is_array( $booking_forms_extended ) ) { | |
| 983 | - foreach ( $booking_forms_extended as $form_extended_key => $form_extended ) { | |
| 984 | - | |
| 985 | - $form_name = ''; | |
| 986 | - | |
| 987 | - if ( is_array( $form_extended ) && ! empty( $form_extended['name'] ) ) { | |
| 988 | - $form_name = sanitize_text_field( (string) $form_extended['name'] ); | |
| 989 | - } elseif ( is_string( $form_extended_key ) ) { | |
| 990 | - $form_name = sanitize_text_field( (string) $form_extended_key ); | |
| 991 | - } | |
| 992 | - | |
| 993 | - if ( ( '' !== $form_name ) && ( 'standard' !== $form_name ) ) { | |
| 994 | - $form_names[] = $form_name; | |
| 995 | - } | |
| 996 | - } | |
| 789 | + if ( ( '' !== $form_name ) && ( 'standard' !== $form_name ) ) { | |
| 790 | + $form_names[] = $form_name; | |
| 997 | 791 | } |
| 998 | 792 | } |
| 999 | 793 | } |
| 794 | + } | |
| 1000 | 795 | |
| 1001 | - $form_names = array_values( array_unique( $form_names ) ); | |
| 796 | + $form_names = array_values( array_unique( $form_names ) ); | |
| 1002 | 797 | |
| 1003 | - foreach ( $form_names as $form_name ) { | |
| 798 | + foreach ( $form_names as $form_name ) { | |
| 1004 | 799 | |
| 1005 | - $pair = wpbc_get__booking_form_pair__for_field_names_listing( | |
| 1006 | - wpbc_get_default_resource(), | |
| 1007 | - $form_name, | |
| 1008 | - $ctx | |
| 1009 | - ); | |
| 800 | + $pair = wpbc_get__booking_form_pair__for_field_names_listing( | |
| 801 | + wpbc_get_default_resource(), | |
| 802 | + $form_name, | |
| 803 | + $ctx | |
| 804 | + ); | |
| 1010 | 805 | |
| 1011 | - $booking_form_fields_arr[] = array( | |
| 1012 | - 'name' => $form_name, | |
| 1013 | - 'form' => $pair['form'], | |
| 1014 | - 'content' => $pair['content'], | |
| 1015 | - ); | |
| 1016 | - } | |
| 806 | + $booking_form_fields_arr[] = array( | |
| 807 | + 'name' => $form_name, | |
| 808 | + 'form' => $pair['form'], | |
| 809 | + 'content' => $pair['content'], | |
| 810 | + ); | |
| 1017 | 811 | } |
| 1018 | 812 | |
| 1019 | 813 | // --------------------------------------------------------------------- |
| 1020 | - // Common parser for both legacy and BFB mode. | |
| 814 | + // Common parser. | |
| 1021 | 815 | // --------------------------------------------------------------------- |
| 1022 | 816 | foreach ( $booking_form_fields_arr as $form_key => $booking_form_element ) { |
| 1023 | 817 | |
| 1024 | 818 | $booking_form = isset( $booking_form_element['form'] ) ? (string) $booking_form_element['form'] : ''; |
| 1025 | 819 | |
| 1026 | - $types = 'text[*]?|email[*]?|time[*]?|textarea[*]?|select[*]?|selectbox[*]?|checkbox[*]?|radio|acceptance|captchac|captchar|file[*]?|quiz'; | |
| 1027 | - $regex = '%\[\s*(' . $types . ')(\s+[a-zA-Z][0-9a-zA-Z:._-]*)([-0-9a-zA-Z:#_/|\s]*)?((?:\s*(?:"[^"]*"|\'[^\']*\'))*)?\s*\]%'; | |
| 1028 | - $regex2 = '%\[\s*(country[*]?|starttime[*]?|endtime[*]?)(\s*[a-zA-Z]*[0-9a-zA-Z:._-]*)([-0-9a-zA-Z:#_/|\s]*)*((?:\s*(?:"[^"]*"|\'[^\']*\'))*)?\s*\]%'; | |
| 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 | + } | |
| 1029 | 829 | |
| 1030 | - $fields_matches = array(); | |
| 1031 | - $fields_matches2 = array(); | |
| 1032 | - | |
| 1033 | - $fields_count = preg_match_all( $regex, $booking_form, $fields_matches ); | |
| 1034 | - $fields_count2 = preg_match_all( $regex2, $booking_form, $fields_matches2 ); | |
| 1035 | - | |
| 1036 | - foreach ( $fields_matches2 as $key => $value ) { | |
| 1037 | - | |
| 1038 | - if ( 2 === (int) $key ) { | |
| 1039 | - $value = $fields_matches2[1]; | |
| 1040 | - } | |
| 1041 | - | |
| 1042 | - if ( ! isset( $fields_matches[ $key ] ) || ! is_array( $fields_matches[ $key ] ) ) { | |
| 1043 | - $fields_matches[ $key ] = array(); | |
| 1044 | - } | |
| 1045 | - | |
| 1046 | - foreach ( $value as $single_value ) { | |
| 1047 | - $fields_matches[ $key ][] = $single_value; | |
| 1048 | - } | |
| 1049 | - } | |
| 1050 | - | |
| 1051 | - $fields_count += $fields_count2; | |
| 1052 | - | |
| 1053 | 830 | $booking_form_fields_arr[ $form_key ]['num'] = $fields_count; |
| 1054 | 831 | $booking_form_fields_arr[ $form_key ]['listing'] = array(); |
| 1055 | 832 | |
| 1056 | 833 | if ( ! isset( $fields_matches[1] ) ) { |
| @@ -1279,14 +1056,27 @@ | ||
| 1279 | 1056 | $booking_form_show = str_replace( '[' . $type_name . ']', $value, $booking_form_show ); |
| 1280 | 1057 | } |
| 1281 | 1058 | } |
| 1282 | 1059 | |
| 1283 | - if (! isset($all_fields_array_without_types[ 'booking_resource_id' ])) $all_fields_array_without_types[ 'booking_resource_id' ] = $bktype; | |
| 1284 | - if (! isset($all_fields_array_without_types[ 'resource_id' ])) $all_fields_array_without_types[ 'resource_id' ] = $bktype; | |
| 1285 | - 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 | + } | |
| 1286 | 1069 | |
| 1287 | - if (! isset($all_fields_array_without_types[ 'type' ])) $all_fields_array_without_types[ 'type' ] = $bktype; | |
| 1288 | - 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 | + } | |
| 1289 | 1079 | |
| 1290 | 1080 | foreach ($extended_params as $key_param=>$value_param) { |
| 1291 | 1081 | if (! isset($all_fields_array_without_types[ $key_param ])) $all_fields_array_without_types[ $key_param ] = $value_param; |
| 1292 | 1082 | } |
| @@ -1408,5 +1198,5 @@ | ||
| 1408 | 1198 | } |
| 1409 | 1199 | |
| 1410 | 1200 | |
| 1411 | 1201 | return $replaced_form; |
| 1412 | -} | |
| 1202 | +} | |