[ Avaa Bypassed ]




Upload:

Command:

www-data@3.16.160.142: ~ $
<?php
/**
 * Handles internationalization of The Events Calendar strings.
 *
 * @since   5.1.1
 *
 * @package Tribe\Events
 */

namespace Tribe\Events;

use Tribe__Cache_Listener as Cache_Listener;
use Tribe__Events__Main as TEC;
use Tribe__Main as Common;

/**
 * Class I18n
 *
 * @since   5.1.1
 *
 * @package Tribe\Events
 */
class I18n {
	/**
	 * A flag to require translation compilation of the input as is.
	 *
	 * @since 5.1.5
	 */
	public const COMPILE_INPUT = 1;

	/**
	 * A flag to require translation compilation of the lower-case version of the input.
	 *
	 * @since 5.1.5
	 */
	public const COMPILE_STRTOLOWER = 2;

	/**
	 * A flag to require translation compilation of the input in its title form.
	 *
	 * @since 5.1.5
	 */
	public const COMPILE_UCFIRST = 4;

	/**
	 * A flag to require translation compilation of the input in all the available forms.
	 *
	 * @since 5.1.5
	 */
	public const COMPILE_ALL = 7;

	/**
	 * A flag to require the translations to be returned indexed by language.
	 *
	 * @since 6.0.13
	 */
	public const RETURN_BY_LANGUAGE = 8;

	/**
	 * A flag to require the translations to include the slug version of the translation.
	 *
	 * @since 6.0.13
	 */
	public const COMPILE_SLUG =  9;

	/**
	 * An instance of the The Events Calendar main class.
	 *
	 * @since 5.1.1
	 *
	 * @var TEC
	 */
	protected $tec;

	/**
	 * I18n constructor.
	 *
	 * @param TEC $tec An instance of The Events Calendar main class.
	 */
	public function __construct( TEC $tec ) {
		$this->tec = $tec;
	}

	/**
	 * Get all possible translations for a String based on the given Languages and Domains
	 *
	 * WARNING: This function is slow because it deals with files, so don't overuse it!
	 *
	 * @since 5.1.1 Moved here from Tribe__Events__Main.
	 * @since 5.1.5   Add support for the $flags argument.
	 *
	 * @param array  $strings          An array of strings (required).
	 * @param array  $languages        Which l10n to fetch the string (required).
	 * @param array  $domains          Possible Domains to re-load.
	 * @param string $default_language The default language to avoid re-doing that.
	 * @param int    $flags            An integer resulting from the combination of compilation flags;
	 *                                 defaults to `static::COMPILE_ALL` to compile all versions of the translations.
	 *                                 `static::COMPILE_INPUT` will compile the translation for the string, as input.
	 *                                 `static::COMPILE_STRTOLOWER` will compile the translation for the string in its
	 *                                 lowercase version.
	 *                                 `static::COMPILE_UCFIRST` will compile the translation for the string in its
	 *                                 title version.
	 *                                 `static::RETURN_BY_LANGUAGE` will return the translations indexed by language.
	 *
	 * @return array<array<string>> A multi level array with the possible translations for the given strings
	 */
	public function get_i18n_strings( $strings, $languages, $domains = [], $default_language = 'en_US', $flags = 7 ) {
		$domains = wp_parse_args(
			$domains,
			[
				// The `default` domain doesn't need file path.
				'default'             => true,
				'the-events-calendar' => $this->tec->plugin_dir . 'lang/',
			]
		);

		return $this->get_i18n_strings_for_domains( $strings, $languages, $domains, $flags );
	}

