> * * @since 0.1.0 */ public static function args_for( string $route_id ): array { return match ( $route_id ) { 'public.session.create' => [ 'form_id' => [ 'required' => true, 'type' => 'integer', 'minimum' => 1, 'sanitize_callback' => 'absint', ], 'timezone' => [ 'required' => false, 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', ], 'locale' => [ 'required' => false, 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', ], ], 'public.session.get', 'public.session.back', 'public.session.submit' => [ 'token' => [ 'required' => true, 'type' => 'string', 'pattern' => '^[a-f0-9]{64}$', 'sanitize_callback' => 'sanitize_text_field', ], ], 'public.session.step' => [ 'token' => [ 'required' => true, 'type' => 'string', 'pattern' => '^[a-f0-9]{64}$', 'sanitize_callback' => 'sanitize_text_field', ], 'name' => [ 'required' => true, 'type' => 'string', 'pattern' => '^[a-z_]+$', 'sanitize_callback' => 'sanitize_key', ], ], 'public.availability' => [ 'service_id' => [ 'required' => true, 'type' => 'integer', 'minimum' => 1, 'sanitize_callback' => 'absint', ], 'duration_id' => [ 'required' => true, 'type' => 'integer', 'minimum' => 1, 'sanitize_callback' => 'absint', ], 'agent_id' => [ 'required' => false, 'type' => 'integer', 'minimum' => 1, 'sanitize_callback' => 'absint', ], 'location_id' => [ 'required' => false, 'type' => 'integer', 'minimum' => 1, 'sanitize_callback' => 'absint', ], 'date_from' => [ 'required' => true, 'type' => 'string', 'pattern' => '^\d{4}-\d{2}-\d{2}$', 'sanitize_callback' => 'sanitize_text_field', ], 'date_to' => [ 'required' => true, 'type' => 'string', 'pattern' => '^\d{4}-\d{2}-\d{2}$', 'sanitize_callback' => 'sanitize_text_field', ], 'attendees' => [ 'required' => false, 'type' => 'integer', 'minimum' => 1, 'default' => 1, 'sanitize_callback' => 'absint', ], 'timezone' => [ 'required' => true, 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', ], 'exclude_booking' => [ 'required' => false, 'type' => 'integer', 'minimum' => 1, 'sanitize_callback' => 'absint', ], ], 'public.services.list', 'public.service_categories.list', 'public.agents.list', 'public.locations.list' => [ 'form_id' => [ 'required' => false, 'type' => 'integer', 'minimum' => 1, 'sanitize_callback' => 'absint', ], 'page' => self::page_arg(), 'per_page' => self::per_page_arg(), ], 'public.coupon.validate' => [ 'token' => [ 'required' => true, 'type' => 'string', 'pattern' => '^[a-f0-9]{64}$', 'sanitize_callback' => 'sanitize_text_field', ], 'code' => [ 'required' => true, 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', ], ], 'public.payment.intent' => [ 'token' => [ 'required' => true, 'type' => 'string', 'pattern' => '^[a-f0-9]{64}$', 'sanitize_callback' => 'sanitize_text_field', ], 'gateway' => [ 'required' => true, 'type' => 'string', 'sanitize_callback' => 'sanitize_key', ], 'payment_type' => [ 'required' => true, 'type' => 'string', 'sanitize_callback' => 'sanitize_key', ], ], 'public.payment.webhook' => [ 'gateway' => [ 'required' => true, 'type' => 'string', 'sanitize_callback' => 'sanitize_key', ], ], 'manage.request_link' => [ 'email' => [ 'required' => true, 'type' => 'string', 'format' => 'email', 'sanitize_callback' => 'sanitize_email', ], ], 'manage.exchange' => [ 'token' => [ 'required' => true, 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', ], ], 'manage.bookings.cancel' => [ 'uuid' => [ 'required' => true, 'type' => 'string', 'format' => 'uuid', 'sanitize_callback' => 'sanitize_text_field', ], ], 'manage.bookings.reschedule' => [ 'uuid' => [ 'required' => true, 'type' => 'string', 'format' => 'uuid', 'sanitize_callback' => 'sanitize_text_field', ], 'start_utc' => [ 'required' => true, 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', ], ], 'admin.bookings.status' => [ 'id' => [ 'required' => true, 'type' => 'integer', 'sanitize_callback' => 'absint', ], 'status' => [ 'required' => true, 'type' => 'string', 'sanitize_callback' => 'sanitize_key', ], 'notify' => [ 'required' => false, 'type' => 'boolean', ], ], 'admin.bookings.update' => [ 'id' => [ 'required' => true, 'type' => 'integer', 'sanitize_callback' => 'absint', ], 'internal_notes' => [ 'required' => false, 'type' => 'string', 'sanitize_callback' => 'sanitize_textarea_field', ], ], 'admin.calendar' => [ 'from' => [ 'required' => false, 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', ], 'to' => [ 'required' => false, 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', ], 'agent_id' => [ 'required' => false, 'type' => 'integer', 'sanitize_callback' => 'absint', ], 'service_id' => [ 'required' => false, 'type' => 'integer', 'sanitize_callback' => 'absint', ], 'location_id' => [ 'required' => false, 'type' => 'integer', 'sanitize_callback' => 'absint', ], 'status' => [ 'required' => false, 'type' => 'string', 'sanitize_callback' => 'sanitize_key', ], ], 'admin.bookings.reschedule' => [ 'id' => [ 'required' => true, 'type' => 'integer', 'sanitize_callback' => 'absint', ], 'start_at' => [ 'required' => true, 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', ], 'end_at' => [ 'required' => false, 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', ], ], 'admin.orders.recovery' => [ 'id' => [ 'required' => true, 'type' => 'integer', 'sanitize_callback' => 'absint', ], ], 'admin.settings.update' => [ 'settings' => [ 'required' => true, 'type' => 'object', ], ], 'admin.wizard.run' => [ 'step' => [ 'required' => true, 'type' => 'string', 'sanitize_callback' => 'sanitize_key', ], 'skip' => [ 'required' => false, 'type' => 'boolean', ], 'business_name' => [ 'required' => false, 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', ], 'timezone' => [ 'required' => false, 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', ], 'currency' => [ 'required' => false, 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', ], 'week_start' => [ 'required' => false, 'type' => 'integer', ], 'time_format' => [ 'required' => false, 'type' => 'string', 'sanitize_callback' => 'sanitize_key', ], 'service_name' => [ 'required' => false, 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', ], 'duration_min' => [ 'required' => false, 'type' => 'integer', ], 'price_minor' => [ 'required' => false, 'type' => 'integer', ], 'hours' => [ 'required' => false, 'type' => 'array', ], 'agent_name' => [ 'required' => false, 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', ], 'agent_email' => [ 'required' => false, 'type' => 'string', 'sanitize_callback' => 'sanitize_email', ], 'payment_mode' => [ 'required' => false, 'type' => 'string', 'sanitize_callback' => 'sanitize_key', ], 'seed_demo' => [ 'required' => false, 'type' => 'boolean', ], ], 'admin.wizard.business' => [ 'business_name' => [ 'required' => false, 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', ], 'timezone' => [ 'required' => false, 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', ], 'currency' => [ 'required' => false, 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', ], 'week_start' => [ 'required' => false, 'type' => 'integer', ], 'time_format' => [ 'required' => false, 'type' => 'string', 'sanitize_callback' => 'sanitize_key', ], ], 'admin.service_durations.list' => [ 'page' => self::page_arg(), 'per_page' => self::per_page_arg(), 'service_id' => [ 'required' => false, 'type' => 'integer', 'minimum' => 1, 'sanitize_callback' => 'absint', ], ], 'admin.service_extras.list' => [ 'page' => self::page_arg(), 'per_page' => self::per_page_arg(), 'service_id' => [ 'required' => false, 'type' => 'integer', 'minimum' => 1, 'sanitize_callback' => 'absint', ], ], 'admin.notification_templates.get', 'admin.notification_templates.update', 'admin.notification_templates.preview', 'admin.notification_templates.test' => [ 'id' => [ 'required' => true, 'type' => 'integer', 'minimum' => 1, 'sanitize_callback' => 'absint', ], ], 'admin.reports.get', 'admin.reports.export' => [ 'from' => [ 'required' => false, 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', ], 'to' => [ 'required' => false, 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', ], 'period' => [ 'required' => false, 'type' => 'string', 'enum' => [ 'today', 'week', 'month' ], 'sanitize_callback' => 'sanitize_key', ], 'timezone' => [ 'required' => false, 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', ], ], 'admin.search' => [ 'q' => [ 'required' => false, 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', ], 'search' => [ 'required' => false, 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', ], ], default => self::default_admin_args( $route_id ), }; } /** * Pagination + id args for typical admin list/item routes. * * @param string $route_id Route id. * @return array> */ private static function default_admin_args( string $route_id ): array { $args = []; if ( str_contains( $route_id, '.list' ) || str_ends_with( $route_id, '.export' ) || str_contains( $route_id, 'activity' ) || str_contains( $route_id, 'notification_log.list' ) ) { $args['page'] = self::page_arg(); $args['per_page'] = self::per_page_arg(); $args['search'] = [ 'required' => false, 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', ]; $args['orderby'] = [ 'required' => false, 'type' => 'string', 'sanitize_callback' => 'sanitize_key', ]; $args['order'] = [ 'required' => false, 'type' => 'string', 'enum' => [ 'asc', 'desc' ], 'sanitize_callback' => 'sanitize_key', ]; } if ( preg_match( '/\.(get|update|delete|status|refund|retry)$/', $route_id ) || str_contains( $route_id, 'schedule' ) || str_contains( $route_id, 'overrides' ) ) { $args['id'] = [ 'required' => false, 'type' => 'integer', 'sanitize_callback' => 'absint', ]; } if ( str_contains( $route_id, 'overrides.delete' ) ) { $args['override_id'] = [ 'required' => true, 'type' => 'integer', 'sanitize_callback' => 'absint', ]; } if ( str_contains( $route_id, 'automations' ) || str_contains( $route_id, 'automation_runs' ) ) { if ( ! str_contains( $route_id, '.list' ) && ! str_contains( $route_id, '.create' ) && ! str_contains( $route_id, '.recipes' ) && ! str_contains( $route_id, '.catalogue' ) && ! str_contains( $route_id, '.from_recipe' ) ) { $args['id'] = [ 'required' => true, 'type' => 'integer', 'minimum' => 1, 'sanitize_callback' => 'absint', ]; } if ( str_contains( $route_id, '.catalogue' ) ) { $args['trigger'] = [ 'required' => false, 'type' => 'string', 'sanitize_callback' => 'sanitize_key', ]; } if ( str_contains( $route_id, '.from_recipe' ) ) { $args['key'] = [ 'required' => true, 'type' => 'string', 'sanitize_callback' => 'sanitize_key', ]; } if ( str_contains( $route_id, '.test' ) ) { $args['subject_id'] = [ 'required' => true, 'type' => 'integer', 'minimum' => 1, 'sanitize_callback' => 'absint', ]; $args['subject_type'] = [ 'required' => false, 'type' => 'string', 'enum' => [ 'booking', 'customer', 'intent', 'payment' ], 'sanitize_callback' => 'sanitize_key', ]; $args['live'] = [ 'required' => false, 'type' => 'boolean', ]; } if ( str_contains( $route_id, '.enable' ) ) { $args['acknowledged'] = [ 'required' => true, 'type' => 'boolean', ]; $args['destructive_ack'] = [ 'required' => false, 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', ]; } if ( str_contains( $route_id, 'automation_runs.list' ) ) { $args['status'] = [ 'required' => false, 'type' => 'string', 'sanitize_callback' => 'sanitize_key', ]; $args['automation_id'] = [ 'required' => false, 'type' => 'integer', 'sanitize_callback' => 'absint', ]; $args['customer_id'] = [ 'required' => false, 'type' => 'integer', 'sanitize_callback' => 'absint', ]; } } return $args; } /** * Page query argument schema. * * @return array */ private static function page_arg(): array { return [ 'required' => false, 'type' => 'integer', 'minimum' => 1, 'default' => 1, 'sanitize_callback' => 'absint', ]; } /** * Per-page query argument schema. * * @return array */ private static function per_page_arg(): array { return [ 'required' => false, 'type' => 'integer', 'minimum' => 1, 'maximum' => 100, 'default' => 20, 'sanitize_callback' => 'absint', ]; } }