Tribe__Tickets_Plus__Main::additional_ticket_settings( array $tickets_fields )
Add additional ticket settings to define slug and choose the template for the attendee info page.
Contents
Parameters
- $tickets_fields
-
(array) (Required) List of ticket fields.
Return
(array) List of ticket fields with additional setting fields added.
Source
File: src/Tribe/Main.php
public function additional_ticket_settings( $tickets_fields ) {
$template_options = array(
'default' => esc_html__( 'Default Page Template', 'event-tickets' ),
);
if ( class_exists( 'Tribe__Events__Main' ) ) {
$template_options['same'] = esc_html__( 'Same as Event Page Template', 'event-tickets' );
}
$templates = get_page_templates();
ksort( $templates );
foreach ( array_keys( $templates ) as $template ) {
$template_options[ $templates[ $template ] ] = $template;
}
$options = array(
'ticket-attendee-info-slug' => array(
'type' => 'text',
'label' => esc_html__( 'Attendee Registration URL slug', 'event-tickets' ),
'tooltip' => esc_html__( 'The slug used for building the URL for the Attendee Registration Info page.', 'event-tickets' ),
'size' => 'medium',
'default' => tribe( 'tickets.attendee_registration' )->get_slug(),
'validation_callback' => 'is_string',
'validation_type' => 'slug',
),
'ticket-attendee-info-template' => array(
'type' => 'dropdown',
'label' => __( 'Attendee Registration template', 'event-tickets' ),
'tooltip' => __( 'Choose a page template to control the appearance of your attendee registration page.', 'event-tickets' ),
'validation_type' => 'options',
'size' => 'large',
'default' => 'default',
'options' => $template_options,
)
);
$page_options = [ '' => __( 'Choose a page or leave blank.', 'event-tickets' ) ];
$pages = get_pages();
if ( $pages ) {
foreach ( $pages as $page ) {
$page_options[ $page->ID ] = $page->post_title;
}
} else {
//if no pages, let the user know they need one
$page_options = [ '' => __( 'You must create a page before using this functionality', 'event-tickets' ) ];
}
$ar_page_description = __( 'Optional: select an existing page to act as your attendee registration page. <strong>Requires</strong> use of the `[tribe_attendee_registration]` shortcode and overrides the above template and URL slug.', 'event-tickets' );
$ar_page = tribe( 'tickets.attendee_registration' )->get_attendee_registration_page();
// this is hooked too early for has_shortcode() to work properly, so regex to the rescue!
if ( ! empty( $ar_page ) && ! preg_match( '/\[tribe_attendee_registration\/?\]/', $ar_page->post_content ) ) {
$ar_slug_description = __( 'Selected page <strong>must</strong> use the `[tribe_attendee_registration]` shortcode. While the shortcode is missing the default redirect will be used.', 'event-tickets' );
}
$options['ticket-attendee-page-id'] = [
'type' => 'dropdown',
'label' => __( 'Attendee Registration page', 'event-tickets' ),
'tooltip' => $ar_page_description,
'validation_type' => 'options',
'size' => 'large',
'default' => 'default',
'options' => $page_options,
];
$array_key = array_key_exists( 'ticket-commerce-form-location', $tickets_fields ) ? 'ticket-commerce-form-location' : 'ticket-enabled-post-types';
return Tribe__Main::array_insert_after_key( $array_key, $tickets_fields, $options );
}
Changelog
| Version | Description |
|---|---|
| 4.10.1 | Introduced. |