Tribe__Tickets__Attendee_Registration__Rewrite::get_bases( string $method = 'regex' )
Get the base slugs for the Plugin Rewrite rules
Contents
WARNING: Don’t mess with the filters below if you don’t know what you are doing
Parameters
- $method
-
(string) (Optional) Use "regex" to return a Regular Expression with the possible Base Slugs using l10n
Default value: 'regex'
Return
(object) Return Base Slugs with l10n variations
Source
File: src/Tribe/Attendee_Registration/Rewrite.php
public function get_bases( $method = 'regex' ) {
$tickets = tribe( 'tickets.main' );
/**
* If you want to modify the base slugs before the i18n happens, use this filter
* All the bases need to have a key and a value, they might be the same or not.
*
* Each value is an array of possible slugs: to improve robustness the "original" English
* slug is supported in addition to translated forms for month, list, today and day: this
* way if the forms are altered (whether through i18n or other custom mods) *after* links
* have already been promulgated, there will be less chance of visitors hitting 404s.
*
* The term "original" here for:
* - events
* - event
*
* Means that is a value that can be overwritten and relies on the user value entered on the
* options page.
*
* @var array $bases
*/
$bases = apply_filters( 'tribe_tickets_rewrite_base_slugs', array(
'attendee-registration' => array( tribe( 'tickets.attendee_registration' )->get_slug() ),
) );
// Remove duplicates (no need to have 'month' twice if no translations are in effect, etc)
$bases = array_map( 'array_unique', $bases );
// By default we load the Default and our plugin domains
$domains = apply_filters( 'tribe_tickets_rewrite_i18n_domains', array(
'default' => true, // Default doesn't need file path
'event-tickets' => $tickets->plugin_dir . 'lang/',
) );
/**
* Use `tribe_tickets_rewrite_i18n_slugs_raw` to modify the raw version of the l10n slugs bases.
*
* This is useful to modify the bases before the method is taken into account.
*
* @param array $bases An array of rewrite bases that have been generated.
* @param string $method The method that's being used to generate the bases; defaults to `regex`.
* @param array $domains An associative array of language domains to use; these would be plugin or themes language
* domains with a `'plugin-slug' => '/absolute/path/to/lang/dir'`
*/
$bases = apply_filters( 'tribe_tickets_rewrite_i18n_slugs_raw', $bases, $method, $domains );
if ( 'regex' === $method ) {
foreach ( $bases as $type => $base ) {
// Escape all the Bases
$base = array_map( 'preg_quote', $base );
// Create the Regular Expression
$bases[ $type ] = '(?:' . implode( '|', $base ) . ')';
}
}
/**
* Use `tribe_tickets_rewrite_i18n_slugs` to modify the final version of the l10n slugs bases
*
* At this stage the method has been applied already and this filter will work with the
* finalized version of the bases.
*
* @param array $bases An array of rewrite bases that have been generated.
* @param string $method The method that's being used to generate the bases; defaults to `regex`.
* @param array $domains An associative array of language domains to use; these would be plugin or themes language
* domains with a `'plugin-slug' => '/absolute/path/to/lang/dir'`
*/
return (object) apply_filters( 'tribe_tickets_rewrite_i18n_slugs', $bases, $method, $domains );
}
Changelog
| Version | Description |
|---|---|
| 4.9 | Introduced. |