-
-
Save tommcfarlin/24e5bae859863d39512abc2af2169fbb to your computer and use it in GitHub Desktop.
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
<?php | |
/** | |
* Retrieves the title of the Event, a custom post type. | |
* | |
* @param int $eventId the ID of the event post type | |
* @return string the title of the post. | |
*/ | |
public function getName(int $eventId): string | |
{ | |
return get_the_title($eventId); | |
} |
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
<?php | |
/** | |
* A helper function for easily retrieving post meta data for a given Event. | |
* | |
* @param int $id the ID of the event | |
* @param string $key the key for the post meta data for which we're retrieveing the data | |
* | |
* @return string the result of retrieiving the meta data | |
*/ | |
private function get(int $id, string $key): string | |
{ | |
return get_post_meta($id, $key, true); | |
} |
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
<?php | |
/** | |
* @param int $eventID the ID of the event | |
* @return string the name of the event of an empty string | |
*/ | |
public function getLocationName($eventId): string | |
{ | |
return $this->get($eventId, 'ymc-event-location-name'); | |
} |
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
<?php | |
/** | |
* @return string the URL to the event next to the current event. | |
*/ | |
public function getNextEventUrl() | |
{ | |
global $wpdb; | |
$results = $wpdb->get_results( | |
$wpdb->prepare( | |
" | |
SELECT * | |
FROM $wpdb->posts | |
WHERE ID > ( | |
SELECT ID | |
FROM $wpdb->posts | |
WHERE ID = %d | |
AND post_type = '%s' | |
AND post_status = '%s' | |
ORDER BY ID ASC | |
) | |
AND post_type = '%s' | |
AND post_status = '%s' | |
ORDER BY ID ASC | |
LIMIT 1 | |
", | |
get_the_ID(), | |
'ymc-events', | |
'publish', | |
'ymc-events', | |
'publish' | |
) | |
); | |
$result = (isset($result[0])) ? $result[0] : ''; | |
return $result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment