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-form-builder/assets/template-records/bfb-activate-templates.php +105 -65 11.4.2 → 11.9 View file →
@@ -105,9 +105,9 @@
105 105 * - upsert = insert if missing, update existing row when seed_version increases.
106 106 *
107 107 * @return array
108 108 */
109 -function wpbc_bfb_activation__get_templates_registry() {
109 +function wpbc_bfb_activation__get_templates_registry() {
110 110
111 111 $templates = array();
112 112 $template_files = array(
113 113
@@ -136,37 +136,51 @@
136 136 wpbc_bfb_activation__get_templates_dir_path() . '/dates_form_with_calendar_next_to_form.php',
137 137 wpbc_bfb_activation__get_templates_dir_path() . '/dates_form_with_vertical_layout.php',
138 138 wpbc_bfb_activation__get_templates_dir_path() . '/dates_form_wizard_2_steps.php',
139 139
140 - // Hints
141 - wpbc_bfb_activation__get_templates_dir_path() . '/time_slots_20_min_3_steps_review_with_hints.php',
142 - wpbc_bfb_activation__get_templates_dir_path() . '/time_appointments_3_steps_review_with_hints.php',
140 +
141 + // Hints
142 + wpbc_bfb_activation__get_templates_dir_path() . '/time_slots_20_min_3_steps_review_with_hints.php',
143 + wpbc_bfb_activation__get_templates_dir_path() . '/time_appointments_3_steps_review_with_hints.php',
143 144 wpbc_bfb_activation__get_templates_dir_path() . '/dates_advanced_3_steps_review_with_hints.php',
144 145 wpbc_bfb_activation__get_templates_dir_path() . '/dates_2_columns_sidebar_hints.php',
145 -
146 - // Example future records:
146 +
147 + // Example future records:
147 148 // wpbc_bfb_activation__get_templates_dir_path() . '/template-contact-inquiry.php',
148 - // wpbc_bfb_activation__get_templates_dir_path() . '/template-event-registration.php',
149 - );
149 + // wpbc_bfb_activation__get_templates_dir_path() . '/template-event-registration.php',
150 + );
151 +
152 + // Keep private live-demo fixtures out of customer template libraries.
153 + if ( function_exists( 'wpbc_is_this_demo' ) && wpbc_is_this_demo() ) {
154 + $template_files = array_merge(
155 + $template_files,
156 + array(
157 + wpbc_bfb_activation__get_templates_dir_path() . '/demo_personal.php',
158 + wpbc_bfb_activation__get_templates_dir_path() . '/demo_business_small.php',
159 + wpbc_bfb_activation__get_templates_dir_path() . '/demo_business_medium.php',
160 + wpbc_bfb_activation__get_templates_dir_path() . '/demo_business_large.php',
161 + wpbc_bfb_activation__get_templates_dir_path() . '/demo_multiuser.php',
162 + wpbc_bfb_activation__get_templates_dir_path() . '/demo_multiuser_owner_1.php',
163 + wpbc_bfb_activation__get_templates_dir_path() . '/demo_multiuser_owner_2.php',
164 + wpbc_bfb_activation__get_templates_dir_path() . '/demo_multiuser_owner_3.php',
165 + )
166 + );
167 + }
168 +
169 + /*
170 + * Template cards are listed newest-first, with the row ID as the final
171 + * tie-breaker. Append preferred templates in increasing display priority.
172 + * The last bundled template seeded is therefore the first library card after
173 + * activation. The insert-only records below never overwrite installed rows.
174 + */
175 + $template_files[] = wpbc_bfb_activation__get_templates_dir_path() . '/appointments_services_flow.php';
176 + $template_files[] = wpbc_bfb_activation__get_templates_dir_path() . '/appointments_services_selection_summary.php';
177 + $template_files[] = wpbc_bfb_activation__get_templates_dir_path() . '/dates_form_with_inline_hints.php';
178 + $template_files[] = wpbc_bfb_activation__get_templates_dir_path() . '/dates_vertical_hints_full_days.php';
179 + $template_files[] = wpbc_bfb_activation__get_templates_dir_path() . '/dates_2_columns_hints_full_days.php';
180 + $template_files[] = wpbc_bfb_activation__get_templates_dir_path() . '/time_slots_2_columns_hints.php';
150 181
151 - // Keep private live-demo fixtures out of customer template libraries.
152 - if ( function_exists( 'wpbc_is_this_demo' ) && wpbc_is_this_demo() ) {
153 - $template_files = array_merge(
154 - $template_files,
155 - array(
156 - wpbc_bfb_activation__get_templates_dir_path() . '/demo_personal.php',
157 - wpbc_bfb_activation__get_templates_dir_path() . '/demo_business_small.php',
158 - wpbc_bfb_activation__get_templates_dir_path() . '/demo_business_medium.php',
159 - wpbc_bfb_activation__get_templates_dir_path() . '/demo_business_large.php',
160 - wpbc_bfb_activation__get_templates_dir_path() . '/demo_multiuser.php',
161 - wpbc_bfb_activation__get_templates_dir_path() . '/demo_multiuser_owner_1.php',
162 - wpbc_bfb_activation__get_templates_dir_path() . '/demo_multiuser_owner_2.php',
163 - wpbc_bfb_activation__get_templates_dir_path() . '/demo_multiuser_owner_3.php',
164 - )
165 - );
166 - }
167 -
168 - foreach ( $template_files as $template_file ) {
182 + foreach ( $template_files as $template_file ) {
169 183 if ( file_exists( $template_file ) ) {
170 184 $template_config = require $template_file;
171 185
172 186 if ( is_array( $template_config ) ) {
@@ -183,52 +197,78 @@
183 197 return $templates;
184 198 }
185 199
186 200 /**
187 - * Add default form appearance settings to bundled template settings_json.
201 + * Keep the replacement Appointment template adjacent to its legacy predecessor.
188 202 *
189 - * Individual templates can override any key in their own settings_json; this only fills missing values.
203 + * The shared list endpoint owns the neutral ordering mechanic. This domain
204 + * registration supplies only the two stable template slugs and does not change
205 + * either insert-only row or its saved timestamp.
190 206 *
191 - * @param string $settings_json Template settings JSON.
207 + * @param array $adjacencies Registered template-library adjacency pairs.
192 208 *
193 - * @return string
209 + * @return array Filtered adjacency pairs.
194 210 */
195 -function wpbc_bfb_activation__add_default_form_appearance_settings( $settings_json ) {
211 +function wpbc_bfb_activation__register_template_library_adjacencies( $adjacencies ) {
196 212
197 - $settings = array();
198 - if ( is_string( $settings_json ) && '' !== trim( $settings_json ) ) {
199 - $decoded = json_decode( (string) $settings_json, true );
200 - if ( is_array( $decoded ) ) {
201 - $settings = $decoded;
202 - }
213 + if ( ! is_array( $adjacencies ) ) {
214 + $adjacencies = array();
203 215 }
204 216
205 - if ( empty( $settings['options'] ) || ! is_array( $settings['options'] ) ) {
206 - $settings['options'] = array();
207 - }
217 + $adjacencies[] = array(
218 + 'before' => 'appointments_services_selection_summary',
219 + 'after' => 'appointments_services_flow',
220 + );
208 221
209 - if ( function_exists( 'wpbc_bfb_settings__strip_form_style_options_from_form_settings' ) ) {
210 - $settings = wpbc_bfb_settings__strip_form_style_options_from_form_settings( $settings );
211 - }
212 -
213 - if ( empty( $settings['css_vars'] ) || ! is_array( $settings['css_vars'] ) ) {
214 - $settings['css_vars'] = array();
215 - }
216 -
217 - if ( empty( $settings['bfb_options'] ) || ! is_array( $settings['bfb_options'] ) ) {
218 - $settings['bfb_options'] = array( 'advanced_mode_source' => 'builder' );
219 - }
220 -
221 - return function_exists( 'wpbc_form_config__encode_json' )
222 - ? wpbc_form_config__encode_json( $settings )
223 - : wp_json_encode( $settings );
222 + return $adjacencies;
224 223 }
224 +add_filter( 'wpbc_bfb_template_library_adjacencies', 'wpbc_bfb_activation__register_template_library_adjacencies' );
225 225
226 226 /**
227 - * Normalize bundled template config.
228 - *
229 - * @param array $template_config Raw template config.
227 + * Add default form appearance settings to bundled template settings_json.
230 228 *
229 + * Individual templates can override any key in their own settings_json; this only fills missing values.
230 + *
231 + * @param string $settings_json Template settings JSON.
232 + *
233 + * @return string
234 + */
235 +function wpbc_bfb_activation__add_default_form_appearance_settings( $settings_json ) {
236 +
237 + $settings = array();
238 + if ( is_string( $settings_json ) && '' !== trim( $settings_json ) ) {
239 + $decoded = json_decode( (string) $settings_json, true );
240 + if ( is_array( $decoded ) ) {
241 + $settings = $decoded;
242 + }
243 + }
244 +
245 + if ( empty( $settings['options'] ) || ! is_array( $settings['options'] ) ) {
246 + $settings['options'] = array();
247 + }
248 +
249 + if ( function_exists( 'wpbc_bfb_settings__strip_form_style_options_from_form_settings' ) ) {
250 + $settings = wpbc_bfb_settings__strip_form_style_options_from_form_settings( $settings );
251 + }
252 +
253 + if ( empty( $settings['css_vars'] ) || ! is_array( $settings['css_vars'] ) ) {
254 + $settings['css_vars'] = array();
255 + }
256 +
257 + if ( empty( $settings['bfb_options'] ) || ! is_array( $settings['bfb_options'] ) ) {
258 + $settings['bfb_options'] = array( 'advanced_mode_source' => 'builder' );
259 + }
260 +
261 + return function_exists( 'wpbc_form_config__encode_json' )
262 + ? wpbc_form_config__encode_json( $settings )
263 + : wp_json_encode( $settings );
264 +}
265 +
266 +/**
267 + * Normalize bundled template config.
268 + *
269 + * @param array $template_config Raw template config.
270 + *
231 271 * @return array
232 272 */
233 273 function wpbc_bfb_activation__normalize_template_config( $template_config ) {
234 274
@@ -276,15 +316,15 @@
276 316 $template_config['record']['is_default'] = (int) $template_config['record']['is_default'];
277 317 $template_config['record']['engine'] = (string) $template_config['record']['engine'];
278 318 $template_config['record']['engine_version'] = (string) $template_config['record']['engine_version'];
279 319 $template_config['record']['title'] = (string) $template_config['record']['title'];
280 - $template_config['record']['description'] = (string) $template_config['record']['description'];
281 - $template_config['record']['picture_url'] = (string) $template_config['record']['picture_url'];
282 - $template_config['record']['settings_json'] = wpbc_bfb_activation__add_default_form_appearance_settings( (string) $template_config['record']['settings_json'] );
283 -
284 - if ( null !== $template_config['record']['booking_resource_id'] ) {
285 - $template_config['record']['booking_resource_id'] = (int) $template_config['record']['booking_resource_id'];
286 - }
320 + $template_config['record']['description'] = (string) $template_config['record']['description'];
321 + $template_config['record']['picture_url'] = (string) $template_config['record']['picture_url'];
322 + $template_config['record']['settings_json'] = wpbc_bfb_activation__add_default_form_appearance_settings( (string) $template_config['record']['settings_json'] );
323 +
324 + if ( null !== $template_config['record']['booking_resource_id'] ) {
325 + $template_config['record']['booking_resource_id'] = (int) $template_config['record']['booking_resource_id'];
326 + }
287 327
288 328 return $template_config;
289 329 }
290 330