Tribe__Events__Repositories__Event::__construct()
Tribe__Events__Repositories__Event constructor.
Sets up the repository default parameters and schema.
Source
File: src/Tribe/Repositories/Event.php
public function __construct() {
parent::__construct();
/**
* Depending on the setting used to present event on the site the timezone used to normalize
* events and the keys used to sort them will be different.
* This initial setting can be reverted on a per-instance base using the `use_utc` method.
*
* @see Tribe__Events__Repositories__Event::use_utc()
*/
if ( Timezones::is_mode( 'site' ) ) {
$this->normal_timezone = new DateTimeZone( 'UTC' );
$this->start_meta_key = '_EventStartDateUTC';
$this->end_meta_key = '_EventEndDateUTC';
} else {
$this->normal_timezone = Timezones::build_timezone_object();
$this->start_meta_key = '_EventStartDate';
$this->end_meta_key = '_EventEndDate';
}
$this->create_args['post_type'] = Tribe__Events__Main::POSTTYPE;
$this->taxonomies = array(
Tribe__Events__Main::TAXONOMY,
'post_tag',
);
// Add event specific aliases.
$this->update_fields_aliases = array_merge( $this->update_fields_aliases, array(
'start_date' => '_EventStartDate',
'end_date' => '_EventEndDate',
'start_date_utc' => '_EventStartDateUTC',
'end_date_utc' => '_EventEndDateUTC',
'duration' => '_EventDuration',
'all_day' => '_EventAllDay',
'timezone' => '_EventTimezone',
'venue' => '_EventVenueID',
'organizer' => '_EventOrganizerID',
'category' => Tribe__Events__Main::TAXONOMY,
'cost' => '_EventCost',
'currency_symbol' => '_EventCurrencySymbol',
'currency_position' => '_EventCurrencyPosition',
'show_map' => '_EventShowMap',
'show_map_link' => '_EventShowMapLink',
'url' => '_EventURL',
'hide_from_upcoming' => '_EventHideFromUpcoming',
// Where is "sticky"? It's handled in the meta filtering by setting `menu_order`.
'featured' => '_tribe_featured',
) );
$this->default_args = array(
'post_type' => Tribe__Events__Main::POSTTYPE,
'order' => 'ASC',
'order_by' => 'event_date',
// We'll be handling the dates, let's mark the query as a non-filtered one.
'tribe_suppress_query_filters' => true,
);
$this->schema = array_merge(
$this->schema,
[
'starts_before' => [ $this, 'filter_by_starts_before' ],
'starts_after' => [ $this, 'filter_by_starts_after' ],
'starts_on_or_after' => [ $this, 'filter_by_starts_on_or_after' ],
'starts_between' => [ $this, 'filter_by_starts_between' ],
'ends_before' => [ $this, 'filter_by_ends_before' ],
'ends_on_or_before' => [ $this, 'filter_by_ends_on_or_before' ],
'ends_after' => [ $this, 'filter_by_ends_after' ],
'ends_between' => [ $this, 'filter_by_ends_between' ],
'date_overlaps' => [ $this, 'filter_by_date_overlaps' ],
'starts_and_ends_between' => [ $this, 'filter_by_starts_and_ends_between' ],
'runs_between' => [ $this, 'filter_by_runs_between' ],
'all_day' => [ $this, 'filter_by_all_day' ],
'multiday' => [ $this, 'filter_by_multiday' ],
'on_calendar_grid' => [ $this, 'filter_by_on_calendar_grid' ],
'timezone' => [ $this, 'filter_by_timezone' ],
'featured' => [ $this, 'filter_by_featured' ],
'hidden' => [ $this, 'filter_by_hidden' ],
'linked_post' => [ $this, 'filter_by_linked_post' ],
'organizer' => [ $this, 'filter_by_organizer' ],
'sticky' => [ $this, 'filter_by_sticky' ],
'venue' => [ $this, 'filter_by_venue' ],
'cost_currency_symbol' => [ $this, 'filter_by_cost_currency_symbol' ],
'cost' => [ $this, 'filter_by_cost' ],
'cost_between' => [ $this, 'filter_by_cost_between' ],
'cost_less_than' => [ $this, 'filter_by_cost_less_than' ],
'cost_greater_than' => [ $this, 'filter_by_cost_greater_than' ],
'on_date' => [ $this, 'filter_by_on_date' ],
]
);
// Add backcompat aliases.
$this->schema['hide_upcoming'] = [ $this, 'filter_by_hidden' ];
$this->schema['start_date'] = [ $this, 'filter_by_starts_on_or_after' ];
$this->schema['end_date'] = [ $this, 'filter_by_ends_on_or_before' ];
$this->add_simple_meta_schema_entry( 'website', '_EventURL' );
$this->add_simple_tax_schema_entry( 'event_category', Tribe__Events__Main::TAXONOMY );
$this->add_simple_tax_schema_entry( 'event_category_not_in', Tribe__Events__Main::TAXONOMY, 'term_not_in' );
$this->add_simple_tax_schema_entry( 'tag', 'post_tag' );
$this->add_simple_tax_schema_entry( 'tag_not_in', 'post_tag', 'term_not_in' );
}
Changelog
| Version | Description |
|---|---|
| 4.9 | Introduced. |