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 +101 -93 11.4.3 → 11.9 View file →
@@ -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' => __( 'Advanced range rules are 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,34 +129,34 @@
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 advanced range rules and change-over settings.
133 + * Check whether current edition supports advanced range rules and change-over settings.
134 134 *
135 135 * @return bool
136 136 */
137 -function wpbc_settings_calendar__is_range_supported() {
138 -
139 - return class_exists( 'wpdev_bk_biz_s' );
140 -}
141 -
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 -}
137 +function wpbc_settings_calendar__is_range_supported() {
157 138
139 + return class_exists( 'wpdev_bk_biz_s' );
140 +}
141 +
158 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 +/**
159 159 * Calendar settings right-sidebar section navigation.
160 160 *
161 161 * @return array
162 162 */
@@ -537,9 +537,9 @@
537 537 * @param string|array $value Week days.
538 538 *
539 539 * @return string
540 540 */
541 -function wpbc_settings_calendar__normalize_week_days( $value ) {
541 +function wpbc_settings_calendar__normalize_week_days( $value ) {
542 542
543 543 if ( is_array( $value ) ) {
544 544 $items = $value;
545 545 } else {
@@ -559,30 +559,30 @@
559 559 }
560 560
561 561 $cleaned = array_values( array_unique( $cleaned ) );
562 562
563 - return empty( $cleaned ) ? '-1' : implode( ',', $cleaned );
564 -}
565 -
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 -}
563 + return empty( $cleaned ) ? '-1' : implode( ',', $cleaned );
564 +}
583 565
584 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 +/**
585 585 * Get settings response.
586 586 *
587 587 * @return array
588 588 */
@@ -593,9 +593,9 @@
593 593 'booking_start_day_weeek' => (string) get_bk_option( 'booking_start_day_weeek' ),
594 594 'booking_calendar_allow_several_months_on_mobile' => (string) get_bk_option( 'booking_calendar_allow_several_months_on_mobile' ),
595 595 'booking_type_of_day_selections' => (string) get_bk_option( 'booking_type_of_day_selections' ),
596 596 'booking_range_selection_type' => (string) get_bk_option( 'booking_range_selection_type' ),
597 - 'booking_range_selection_days_count' => (string) wpbc_settings_calendar__normalize_fixed_range_days_count( 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' ) ),
598 598 'booking_range_start_day' => wpbc_settings_calendar__normalize_week_days( get_bk_option( 'booking_range_start_day' ) ),
599 599 'booking_range_selection_days_count_dynamic' => (string) get_bk_option( 'booking_range_selection_days_count_dynamic' ),
600 600 'booking_range_selection_days_max_count_dynamic' => (string) get_bk_option( 'booking_range_selection_days_max_count_dynamic' ),
601 601 'booking_range_selection_days_specific_num_dynamic' => (string) get_bk_option( 'booking_range_selection_days_specific_num_dynamic' ),
@@ -655,12 +655,12 @@
655 655 ? wpbc_get_specific_range_dates__as_comma_list( $current['booking_range_selection_days_specific_num_dynamic'] )
656 656 : $current['booking_range_selection_days_specific_num_dynamic'];
657 657
658 658 return array(
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'] ),
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'] ),
663 663 'fixed__week_days__start' => wpbc_settings_calendar__normalize_week_days( $current['booking_range_start_day'] ),
664 664 'dynamic__days_min' => max( 1, absint( $current['booking_range_selection_days_count_dynamic'] ) ),
665 665 'dynamic__days_max' => max( 1, absint( $current['booking_range_selection_days_max_count_dynamic'] ) ),
666 666 'dynamic__days_specific' => (string) $specific_days,
@@ -809,18 +809,26 @@
809 809 * @param array $request_params Calendar-load request params.
810 810 *
811 811 * @return bool
812 812 */
813 -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 +}
814 830
815 - return (
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 -}
822 -
823 831 /**
824 832 * Get option overrides from Calendar Settings calendar-load AJAX request.
825 833 *
826 834 * @param array $request_params Calendar-load request params.
@@ -984,9 +992,9 @@
984 992
985 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'];
986 994 $cleaned['booking_range_selection_type'] = in_array( $range_type, array( 'fixed', 'dynamic' ), true ) ? $range_type : 'dynamic';
987 995
988 - $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'] );
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'] );
989 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'] ) ) );
990 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'] ) ) );
991 999 if ( (int) $cleaned['booking_range_selection_days_max_count_dynamic'] < (int) $cleaned['booking_range_selection_days_count_dynamic'] ) {
992 1000 $cleaned['booking_range_selection_days_max_count_dynamic'] = $cleaned['booking_range_selection_days_count_dynamic'];
@@ -1118,18 +1126,18 @@
1118 1126 $free_keys[] = 'booking_legend_is_show_item_' . $legend_item;
1119 1127 $free_keys[] = 'booking_legend_text_for_item_' . $legend_item;
1120 1128 }
1121 1129
1122 - $previous_day_mode = (string) get_bk_option( 'booking_type_of_day_selections' );
1123 - foreach ( $free_keys as $key ) {
1124 - update_bk_option( $key, $cleaned_data[ $key ] );
1125 - }
1126 -
1127 - // Keep a newly selected Free range upgrade-safe: Business Small+ must continue with the same two-click subtype.
1128 - if ( ! $range_supported && 'range' === $cleaned_data['booking_type_of_day_selections'] && 'range' !== $previous_day_mode ) {
1129 - update_bk_option( 'booking_range_selection_type', 'dynamic' );
1130 - }
1130 + $previous_day_mode = (string) get_bk_option( 'booking_type_of_day_selections' );
1131 + foreach ( $free_keys as $key ) {
1132 + update_bk_option( $key, $cleaned_data[ $key ] );
1133 + }
1131 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 +
1132 1140 if ( $range_supported ) {
1133 1141 foreach ( $premium_keys as $key ) {
1134 1142 update_bk_option( $key, $cleaned_data[ $key ] );
1135 1143 }
@@ -1279,9 +1287,9 @@
1279 1287 <?php
1280 1288 }
1281 1289
1282 1290 /**
1283 - * Render the Business Small+ explanation for advanced range controls.
1291 + * Render the Business Small+ explanation for advanced range controls.
1284 1292 *
1285 1293 * @return void
1286 1294 */
1287 1295 function wpbc_settings_calendar__render_range_upgrade_note() {
@@ -1288,10 +1296,10 @@
1288 1296
1289 1297 ?>
1290 1298 <div class="wpbc_calendar_premium_note" data-wpbc-calendar-range-upgrade-note="1">
1291 1299 <div>
1292 - <strong><?php esc_html_e( 'Advanced range selection rules', 'booking' ); ?></strong>
1293 - <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>
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>
1294 1302 </div>
1295 1303 <div class="wpbc_calendar_premium_note_actions">
1296 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>
1297 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>
@@ -1627,11 +1635,11 @@
1627 1635 'is_show_top_path' => true,
1628 1636 'right_vertical_sidebar__is_show' => true,
1629 1637 'right_vertical_sidebar__default_view_mode' => '',
1630 1638 'right_vertical_sidebar_compact__is_show' => true,
1631 - 'left_navigation__default_view_mode' => 'compact',
1639 + 'left_navigation__default_view_mode' => '', // FixIn:11.7.1.1: 'compact',
1632 1640 'top_path_title' => __( 'Calendar', 'booking' ),
1633 - '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;',
1634 1642 'hint' => __( 'Preview and configure date selection, range selection, and change-over behavior.', 'booking' ),
1635 1643 'page_title' => __( 'Calendar Settings', 'booking' ),
1636 1644 'link' => '',
1637 1645 'position' => '',
@@ -1761,25 +1769,25 @@
1761 1769 'id' => 'wpbc_calendar_days_selection_group',
1762 1770 'group' => 'settings-calendar-days-selection',
1763 1771 'title' => __( 'Days Selection', 'booking' ),
1764 1772 'open' => ( '' === $open_section || 'days_selection' === $open_section ),
1765 - ),
1766 - function () use ( $settings, $is_premium_lock ) {
1767 - $selected_day_mode = in_array( $settings['booking_type_of_day_selections'], array( 'single', 'multiple', 'range' ), true )
1768 - ? $settings['booking_type_of_day_selections']
1769 - : 'multiple';
1770 - $range_days_title = wpbc_settings_calendar__get_range_days_title();
1771 - ?>
1772 - <div class="wpbc_calendar_radio_stack" data-wpbc-calendar-days-mode="1">
1773 - <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>
1774 - <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>
1775 - <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>
1776 - </div>
1777 - <?php if ( $is_premium_lock ) : ?>
1778 - <?php wpbc_settings_calendar__render_range_upgrade_note(); ?>
1779 - <?php endif; ?>
1780 - <?php if ( ! $is_premium_lock ) : ?>
1781 - <div class="wpbc_calendar_subsettings" data-wpbc-calendar-range-settings="1">
1773 + ),
1774 + function () use ( $settings, $is_premium_lock ) {
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();
1779 + ?>
1780 + <div class="wpbc_calendar_radio_stack" data-wpbc-calendar-days-mode="1">
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>
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>
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>
1784 + </div>
1785 + <?php if ( $is_premium_lock ) : ?>
1786 + <?php wpbc_settings_calendar__render_range_upgrade_note(); ?>
1787 + <?php endif; ?>
1788 + <?php if ( ! $is_premium_lock ) : ?>
1789 + <div class="wpbc_calendar_subsettings" data-wpbc-calendar-range-settings="1">
1782 1790 <div class="wpbc_calendar_radio_stack">
1783 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>
1784 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>
1785 1793 </div>
@@ -1815,12 +1823,12 @@
1815 1823 <label><input type="radio" name="booking_range_start_day_dynamic_mode" value="-1" <?php checked( '-1', $settings['booking_range_start_day_dynamic'] ); ?> /> <?php esc_html_e( 'Any day of week', 'booking' ); ?></label>
1816 1824 <label><input type="radio" name="booking_range_start_day_dynamic_mode" value="specific" <?php checked( '-1' !== $settings['booking_range_start_day_dynamic'] ); ?> /> <?php esc_html_e( 'Specific day(s) of week', 'booking' ); ?></label>
1817 1825 <?php wpbc_settings_calendar__render_weekday_checks( 'booking_range_start_day_dynamic_weekdays', $settings['booking_range_start_day_dynamic'] ); ?>
1818 1826 </div>
1819 - </div>
1820 - </div>
1821 - <?php endif; ?>
1822 - <?php
1827 + </div>
1828 + </div>
1829 + <?php endif; ?>
1830 + <?php
1823 1831 }
1824 1832 );
1825 1833
1826 1834 WPBC_UI_Sidebar_Panels::render_collapsible_group(