	/**
	 * Get all possible translations for a String based on the given Languages and Domains.
	 *
	 * WARNING: This function is slow because it deals with files, so don't overuse it!
	 * Differently from the `get_i18n_strings` method this will not use any domain that's not specified.
	 *
	 * @since 5.1.1
	 * @since 5.1.5   Add support for the $flags argument.
	 * @since 6.0.13     Add support for the `RETURN_BY_LANGUAGE` and `COMPILE_SLUG` flags.
	 *
	 * @param array $strings    An array of strings (required).
	 * @param array $languages Which l10n to fetch the string (required).
	 * @param array $domains   Possible domains to re-load.
	 * @param int   $flags     An integer resulting from the combination of compilation flags;
	 *                         defaults to `static::COMPILE_ALL` to compile all versions of the translations.
	 *                         `static::COMPILE_INPUT` will compile the translation for the string, as input.
	 *                         `static::COMPILE_STRTOLOWER` will compile the translation for the string in its lowercase
	 *                         version.
	 *                         `static::COMPILE_UCFIRST` will compile the translation for the string in its title
	 *                         version.
	 *                         `static::RETURN_BY_LANGUAGE` will return the translations indexed by language.
	 *
	 * @return array<string,array|string> A multi level array with the possible translations for the given strings.
	 */
	public function get_i18n_strings_for_domains( $strings, $languages, $domains = [ 'default' ], $flags = 7 ) {
		sort( $languages );
		$strings_buffer = [ $strings ];

		foreach ( $languages as $language ) {
			// Override the current locale w/ the one we need to compile the translations.
			$language_strings            = $this->with_locale(
				$language,
				[ $this, 'compile_translations' ],
				[ $strings, $domains, $flags ]
			);
			$strings_buffer[ $language ] = $language_strings;
		}

		foreach ( $strings_buffer as $language => $language_strings ) {
			foreach ( $language_strings as &$set ) {
				$set = array_map( 'sanitize_text_field', array_unique( array_filter( (array) $set ) ) );
			}
			$strings_buffer[ $language ] = $language_strings;
		}

		if ( $flags & static::RETURN_BY_LANGUAGE ) {
			foreach ( $strings_buffer as &$entries ) {
				foreach ( $entries as &$entry ) {
					$entry = array_values( $entry );
				}
			}

			return $strings_buffer;
		}

		if ( count( $strings_buffer ) === 1 ) {
			return reset( $strings_buffer );
		}

		$merged = array_merge_recursive( ... array_values( $strings_buffer ) );

		// Deduplicate each set of translations.
		foreach ( $merged as &$set ) {
			$set = array_unique( $set );
		}

		return $merged;
	}

	/**
	 * Get all possible translations for a URL String based on the given Languages and Domains.
	 *
	 * WARNING: This function is slow because it deals with files, so don't overuse it!
	 * Differently from the `get_i18n_strings` method this will not use any domain that's not specified.
	 *
	 * This function is same as above one, but instead of sanitizing with 'sanitize_key()' which removes '%',
	 * it uses 'sanitize_title()'.
	 *
	 * @since 6.0.2
	 * @since 6.0.13  Add support for `static::COMPILE_SLUG` flag.
	 *
	 * @param array<string> $strings   An array of strings (required).
	 * @param array<string> $languages Which l10n to fetch the string (required).
	 * @param array<string> $domains   Possible domains to re-load.
	 * @param int           $flags     An integer resulting from the combination of compilation flags;
	 *                                 defaults to `static::COMPILE_ALL` to compile all versions of the translations.
	 *                                 `static::COMPILE_INPUT` will compile the translation for the string, as input.
	 *                                 `static::COMPILE_STRTOLOWER` will compile the translation for the string in its
	 *                                 lowercase version.
	 *                                 `static::COMPILE_UCFIRST` will compile the translation for the string in its title
	 *                                 version.
	 *                                 `static::COMPILE_SLUG` will compile the translation for the string in its slug
	 *                                 version.
	 *
	 * @return array<string,array|string> A multi level array with the possible translations for the given strings.
	 */
	public function get_i18n_url_strings_for_domains( $strings, $languages, $domains = [ 'default' ], $flags = 7 ) {
		sort( $languages );
		$strings_buffer = [ $strings ];

		foreach ( $languages as $language ) {
			// Override the current locale w/ the one we need to compile the translations.
			$language_strings = $this->with_locale(
				$language,
				[ $this, 'compile_translations' ],
				[ $strings, $domains, $flags ]
			);
			$strings_buffer[] = $language_strings;
		}

		$strings = count( $strings_buffer ) > 1
			? array_merge_recursive( ... $strings_buffer )
			: reset( $strings_buffer );

		// Prevent empty strings and duplicates.
		foreach ( $strings as $key => $value ) {
			$strings[ $key ] = array_filter(
				array_unique(
					array_map( 'sanitize_title', (array) $value )
				)
			);
		}

		return $strings;
	}

