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
booking / includes / page-appointment-services / catalog / appointment-services-catalog-config.php

appointment-services-catalog-config.php in Booking Calendar 11.9, at includes/page-appointment-services/catalog/appointment-services-catalog-config.php

221 lines 11.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Appointment Services shared catalog configuration.
4 *
5 * @package Booking Calendar
6 * @since 11.6.0
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit;
11 }
12
13 /**
14 * Return the Service-owned column, view, feature, and template declaration.
15 *
16 * This configuration contains presentation allow-lists only. Service SQL,
17 * edition rules, ownership, and mutations remain in the Service domain.
18 *
19 * @return array<string,mixed> Shared catalog configuration.
20 */
21 function wpbc_appointment_services_get_catalog_config() {
22 $allowed_sort_keys = array( 'service_id', 'title', 'duration', 'price', 'status' );
23 $definitions = array(
24 'service' => array( 'label' => __( 'Service', 'booking' ), 'class' => 'column-service', 'sort_key' => 'title', 'required' => true, 'reorderable' => true ),
25 'duration' => array( 'label' => __( 'Duration', 'booking' ), 'class' => 'column-duration', 'sort_key' => 'duration', 'required' => false, 'reorderable' => true ),
26 'price' => array( 'label' => __( 'Price', 'booking' ), 'class' => 'column-price', 'sort_key' => 'price', 'required' => false, 'reorderable' => true ),
27 'providers' => array( 'label' => __( 'Providers', 'booking' ), 'class' => 'column-providers', 'sort_key' => '', 'required' => false, 'reorderable' => true ),
28 'availability' => array( 'label' => __( 'Weekly Availability', 'booking' ), 'class' => 'column-weekdays', 'sort_key' => '', 'required' => false, 'reorderable' => true ),
29 'status' => array( 'label' => __( 'Status', 'booking' ), 'class' => 'column-status', 'sort_key' => 'status', 'required' => false, 'reorderable' => true ),
30 'actions' => array( 'label' => __( 'Actions', 'booking' ), 'class' => 'column-actions', 'sort_key' => '', 'required' => true, 'reorderable' => true ),
31 );
32 if ( ! wpbc_appointment_services_is_pricing_available() ) {
33 unset( $definitions['price'] );
34 $allowed_sort_keys = array_values( array_diff( $allowed_sort_keys, array( 'price' ) ) );
35 }
36 $columns = array_keys( $definitions );
37
38 return array(
39 'id' => 'appointment_services_catalog',
40 'action' => 'WPBC_AJX_APPOINTMENT_SERVICES_LIST',
41 'nonce_name' => 'wpbc_appointment_services_ajax_nonce',
42 'items_per_page' => array( 'default' => 10, 'options' => array( 5, 10, 50, 100 ), 'maximum' => 100 ),
43 'sorting' => array( 'default_key' => 'service_id', 'default_order' => 'desc', 'allowed_keys' => $allowed_sort_keys ),
44 'filters' => array(
45 'status' => array(
46 'default' => 'all',
47 'allowed' => array( 'all', 'active', 'inactive', 'archived' ),
48 ),
49 'resource_id' => array(
50 'default' => 0,
51 'minimum' => 0,
52 ),
53 ),
54 'actions' => array(
55 'edit' => array(
56 'surface' => 'row',
57 'mutation' => false,
58 ),
59 'duplicate' => array(
60 'surface' => 'inspector',
61 'mutation' => true,
62 ),
63 'archive' => array(
64 'surface' => 'row',
65 'mutation' => true,
66 ),
67 'delete' => array(
68 'surface' => 'selection',
69 'mutation' => true,
70 ),
71 ),
72 'columns' => array(
73 'allowed' => $columns,
74 'default_visible' => $columns,
75 'default_order' => $columns,
76 'required' => array( 'service', 'actions' ),
77 'definitions' => $definitions,
78 ),
79 'views' => array(
80 'default' => 'overview',
81 'definitions' => array(
82 'overview' => array( 'label' => __( 'Overview', 'booking' ), 'fields' => $columns ),
83 ),
84 ),
85 'features' => array(
86 'selection' => true,
87 'range_selection' => true,
88 'column_preferences' => true,
89 'column_order' => true,
90 'template_packs' => true,
91 'hierarchy' => false,
92 'expanded_details' => false,
93 'inspector' => true,
94 'inline_operations' => true,
95 'bulk_operations' => true,
96 'bulk_delete' => true,
97 ),
98 'templates' => array(
99 'catalog' => 'wpbc-appointment-services-catalog',
100 'shell' => 'wpbc-ui-catalog-shell',
101 'items' => 'wpbc-appointment-services-table',
102 'header' => 'wpbc-appointment-services-header',
103 'cards_header' => 'wpbc-appointment-services-cards-header',
104 'row' => 'wpbc-appointment-service-row',
105 'card' => 'wpbc-appointment-service-card',
106 'status_label' => 'wpbc-appointment-service-status-label',
107 'provider_labels' => 'wpbc-appointment-service-provider-labels',
108 'pagination' => 'wpbc-appointment-services-pagination',
109 'empty' => 'wpbc-ui-catalog-empty',
110 'error' => 'wpbc-appointment-services-error',
111 'inspector' => 'wpbc-ui-catalog-inspector-shell',
112 'inspector_create' => 'wpbc-appointment-service-inspector-create',
113 'inspector_edit' => 'wpbc-appointment-service-inspector-edit',
114 'inline_bar' => 'wpbc-appointment-services-inline-bar',
115 'inline_field' => 'wpbc-appointment-service-inline-field',
116 'inline_review' => 'wpbc-appointment-services-inline-review',
117 'bulk_edit' => 'wpbc-appointment-services-bulk-edit',
118 'bulk_review' => 'wpbc-appointment-services-bulk-review',
119 'delete_review' => 'wpbc-appointment-services-delete-review',
120 ),
121 'default_template_pack' => 'table',
122 'template_packs' => array(
123 'table' => array( 'catalog' => 'wpbc-appointment-services-catalog', 'items' => 'wpbc-appointment-services-table', 'header' => 'wpbc-appointment-services-header', 'row' => 'wpbc-appointment-service-row' ),
124 'compact' => array( 'catalog' => 'wpbc-appointment-services-catalog', 'items' => 'wpbc-appointment-services-compact', 'header' => 'wpbc-appointment-services-header', 'row' => 'wpbc-appointment-service-row' ),
125 'cards' => array( 'catalog' => 'wpbc-appointment-services-catalog', 'items' => 'wpbc-appointment-services-cards', 'header' => 'wpbc-appointment-services-cards-header', 'row' => 'wpbc-appointment-service-card' ),
126 ),
127 'i18n' => array(
128 'catalog_label' => __( 'Services catalog', 'booking' ),
129 'loading' => __( 'Loading Services', 'booking' ) . '...',
130 'empty_title' => __( 'No items found', 'booking' ),
131 'empty_message' => __( 'There are no items to display for this request.', 'booking' ),
132 'error_title' => __( 'Services unavailable', 'booking' ),
133 'error_message' => __( 'Services could not be loaded. Please refresh the page and try again.', 'booking' ),
134 'search_placeholder' => __( 'Search Services', 'booking' ),
135 'column_service' => __( 'Service', 'booking' ),
136 'column_duration' => __( 'Duration', 'booking' ),
137 'column_price' => __( 'Price', 'booking' ),
138 'column_providers' => __( 'Providers', 'booking' ),
139 'column_availability' => __( 'Weekly Availability', 'booking' ),
140 'column_status' => __( 'Status', 'booking' ),
141 'column_actions' => __( 'Actions', 'booking' ),
142 'column_id' => __( 'ID', 'booking' ),
143 'active' => __( 'Active', 'booking' ),
144 'inactive' => __( 'Draft', 'booking' ),
145 'archived' => __( 'Archived', 'booking' ),
146 'edit' => __( 'Edit Service', 'booking' ),
147 'archive' => __( 'Archive Service', 'booking' ),
148 'no_provider' => __( 'No Providers assigned', 'booking' ),
149 'available' => __( 'Available', 'booking' ),
150 'unavailable' => __( 'Unavailable', 'booking' ),
151 'layout_table' => __( 'Default', 'booking' ),
152 'layout_compact' => __( 'Compact', 'booking' ),
153 'layout_cards' => __( 'Cards', 'booking' ),
154 'layout_label' => __( 'Layout', 'booking' ),
155 'sort_by' => __( 'Sort by', 'booking' ),
156 'sort_services' => __( 'Sort Services', 'booking' ),
157 'customize_columns' => __( 'Customize columns', 'booking' ),
158 'columns_legend' => __( 'Visible columns', 'booking' ),
159 'close_columns' => __( 'Close column settings', 'booking' ),
160 'always_visible' => __( 'Always visible', 'booking' ),
161 'select_all' => __( 'Select all visible Services', 'booking' ),
162 'selected_services' => __( 'Selected Services:', 'booking' ),
163 'clear_selection' => __( 'Clear selection', 'booking' ),
164 'edit_selected' => __( 'Edit selected', 'booking' ),
165 'delete_selected' => __( 'Delete selected', 'booking' ),
166 'edit_rows' => __( 'Edit rows', 'booking' ),
167 'reset_order' => __( 'Reset column order', 'booking' ),
168 'reset_preferences' => __( 'Reset to default', 'booking' ),
169 'show_label' => __( 'Show', 'booking' ),
170 'per_page_label' => __( 'per page', 'booking' ),
171 'pagination_label' => __( 'Services pagination', 'booking' ),
172 'previous_page' => __( 'Previous page', 'booking' ),
173 'next_page' => __( 'Next page', 'booking' ),
174 'page_number' => __( 'Page number', 'booking' ),
175 /* translators: 1: First visible item, 2: Last visible item, 3: Total Services. */
176 'showing' => __( 'Showing %1$s–%2$s of %3$s Services', 'booking' ),
177 ),
178 );
179 }
180
181 /**
182 * Register the Service catalog and its domain-owned WP templates.
183 *
184 * @return true|WP_Error Registration result.
185 */
186 function wpbc_appointment_services_register_catalog() {
187 static $registration_result = null;
188 if ( null !== $registration_result ) {
189 return $registration_result;
190 }
191 $template_directory = dirname( __DIR__ ) . '/templates/catalog';
192 $registration_result = WPBC_UI_Catalog_Registry::get_instance()->register(
193 wpbc_appointment_services_get_catalog_config(),
194 new WPBC_Appointment_Services_Catalog_Provider(),
195 array(
196 'wpbc-appointment-services-catalog' => $template_directory . '/catalog-wptpl.php',
197 'wpbc-appointment-services-table' => $template_directory . '/table-wptpl.php',
198 'wpbc-appointment-services-compact' => $template_directory . '/compact-wptpl.php',
199 'wpbc-appointment-services-cards' => $template_directory . '/cards-wptpl.php',
200 'wpbc-appointment-services-header' => $template_directory . '/header-wptpl.php',
201 'wpbc-appointment-services-cards-header' => $template_directory . '/cards-header-wptpl.php',
202 'wpbc-appointment-service-row' => $template_directory . '/service-row-wptpl.php',
203 'wpbc-appointment-service-card' => $template_directory . '/service-card-wptpl.php',
204 'wpbc-appointment-service-status-label' => $template_directory . '/status-label-wptpl.php',
205 'wpbc-appointment-service-provider-labels' => $template_directory . '/provider-labels-wptpl.php',
206 'wpbc-appointment-services-pagination' => $template_directory . '/pagination-wptpl.php',
207 'wpbc-appointment-services-error' => $template_directory . '/error-wptpl.php',
208 'wpbc-appointment-service-inspector-create' => $template_directory . '/inspector-create-wptpl.php',
209 'wpbc-appointment-service-inspector-edit' => $template_directory . '/inspector-edit-wptpl.php',
210 'wpbc-appointment-services-inline-bar' => $template_directory . '/inline-bar-wptpl.php',
211 'wpbc-appointment-service-inline-field' => $template_directory . '/inline-field-wptpl.php',
212 'wpbc-appointment-services-inline-review' => $template_directory . '/inline-review-wptpl.php',
213 'wpbc-appointment-services-bulk-edit' => $template_directory . '/bulk-edit-wptpl.php',
214 'wpbc-appointment-services-bulk-review' => $template_directory . '/bulk-review-wptpl.php',
215 'wpbc-appointment-services-delete-review' => $template_directory . '/delete-review-wptpl.php',
216 )
217 );
218
219 return $registration_result;
220 }
221