Tribe_Events::args_to_repository( array $repository_args, array $arguments, Tribe__Context $context, TribeEventsViewsV2View_Interface $view )

Translates shortcode arguments to their Repository argument counterpart.


Parameters

$repository_args

(array) (Required) The current repository arguments.

$arguments

(array) (Required) The shortcode arguments to translate.

$context

(Tribe__Context) (Required) The shortcode arguments to translate.

$view

(TribeEventsViewsV2View_Interface) (Required) The View that will use the repository arguments.


Top ↑

Return

(array) The translated shortcode arguments.


Top ↑

Source

File: src/Tribe/Views/V2/Shortcodes/Tribe_Events.php

	public function args_to_repository( array $repository_args, array $arguments, $context ) {
		if ( isset( $arguments['cat'] ) ) {
			$repository_args['category'] = $arguments['cat'];
		}

		if ( isset( $arguments['category'] ) ) {
			$repository_args['category'] = $arguments['category'];
		}

		if ( isset( $arguments['date'] ) ) {
			// The date can be used in many ways, so we juggle a bit here.
			$date_filters = tribe_events()->get_date_filters();
			$date_keys    = array_filter(
				$repository_args,
				static function ( $key ) use ( $date_filters ) {
					return in_array( $key, $date_filters, true );
				},
				ARRAY_FILTER_USE_KEY
			);

			if ( count( $date_keys ) === 1 ) {
				if ( $date_keys[0] === $arguments['date'] ) {
					// Let's only set it if we are sure.
					$repository_args[ array_keys( $date_keys )[0] ] = $arguments['date'];
				} else {
					$repository_args[ array_keys( $date_keys )[0] ] = reset( $date_keys );
				}
			}
		}

		if ( isset( $arguments['featured'] ) ) {
			$repository_args['featured'] = tribe_is_truthy( $arguments['featured'] );
		}

		return $repository_args;
	}

Top ↑

Changelog

Changelog
Version Description
4.7.9 Introduced.