Tribe__Events__Rewrite::get_localized_bases( array $bases, array $domains )

Returns the map of localized bases for the specified text domains.

The bases are the ones used to build the permalinks, the domains are those of the currently activated plugins that include a localized rewrite component.


Parameters

$bases

(<span class="array">array) (Required) The bases to set up the locale translation for.

$domains

(<span class="array">array) (Required) A list of text domains belonging to the plugins currently active that handle and provide support for a localized rewrite component.


Top ↑

Return

(array<string,string>) A map relating the bases in their English, lowercase form to their current locale translated form.


Top ↑

Source

File: src/Tribe/Rewrite.php

	public function get_localized_bases( array $bases, array $domains ) {
		$locale             = get_locale();
		$cache_key          = __METHOD__ . md5( serialize( array_merge( $bases, $domains, [ $locale ] ) ) );
		$expiration_trigger = Cache_Listener::TRIGGER_GENERATE_REWRITE_RULES;

		$cached = tribe_cache()->get( $cache_key, $expiration_trigger, false );

		if ( false !== $cached ) {
			return $cached;
		}

		$localized_bases = tribe( 'tec.i18n' )->get_i18n_strings_for_domains( $bases, [ $locale ], $domains );

		$return = array_filter(
			array_map(
				static function ( $locale_base ) {
					return is_array( $locale_base ) ? end( $locale_base ) : false;
				},
				$localized_bases
			)
		);

		tribe_cache()->set( $cache_key, $return, DAY_IN_SECONDS, $expiration_trigger );

		return $return;
	}

Top ↑

Changelog

Changelog
Version Description
5.1.1 Introduced.