-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mechanisms for fetching groups of events by calendar ID or taxonomy t…
…erms
- Loading branch information
Showing
5 changed files
with
134 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
/** | ||
* Utilities for fetching ticketed events. | ||
* | ||
* @category Events | ||
* @package My Tickets | ||
* @author Joe Dolson | ||
* @license GPLv2 or later | ||
* @link https://www.joedolson.com/my-tickets/ | ||
*/ | ||
|
||
/** | ||
* Fetch a group of events on a taxonomy term. | ||
* | ||
* @param string|array $term A term slug or array of term slugs. | ||
* @param string $taxonomy A taxonomy name. Optional; default 'mt-event-group'. | ||
* @param array $types An array of post type names. Optiona; default all enabled types. | ||
* | ||
* @return array | ||
*/ | ||
function mt_get_events_by_term( $term, $taxonomy = 'mt-event-group', $types = array() ) { | ||
$options = array_merge( mt_default_settings(), get_option( 'mt_settings', array() ) ); | ||
$types = ( empty( $types ) ) ? $options['mt_post_types'] : $types; | ||
$args = array( | ||
'post_type' => $types, | ||
'tax_query' => array( | ||
array( | ||
'taxonomy' => $taxonomy, | ||
'field' => 'slug', | ||
'terms' => $term, | ||
), | ||
), | ||
'fields' => 'ids', | ||
'posts_per_page' => -1, | ||
); | ||
|
||
$posts = get_posts( $args ); | ||
|
||
return $posts; | ||
} | ||
|
||
/** | ||
* Fetch a group of events using a My Calendar group ID. Argument is an event ID, gets all events in the same group as that event. | ||
* | ||
* @param string $event_id A My Calendar event ID. | ||
* | ||
* @return array | ||
*/ | ||
function mt_get_events_by_group_id( $event_id ) { | ||
$events = array(); | ||
if ( function_exists( 'mc_get_data' ) ) { | ||
$group_id = mc_get_data( 'event_group_id', $event_id ); | ||
$events = mc_get_grouped_events( $group_id ); | ||
} | ||
|
||
return $events; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters