booking
/
includes
/
page-form-builder
/
field-packs
/
appointment-start-over
/
appointment-start-over.php
appointment-start-over.php in Booking Calendar 11.9, at includes/page-form-builder/field-packs/appointment-start-over/appointment-start-over.php
| 1 | <?php |
| 2 | /** |
| 3 | * WPBC BFB Pack: Appointment Start Over button. |
| 4 | * |
| 5 | * The exported control is declarative. The public Appointment controller owns |
| 6 | * its behavior and restarts only the closest [booking_appointment] instance. |
| 7 | * |
| 8 | * @package Booking Calendar |
| 9 | * @since 11.5.0 |
| 10 | */ |
| 11 | |
| 12 | if ( ! defined( 'ABSPATH' ) ) { |
| 13 | exit; |
| 14 | } |
| 15 | |
| 16 | /** |
| 17 | * Register the Appointment Start Over field schema and Inspector controls. |
| 18 | * |
| 19 | * @param array $packs Registered Builder field packs. |
| 20 | * |
| 21 | * @return array Updated field packs. |
| 22 | */ |
| 23 | function wpbc_bfb_register_field_packs__appointment_start_over( $packs ) { |
| 24 | $packs['appointment_start_over'] = array( |
| 25 | 'kind' => 'field', |
| 26 | 'type' => 'appointment_start_over', |
| 27 | 'label' => __( 'Start Over Button', 'booking' ), |
| 28 | 'icon' => 'wpbc-bi-arrow-counterclockwise', |
| 29 | 'usage_key' => 'appointment_start_over', |
| 30 | 'schema' => array( |
| 31 | 'props' => array( |
| 32 | 'label' => array( 'type' => 'string', 'default' => __( 'Start over', 'booking' ) ), |
| 33 | 'cssclass_extra' => array( 'type' => 'string', 'default' => '' ), |
| 34 | 'html_id' => array( 'type' => 'string', 'default' => '' ), |
| 35 | 'help' => array( 'type' => 'string', 'default' => '' ), |
| 36 | ), |
| 37 | ), |
| 38 | 'inspector_ui' => array( |
| 39 | 'title' => __( 'Start Over Button', 'booking' ), |
| 40 | 'description' => __( 'Return the customer to the first available step of the Appointment selector.', 'booking' ), |
| 41 | 'header_variant' => 'toolbar', |
| 42 | 'header_actions' => array( 'deselect', 'scrollto', 'move-up', 'move-down', 'duplicate', 'delete' ), |
| 43 | 'groups' => array( |
| 44 | array( |
| 45 | 'key' => 'basic', |
| 46 | 'label' => __( 'Basic', 'booking' ), |
| 47 | 'open' => true, |
| 48 | 'controls' => array( |
| 49 | array( 'type' => 'text', 'key' => 'label', 'label' => __( 'Label', 'booking' ) ), |
| 50 | array( |
| 51 | 'type' => 'textarea', |
| 52 | 'key' => 'help', |
| 53 | 'label' => __( 'Help text', 'booking' ), |
| 54 | 'rows' => 3, |
| 55 | ), |
| 56 | ), |
| 57 | ), |
| 58 | array( |
| 59 | 'key' => 'appearance', |
| 60 | 'label' => __( 'Advanced', 'booking' ), |
| 61 | 'controls' => array( |
| 62 | array( 'type' => 'text', 'key' => 'cssclass_extra', 'label' => __( 'Extra CSS classes', 'booking' ) ), |
| 63 | array( 'type' => 'text', 'key' => 'html_id', 'label' => __( 'HTML ID', 'booking' ) ), |
| 64 | ), |
| 65 | ), |
| 66 | ), |
| 67 | ), |
| 68 | ); |
| 69 | |
| 70 | return $packs; |
| 71 | } |
| 72 | add_filter( 'wpbc_bfb_register_field_packs', 'wpbc_bfb_register_field_packs__appointment_start_over' ); |
| 73 | |
| 74 | /** |
| 75 | * Enqueue the Appointment Start Over renderer and exporters in Form Builder. |
| 76 | * |
| 77 | * @param string $page Current admin page slug. |
| 78 | * |
| 79 | * @return void |
| 80 | */ |
| 81 | function wpbc_bfb_enqueue__appointment_start_over_js( $page ) { |
| 82 | wp_enqueue_script( |
| 83 | 'wpbc-bfb_field_appointment_start_over', |
| 84 | wpbc_plugin_url( '/includes/page-form-builder/field-packs/appointment-start-over/_out/appointment-start-over.js' ), |
| 85 | array( 'wpbc-bfb' ), |
| 86 | WP_BK_VERSION_NUM, |
| 87 | true |
| 88 | ); |
| 89 | } |
| 90 | add_action( 'wpbc_enqueue_js_field_pack', 'wpbc_bfb_enqueue__appointment_start_over_js', 10, 1 ); |
| 91 | |
| 92 | /** |
| 93 | * Add the Appointment Start Over item to the navigation palette. |
| 94 | * |
| 95 | * @param string $group Palette group. |
| 96 | * @param string $position Position inside the group. |
| 97 | * |
| 98 | * @return void |
| 99 | */ |
| 100 | function wpbc_bfb_palette_register_items__appointment_start_over( $group, $position ) { |
| 101 | if ( 'navigation' !== $group || 'top' !== $position ) { |
| 102 | return; |
| 103 | } |
| 104 | ?> |
| 105 | <li class="wpbc_bfb__field" |
| 106 | data-id="appointment_start_over" |
| 107 | data-type="appointment_start_over" |
| 108 | data-usage_key="appointment_start_over" |
| 109 | data-label="<?php echo esc_attr( __( 'Start over', 'booking' ) ); ?>"> |
| 110 | <i class="menu_icon icon-1x wpbc-bi-arrow-counterclockwise"></i> |
| 111 | <span class="wpbc_bfb__field-label"><?php echo esc_html( __( 'Start Over', 'booking' ) ); ?></span> |
| 112 | <span class="wpbc_bfb__field-type"><?php echo esc_html__( 'Appointment', 'booking' ); ?></span> |
| 113 | </li> |
| 114 | <?php |
| 115 | } |
| 116 | add_action( 'wpbc_bfb_palette_register_items', 'wpbc_bfb_palette_register_items__appointment_start_over', 10, 2 ); |
| 117 |