'A', * 'label' => 'Week A', * 'slots' => array( * // 1..7 (Mon..Sun). Each is array of ranges: array( array( 'from' => '10:00', 'to' => '12:00' ), ... ) * '1' => array( array( 'from' => '10:00', 'to' => '12:00' ) ), * '2' => array(), * ... * '7' => array() * ), * ), * ... * ) * * @param array $packs Accumulated packs. * * @return array Modified packs with "time_slots" field included. */ function wpbc_bfb_register_field_packs__field_time_slots_wptpl( $packs ) { $default_profile_slots = array( '1' => array(), '2' => array(), '3' => array(), '4' => array(), '5' => array(), '6' => array(), '7' => array(), ); $packs['time_slots'] = array( 'kind' => 'field', 'type' => 'time_slots', 'label' => __( 'Time Slots', 'booking' ), 'icon' => 'wpbc_icn_schedule', 'usage_key' => 'time_slots', // Schema drives coercion/defaults/serialization. 'schema' => array( 'props' => array( 'label' => array( 'type' => 'string', 'default' => __( 'Time Slots', 'booking' ) ), 'name' => array( 'type' => 'string', 'default' => '' ), 'html_id' => array( 'type' => 'string', 'default' => '' ), 'required' => array( 'type' => 'boolean', 'default' => false ), 'cssclass' => array( 'type' => 'string', 'default' => '' ), 'help' => array( 'type' => 'string', 'default' => '' ), // Grid configuration. 'start_time' => array( 'type' => 'string', 'default' => '08:00' ), 'end_time' => array( 'type' => 'string', 'default' => '20:00' ), 'step_minutes' => array( 'type' => 'number', 'default' => 30, 'min' => 5, 'max' => 180 ), // Week cycle (profiles). 'week_cycle' => array( 'type' => 'number', 'default' => 1, 'min' => 1, 'max' => 6 ), 'profiles' => array( 'type' => 'array', 'default' => array( array( 'key' => 'A', 'label' => 'Week A', 'slots' => $default_profile_slots, ), ), ), // Appearance. 'min_width' => array( 'type' => 'string', 'default' => '320px' ), ), ), 'templates_printer' => 'wpbc_bfb_field_time_slots_wptpl_print_templates', ); return $packs; } add_filter( 'wpbc_bfb_register_field_packs', 'wpbc_bfb_register_field_packs__field_time_slots_wptpl' ); /** * Enqueue the Time Slots (WP-template) pack JS for the Builder page. * * @param string $page Current admin page slug (from core). * * @return void */ function wpbc_bfb_enqueue__field_time_slots_wptpl_js( $page ) { wp_enqueue_script( 'wpbc-bfb_field_time_slots_wptpl', wpbc_plugin_url( '/includes/page-form-builder/field-packs/time-grid/_out/time-grid-wptpl.js' ), array( 'wp-util', 'wpbc-bfb' ), WP_BK_VERSION_NUM, true ); } add_action( 'wpbc_enqueue_js_field_pack', 'wpbc_bfb_enqueue__field_time_slots_wptpl_js', 10, 1 ); /** * Print wp.template() blocks for the Time Slots field. * * Templates: * - Preview: compact visualization of defined slots per week profile. * - Inspector: full interactive grid editor (click/drag) + profile (week-cycle) control. * * @param string $page The current page slug (core passes the Builder slug here). * * @return void */ function wpbc_bfb_field_time_slots_wptpl_print_templates( $page ) { if ( WPBC_BFB_BUILDER_PAGE_SLUG !== $page ) { return; } ?> tag ID: * id="tmpl-wpbc-bfb-inspector-time-slots" * with the new one (underscore): * id="tmpl-wpbc-bfb-inspector-time_slots" * * File: /includes/page-form-builder/field-packs/time-slots/field-time-slots-wptpl.php */ ?>