PluginProbe
Booking Calendar / 11.8.2
Booking Calendar v11.8.2
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 10.11.3 All 202 releases
← All changes | core/admin/api-settings.php +107 -12 11.411.8.2 View file →
@@ -1,4 +1,4 @@
1 1 <?php
2 2 /**
3 3 * @version 1.0
4 4 * @package General Settings API - Saving different options
@@ -914,16 +914,30 @@
914 914 $field_options = array(
915 915 'vm_booking_listing' => __('Bookings Listing' ,'booking') // FixIn: 9.6.3.5.
916 916 , 'vm_calendar' => __('Timeline View' ,'booking')
917 917 );
918 - $this->fields['booking_listing_default_view_mode'] = array(
919 - 'type' => 'select'
918 + $this->fields['booking_listing_default_view_mode'] = array(
919 + 'type' => 'select'
920 920 , 'default' => $default_options_values['booking_listing_default_view_mode'] //'vm_calendar'
921 921 , 'title' => __('Default booking admin page', 'booking')
922 922 , 'description' => __('Select your default view mode of bookings at the booking listing page' ,'booking')
923 923 , 'options' => $field_options
924 - , 'group' => 'booking_listing'
925 - );
924 + , 'group' => 'booking_listing'
925 + );
926 +
927 + if ( class_exists( 'wpdev_bk_personal' ) ) {
928 + $this->fields['booking_admin_edit_booking_mode'] = array(
929 + 'type' => 'select',
930 + 'default' => $default_options_values['booking_admin_edit_booking_mode'],
931 + 'title' => __( 'Edit booking in', 'booking' ),
932 + 'description' => __( 'Choose whether Edit booking opens in a popup or on the dedicated Add Booking page.', 'booking' ),
933 + 'options' => array(
934 + 'popup' => __( 'Popup window (default)', 'booking' ),
935 + 'add_booking_page' => __( 'Add Booking page', 'booking' ),
936 + ),
937 + 'group' => 'booking_listing',
938 + );
939 + }
926 940
927 941 // Default booking resources.
928 942 $this->fields = apply_filters( 'wpbc_settings_booking_listing_br_default_count', $this->fields, $default_options_values );
929 943
@@ -1174,12 +1188,44 @@
1174 1188 // auto_cancelation_approval
1175 1189 $this->fields = apply_filters( 'wpbc_settings_auto_cancelation_approval_section', $this->fields, $default_options_values );
1176 1190 // </editor-fold>
1177 1191
1178 - // <editor-fold defaultstate="collapsed" desc=" Advanced " >
1179 -
1180 -
1181 - $this->fields = apply_filters( 'wpbc_settings_edit_url_hash', $this->fields, $default_options_values );
1192 + // <editor-fold defaultstate="collapsed" desc=" Advanced " >
1193 +
1194 + if ( wpbc_is_11_6_features_enabled() && wpbc_booking_resources_catalog_can_manage_settings() ) {
1195 + $is_pro_compatible = wpbc_booking_resources_catalog_is_pro_compatible();
1196 + $description = __( 'Choose the new or legacy pages for upgraded administration catalogs, including Seasonal Availability and Searchable Resources when their new catalogs are enabled. Legacy pages remain available for compatibility.', 'booking' );
1197 +
1198 + if ( ! $is_pro_compatible ) {
1199 + $pro_version = wpbc_booking_resources_catalog_get_pro_version();
1200 + if ( '' === $pro_version ) {
1201 + $pro_version = __( 'Unknown', 'booking' );
1202 + }
1203 +
1204 + /* translators: 1: Detected Booking Calendar Pro version, 2: Minimum compatible Pro version. */
1205 + $description = sprintf( __( 'Legacy catalog mode is required because Booking Calendar Pro %1$s is active. Update Pro to %2$s or newer to use the new catalogs. Legacy pages remain available for compatibility.', 'booking' ), esc_html( $pro_version ), esc_html( wpbc_booking_resources_catalog_get_minimum_pro_version() ) );
1206 + }
1207 +
1208 + $this->fields['booking_resources_catalog_renderer'] = array(
1209 + 'type' => 'select',
1210 + 'default' => 'new',
1211 + 'title' => __( 'Use legacy catalog pages', 'booking' ),
1212 + 'description' => $description,
1213 + 'options' => array(
1214 + 'new' => __( 'No — use the new catalogs', 'booking' ),
1215 + 'legacy' => __( 'Yes — use legacy catalog pages (Deprecated)', 'booking' ),
1216 + ),
1217 + 'group' => 'advanced',
1218 + 'disabled' => ! $is_pro_compatible,
1219 + );
1220 +
1221 + if ( ! $is_pro_compatible ) {
1222 + $this->fields['booking_resources_catalog_renderer']['value'] = 'legacy';
1223 + }
1224 + }
1225 +
1226 +
1227 + $this->fields = apply_filters( 'wpbc_settings_edit_url_hash', $this->fields, $default_options_values );
1182 1228 // FixIn: 10.10.1.2 $this->fields = apply_filters( 'wpbc_settings_resource_no_update__during_editing', $this->fields, $default_options_values );
1183 1229
1184 1230 // Show advanced settings of JavaScript loading
1185 1231
@@ -1972,12 +2018,61 @@
1972 2018 } ); ";
1973 2019
1974 2020
1975 2021 // Enqueue JS to the footer of the page
1976 - wpbc_enqueue_js( $js_script );
1977 - }
1978 -
1979 -}
2022 + wpbc_enqueue_js( $js_script );
2023 + }
2024 +
2025 + /**
2026 + * Validate the temporary shared 11.6 catalog renderer preference.
2027 + *
2028 + * The General Settings form verifies its nonce before invoking the Settings
2029 + * API. This field adds an explicit capability boundary and allow list. When
2030 + * compatibility forces disabled legacy views, the existing Resources-named
2031 + * storage key is preserved instead of being overwritten by a derived value.
2032 + *
2033 + * @param string $post_key Full Settings API POST key.
2034 + *
2035 + * @return string Allow-listed stored renderer preference.
2036 + */
2037 + public function validate_booking_resources_catalog_renderer_post( $post_key ) {
2038 + $stored_renderer = wpbc_booking_resources_catalog_get_stored_renderer();
2039 +
2040 + if ( ! wpbc_booking_resources_catalog_can_manage_settings() || ! wpbc_booking_resources_catalog_is_pro_compatible() ) {
2041 + return $stored_renderer;
2042 + }
2043 +
2044 + $submitted_renderer = self::validate_select_post_static( $post_key );
2045 + if ( ! is_string( $submitted_renderer ) || ! in_array( $submitted_renderer, array( 'new', 'legacy' ), true ) ) {
2046 + return $stored_renderer;
2047 + }
2048 +
2049 + return $submitted_renderer;
2050 + }
2051 +
2052 + /**
2053 + * Validate the administrator edit-booking destination.
2054 + *
2055 + * The General Settings page owns nonce and capability checks. This method
2056 + * adds an explicit allow list and preserves the current normalized setting
2057 + * when a malformed value is submitted.
2058 + *
2059 + * @param string $post_key Full Settings API POST key.
2060 + *
2061 + * @return string Allow-listed edit destination.
2062 + */
2063 + public function validate_booking_admin_edit_booking_mode_post( $post_key ) {
2064 + $stored_mode = wpbc_get_booking_admin_edit_mode();
2065 + $submitted_mode = self::validate_select_post_static( $post_key );
2066 +
2067 + if ( ! is_string( $submitted_mode ) || ! in_array( $submitted_mode, array( 'popup', 'add_booking_page' ), true ) ) {
2068 + return $stored_mode;
2069 + }
2070 +
2071 + return $submitted_mode;
2072 + }
2073 +
2074 +}
1980 2075
1981 2076
1982 2077 /**
1983 2078 * Override VALIDATED fields BEFORE saving to DB