	/**
	 * Executes a callback ensuring the `current_locale` will be set to the specified language code.
	 *
	 * The method will backup and detach the functions and methods currently filtering the `locale` filter to execute
	 * the callback in isolation and restore the filters after that.
	 * The main purpose of this method is to avoid a rat race against plugins and themes that will filter the locale
	 * by attaching the filtering method or function at `PHP_INT_MAX`.
	 *
	 * @since 5.1.1
	 * @since 5.4.0 Changed the method visibility to public.
	 *
	 * @param string       $locale The locale to set for the execution of the callback.
	 * @param callable     $do     The callable to execute in the context of a specific locale.
	 * @param array<mixed> $args   A set of arguments that will be passed to the callback.
	 *
	 * @return mixed The callback return value, if any.
	 */
	public function with_locale( $locale, callable $do, array $args = [] ) {
		global $wp_filter;
		// Backup the current state of the locale filter.
		$locale_filters_backup = isset( $wp_filter['locale'] ) ? $wp_filter['locale'] : new \WP_Hook;
		// Set the `locale` filter to a new hook, nothing is hooked to it.
		$wp_filter['locale'] = new \WP_Hook();

		$force_locale = static function () use ( $locale ) {
			return $locale;
		};

		add_filter( 'locale', $force_locale );
		add_filter( 'pre_determine_locale', $force_locale );
		$result = $do( ...$args );
		remove_filter( 'locale', $force_locale );
		remove_filter( 'pre_determine_locale', $force_locale );

		$domains = isset( $args[1] ) ? (array) $args[1] : false;
		if ( false !== $domains ) {
			foreach ( $domains as $domain => $file ) {
				// Reload it with the correct language.
				unload_textdomain( $domain );

				if ( 'default' === $domain ) {
					load_default_textdomain();
				} elseif ( is_string( $file ) ) {
					Common::instance()->load_text_domain( $domain, $file );
				}
			}
		}

		// Restore the `locale` filtering functions.
		$wp_filter['locale'] = $locale_filters_backup;

		return $result;
	}

	/**
	 * Compiles the translations for a set of strings iterating on a set of domains.
	 *
	 * The 4th argument is a bitmask to control the compiled translations.
	 * E.g. `$i18n->compile_translations( $strings, $domains, I18n::COMPILE_STRTOLOWER);` will only compile
	 * translations of the strings in their `strtolower` versions.
	 * Combine the flags using the usual PHP syntax: `I18n::COMPILE_INPUT | I18n::COMPILE_STRTOLOWER` to compile
	 * only the translation of the string as input and in their lowercase version.
	 *
	 * @since 5.1.1
	 * @since 5.1.5   Add support for the $flags argument.
	 * @since 6.0.13     Add support for the `static::COMPILE_SLUG` flag.
	 *
	 * @param array<string,array|string> $strings The set of strings to compile the translations for.
	 * @param string|array<string>       $domains The domain(s) that should be used to compile the string translations.
	 * @param int                        $flags   An integer resulting from the combination of compilation flags;
	 *                                            defaults to `static::COMPILE_ALL` to compile all versions of the
	 *                                            translations.
	 *                                            `static::COMPILE_INPUT` will compile the translation for the string,
	 *                                            as input.
	 *                                            `static::COMPILE_STRTOLOWER` will compile the translation for the
	 *                                            string in its lowercase version.
	 *                                            `static::COMPILE_UCFIRST` will compile the translation for the string
	 *                                            in its title version.
	 *                                            `static::COMPILE_SLUG` will compile the translation for the string in
	 *                                            its slug version.
	 *
	 * @return array<string|array> A map of the compiled string translations.
	 */
	public function compile_translations( array $strings, $domains, $flags = 7 ) {
		$cache_salts = [ $strings, $domains, get_locale() ];
		$cache_key   = __METHOD__ . md5( serialize( $cache_salts ) );

		$expiration_trigger = Cache_Listener::TRIGGER_UPDATED_OPTION;
		$cached             = tribe_cache()->get( $cache_key, $expiration_trigger, false, DAY_IN_SECONDS );

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

		foreach ( (array) $domains as $domain => $file ) {
			// Reload it with the correct language.
			unload_textdomain( $domain );

			if ( 'default' === $domain ) {
				load_default_textdomain();
			} else {
				Common::instance()->load_text_domain( $domain, $file );
			}

			// Loop on the strings the build the possible translations.
			foreach ( $strings as $key => $value ) {
				$value = is_array( $value ) ? reset( $value ) : $value;
				if ( ! is_string( $value ) ) {
					continue;
				}

				// Make sure we have an array.
				$strings[ $key ] = (array) $strings[ $key ];

				// Grab the possible strings for default and any other domain.
				if ( 'default' === $domain ) {
					if ( $flags & static::COMPILE_SLUG ) {
						$strings[ $key ][] = sanitize_key( __( $value ) );
					}
					if ( $flags & static::COMPILE_INPUT ) {
						$strings[ $key ][] = __( $value );
					}
					if ( $flags & static::COMPILE_STRTOLOWER ) {
						$strings[ $key ][] = __( strtolower( $value ) );
					}
					if ( $flags & static::COMPILE_UCFIRST ) {
						$strings[ $key ][] = __( ucfirst( $value ) );
					}
				} else {
					if ( $flags & static::COMPILE_SLUG ) {
						$strings[ $key ][] = sanitize_key( __( $value, $domain ) );
					}
					if ( $flags & static::COMPILE_INPUT ) {
						$strings[ $key ][] = __( $value, $domain );
					}
					if ( $flags & static::COMPILE_STRTOLOWER ) {
						$strings[ $key ][] = __( strtolower( $value ), $domain );
					}
					if ( $flags & static::COMPILE_UCFIRST ) {
						$strings[ $key ][] = __( ucfirst( $value ), $domain );
					}
				}
			}
		}

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

		return $strings;
	}
}

