PluginProbe
Booking Calendar / 11.9
Booking Calendar v11.9
11.9 11.8.4 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 All 205 releases
← All changes | includes/page-settings-calendar/settings_calendar__page.php +77 -28 11.3 → 11.9 View file →
@@ -1,4 +1,4 @@
1 1 <?php
2 2 /**
3 3 * Calendar settings page.
4 4 *
@@ -101,9 +101,9 @@
101 101 'saved' => __( 'Calendar settings updated.', 'booking' ),
102 102 'save_failed' => __( 'Unable to save calendar settings.', 'booking' ),
103 103 'preview_failed' => __( 'Unable to refresh calendar preview.', 'booking' ),
104 104 'loading' => __( 'Loading', 'booking' ),
105 - 'premium_notice' => __( 'Range days selection is available in Booking Calendar Business Small or higher. Open the live demo to test the real behavior.', 'booking' ),
105 + 'premium_notice' => __( 'Advanced range rules are available in Booking Calendar Business Small or higher. Open the live demo to test the real behavior.', 'booking' ),
106 106 'premium_changeover_notice' => __( 'Changeover days are available in Booking Calendar Business Small or higher. Open the live demo to test the real behavior.', 'booking' ),
107 107 'premium_option_notice' => __( 'This option is available in Booking Calendar Business Small or higher.', 'booking' ),
108 108 ),
109 109 'is_range_supported' => wpbc_settings_calendar__is_range_supported() ? 1 : 0,
@@ -129,9 +129,9 @@
129 129 }
130 130 add_action( 'admin_footer', 'wpbc_settings_calendar_print_tooltip_js', 67 );
131 131
132 132 /**
133 - * Check whether current edition supports range/change-over calendar settings.
133 + * Check whether current edition supports advanced range rules and change-over settings.
134 134 *
135 135 * @return bool
136 136 */
137 137 function wpbc_settings_calendar__is_range_supported() {
@@ -139,8 +139,24 @@
139 139 return class_exists( 'wpdev_bk_biz_s' );
140 140 }
141 141
142 142 /**
143 + * Get the main Range days option title for the current edition.
144 + *
145 + * Free and Personal expose only the unrestricted two-click range. Business
146 + * Small and higher select one-click or two-click behavior in the subtype
147 + * controls shown below the main option.
148 + *
149 + * @return string
150 + */
151 +function wpbc_settings_calendar__get_range_days_title() {
152 +
153 + return wpbc_settings_calendar__is_range_supported()
154 + ? __( 'Range days', 'booking' )
155 + : __( 'Range days - 2 mouse clicks', 'booking' );
156 +}
157 +
158 +/**
143 159 * Calendar settings right-sidebar section navigation.
144 160 *
145 161 * @return array
146 162 */
@@ -547,8 +563,26 @@
547 563 return empty( $cleaned ) ? '-1' : implode( ',', $cleaned );
548 564 }
549 565
550 566 /**
567 + * Normalize the fixed one-click range length.
568 + *
569 + * Existing installations may not have this option yet. Keep explicitly
570 + * configured values, including one day, but use three days when it is empty
571 + * or invalid.
572 + *
573 + * @param mixed $value Fixed range day count.
574 + *
575 + * @return int
576 + */
577 +function wpbc_settings_calendar__normalize_fixed_range_days_count( $value ) {
578 +
579 + $days_count = absint( $value );
580 +
581 + return ( 0 < $days_count ) ? min( 180, $days_count ) : 3;
582 +}
583 +
584 +/**
551 585 * Get settings response.
552 586 *
553 587 * @return array
554 588 */
@@ -559,9 +593,9 @@
559 593 'booking_start_day_weeek' => (string) get_bk_option( 'booking_start_day_weeek' ),
560 594 'booking_calendar_allow_several_months_on_mobile' => (string) get_bk_option( 'booking_calendar_allow_several_months_on_mobile' ),
561 595 'booking_type_of_day_selections' => (string) get_bk_option( 'booking_type_of_day_selections' ),
562 596 'booking_range_selection_type' => (string) get_bk_option( 'booking_range_selection_type' ),
563 - 'booking_range_selection_days_count' => (string) get_bk_option( 'booking_range_selection_days_count' ),
597 + 'booking_range_selection_days_count' => (string) wpbc_settings_calendar__normalize_fixed_range_days_count( get_bk_option( 'booking_range_selection_days_count' ) ),
564 598 'booking_range_start_day' => wpbc_settings_calendar__normalize_week_days( get_bk_option( 'booking_range_start_day' ) ),
565 599 'booking_range_selection_days_count_dynamic' => (string) get_bk_option( 'booking_range_selection_days_count_dynamic' ),
566 600 'booking_range_selection_days_max_count_dynamic' => (string) get_bk_option( 'booking_range_selection_days_max_count_dynamic' ),
567 601 'booking_range_selection_days_specific_num_dynamic' => (string) get_bk_option( 'booking_range_selection_days_specific_num_dynamic' ),
@@ -621,10 +655,12 @@
621 655 ? wpbc_get_specific_range_dates__as_comma_list( $current['booking_range_selection_days_specific_num_dynamic'] )
622 656 : $current['booking_range_selection_days_specific_num_dynamic'];
623 657
624 658 return array(
625 - 'days_select_mode' => ( 'range' === $current['booking_type_of_day_selections'] ) ? $current['booking_range_selection_type'] : $current['booking_type_of_day_selections'],
626 - 'fixed__days_num' => max( 1, absint( $current['booking_range_selection_days_count'] ) ),
659 + 'days_select_mode' => ( 'range' === $current['booking_type_of_day_selections'] )
660 + ? ( wpbc_settings_calendar__is_range_supported() ? $current['booking_range_selection_type'] : 'dynamic' )
661 + : $current['booking_type_of_day_selections'],
662 + 'fixed__days_num' => wpbc_settings_calendar__normalize_fixed_range_days_count( $current['booking_range_selection_days_count'] ),
627 663 'fixed__week_days__start' => wpbc_settings_calendar__normalize_week_days( $current['booking_range_start_day'] ),
628 664 'dynamic__days_min' => max( 1, absint( $current['booking_range_selection_days_count_dynamic'] ) ),
629 665 'dynamic__days_max' => max( 1, absint( $current['booking_range_selection_days_max_count_dynamic'] ) ),
630 666 'dynamic__days_specific' => (string) $specific_days,
@@ -773,18 +809,26 @@
773 809 * @param array $request_params Calendar-load request params.
774 810 *
775 811 * @return bool
776 812 */
777 -function wpbc_settings_calendar__is_calendar_load_preview_request_allowed( $request_params ) {
813 +function wpbc_settings_calendar__is_calendar_load_preview_request_allowed( $request_params ) {
814 +
815 + $is_settings_preview_allowed = (
816 + ! empty( $request_params['wpbc_settings_calendar_preview'] )
817 + && function_exists( 'wpbc_is_mu_user_can_be_here' )
818 + && wpbc_is_mu_user_can_be_here( 'only_super_admin' )
819 + && current_user_can( wpbc_settings_calendar__get_manage_cap() )
820 + );
821 + if ( $is_settings_preview_allowed ) {
822 + return true;
823 + }
824 +
825 + return (
826 + class_exists( 'WPBC_Setup_Wizard_Date_Selection' )
827 + && WPBC_Setup_Wizard_Date_Selection::is_calendar_preview_request_allowed( (array) $request_params )
828 + );
829 +}
778 830
779 - return (
780 - ! empty( $request_params['wpbc_settings_calendar_preview'] )
781 - && function_exists( 'wpbc_is_mu_user_can_be_here' )
782 - && wpbc_is_mu_user_can_be_here( 'only_super_admin' )
783 - && current_user_can( wpbc_settings_calendar__get_manage_cap() )
784 - );
785 -}
786 -
787 831 /**
788 832 * Get option overrides from Calendar Settings calendar-load AJAX request.
789 833 *
790 834 * @param array $request_params Calendar-load request params.
@@ -948,9 +992,9 @@
948 992
949 993 $range_type = isset( $post_data['booking_range_selection_type'] ) ? sanitize_key( wp_unslash( $post_data['booking_range_selection_type'] ) ) : $current['booking_range_selection_type'];
950 994 $cleaned['booking_range_selection_type'] = in_array( $range_type, array( 'fixed', 'dynamic' ), true ) ? $range_type : 'dynamic';
951 995
952 - $cleaned['booking_range_selection_days_count'] = (string) min( 180, max( 1, absint( isset( $post_data['booking_range_selection_days_count'] ) ? wp_unslash( $post_data['booking_range_selection_days_count'] ) : $current['booking_range_selection_days_count'] ) ) );
996 + $cleaned['booking_range_selection_days_count'] = (string) wpbc_settings_calendar__normalize_fixed_range_days_count( isset( $post_data['booking_range_selection_days_count'] ) ? wp_unslash( $post_data['booking_range_selection_days_count'] ) : $current['booking_range_selection_days_count'] );
953 997 $cleaned['booking_range_selection_days_count_dynamic'] = (string) min( 1095, max( 1, absint( isset( $post_data['booking_range_selection_days_count_dynamic'] ) ? wp_unslash( $post_data['booking_range_selection_days_count_dynamic'] ) : $current['booking_range_selection_days_count_dynamic'] ) ) );
954 998 $cleaned['booking_range_selection_days_max_count_dynamic'] = (string) min( 1095, max( 1, absint( isset( $post_data['booking_range_selection_days_max_count_dynamic'] ) ? wp_unslash( $post_data['booking_range_selection_days_max_count_dynamic'] ) : $current['booking_range_selection_days_max_count_dynamic'] ) ) );
955 999 if ( (int) $cleaned['booking_range_selection_days_max_count_dynamic'] < (int) $cleaned['booking_range_selection_days_count_dynamic'] ) {
956 1000 $cleaned['booking_range_selection_days_max_count_dynamic'] = $cleaned['booking_range_selection_days_count_dynamic'];
@@ -1082,15 +1126,18 @@
1082 1126 $free_keys[] = 'booking_legend_is_show_item_' . $legend_item;
1083 1127 $free_keys[] = 'booking_legend_text_for_item_' . $legend_item;
1084 1128 }
1085 1129
1130 + $previous_day_mode = (string) get_bk_option( 'booking_type_of_day_selections' );
1086 1131 foreach ( $free_keys as $key ) {
1087 - if ( 'booking_type_of_day_selections' === $key && ! $range_supported && 'range' === $cleaned_data[ $key ] ) {
1088 - continue;
1089 - }
1090 1132 update_bk_option( $key, $cleaned_data[ $key ] );
1091 1133 }
1092 1134
1135 + // Keep a newly selected Free range upgrade-safe: Business Small+ must continue with the same two-click subtype.
1136 + if ( ! $range_supported && 'range' === $cleaned_data['booking_type_of_day_selections'] && 'range' !== $previous_day_mode ) {
1137 + update_bk_option( 'booking_range_selection_type', 'dynamic' );
1138 + }
1139 +
1093 1140 if ( $range_supported ) {
1094 1141 foreach ( $premium_keys as $key ) {
1095 1142 update_bk_option( $key, $cleaned_data[ $key ] );
1096 1143 }
@@ -1240,9 +1287,9 @@
1240 1287 <?php
1241 1288 }
1242 1289
1243 1290 /**
1244 - * Render shared Business Small+ explanation for range/changeover locked controls.
1291 + * Render the Business Small+ explanation for advanced range controls.
1245 1292 *
1246 1293 * @return void
1247 1294 */
1248 1295 function wpbc_settings_calendar__render_range_upgrade_note() {
@@ -1249,10 +1296,10 @@
1249 1296
1250 1297 ?>
1251 1298 <div class="wpbc_calendar_premium_note" data-wpbc-calendar-range-upgrade-note="1">
1252 1299 <div>
1253 - <strong><?php esc_html_e( 'Range days selection', 'booking' ); ?></strong>
1254 - <p><?php esc_html_e( 'Visitors select a start and end date, with optional minimum and maximum range length and allowed start weekdays. This feature is available in Booking Calendar Business Small or higher.', 'booking' ); ?></p>
1300 + <strong><?php esc_html_e( 'Advanced range selection rules', 'booking' ); ?></strong>
1301 + <p><?php esc_html_e( 'Two-click range selection is included. Fixed one-click ranges, minimum and maximum lengths, specific permitted lengths, and allowed start weekdays are available in Booking Calendar Business Small or higher.', 'booking' ); ?></p>
1255 1302 </div>
1256 1303 <div class="wpbc_calendar_premium_note_actions">
1257 1304 <a class="button button-secondary" href="<?php echo esc_url( 'https://bm.wpbookingcalendar.com/' ); ?>" target="_blank"><?php esc_html_e( 'View live demo', 'booking' ); ?></a>
1258 1305 <a class="button button-primary" href="<?php echo esc_url( wpbc_settings_calendar__get_premium_url( 'Business Small+' ) ); ?>" target="_blank"><?php esc_html_e( 'Upgrade', 'booking' ); ?></a>
@@ -1588,11 +1635,11 @@
1588 1635 'is_show_top_path' => true,
1589 1636 'right_vertical_sidebar__is_show' => true,
1590 1637 'right_vertical_sidebar__default_view_mode' => '',
1591 1638 'right_vertical_sidebar_compact__is_show' => true,
1592 - 'left_navigation__default_view_mode' => 'compact',
1639 + 'left_navigation__default_view_mode' => '', // FixIn:11.7.1.1: 'compact',
1593 1640 'top_path_title' => __( 'Calendar', 'booking' ),
1594 - 'title' => __( 'Calendar', 'booking' ) . '<span class="wpbc_new_label" style="margin-left: auto;">' . esc_html__( 'New', 'booking' ) . '</span>&nbsp;&nbsp;',
1641 + 'title' => __( 'Calendar', 'booking' ), // . '<span class="wpbc_new_label" style="margin-left: auto;">' . esc_html__( 'New', 'booking' ) . '</span>&nbsp;&nbsp;',
1595 1642 'hint' => __( 'Preview and configure date selection, range selection, and change-over behavior.', 'booking' ),
1596 1643 'page_title' => __( 'Calendar Settings', 'booking' ),
1597 1644 'link' => '',
1598 1645 'position' => '',
@@ -1724,21 +1771,22 @@
1724 1771 'title' => __( 'Days Selection', 'booking' ),
1725 1772 'open' => ( '' === $open_section || 'days_selection' === $open_section ),
1726 1773 ),
1727 1774 function () use ( $settings, $is_premium_lock ) {
1728 - $selected_day_mode = ( $is_premium_lock && 'range' === $settings['booking_type_of_day_selections'] ) ? 'multiple' : $settings['booking_type_of_day_selections'];
1729 - $range_dismiss_id = wpbc_settings_calendar__get_premium_option_dismiss_id( 'booking_type_of_day_selections_range' );
1775 + $selected_day_mode = in_array( $settings['booking_type_of_day_selections'], array( 'single', 'multiple', 'range' ), true )
1776 + ? $settings['booking_type_of_day_selections']
1777 + : 'multiple';
1778 + $range_days_title = wpbc_settings_calendar__get_range_days_title();
1730 1779 ?>
1731 1780 <div class="wpbc_calendar_radio_stack" data-wpbc-calendar-days-mode="1">
1732 1781 <label><input type="radio" name="booking_type_of_day_selections" value="single" <?php checked( 'single', $selected_day_mode ); ?> /> <span><?php esc_html_e( 'Single day', 'booking' ); ?></span></label>
1733 1782 <label><input type="radio" name="booking_type_of_day_selections" value="multiple" <?php checked( 'multiple', $selected_day_mode ); ?> /> <span><?php esc_html_e( 'Multiple days', 'booking' ); ?></span></label>
1734 - <?php if ( ! $is_premium_lock || wpbc_settings_calendar__is_dismissed_visible( $range_dismiss_id ) ) : ?>
1735 - <label id="<?php echo esc_attr( $is_premium_lock ? $range_dismiss_id : '' ); ?>" class="<?php echo $is_premium_lock ? 'is-premium' : ''; ?>"><input type="radio" name="booking_type_of_day_selections" value="range" <?php checked( 'range', $selected_day_mode ); ?> <?php echo $is_premium_lock ? 'data-wpbc-calendar-premium="1" data-wpbc-calendar-premium-range-info="1"' : ''; ?> /> <span><?php esc_html_e( 'Range days', 'booking' ); ?></span> <?php $is_premium_lock && wpbc_settings_calendar__render_premium_label( 'Business Small+', '', $range_dismiss_id ); ?></label>
1736 - <?php endif; ?>
1783 + <label><input type="radio" name="booking_type_of_day_selections" value="range" <?php checked( 'range', $selected_day_mode ); ?> /> <span><?php echo esc_html( $range_days_title ); ?></span></label>
1737 1784 </div>
1738 1785 <?php if ( $is_premium_lock ) : ?>
1739 1786 <?php wpbc_settings_calendar__render_range_upgrade_note(); ?>
1740 1787 <?php endif; ?>
1788 + <?php if ( ! $is_premium_lock ) : ?>
1741 1789 <div class="wpbc_calendar_subsettings" data-wpbc-calendar-range-settings="1">
1742 1790 <div class="wpbc_calendar_radio_stack">
1743 1791 <label><input type="radio" name="booking_range_selection_type" value="fixed" <?php checked( 'fixed', $settings['booking_range_selection_type'] ); ?> /> <span><?php esc_html_e( 'Select a fixed number of days with 1 mouse click', 'booking' ); ?></span></label>
1744 1792 <label><input type="radio" name="booking_range_selection_type" value="dynamic" <?php checked( 'dynamic', $settings['booking_range_selection_type'] ); ?> /> <span><?php esc_html_e( 'Select a dynamic range of days with 2 mouse clicks', 'booking' ); ?></span></label>
@@ -1777,8 +1825,9 @@
1777 1825 <?php wpbc_settings_calendar__render_weekday_checks( 'booking_range_start_day_dynamic_weekdays', $settings['booking_range_start_day_dynamic'] ); ?>
1778 1826 </div>
1779 1827 </div>
1780 1828 </div>
1829 + <?php endif; ?>
1781 1830 <?php
1782 1831 }
1783 1832 );
1784 1833