public
Theater_Date[]
|
#
get( array[string] $filters = array() )
Gets a list of event dates.
Gets a list of event dates.
Usage
Theater_Dates::get();
Theater_Dates::get( array( 'event' => 123, 'start' => 'now' ) );
Shorthand
This method is also used if you call the Theater_Dates class as a function:
$dates = new Theater_Dates;
foreach ( $dates() as $date ) {
echo $date->title();
}
Parameters
- $filters
An array of filter arguments. Optional.
Possible argument values:
argument |
type |
description |
cat |
int|string |
Category ID or comma-separated list of IDs. |
category_name |
string |
Category slug. |
category__and |
string |
An array of category IDs (AND in). |
category__in |
int[] |
An array of category IDs (OR in, no children). |
category__not_in |
int[] |
An array of category IDs (NOT in). |
tag |
string |
Tag slug. Comma-separated (either), Plus-separated (all). |
end |
string |
A date/time string. Only show event dates that start before this date. |
|
|
Valid formats are explained in |
|
|
Date and Time Formats. |
event |
int|array |
Event ID of an array of event IDs. Only show dates of one or more events. |
limit |
int |
Number of dates to return. Use -1 to show all event dates. |
order |
string |
The order in which to return the event dates. Either ASC or DESC . |
post__in |
int[] |
Array of event date IDs. |
post__not_in |
int[] |
Array of event date IDs. |
season |
int |
Season ID. Only show event dates for this season |
s |
string |
Search keyword(s). Prepending a term with a hyphen will |
|
|
exclude events matching that term. Eg, 'pillow -sofa' will |
|
|
return events containing 'pillow' but not 'sofa'. |
start |
string |
A date/time string. Only show event dates that start after this date. |
|
|
Valid formats are explained in |
|
|
Date and Time Formats. |
status |
array |
Array of post statusses. Only show event dates of events with these |
|
|
statuses. |
Returns
Theater_Date[] An array of events.
Since
0.5
0.10 Renamed method from load() to get() .
Added 'order' to $args.
0.10.14 Preload events with their productions.
This dramatically decreases the number of queries needed to show a listing of events.
0.10.15 'Start' and 'end' $args now account for timezones.
Fixes #117.
0.11.8 Support for 'post__in' and 'post__not_in'.
Fixes #128.
0.13 Added support for multiple productions.
0.13.1 'Start' and 'end' filter explicitly set to 'NUMERIC'.
Fixes #168.
0.15 Added support for 's' (keyword search).
0.16 Replaced the production filter with the event filter.
Uses
Theater_Dates::$default_args
WPT_Order::meta_key to get the key to filter when the 'start' or 'end' filter is used.
Theater_Date::post_type_name to get the event date post type.
WPT_Production::post_type_name to get the events post type if the 'event' or
's' (keyword search) filter is used.
WPT_Season::post_type_name to get the seasons post type if the 'season' filter is used.
WPT_Productions::get() to find productions if the 's' (keyword search) filter is used.
Theater_Date to create a new event date object for each event in the list.
Used by
Overrides
|
public
array[string]string
|
#
get_categories( array $filters = array() )
Gets an array of all categories for an event dates list.
Gets an array of all categories for an event dates list.
Parameters
- $filters
- See Theater_Dates::get() for possible values.
Returns
array[string]string An array of category slug => name pairs.
Since
0.5
0.10 Renamed method from categories() to get_categories() .
0.10.2 Now returns the slug instead of the term_id as the array keys.
0.10.14 Significally decreased the number of queries used.
Uses
Theater_Dates::get() to get a list of all event dates for a list.
|
protected
array
|
#
get_classes_for_html( array $args = array() )
Gets the CSS classes for an event dates list.
Gets the CSS classes for an event dates list.
Parameters
- $args
- See
Theater_Dates::get_html() for possible values. Default: array().
Returns
array The CSS classes.
Since
0.10
0.14.7 Added $args to parent::get_classes_for_html() .
Uses
Theater_Lists::get_classes_for_html() to retrieve the default classes for a list.
Overrides
|
public
array
|
#
get_days( array $filters = array() )
Gets an array of all days with event dates.
Gets an array of all days with event dates.
Parameters
- $filters
- See
Theater_Dates::get() for possible values.
Returns
array Days.
Since
0.8
0.10 No longer limits the output to days with upcoming events.
See: https://github.com/slimndap/wp-theatre/issues/75
Renamed method from days() to get_days() .
0.10.1 Removed custom sorting. Rely on the sorting order of the events instead.
0.10.6 Added custom sorting again.
Can't rely on sorting order of events, because historic events have no
_wpt_order set.
Uses
Theater_Dates::get() to get a list of all event dates for a list.
|
public
string
|
#
get_html( array[string] $args = array() )
Gets a fully formatted list of event dates in HTML.
Gets a fully formatted list of event dates in HTML.
The list of dates is compiled using filter arguments that are part of $args .
Basic usage
echo Theater_Dates::get_html();
echo Theater_Dates::get_html( array( 'start' => 'now' ) );
See Theater_Dates::get() for possible values for $args .
Customized output
Additionally, it is possible to customize the output using formatting argument:
echo Theater_Dates::get_html( array( 'paginateby' => 'category' ) );
echo Theater_Dates::get_html( array( 'start' => 'now' ) );
The event dates can be shown on a single page or be cut up into multiple pages by setting
$paginateby . If $paginateby is set then a page navigation is added to the top of
the listing.
The dates can be grouped inside the pages by setting $groupby .
Parameters
- $args
An array of arguments. Optional.
The possible argument are identical to Theater_Dates::get() , plus the following formatting arguments:
Possible argument values:
argument |
type |
description |
paginateby |
string[] |
Array of field names to paginate the list by. |
|
|
Possible values: day , month , year and category . |
groupby |
string |
Field name to group the list by. |
|
|
Possible values: day , month , year and category . |
template |
string |
Template to use for the individual event dates. |
Returns
string A fully formatted list of event dates in HTML.
Since
0.5
0.10 Moved parts of this method to seperate reusable methods.
Renamed method from html() to get_html() .
Rewrote documentation.
Uses
Overrides
|
protected
string
|
#
get_html_for_category( string $category_slug, array $args = array() )
Gets a list of event dates in HTML for a single category.
Gets a list of event dates in HTML for a single category.
Parameters
- $category_slug
- Slug of the category.
- $args
- See Theater_Dates::get_html() for possible values.
Returns
string The HTML.
Since
0.10
0.10.2 Category now uses slug instead of term_id.
Uses
Theater_Dates::get_html_grouped();
|
protected
string
|
#
get_html_for_day( string $day, array $args = array() )
Gets a list of event dates in HTML for a single day.
Gets a list of event dates in HTML for a single day.
Parameters
- $day
- The day in
YYYY-MM-DD format.
- $args
- See Theater_Dates::get_html() for possible values.
Returns
string The HTML.
Since
0.10
Uses
Theater_Dates::get_html_grouped();
|
protected
string
|
#
get_html_for_month( string $month, array $args = array() )
Gets a list of event dates in HTML for a single month.
Gets a list of event dates in HTML for a single month.
Parameters
- $month
- $day The month in
YYYY-MM format.
- $args
- See Theater_Dates::get_html() for possible values.
Returns
string The HTML.
Since
0.10
Uses
Theater_Dates::get_html_grouped();
|
protected
string
|
#
get_html_for_year( string $year, array $args = array() )
Gets a list of event dates in HTML for a single year.
Gets a list of event dates in HTML for a single year.
Parameters
- $year
- $day The year in
YYYY format.
- $args
- See Theater_Dates::get_html() for possible values.
Returns
string The HTML.
Since
0.10
Uses
Theater_Dates::get_html_grouped();
|
protected
string
|
#
get_html_for_page( array $args = array() )
Gets a list of event dates in HTML for a page.
Gets a list of event dates in HTML for a page.
Parameters
- $args
- See Theater_Dates::get_html() for possible values.
Returns
string The HTML.
Since
0.10
Uses
Theater_Dates::get_html_grouped()
Theater_Dates::get_html_for_year()
Theater_Dates::get_html_for_month()
Theater_Dates::get_html_for_day()
Theater_Dates::get_html_for_category()
Overrides
|
protected
string
|
#
get_html_grouped( array $args = array() )
Gets a grouped list of event dates in HTML.
Gets a grouped list of event dates in HTML.
The event dates can be grouped inside a page by setting $groupby.
If $groupby is not set then all events are show in a single, ungrouped list.
Parameters
- $args
- See Theater_Dates::get_html() for possible values.
Returns
string The HTML.
Since
0.10
0.14.7 Added $args to $event->html().
Uses
Theater_Dates::$default_args_for_html
Theater_Dates::html()
Theater_Dates::get_html_for_month()
Theater_Dates::get_html_for_day()
Theater_Dates::get_html_for_category()
Theater_Dates::get()
Theater_Dates::preload_dates_with_events()
Theater_Date::get_html() to get the HTML output of an event date.
|
protected
string
|
#
get_html_page_navigation( array $args = array() )
Gets the page navigation for an event dates list in HTML.
Gets the page navigation for an event dates list in HTML.
Parameters
- $args
The arguments being used for the event listing.
See Theater_Dates::get_html() for possible values.
Returns
string The HTML for the page navigation.
Since
0.10
0.13.4 Show the pagination filters in the same order as the
the 'paginateby' argument.
Uses
Overrides
|
public
array
|
#
get_months( array $filters = array() )
Gets all months that have events.
Gets all months that have events.
Parameters
- $filters
- See Theater_Dates::get() for possible values.
Returns
array Months.
Since
0.5
0.10 No longer limits the output to months with upcoming events.
See: https://github.com/slimndap/wp-theatre/issues/75
Renamed method from months() to get_months() .
0.10.1 Removed custom sorting. Rely on the sorting order of the events instead.
0.10.6 Added custom sorting again.
Can't rely on sorting order of events, because historic events have no
_wpt_order set.
Uses
Theater_Dates::get() to get a list of all event dates for a list.
Theater_Date::datetime()
|
public
array
|
#
get_years( array $filters = array() )
Gets all distincs years for an event dates list.
Gets all distincs years for an event dates list.
Parameters
- $filters
- See Theater_Dates::get() for possible values.
Returns
array Years.
Since
0.10
0.10.1 Removed custom sorting. Rely on the sorting order of the events instead.
0.10.6 Added custom sorting again.
Can't rely on sorting order of events, because historic events have no
_wpt_order set.
Uses
Theater_Dates::get() to get a list of all event dates for a list.
Theater_Date::datetime()
|
protected
Theater_Date[]
|
#
preload_dates_with_events( Theater_Date[] $dates )
Preloads dates with their events.
Preloads dates with their events.
Sets the event of a each date in a list of event dates with a single query.
This dramatically decreases the number of queries needed to show a list of event dates.
Parameters
- $dates
- $events An array of Theater_Date objects.
Returns
Theater_Date[] An array of Theater_Date objects, with the event preloaded.
Since
0.10.14
Uses
WPT_Production::post_type_name
Theater_Date::$ID
Theater_Date::$production
WPT_Production
|
public
|
#
categories( $filters = array() )
Deprecated
0.10
See
Theater_Dates::get_categories()
|
public
|
#
days( $filters = array() )
Deprecated
0.10
See
Theater_Dates::get_days()
|
public
Theater_Date|boolean
|
#
last( )
Gets the last event date.
Gets the last event date.
Deprecated
0.16
Returns
Theater_Date|boolean The last event date or if no event date is found.
Since
0.8
|
public
|
#
months( $filters = array() )
Deprecated
0.10
See
Theater_Dates::get_months()
|