Filemanager

Name Type Size Permission Actions
Admin Folder 0777
Aggregator Folder 0777
Ajax Folder 0777
Collections Folder 0777
Customizer Folder 0777
Dates Folder 0777
Editor Folder 0777
Event_Status Folder 0777
Event_Tickets Folder 0777
Featured_Events Folder 0777
Google Folder 0777
Importer Folder 0777
Integrations Folder 0777
JSON_LD Folder 0777
Linked_Posts Folder 0777
Meta Folder 0777
Models Folder 0777
REST Folder 0777
Repositories Folder 0777
Revisions Folder 0777
Service_Providers Folder 0777
Shortcode Folder 0777
Taxonomy Folder 0777
Template Folder 0777
Utils Folder 0777
Validator Folder 0777
Views Folder 0777
API.php File 29.34 KB 0644
Adjacent_Events.php File 10.27 KB 0644
Admin_List.php File 14.84 KB 0644
Aggregator.php File 17.13 KB 0644
Amalgamator.php File 14.04 KB 0644
Assets.php File 18.52 KB 0644
Capabilities.php File 5.56 KB 0644
Constants.php File 1.78 KB 0644
Cost_Utils.php File 4.81 KB 0644
Deactivation.php File 1.47 KB 0644
Default_Values.php File 793 B 0644
Editor.php File 17.7 KB 0644
Embedded_Maps.php File 5.54 KB 0644
Event_Cleaner.php File 2.65 KB 0644
Event_Cleaner_Scheduler.php File 8.36 KB 0644
Featured_Events.php File 1.75 KB 0644
Front_Page_View.php File 10.73 KB 0644
Gutenberg.php File 3.27 KB 0644
I18n.php File 14.5 KB 0644
Ignored_Events.php File 31.48 KB 0644
Linked_Posts.php File 47.54 KB 0644
Main.php File 137.8 KB 0644
Options_Exception.php File 890 B 0644
Organizer.php File 25.63 KB 0644
Plugin_Register.php File 1007 B 0644
Post_Exception.php File 859 B 0644
Privacy.php File 1.31 KB 0644
Query.php File 18.14 KB 0644
Rewrite.php File 28.77 KB 0644
Template_Factory.php File 15.11 KB 0644
Templates.php File 6.48 KB 0644
Timezones.php File 6.36 KB 0644
Updater.php File 9.8 KB 0644
Venue.php File 28.32 KB 0644
iCal.php File 30.9 KB 0644