| @@ -1,4 +1,4 @@ | ||
| 1 | 1 | <?php /** |
| 2 | 2 | * @version 1.0 |
| 3 | 3 | * @package Booking Calendar |
| 4 | 4 | * @category Toolbar. Data for UI Elements at Booking Calendar admin pages |
| @@ -18,10 +18,16 @@ | ||
| 18 | 18 | // --------------------------------------------------------------------------------------------------------------------- |
| 19 | 19 | |
| 20 | 20 | |
| 21 | 21 | /** T o o l b a r C o n t a i n e r f o r Add New Booking */ |
| 22 | -function wpbc_add_new_booking_toolbar() { | |
| 22 | +function wpbc_add_new_booking_toolbar( $args = array() ) { | |
| 23 | 23 | |
| 24 | + $defaults = array( | |
| 25 | + 'resource_id' => null, | |
| 26 | + 'booking_form' => null, | |
| 27 | + ); | |
| 28 | + $args = wp_parse_args( $args, $defaults ); | |
| 29 | + | |
| 24 | 30 | wpbc_clear_div(); |
| 25 | 31 | |
| 26 | 32 | // Toolbar //////////////////////////////////////////////////////////////// |
| 27 | 33 | |
| @@ -83,29 +89,22 @@ | ||
| 83 | 89 | |
| 84 | 90 | wpbc_toolbar_btn__resource_selection(); |
| 85 | 91 | } |
| 86 | 92 | |
| 87 | - $is_bfb_enabled = (bool) WPBC_Frontend_Settings::is_bfb_enabled( null ); | |
| 88 | - if ( $is_bfb_enabled ) { | |
| 89 | - WPBC_FE_Custom_Form_Helper::wpbc_bfb__custom_booking_forms_list__selectbox_html(); | |
| 90 | - } else { | |
| 91 | - if ( function_exists( 'wpbc_toolbar_btn__form_selection' ) ) { | |
| 92 | - wpbc_toolbar_btn__form_selection(); | |
| 93 | - } | |
| 94 | - } | |
| 95 | - | |
| 96 | - //////////////////////////////////////////////////////////////////// | |
| 93 | + WPBC_FE_Custom_Form_Helper::wpbc_bfb__custom_booking_forms_list__selectbox_html(); | |
| 94 | + | |
| 95 | + //////////////////////////////////////////////////////////////////// | |
| 97 | 96 | ?><div class="clear-for-mobile"></div><?php |
| 98 | 97 | |
| 99 | 98 | ?><div class="control-group wpbc-no-padding" style="float:right;margin-right: 0;margin-left: 15px;"><?php |
| 100 | 99 | |
| 101 | - wpbc_toolbar_btn__add_past_booking(); | |
| 100 | + wpbc_toolbar_btn__add_past_booking( $args ); | |
| 102 | 101 | |
| 103 | 102 | if ( function_exists( 'wpbc_toolbar_btn__auto_fill' ) ) { |
| 104 | 103 | wpbc_toolbar_btn__auto_fill(); |
| 105 | 104 | } |
| 106 | 105 | |
| 107 | - wpbc_toolbar_btn__add_new_booking(); | |
| 106 | + wpbc_toolbar_btn__add_new_booking( $args ); | |
| 108 | 107 | |
| 109 | 108 | ?></div><?php |
| 110 | 109 | //////////////////////////////////////////////////////////////////// |
| 111 | 110 | |
| @@ -829,19 +828,35 @@ | ||
| 829 | 828 | * Button for ability to add bookings in the past. |
| 830 | 829 | * |
| 831 | 830 | * @return void |
| 832 | 831 | */ |
| 833 | -function wpbc_toolbar_btn__add_past_booking() { | |
| 832 | +function wpbc_toolbar_btn__add_past_booking( $args = array() ) { | |
| 834 | 833 | |
| 835 | 834 | if ( isset( $_GET['allow_past'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing |
| 836 | 835 | return; |
| 837 | 836 | } |
| 838 | 837 | |
| 838 | + $defaults = array( | |
| 839 | + 'resource_id' => null, | |
| 840 | + 'booking_form' => null, | |
| 841 | + ); | |
| 842 | + $args = wp_parse_args( $args, $defaults ); | |
| 843 | + | |
| 839 | 844 | $link = wpbc_get_new_booking_url(); |
| 840 | 845 | |
| 841 | - $link .= ( ! empty( $_REQUEST['booking_type'] ) ) ? '&booking_type=' . intval( $_REQUEST['booking_type'] ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing | |
| 842 | - $link .= ( ! empty( $_REQUEST['booking_form'] ) ) ? '&booking_form=' . sanitize_text_field( wp_unslash( $_REQUEST['booking_form'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing | |
| 843 | - $link .= ( ! empty( $_REQUEST['booking_hash'] ) ) ? '&booking_form=' . sanitize_text_field( wp_unslash( $_REQUEST['booking_hash'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing | |
| 846 | + if ( null !== $args['resource_id'] ) { | |
| 847 | + $link .= '&booking_type=' . absint( $args['resource_id'] ); | |
| 848 | + } else { | |
| 849 | + $link .= ( ! empty( $_REQUEST['booking_type'] ) ) ? '&booking_type=' . intval( $_REQUEST['booking_type'] ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing | |
| 850 | + } | |
| 851 | + | |
| 852 | + if ( null !== $args['booking_form'] ) { | |
| 853 | + $link .= '&booking_form=' . sanitize_text_field( wp_unslash( (string) $args['booking_form'] ) ); | |
| 854 | + } else { | |
| 855 | + $link .= ( ! empty( $_REQUEST['booking_form'] ) ) ? '&booking_form=' . sanitize_text_field( wp_unslash( $_REQUEST['booking_form'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing | |
| 856 | + } | |
| 857 | + | |
| 858 | + $link .= ( ! empty( $_REQUEST['booking_hash'] ) ) ? '&booking_hash=' . sanitize_text_field( wp_unslash( $_REQUEST['booking_hash'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing | |
| 844 | 859 | $link .= ( ! empty( $_REQUEST['is_show_payment_form'] ) ) ? '&is_show_payment_form=Off' : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing |
| 845 | 860 | $link .= ( ! empty( $_REQUEST['parent_res'] ) ) ? '&parent_res=' . intval( $_REQUEST['parent_res'] ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing |
| 846 | 861 | |
| 847 | 862 | $el_id = 'is_allow_bookings_in_past'; |
| @@ -871,12 +886,18 @@ | ||
| 871 | 886 | } |
| 872 | 887 | |
| 873 | 888 | |
| 874 | 889 | /** Add New Booking Button*/ |
| 875 | -function wpbc_toolbar_btn__add_new_booking() { | |
| 890 | +function wpbc_toolbar_btn__add_new_booking( $args = array() ) { | |
| 876 | 891 | |
| 877 | - // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing | |
| 878 | - if ( isset( $_GET['booking_type'] ) ) { | |
| 892 | + $defaults = array( | |
| 893 | + 'resource_id' => null, | |
| 894 | + ); | |
| 895 | + $args = wp_parse_args( $args, $defaults ); | |
| 896 | + | |
| 897 | + if ( null !== $args['resource_id'] ) { | |
| 898 | + $bk_type = absint( $args['resource_id'] ); | |
| 899 | + } elseif ( isset( $_GET['booking_type'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing | |
| 879 | 900 | $bk_type = intval( $_GET['booking_type'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing |
| 880 | 901 | } else { |
| 881 | 902 | $bk_type = 1; |
| 882 | 903 | } |
| @@ -1600,5 +1621,5 @@ | ||
| 1600 | 1621 | }); |
| 1601 | 1622 | </script> |
| 1602 | 1623 | <?php |
| 1603 | 1624 | |
| 1604 | -} | |
| 1625 | +} | |