PluginProbe
Booking Calendar / 11.8.3
Booking Calendar v11.8.3
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 10.11 All 204 releases
← All changes | includes/page-setup/setup_steps.php +323 -218 11.511.8.3 View file →
@@ -41,12 +41,31 @@
41 41 * Whether the setup bar has already been printed in the current request.
42 42 *
43 43 * @var bool
44 44 */
45 - private static $is_top_bar_rendered = false;
45 + private static $is_top_bar_rendered = false;
46 +
47 + /**
48 + * Check whether the legacy floating Setup Wizard bar is enabled.
49 + *
50 + * The bar is temporarily disabled while the initial Setup Wizard hands the
51 + * user directly to Form Builder. The filter preserves a bounded rollback
52 + * path without changing Setup Wizard progress or stored configuration.
53 + *
54 + * @return bool True when the floating Setup Wizard bar may be registered.
55 + */
56 + private static function is_floating_setup_bar_enabled() {
57 +
58 + /**
59 + * Filter whether the legacy floating Setup Wizard bar is enabled.
60 + *
61 + * @param bool $is_enabled Whether the floating Setup Wizard bar is enabled.
62 + */
63 + return (bool) apply_filters( 'wpbc_setup_wizard_floating_bar_enabled', false );
64 + }
65 +
66 + public function __construct() {
46 67
47 - public function __construct() {
48 -
49 68 if ( WPBC()->is_wp_inited() || did_action( 'init' ) ) {
50 69 $this->init_steps_data();
51 70 } else {
52 71 add_action( 'init', array( $this, 'init_steps_data' ) );
@@ -51,12 +70,12 @@
51 70 } else {
52 71 add_action( 'init', array( $this, 'init_steps_data' ) );
53 72 }
54 73
55 - if ( ! self::$is_top_bar_hook_registered ) {
56 - add_action( 'wpbc_after_wpbc_page_top__header_tabs', array( $this, 'show_top_right_wizard_button' ), 10, 3 );
57 - self::$is_top_bar_hook_registered = true;
58 - }
74 + if ( self::is_floating_setup_bar_enabled() && ! self::$is_top_bar_hook_registered ) {
75 + add_action( 'wpbc_after_wpbc_page_top__header_tabs', array( $this, 'show_top_right_wizard_button' ), 10, 3 );
76 + self::$is_top_bar_hook_registered = true;
77 + }
59 78
60 79 }
61 80
62 81 /**
@@ -111,19 +130,19 @@
111 130
112 131 if ( $is_i18n_ready && function_exists( 'wpbc_setup_wizard__get_step_route_metadata' ) ) {
113 132 $steps_arr[ $step_name ] = array_merge(
114 133 $steps_arr[ $step_name ],
115 - wpbc_setup_wizard__get_step_route_metadata( $step_name )
116 - );
117 - }
118 - }
119 -
120 - foreach ( array( 'service_provider', 'date_selection', 'changeover_days', 'working_time', 'time_slots_availability', 'date_availability', 'form_structure', 'color_theme', 'wizard_publish' ) as $continue_step_name ) {
121 - if ( isset( $steps_arr[ $continue_step_name ] ) ) {
122 - $steps_arr[ $continue_step_name ]['next_title'] = $is_i18n_ready ? __( 'Continue', 'booking' ) : 'Continue';
123 - }
124 - }
125 -
134 + wpbc_setup_wizard__get_step_route_metadata( $step_name )
135 + );
136 + }
137 + }
138 +
139 + foreach ( array( 'service_provider', 'date_selection', 'changeover_days', 'working_time', 'time_slots_availability', 'date_availability', 'form_structure', 'color_theme', 'wizard_publish' ) as $continue_step_name ) {
140 + if ( isset( $steps_arr[ $continue_step_name ] ) ) {
141 + $steps_arr[ $continue_step_name ]['next_title'] = $is_i18n_ready ? __( 'Continue', 'booking' ) : 'Continue';
142 + }
143 + }
144 +
126 145 $this->steps_arr = $steps_arr;
127 146 $this->is_steps_data_initialized = true;
128 147 }
129 148
@@ -812,16 +831,30 @@
812 831 *
813 832 * Show Continue Setup Wizard Button
814 833 * @return void
815 834 */
816 - public function show_top_right_wizard_button() {
835 + public function show_top_right_wizard_button() {
836 +
837 + if ( ! self::is_floating_setup_bar_enabled() ) {
838 + return false;
839 + }
840 +
841 + if ( ! wpbc_is_setup_wizard_page() ) {
842 + $explicit_step_context = false;
817 843
818 - if ( ! wpbc_is_setup_wizard_page() ){
844 + // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only Setup Wizard routing context.
845 + if ( isset( $_GET['wpbc_setup_step'] ) && is_scalar( $_GET['wpbc_setup_step'] ) ) {
846 + // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only Setup Wizard routing context.
847 + $request_step = sanitize_key( wp_unslash( $_GET['wpbc_setup_step'] ) );
848 + $explicit_step_context = isset( $this->steps_arr[ $request_step ] )
849 + && function_exists( 'wpbc_setup_wizard_page__has_explicit_step_context' )
850 + && wpbc_setup_wizard_page__has_explicit_step_context( $request_step );
851 + }
819 852
820 853 if (
821 854 ( ! wpbc_is_user_can_access_wizard_page() ) ||
822 - ( $this->db__is_all_steps_completed() )
823 - ){
855 + ( $this->db__is_all_steps_completed() && ! $explicit_step_context )
856 + ) {
824 857 return false;
825 858 }
826 859
827 860 if ( self::$is_top_bar_rendered ) {
@@ -837,26 +870,26 @@
837 870 $continue_url = $this->get_step_continue_url( $current_step );
838 871 if ( ! empty( $detected_page_step ) && isset( $this->steps_arr[ $detected_page_step ] ) ) {
839 872 $continue_url = add_query_arg( 'wpbc_setup_from_page_step', $detected_page_step, $continue_url );
840 873 }
841 - $prior_url = $this->get_step_prior_url( $current_step );
842 - $step_title = $this->get_step_title( $current_step );
843 - $step_heading = $this->get_step_heading( $current_step );
844 - $step_save_page_title = ( 'form_structure' === $current_step ) ? __( 'Form Builder', 'booking' ) : $step_title;
845 - $description = $this->get_step_description( $current_step );
846 - $save_behavior = $this->get_step_save_behavior( $current_step );
847 - $target_selector = $this->get_step_meta_value( $current_step, 'target_selector' );
848 - $scroll_selector = $this->get_step_meta_value( $current_step, 'scroll_selector' );
849 - $highlight_selector = $this->get_step_meta_value( $current_step, 'highlight_selector' );
850 - $highlight_disabled = $this->get_step_meta_value( $current_step, 'highlight_disabled' );
851 - $highlight_all = $this->get_step_meta_value( $current_step, 'highlight_all' );
874 + $prior_url = $this->get_step_prior_url( $current_step );
875 + $step_title = $this->get_step_title( $current_step );
876 + $step_heading = $this->get_step_heading( $current_step );
877 + $step_save_page_title = ( 'form_structure' === $current_step ) ? __( 'Form Builder', 'booking' ) : $step_title;
878 + $description = $this->get_step_description( $current_step );
879 + $save_behavior = $this->get_step_save_behavior( $current_step );
880 + $target_selector = $this->get_step_meta_value( $current_step, 'target_selector' );
881 + $scroll_selector = $this->get_step_meta_value( $current_step, 'scroll_selector' );
882 + $highlight_selector = $this->get_step_meta_value( $current_step, 'highlight_selector' );
883 + $highlight_disabled = $this->get_step_meta_value( $current_step, 'highlight_disabled' );
884 + $highlight_all = $this->get_step_meta_value( $current_step, 'highlight_all' );
852 885 $form_selector = $this->get_step_meta_value( $current_step, 'form_selector' );
853 886 $save_selector = $this->get_step_meta_value( $current_step, 'save_selector' );
854 887 $save_ajax_action = $this->get_step_meta_value( $current_step, 'save_ajax_action' );
855 - $save_events = $this->get_step_meta_value( $current_step, 'save_events' );
856 - $open_action = $this->get_step_meta_value( $current_step, 'open_action' );
857 - $secondary_action_url = $this->get_step_meta_value( $current_step, 'secondary_action_url' );
858 - $secondary_action_label = $this->get_step_meta_value( $current_step, 'secondary_action_label' );
888 + $save_events = $this->get_step_meta_value( $current_step, 'save_events' );
889 + $open_action = $this->get_step_meta_value( $current_step, 'open_action' );
890 + $secondary_action_url = $this->get_step_meta_value( $current_step, 'secondary_action_url' );
891 + $secondary_action_label = $this->get_step_meta_value( $current_step, 'secondary_action_label' );
859 892 $can_save_from_bar = ( 'manual_save_required' === $save_behavior && ! empty( $save_selector ) );
860 893 $continue_title = ( 'complete' === $save_behavior ) ? __( 'Finish Setup', 'booking' ) : __( 'Continue', 'booking' );
861 894 if ( $can_save_from_bar ) {
862 895 $continue_title = __( 'Save and Continue', 'booking' );
@@ -868,17 +901,17 @@
868 901 $mark_saved_nonce = wp_create_nonce( 'wpbc_setup_wizard_mark_step_saved' );
869 902 $step_target_url = $this->get_step_target_url( $current_step );
870 903 $skip_wizard_url = add_query_arg( 'wpbc_setup_wizard', 'completed', wpbc_get_bookings_url() );
871 904 $reset_wizard_url = add_query_arg( 'wpbc_setup_wizard', 'reset', wpbc_get_setup_wizard_page_url() );
872 - $save_required_note = sprintf(
905 + $save_required_note = sprintf(
873 906 /* translators: %s: setup target page title. */
874 907 __( 'Save changes on the %s page before continuing.', 'booking' ),
875 - '<a href="' . esc_url( $step_target_url ) . '">' . esc_html( $step_save_page_title ) . '</a>'
876 - );
877 - $test_page_links = (
878 - 'wizard_publish' === $current_step
879 - && function_exists( 'wpbc_booking_modes_get_setup_test_page_links' )
880 - ) ? wpbc_booking_modes_get_setup_test_page_links() : array();
908 + '<a href="' . esc_url( $step_target_url ) . '">' . esc_html( $step_save_page_title ) . '</a>'
909 + );
910 + $test_page_links = (
911 + 'wizard_publish' === $current_step
912 + && function_exists( 'wpbc_booking_modes_get_setup_test_page_links' )
913 + ) ? wpbc_booking_modes_get_setup_test_page_links() : array();
881 914
882 915 // FixIn: 10.12.1.1.
883 916 ?><style type="text/css">
884 917 @media screen and (max-width: 782px) {
@@ -999,61 +1032,61 @@
999 1032 color: #fff;
1000 1033 outline: none;
1001 1034 box-shadow: none;
1002 1035 }
1003 - .wpbc_setup_wizard_bar_drag_handle {
1004 - cursor: move;
1005 - }
1006 - .wpbc_page_top__wizard_button_actions {
1007 - display: flex;
1008 - flex-flow: row nowrap;
1009 - justify-content: flex-end;
1010 - align-items: center;
1011 - gap: 8px;
1012 - }
1013 - .wpbc_page_top__wizard_button_actions .button {
1014 - font-size: 11px;
1015 - min-height: 10px;
1016 - line-height: 1.8;
1017 - margin: 0;
1018 - }
1019 - .wpbc_page_top__wizard_button_actions .button.button-secondary {
1020 - background-color: #e4e4e4;
1021 - }
1022 - .wpbc_setup_wizard_test_page_actions {
1023 - display: flex;
1024 - flex-flow: row wrap;
1025 - align-items: center;
1026 - gap: 8px;
1027 - font-size: 11px;
1028 - font-weight: 400;
1029 - line-height: 1.35;
1030 - }
1031 - .wpbc_page_top__wizard_button[data-wpbc-setup-step="wizard_publish"] .wpbc_page_top__wizard_button_actions {
1032 - flex-flow: row wrap;
1033 - }
1034 - .wpbc_page_top__wizard_button_actions .button.wpbc_setup_wizard_test_page_button,
1035 - .wpbc_page_top__wizard_button_actions .button.wpbc_setup_wizard_test_page_button:hover,
1036 - .wpbc_page_top__wizard_button_actions .button.wpbc_setup_wizard_test_page_button:focus {
1037 - margin: 20px 0;
1038 - background: #71a501;
1039 - border-color: #71a501;
1040 - color: #f0ffce;
1041 - }
1042 - .wpbc_page_top__wizard_button_actions .button.wpbc_setup_wizard_test_page_button:first-child {
1043 - margin-right: auto;
1044 - margin-left: 0;
1045 - }
1046 - .wpbc_page_top__wizard_button[data-wpbc-setup-step="wizard_publish"] .wpbc_page_top__wizard_button_actions.wpbc_page_top__wizard_button_links {
1047 - margin: 0;
1048 - gap: 10px 15px;
1049 - justify-content: flex-start;
1050 - }
1051 - .wpbc_page_top__wizard_button_actions.wpbc_page_top__wizard_button_links .button.wpbc_setup_wizard_test_page_button:first-child,
1052 - .wpbc_page_top__wizard_button[data-wpbc-setup-step="wizard_publish"] .wpbc_page_top__wizard_button_actions.wpbc_page_top__wizard_button_links a {
1053 - margin: 0;
1054 - flex: 0 1 auto;
1055 - }
1036 + .wpbc_setup_wizard_bar_drag_handle {
1037 + cursor: move;
1038 + }
1039 + .wpbc_page_top__wizard_button_actions {
1040 + display: flex;
1041 + flex-flow: row nowrap;
1042 + justify-content: flex-end;
1043 + align-items: center;
1044 + gap: 8px;
1045 + }
1046 + .wpbc_page_top__wizard_button_actions .button {
1047 + font-size: 11px;
1048 + min-height: 10px;
1049 + line-height: 1.8;
1050 + margin: 0;
1051 + }
1052 + .wpbc_page_top__wizard_button_actions .button.button-secondary {
1053 + background-color: #e4e4e4;
1054 + }
1055 + .wpbc_setup_wizard_test_page_actions {
1056 + display: flex;
1057 + flex-flow: row wrap;
1058 + align-items: center;
1059 + gap: 8px;
1060 + font-size: 11px;
1061 + font-weight: 400;
1062 + line-height: 1.35;
1063 + }
1064 + .wpbc_page_top__wizard_button[data-wpbc-setup-step="wizard_publish"] .wpbc_page_top__wizard_button_actions {
1065 + flex-flow: row wrap;
1066 + }
1067 + .wpbc_page_top__wizard_button_actions .button.wpbc_setup_wizard_test_page_button,
1068 + .wpbc_page_top__wizard_button_actions .button.wpbc_setup_wizard_test_page_button:hover,
1069 + .wpbc_page_top__wizard_button_actions .button.wpbc_setup_wizard_test_page_button:focus {
1070 + margin: 20px 0;
1071 + background: #71a501;
1072 + border-color: #71a501;
1073 + color: #f0ffce;
1074 + }
1075 + .wpbc_page_top__wizard_button_actions .button.wpbc_setup_wizard_test_page_button:first-child {
1076 + margin-right: auto;
1077 + margin-left: 0;
1078 + }
1079 + .wpbc_page_top__wizard_button[data-wpbc-setup-step="wizard_publish"] .wpbc_page_top__wizard_button_actions.wpbc_page_top__wizard_button_links {
1080 + margin: 0;
1081 + gap: 10px 15px;
1082 + justify-content: flex-start;
1083 + }
1084 + .wpbc_page_top__wizard_button_actions.wpbc_page_top__wizard_button_links .button.wpbc_setup_wizard_test_page_button:first-child,
1085 + .wpbc_page_top__wizard_button[data-wpbc-setup-step="wizard_publish"] .wpbc_page_top__wizard_button_actions.wpbc_page_top__wizard_button_links a {
1086 + margin: 0;
1087 + flex: 0 1 auto;
1088 + }
1056 1089 .wpbc_page_top__wizard_button_actions .button.disabled,
1057 1090 .wpbc_page_top__wizard_button_actions .button[aria-disabled="true"] {
1058 1091 cursor: not-allowed;
1059 1092 opacity: 0.55;
@@ -1152,11 +1185,11 @@
1152 1185 data-wpbc-setup-ajax-url="<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>"
1153 1186 data-wpbc-setup-mark-saved-nonce="<?php echo esc_attr( $mark_saved_nonce ); ?>"
1154 1187 data-wpbc-setup-target-selector="<?php echo esc_attr( $target_selector ); ?>"
1155 1188 data-wpbc-setup-scroll-selector="<?php echo esc_attr( $scroll_selector ); ?>"
1156 - data-wpbc-setup-highlight-selector="<?php echo esc_attr( $highlight_selector ); ?>"
1157 - data-wpbc-setup-highlight-disabled="<?php echo esc_attr( $highlight_disabled ); ?>"
1158 - data-wpbc-setup-highlight-all="<?php echo esc_attr( $highlight_all ); ?>"
1189 + data-wpbc-setup-highlight-selector="<?php echo esc_attr( $highlight_selector ); ?>"
1190 + data-wpbc-setup-highlight-disabled="<?php echo esc_attr( $highlight_disabled ); ?>"
1191 + data-wpbc-setup-highlight-all="<?php echo esc_attr( $highlight_all ); ?>"
1159 1192 data-wpbc-setup-form-selector="<?php echo esc_attr( $form_selector ); ?>"
1160 1193 data-wpbc-setup-save-selector="<?php echo esc_attr( $save_selector ); ?>"
1161 1194 data-wpbc-setup-save-ajax-action="<?php echo esc_attr( $save_ajax_action ); ?>"
1162 1195 data-wpbc-setup-save-events="<?php echo esc_attr( $save_events ); ?>"
@@ -1184,9 +1217,9 @@
1184 1217 <button type="button"
1185 1218 class="wpbc_setup_wizard_bar_icon_button wpbc_setup_wizard_bar_reset_button"
1186 1219 title="<?php esc_attr_e( 'Reset setup bar position', 'booking' ); ?>"
1187 1220 aria-label="<?php esc_attr_e( 'Reset setup bar position', 'booking' ); ?>">
1188 - <i class="menu_icon icon-1x wpbc_icn_refresh"></i>
1221 + <i class="menu_icon icon-1x wpbc_icn_rotate_90 wpbc_icn_pin_invoke"></i>
1189 1222 </button>
1190 1223 <button type="button"
1191 1224 class="wpbc_setup_wizard_bar_icon_button wpbc_setup_wizard_bar_toggle_button"
1192 1225 title="<?php esc_attr_e( 'Collapse setup bar', 'booking' ); ?>"
@@ -1191,9 +1224,9 @@
1191 1224 class="wpbc_setup_wizard_bar_icon_button wpbc_setup_wizard_bar_toggle_button"
1192 1225 title="<?php esc_attr_e( 'Collapse setup bar', 'booking' ); ?>"
1193 1226 aria-label="<?php esc_attr_e( 'Collapse setup bar', 'booking' ); ?>"
1194 1227 aria-expanded="true">
1195 - <i class="menu_icon icon-1x wpbc_icn_expand_less"></i>
1228 + <i class="menu_icon icon-1x wpbc_icn_minimize"></i>
1196 1229 </button>
1197 1230 </div>
1198 1231 </div>
1199 1232 <div class="name_item wpbc_setup_wizard_bar_expandable" style="flex:1 1 100%;font-size:13px;font-weight:600;line-height:1.35;margin:3px 0 0;color:#f1f1f1;">
@@ -1216,9 +1249,9 @@
1216 1249 <div class="progress_line"
1217 1250 style="font-size: 6px;font-weight: 600;border-radius: 6px;word-wrap: normal;white-space: nowrap;background: #8ECE01;width: <?php echo esc_attr( $this->get_progess_value( $current_step ) ); ?>%;height: 3px;"></div>
1218 1251 </div>
1219 1252 </div>
1220 - <?php if ( 'manual_save_required' === $save_behavior ) { ?>
1253 + <?php if ( 'manual_save_required' === $save_behavior ) { ?>
1221 1254 <div class="wpbc_page_top__wizard_button_note wpbc_setup_wizard_bar_expandable<?php echo $is_step_saved ? ' wpbc_setup_wizard_bar_note_saved' : ''; ?>">
1222 1255 <?php
1223 1256 if ( $is_step_saved ) {
1224 1257 esc_html_e( 'Changes saved. You can continue.', 'booking' );
@@ -1225,42 +1258,42 @@
1225 1258 } else {
1226 1259 echo wp_kses_post( $save_required_note );
1227 1260 }
1228 1261 ?>
1229 - </div>
1230 - <?php } ?>
1231 - <?php if ( 'wizard_publish' === $current_step && empty( $test_page_links ) ) { ?>
1232 - <div class="wpbc_setup_wizard_test_page_actions wpbc_setup_wizard_bar_expandable">
1233 - <span><?php esc_html_e( 'No published booking page was found yet. Use QuickStart or the page publishing controls, then return to this step.', 'booking' ); ?></span>
1234 - </div>
1235 - <?php } ?>
1236 - <?php if ( 'wizard_publish' === $current_step && ! empty( $test_page_links ) ) { ?>
1237 - <div class="wpbc_page_top__wizard_button_actions wpbc_setup_wizard_bar_expandable wpbc_page_top__wizard_button_links">
1238 - <?php foreach ( $test_page_links as $test_page_link ) {
1239 - if ( empty( $test_page_link['url'] ) || empty( $test_page_link['label'] ) ) {
1240 - continue;
1241 - }
1242 - ?>
1243 - <a class="button button-primary secondary wpbc_setup_wizard_test_page_button"
1244 - href="<?php echo esc_url( $test_page_link['url'] ); ?>"
1245 - target="_blank"
1246 - rel="noopener noreferrer"><?php echo esc_html( $test_page_link['label'] ); ?></a>
1247 - <?php } ?>
1248 - </div>
1249 - <?php } ?>
1250 - <div class="wpbc_page_top__wizard_button_actions wpbc_setup_wizard_bar_expandable">
1251 - <?php if ( ! empty( $secondary_action_url ) && ! empty( $secondary_action_label ) ) { ?>
1252 - <a class="button button-secondary wpbc_setup_wizard_secondary_action"
1253 - href="<?php echo esc_url( $secondary_action_url ); ?>"><?php echo esc_html( $secondary_action_label ); ?></a>
1254 - <?php } ?>
1255 - <?php if ( ! empty( $prior_url ) ) { ?>
1256 - <a href="<?php echo esc_url( $prior_url ); ?>" class="button button-secondary"><?php esc_html_e( 'Back', 'booking' ); ?></a>
1257 - <?php } ?>
1258 - <a href="<?php echo esc_url( $continue_href ); ?>"
1259 - class="button button-primary wpbc_setup_wizard_continue_button<?php echo $is_continue_disabled ? ' disabled' : ''; ?>"
1260 - data-wpbc-setup-continue-url="<?php echo esc_url( $continue_url ); ?>"
1261 - <?php echo $is_continue_disabled ? 'aria-disabled="true"' : ''; ?>><?php echo esc_html( $continue_title ); ?></a>
1262 - </div>
1262 + </div>
1263 + <?php } ?>
1264 + <?php if ( 'wizard_publish' === $current_step && empty( $test_page_links ) ) { ?>
1265 + <div class="wpbc_setup_wizard_test_page_actions wpbc_setup_wizard_bar_expandable">
1266 + <span><?php esc_html_e( 'No published booking page was found yet. Use QuickStart or the page publishing controls, then return to this step.', 'booking' ); ?></span>
1267 + </div>
1268 + <?php } ?>
1269 + <?php if ( 'wizard_publish' === $current_step && ! empty( $test_page_links ) ) { ?>
1270 + <div class="wpbc_page_top__wizard_button_actions wpbc_setup_wizard_bar_expandable wpbc_page_top__wizard_button_links">
1271 + <?php foreach ( $test_page_links as $test_page_link ) {
1272 + if ( empty( $test_page_link['url'] ) || empty( $test_page_link['label'] ) ) {
1273 + continue;
1274 + }
1275 + ?>
1276 + <a class="button button-primary secondary wpbc_setup_wizard_test_page_button"
1277 + href="<?php echo esc_url( $test_page_link['url'] ); ?>"
1278 + target="_blank"
1279 + rel="noopener noreferrer"><?php echo esc_html( $test_page_link['label'] ); ?></a>
1280 + <?php } ?>
1281 + </div>
1282 + <?php } ?>
1283 + <div class="wpbc_page_top__wizard_button_actions wpbc_setup_wizard_bar_expandable">
1284 + <?php if ( ! empty( $secondary_action_url ) && ! empty( $secondary_action_label ) ) { ?>
1285 + <a class="button button-secondary wpbc_setup_wizard_secondary_action"
1286 + href="<?php echo esc_url( $secondary_action_url ); ?>"><?php echo esc_html( $secondary_action_label ); ?></a>
1287 + <?php } ?>
1288 + <?php if ( ! empty( $prior_url ) ) { ?>
1289 + <a href="<?php echo esc_url( $prior_url ); ?>" class="button button-secondary"><?php esc_html_e( 'Back', 'booking' ); ?></a>
1290 + <?php } ?>
1291 + <a href="<?php echo esc_url( $continue_href ); ?>"
1292 + class="button button-primary wpbc_setup_wizard_continue_button<?php echo $is_continue_disabled ? ' disabled' : ''; ?>"
1293 + data-wpbc-setup-continue-url="<?php echo esc_url( $continue_url ); ?>"
1294 + <?php echo $is_continue_disabled ? 'aria-disabled="true"' : ''; ?>><?php echo esc_html( $continue_title ); ?></a>
1295 + </div>
1263 1296 <div class="wpbc_page_top__wizard_button_links wpbc_setup_wizard_bar_expandable">
1264 1297 <a href="<?php echo esc_url( $skip_wizard_url ); ?>"
1265 1298 title="<?php esc_attr_e( 'Exit and skip the setup wizard', 'booking' ); ?>">
1266 1299 <?php esc_html_e( 'Exit and skip the setup wizard', 'booking' ); ?>
@@ -1280,11 +1313,11 @@
1280 1313 var step = $bar.attr( 'data-wpbc-setup-step' ) || '';
1281 1314 var saveBehavior = $bar.attr( 'data-wpbc-setup-save-behavior' ) || '';
1282 1315 var selector = $bar.attr( 'data-wpbc-setup-target-selector' ) || '';
1283 1316 var scrollSelector = $bar.attr( 'data-wpbc-setup-scroll-selector' ) || selector;
1284 - var highlightSelector = $bar.attr( 'data-wpbc-setup-highlight-selector' ) || selector;
1285 - var highlightDisabled = ( '1' === ( $bar.attr( 'data-wpbc-setup-highlight-disabled' ) || '' ) );
1286 - var highlightAll = ( '1' === ( $bar.attr( 'data-wpbc-setup-highlight-all' ) || '' ) );
1317 + var highlightSelector = $bar.attr( 'data-wpbc-setup-highlight-selector' ) || selector;
1318 + var highlightDisabled = ( '1' === ( $bar.attr( 'data-wpbc-setup-highlight-disabled' ) || '' ) );
1319 + var highlightAll = ( '1' === ( $bar.attr( 'data-wpbc-setup-highlight-all' ) || '' ) );
1287 1320 var formSelector = $bar.attr( 'data-wpbc-setup-form-selector' ) || '';
1288 1321 var saveSelector = $bar.attr( 'data-wpbc-setup-save-selector' ) || '';
1289 1322 var saveAjaxAction = $bar.attr( 'data-wpbc-setup-save-ajax-action' ) || '';
1290 1323 var saveEvents = ( $bar.attr( 'data-wpbc-setup-save-events' ) || '' ).split( ',' );
@@ -1305,10 +1338,10 @@
1305 1338 var positionStorageKey = 'wpbc_setup_wizard_bar_position';
1306 1339 var collapsedStorageKey = 'wpbc_setup_wizard_bar_collapsed';
1307 1340 var collapseLabel = <?php echo wp_json_encode( __( 'Collapse setup bar', 'booking' ) ); ?>;
1308 1341 var expandLabel = <?php echo wp_json_encode( __( 'Expand setup bar', 'booking' ) ); ?>;
1309 - var $target;
1310 - var $highlightTargets = jQuery();
1342 + var $target;
1343 + var $highlightTargets = jQuery();
1311 1344 var saveClicked = false;
1312 1345 var saveAndContinueRequested = false;
1313 1346 var saveAndContinueRedirecting = false;
1314 1347
@@ -1384,16 +1417,16 @@
1384 1417 '--wpbc-setup-bar-auto-top': ''
1385 1418 } );
1386 1419 }
1387 1420
1388 - function wpbcSetupWizardShouldUseTopDefault() {
1389 - return -1 !== jQuery.inArray( step, [
1390 - 'date_selection',
1391 - 'changeover_days',
1392 - 'working_time',
1393 - 'time_slots_availability',
1394 - 'date_availability'
1395 - ] );
1421 + function wpbcSetupWizardShouldUseTopDefault() {
1422 + return -1 !== jQuery.inArray( step, [
1423 + 'date_selection',
1424 + 'changeover_days',
1425 + 'working_time',
1426 + 'time_slots_availability',
1427 + 'date_availability'
1428 + ] );
1396 1429 }
1397 1430
1398 1431 function wpbcSetupWizardGetRightSidebarOffset() {
1399 1432 var viewportWidth = jQuery( window ).width();
@@ -1437,14 +1470,14 @@
1437 1470 wpbcSetupWizardApplyPosition( null );
1438 1471 return;
1439 1472 }
1440 1473
1441 - // Clear any visible inspector while retaining the minimum offset used by the Days Availability page.
1442 - rightOffset = wpbcSetupWizardGetRightSidebarOffset();
1443 - if ( 'date_availability' === step ) {
1444 - rightOffset = Math.max( rightOffset, 60 );
1445 - }
1446 - maxRight = Math.max( 15, jQuery( window ).width() - barWidth - 10 );
1474 + // Clear any visible inspector while retaining the minimum offset used by the Days Availability page.
1475 + rightOffset = wpbcSetupWizardGetRightSidebarOffset();
1476 + if ( 'date_availability' === step ) {
1477 + rightOffset = Math.max( rightOffset, 60 );
1478 + }
1479 + maxRight = Math.max( 15, jQuery( window ).width() - barWidth - 10 );
1447 1480
1448 1481 if ( wpbcSetupWizardShouldUseTopDefault() ) {
1449 1482 $bar
1450 1483 .removeClass( 'wpbc_setup_wizard_bar_is_moved' )
@@ -1482,38 +1515,38 @@
1482 1515 wpbcSetupWizardStorageSet( positionStorageKey, JSON.stringify( clampedPosition ) );
1483 1516 wpbcSetupWizardApplyPosition( clampedPosition );
1484 1517 }
1485 1518
1486 - function wpbcSetupWizardApplySavedPosition() {
1487 - var savedPosition = wpbcSetupWizardStorageGet( positionStorageKey );
1488 - var rightSidebarOffset;
1489 - var barRect;
1490 - var sidebarLeft;
1491 -
1492 - if ( ! savedPosition ) {
1493 - wpbcSetupWizardApplyDefaultPosition();
1494 - return;
1495 - }
1496 -
1497 - try {
1498 - wpbcSetupWizardApplyPosition( JSON.parse( savedPosition ) );
1499 - } catch ( _e ) {
1500 - wpbcSetupWizardStorageRemove( positionStorageKey );
1501 - wpbcSetupWizardApplyDefaultPosition();
1502 - return;
1503 - }
1504 -
1505 - rightSidebarOffset = wpbcSetupWizardGetRightSidebarOffset();
1506 - if ( 'service_provider' === step && rightSidebarOffset > 15 ) {
1507 - barRect = $bar[0].getBoundingClientRect();
1508 - sidebarLeft = jQuery( window ).width() - rightSidebarOffset + 15;
1509 -
1510 - if ( barRect.right > ( sidebarLeft - 10 ) ) {
1511 - wpbcSetupWizardApplyDefaultPosition();
1512 - }
1513 - }
1514 - }
1519 + function wpbcSetupWizardApplySavedPosition() {
1520 + var savedPosition = wpbcSetupWizardStorageGet( positionStorageKey );
1521 + var rightSidebarOffset;
1522 + var barRect;
1523 + var sidebarLeft;
1515 1524
1525 + if ( ! savedPosition ) {
1526 + wpbcSetupWizardApplyDefaultPosition();
1527 + return;
1528 + }
1529 +
1530 + try {
1531 + wpbcSetupWizardApplyPosition( JSON.parse( savedPosition ) );
1532 + } catch ( _e ) {
1533 + wpbcSetupWizardStorageRemove( positionStorageKey );
1534 + wpbcSetupWizardApplyDefaultPosition();
1535 + return;
1536 + }
1537 +
1538 + rightSidebarOffset = wpbcSetupWizardGetRightSidebarOffset();
1539 + if ( 'service_provider' === step && rightSidebarOffset > 15 ) {
1540 + barRect = $bar[0].getBoundingClientRect();
1541 + sidebarLeft = jQuery( window ).width() - rightSidebarOffset + 15;
1542 +
1543 + if ( barRect.right > ( sidebarLeft - 10 ) ) {
1544 + wpbcSetupWizardApplyDefaultPosition();
1545 + }
1546 + }
1547 + }
1548 +
1516 1549 function wpbcSetupWizardResetPosition() {
1517 1550 wpbcSetupWizardStorageRemove( positionStorageKey );
1518 1551 wpbcSetupWizardApplyDefaultPosition();
1519 1552 }
@@ -1524,10 +1557,10 @@
1524 1557 .attr( 'aria-expanded', isCollapsed ? 'false' : 'true' )
1525 1558 .attr( 'title', isCollapsed ? expandLabel : collapseLabel )
1526 1559 .attr( 'aria-label', isCollapsed ? expandLabel : collapseLabel );
1527 1560 $toggleIcon
1528 - .toggleClass( 'wpbc_icn_expand_less', ! isCollapsed )
1529 - .toggleClass( 'wpbc_icn_expand_more', !! isCollapsed );
1561 + .toggleClass( 'wpbc_icn_minimize', ! isCollapsed )
1562 + .toggleClass( 'wpbc_icn_fullscreen', !! isCollapsed );
1530 1563 wpbcSetupWizardStorageSet( collapsedStorageKey, isCollapsed ? '1' : '0' );
1531 1564 wpbcSetupWizardApplySavedPosition();
1532 1565 }
1533 1566
@@ -1579,15 +1612,19 @@
1579 1612 } );
1580 1613
1581 1614 wpbcSetupWizardSetCollapsed( '1' === wpbcSetupWizardStorageGet( collapsedStorageKey ) );
1582 1615 wpbcSetupWizardApplySavedPosition();
1583 - setTimeout( wpbcSetupWizardApplySavedPosition, 400 );
1584 - setTimeout( wpbcSetupWizardApplySavedPosition, 1000 );
1585 - jQuery( window ).on( 'resize.wpbc_setup_wizard_bar', wpbcSetupWizardApplySavedPosition );
1586 - jQuery( document ).on( 'wpbc_setup_wizard_layout_changed.wpbc_setup_wizard_bar', wpbcSetupWizardApplySavedPosition );
1616 + setTimeout( wpbcSetupWizardApplySavedPosition, 400 );
1617 + setTimeout( wpbcSetupWizardApplySavedPosition, 1000 );
1618 + jQuery( window ).on( 'resize.wpbc_setup_wizard_bar', wpbcSetupWizardApplySavedPosition );
1619 + jQuery( document ).on( 'wpbc_setup_wizard_layout_changed.wpbc_setup_wizard_bar', wpbcSetupWizardApplySavedPosition );
1587 1620
1588 1621 function wpbcSetupWizardOpenPublishArea() {
1589 - var isResourcesPage = -1 !== window.location.href.indexOf( 'page=wpbc-resources' );
1622 + var currentUrl = new window.URL( window.location.href );
1623 + var currentResourcesTab = currentUrl.searchParams.get( 'tab' ) || '';
1624 + var isResourcesPage = 'wpbc-resources' === currentUrl.searchParams.get( 'page' )
1625 + && ( '' === currentResourcesTab || 'resources' === currentResourcesTab );
1626 + var catalogMount = document.getElementById( 'wpbc_catalog_booking_resources' );
1590 1627 var publishTabSelectors = [
1591 1628 '.wpdvlp-sub-tabs .nav-tab',
1592 1629 '.wpdvlp-top-tabs .nav-tab',
1593 1630 '.wpbc_settings_navigation_item a',
@@ -1603,24 +1640,92 @@
1603 1640 '.wpbc_ajx_toolbar button',
1604 1641 'a.button',
1605 1642 'button.button'
1606 1643 ].join( ',' );
1607 - var publishTargetSelector = [
1608 - '.wpbc_resources_table .ui_group__publish_btn:visible',
1609 - '#wpbc_booking_resource_table .ui_group__publish_btn:visible',
1610 - '.wpbc_resource_field__switchable.wpbc_resource_field__publish:visible',
1611 - '.wpbc_resource_field__publish:visible',
1612 - '.wpbc_resource_publish:visible',
1613 - '.wpbc_publish_resources:visible',
1614 - '[data-wpbc-resource-publish]:visible'
1615 - ].join( ',' );
1644 + var publishTargetSelector = [
1645 + '.wpbc_resources_table .ui_group__publish_btn:visible',
1646 + '#wpbc_booking_resource_table .ui_group__publish_btn:visible',
1647 + '.wpbc_resource_field__switchable.wpbc_resource_field__publish:visible',
1648 + '.wpbc_resource_field__publish:visible',
1649 + '.wpbc_resource_publish:visible',
1650 + '.wpbc_publish_resources:visible',
1651 + '[data-wpbc-resource-publish]:visible'
1652 + ].join( ',' );
1616 1653 var $publishTab;
1617 1654 var $publishToggle;
1618 1655
1619 - if ( ( 'wizard_publish' !== step && 'publish_area' !== openAction ) || ! isResourcesPage ) {
1656 + if ( 'wizard_publish' !== step || ! isResourcesPage ) {
1620 1657 return;
1621 1658 }
1622 1659
1660 + if ( 'catalog_publish' === openAction && catalogMount ) {
1661 + var catalogPublishRequested = false;
1662 + /**
1663 + * Open the first authorized Resource at its publishing inspector section.
1664 + *
1665 + * @param {CustomEvent|null} renderEvent Shared catalog render event.
1666 + * @return {void}
1667 + */
1668 + var openCatalogPublishing = function( renderEvent ) {
1669 + var catalogResponse = renderEvent && renderEvent.detail ? renderEvent.detail.response : null;
1670 + var publishAction = catalogMount.querySelector( '[data-wpbc-booking-resource-action="publish_resource"][data-wpbc-booking-resource-id]' );
1671 + var resourceId = publishAction ? Number( publishAction.getAttribute( 'data-wpbc-booking-resource-id' ) || 0 ) : 0;
1672 +
1673 + if ( ! resourceId && catalogResponse && Array.isArray( catalogResponse.items ) ) {
1674 + catalogResponse.items.some( function( resource ) {
1675 + var isPublishAuthorized = Array.isArray( resource.action_items ) && resource.action_items.some( function( resourceAction ) {
1676 + return resourceAction && 'publish_resource' === resourceAction.id;
1677 + } );
1678 +
1679 + if ( ! isPublishAuthorized ) {
1680 + return false;
1681 + }
1682 +
1683 + resourceId = Number( resource.id || 0 );
1684 + return 0 < resourceId;
1685 + } );
1686 + }
1687 + if ( catalogPublishRequested || ! resourceId ) {
1688 + return;
1689 + }
1690 +
1691 + catalogPublishRequested = true;
1692 + catalogMount.removeEventListener( 'wpbc:ui-catalog-rendered', openCatalogPublishing );
1693 +
1694 + // Defer until the domain catalog has completed its synchronous mount listeners.
1695 + window.setTimeout( function() {
1696 + var resourceActionEvent;
1697 +
1698 + if ( 'function' === typeof window.CustomEvent ) {
1699 + resourceActionEvent = new window.CustomEvent( 'wpbc:booking-resource-action', {
1700 + bubbles: false,
1701 + detail: {
1702 + action: 'publish_resource',
1703 + resource_id: resourceId,
1704 + source: 'setup_wizard'
1705 + }
1706 + } );
1707 + } else {
1708 + resourceActionEvent = document.createEvent( 'CustomEvent' );
1709 + resourceActionEvent.initCustomEvent( 'wpbc:booking-resource-action', false, false, {
1710 + action: 'publish_resource',
1711 + resource_id: resourceId,
1712 + source: 'setup_wizard'
1713 + } );
1714 + }
1715 + document.dispatchEvent( resourceActionEvent );
1716 + }, 0 );
1717 + };
1718 +
1719 + catalogMount.addEventListener( 'wpbc:ui-catalog-rendered', openCatalogPublishing );
1720 + openCatalogPublishing( null );
1721 + return;
1722 + }
1723 +
1724 + if ( 'publish_area' !== openAction ) {
1725 + return;
1726 + }
1727 +
1623 1728 $publishTab = jQuery( publishTabSelectors ).filter( ':visible' ).filter( function() {
1624 1729 var $element = jQuery( this );
1625 1730 var text = $element.text() || '';
1626 1731 var href = $element.attr( 'href' ) || '';
@@ -2143,24 +2248,24 @@
2143 2248 if ( ! selector && ! scrollSelector && ! highlightSelector ) {
2144 2249 return;
2145 2250 }
2146 2251
2147 - if ( ! highlightDisabled && highlightAll ) {
2148 - try {
2149 - $highlightTargets = jQuery( highlightSelector || selector ).filter( ':visible' );
2150 - } catch ( _e ) {
2151 - $highlightTargets = jQuery();
2152 - }
2153 -
2154 - $highlightTargets.each( function() {
2155 - wpbcSetupWizardHighlightElement( jQuery( this ) );
2156 - } );
2157 - } else if ( ! highlightDisabled ) {
2158 - $highlightTargets = wpbcSetupWizardGetFirstElement( highlightSelector || selector );
2159 - wpbcSetupWizardHighlightElement( $highlightTargets );
2160 - }
2161 -
2162 - $target = $highlightTargets.first();
2252 + if ( ! highlightDisabled && highlightAll ) {
2253 + try {
2254 + $highlightTargets = jQuery( highlightSelector || selector ).filter( ':visible' );
2255 + } catch ( _e ) {
2256 + $highlightTargets = jQuery();
2257 + }
2258 +
2259 + $highlightTargets.each( function() {
2260 + wpbcSetupWizardHighlightElement( jQuery( this ) );
2261 + } );
2262 + } else if ( ! highlightDisabled ) {
2263 + $highlightTargets = wpbcSetupWizardGetFirstElement( highlightSelector || selector );
2264 + wpbcSetupWizardHighlightElement( $highlightTargets );
2265 + }
2266 +
2267 + $target = $highlightTargets.first();
2163 2268
2164 2269 setTimeout( function() {
2165 2270 var $scrollTarget = wpbcSetupWizardGetFirstElement( scrollSelector || ( highlightDisabled ? selector : highlightSelector ) || selector );
2166 2271 if ( ! $scrollTarget.length ) {