本文整理汇总了PHP中TribeEvents::postIdHelper方法的典型用法代码示例。如果您正苦于以下问题:PHP TribeEvents::postIdHelper方法的具体用法?PHP TribeEvents::postIdHelper怎么用?PHP TribeEvents::postIdHelper使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TribeEvents
的用法示例。
在下文中一共展示了TribeEvents::postIdHelper方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tribe_get_gcal_link
/**
* Google Calendar Link
*
* Returns an "add to Google Calendar link for a single event. Must be used in the loop
*
* @param int $postId (optional)
*
* @return string URL for google calendar.
* @since 2.0
*/
function tribe_get_gcal_link($postId = null)
{
$postId = TribeEvents::postIdHelper($postId);
$tribe_ecp = TribeEvents::instance();
$output = esc_url($tribe_ecp->googleCalendarLink($postId));
return apply_filters('tribe_get_gcal_link', $output);
}
示例2: tribe_get_venue_id
/**
* Venue ID
*
* Returns the event Venue ID.
*
* @param int $postId can supply either event id or venue id, if none specified, current post is used
*
* @return int Venue ID
*/
function tribe_get_venue_id($postId = null)
{
$postId = TribeEvents::postIdHelper($postId);
if (tribe_is_venue($postId)) {
return $postId;
} else {
return apply_filters('tribe_get_venue_id', tribe_get_event_meta($postId, '_EventVenueID', true));
}
}
示例3: tribe_venue_upcoming_events
/**
* Output the upcoming events associated with a venue
*
* @return void
* @since 3.0
*/
function tribe_venue_upcoming_events($post_id = false)
{
$post_id = TribeEvents::postIdHelper($post_id);
if ($post_id) {
// turn off the venue group
tribe_set_the_meta_visibility('tribe_event_venue', false, 'meta_group');
$args = array('venue' => $post_id, 'eventDisplay' => 'upcoming');
$html = tribe_include_view_list($args);
// housekeeping: turn on the venue meta group before we leave
tribe_set_the_meta_visibility('tribe_event_venue', true, 'meta_group');
return apply_filters('tribe_venue_upcoming_events', $html);
}
}
示例4: tribe_get_end_date
/**
* End Date
*
* Returns the event end date
*
* @param int $postId (optional) this only works for non recurring events
* @param bool $displayTime If true shows date and time, if false only shows date
* @param string $dateFormat Allows date and time formating using standard php syntax (http://php.net/manual/en/function.date.php)
* @return string Date
* @todo support $postId for recurring events.
* @since 2.0
*/
function tribe_get_end_date($postId = null, $displayTime = 'true', $dateFormat = '')
{
$postId = TribeEvents::postIdHelper($postId);
if (!$postId || function_exists('tribe_is_recurring_event') && tribe_is_recurring_event($postId)) {
global $post;
} else {
$post = get_post($postId);
}
if (tribe_get_all_day($postId)) {
$displayTime = false;
}
if (empty($post->EventEndDate)) {
$post->EventEndDate = tribe_get_event_meta($postId, '_EventEndDate', true);
}
if (isset($post->EventEndDate)) {
$date = strtotime($post->EventEndDate);
} else {
return;
// '—';
}
return tribe_event_format_date($date, $displayTime, $dateFormat);
}
示例5: get_custom_field_by_label
/**
* get_custom_field_by_label
*
* retrieve a custom field's value by searching its label
* instead of its (more obscure) ID
* @author Joachim Kudish
* @since 2.0.3
* @param (string) $label, the label to search for
* @param (int) $eventID (optional), the event to look for, defaults to global $post
* @return (string) value of the field
*/
public static function get_custom_field_by_label($label, $eventID = null)
{
$eventID = TribeEvents::postIdHelper($eventID);
$customFields = tribe_get_option('custom-fields', false);
if (is_array($customFields)) {
foreach ($customFields as $field) {
if ($field['label'] == $label) {
return get_post_meta($eventID, $field['name'], true);
}
}
}
}
示例6: tribe_format_currency
/**
* Receives a float and formats it with a currency symbol
*
* @param $cost pricing to format
*/
function tribe_format_currency($cost, $postId = null, $currency_symbol = null, $reverse_position = null)
{
$postId = TribeEvents::postIdHelper($postId);
// if no currency symbol was passed, and we're looking at a particular event,
// let's check if there was a currency symbol set on that event
if ($postId && $currency_symbol == null) {
$currency_symbol = tribe_get_event_meta($postId, '_EventCurrencySymbol', true);
}
// if no currency symbol was passed, or we're not looking at a particular event,
// let's get the default currency symbol
if (!$postId || !$currency_symbol) {
$currency_symbol = tribe_get_option('defaultCurrencySymbol', '$');
}
if ($postId && $reverse_position == null) {
$reverse_position = tribe_get_event_meta($postId, '_EventCurrencyPosition', true);
$reverse_position = 'suffix' === $reverse_position;
}
if (!$reverse_position || !$postId) {
$reverse_position = tribe_get_option('reverseCurrencyPosition', false);
}
$cost = $reverse_position ? $cost . $currency_symbol : $currency_symbol . $cost;
return $cost;
}
示例7: tribe_get_cost
/**
* Get an event's cost
*
*
* @param null|int $postId (optional)
* @param bool $withCurrencySymbol Include the currency symbol
* @return string Cost of the event.
*/
function tribe_get_cost($postId = null, $withCurrencySymbol = false)
{
$tribe_ecp = TribeEvents::instance();
$postId = TribeEvents::postIdHelper($postId);
$cost = tribe_get_event_meta($postId, '_EventCost', true);
if ($cost === '') {
$cost = '';
} elseif ($cost === '0') {
$cost = __("Free", 'tribe-events-calendar');
} else {
$cost = esc_html($cost);
}
if ($withCurrencySymbol && is_numeric($cost)) {
$currency = tribe_get_event_meta($postId, '_EventCurrencySymbol', true);
if (!$currency) {
$currency = tribe_get_option('defaultCurrencySymbol', '$');
}
$cost = $currency . $cost;
}
return apply_filters('tribe_get_cost', $cost, $postId, $withCurrencySymbol);
}
示例8: sp_post_id_helper
/**
* @deprecated
*/
function sp_post_id_helper($postId)
{
_deprecated_function(__FUNCTION__, '2.0');
return TribeEvents::postIdHelper($postId);
}
示例9: tribe_get_cost
/**
* Event Cost
*
* If EventBrite plugin is active
* - If the event is registered in eventbrite, and has one ticket. Return the cost of that ticket.
* - If the event is registered in eventbrite, and there are many tickets, return "Varies"
* - If the event is not registered in eventbrite, and there is meta, return that.
* - If the event is not registered in eventbrite, and there is no meta, return ""
*
* @param int $postId (optional)
* @return string Cost of the event.
*/
function tribe_get_cost($postId = null)
{
$tribe_ecp = TribeEvents::instance();
$postId = TribeEvents::postIdHelper($postId);
if (class_exists('Eventbrite_for_TribeEvents')) {
global $spEventBrite;
$returned = $spEventBrite->tribe_get_cost($postId);
if ($returned) {
return apply_filters('tribe_get_cost', esc_html($returned));
}
}
$cost = tribe_get_event_meta($postId, '_EventCost', true);
if ($cost === '') {
$cost = '';
} elseif ($cost == '0') {
$cost = __("Free", 'tribe-events-calendar');
} else {
$cost = esc_html($cost);
}
return apply_filters('tribe_get_cost', $cost);
}
示例10: get_ids
protected function get_ids($post_id)
{
$post_id = $post_id = TribeEvents::postIdHelper($post_id);
$this->event_id = tribe_is_event($post_id) ? $post_id : 0;
$this->venue_id = tribe_is_venue($post_id) ? $post_id : tribe_get_venue_id($post_id);
}
示例11: tribe_get_organizer_website_url
function tribe_get_organizer_website_url($postId = null)
{
$postId = TribeEvents::postIdHelper($postId);
$output = esc_url(tribe_get_event_meta(tribe_get_organizer_id($postId), '_OrganizerWebsite', true));
return apply_filters('tribe_get_organizer_website_url', $output);
}
示例12: tribe_get_related_posts
/**
* Template tag to get related posts for the current post.
*
* @since 1.1
* @author Paul Hughes
* @param int $count number of related posts to return.
* @param int|obj $post the post to get related posts to, defaults to current global $post
* @return array the related posts.
*/
function tribe_get_related_posts($count = 3, $post = false)
{
$post_id = TribeEvents::postIdHelper($post);
$tags = wp_get_post_tags($post_id, array('fields' => 'ids'));
$categories = wp_get_object_terms($post_id, TribeEvents::TAXONOMY, array('fields' => 'ids'));
if (!$tags && !$categories) {
return;
}
$args = array('posts_per_page' => $count, 'post__not_in' => array($post_id), 'eventDisplay' => 'upcoming', 'tax_query' => array('relation' => 'OR'), 'orderby' => 'rand');
if ($tags) {
$args['tax_query'][] = array('taxonomy' => 'post_tag', 'field' => 'id', 'terms' => $tags);
}
if ($categories) {
$args['tax_query'][] = array('taxonomy' => TribeEvents::TAXONOMY, 'field' => 'id', 'terms' => $categories);
}
$args = apply_filters('tribe_related_posts_args', $args);
if ($args) {
$posts = TribeEventsQuery::getEvents($args);
} else {
$posts = array();
}
return apply_filters('tribe_get_related_posts', $posts);
}
示例13: tribe_embed_google_map
/**
* Google Map Embed Test
*
* Check if embed google map is enabled for this event.
*
* @param int $postId Id of the post, if none specified, current post is used
* @return bool True if google map option is set to embed the map
* @since 2.0
*/
function tribe_embed_google_map($postId = null)
{
if (!$postId) {
return 0;
}
$postId = TribeEvents::postIdHelper($postId);
return get_post_meta(get_the_ID(), '_EventShowMap', 1) == 1;
}
示例14: tribe_community_events_is_venue_edit_screen
/**
* Test to see if this is the Venue edit screen
*
* @param int|null $venue_id (optional)
* @return bool
* @author Peter Chester
* @since 3.1
*/
function tribe_community_events_is_venue_edit_screen($venue_id = null)
{
$venue_id = TribeEvents::postIdHelper($venue_id);
return tribe_is_venue($venue_id);
}
示例15: tribe_show_google_map_link
/**
* Google Map Link Test
*
* Check if google map link is enabled for this event
*
* @param int $postId Id of the post, if none specified, current post is used
* @return bool True if google map link is set to display the event
* @since 2.0
*/
function tribe_show_google_map_link($postId = null)
{
$output = false;
$postId = TribeEvents::postIdHelper($postId);
$post_type = get_post_type($postId);
if ($post_type == TribeEvents::POSTTYPE) {
$output = get_post_meta($postId, '_EventShowMapLink', 1) == 1;
} elseif ($post_type == TribeEvents::VENUE_POST_TYPE) {
$output = get_post_meta($postId, '_VenueShowMapLink', 1) !== 'false' ? 1 : 0;
}
return apply_filters('tribe_show_google_map_link', $output);
}