/** * Responsible for displaying a user's custom recurrence pattern description. * * @deprecated since 3.6 * @param string $meta_id The meta group this is in. * @return string The custom description. * @author Timothy Wood * @since 3.0 */ public static function custom_recurrence_description($meta_id) { global $_tribe_meta_factory; $post_id = get_the_ID(); $recurrence_meta = TribeEventsRecurrenceMeta::getRecurrenceMeta($post_id); $recurrence_description = !empty($recurrence_meta['recCustomRecurrenceDescription']) ? $recurrence_meta['recCustomRecurrenceDescription'] : tribe_get_recurrence_text($post_id); $html = tribe_is_recurring_event($post_id) ? Tribe_Meta_Factory::template($_tribe_meta_factory->meta[$meta_id]['label'], $recurrence_description, $meta_id) : ''; return apply_filters('tribe_event_pro_meta_custom_recurrence_description', $html); }
protected function should_filter_permalink($post, $sample) { if ($post->post_type != TribeEvents::POSTTYPE) { return false; } if (!tribe_is_recurring_event($post->ID)) { return false; } $unpublished = isset($post->post_status) && in_array($post->post_status, array('draft', 'pending', 'auto-draft')); if ($unpublished && !$sample) { return false; } return true; }
public static function addDateToEventPermalink($permalink, $the_post) { global $post; $event = $the_post ? $the_post : $post; if (tribe_is_recurring_event($post->ID)) { $events = TribeEvents::instance(); if ('' == get_option('permalink_structure') || false == $events->getOption('useRewriteRules', true)) { return esc_url(add_query_arg('eventDate', TribeDateUtils::dateOnly($event->EventStartDate), get_permalink($event->ID))); } else { return $permalink . TribeDateUtils::dateOnly($event->EventStartDate); } } else { return $permalink; } }
public function get_output($event_ID, $complete, $show_seconds, $event_date = null) { $ret = $complete; ob_start(); include Tribe__Events__Templates::getTemplateHierarchy('pro/widgets/countdown-widget'); $hourformat = ob_get_clean(); // Get the event start date. $startdate = tribe_is_recurring_event($event_ID) ? $event_date . ' ' . tribe_get_start_date($event_ID, false, Tribe__Events__Date_Utils::DBTIMEFORMAT) : tribe_get_start_date($event_ID, false, Tribe__Events__Date_Utils::DBDATETIMEFORMAT); // Get the number of seconds remaining until the date in question. $seconds = strtotime($startdate) - current_time('timestamp'); if ($seconds > 0) { $ret = $this->generate_countdown_output($seconds, $complete, $hourformat, $event_ID, $event_date); } return $ret; }
public static function print_all_events_link() { if (tribe_is_recurring_event()) { ?> <p class="tribe-events-back tribe-events-loop"> <a href="<?php echo esc_url(tribe_get_events_link()); ?> "> <?php printf('« ' . esc_html__('All %s', 'the-events-calendar'), tribe_get_event_label_plural()); ?> </a> </p> <?php } }
/** * Returns the link to export the whole recurring series in iCal format. * * @param int|WP_Pos|null $event_id A event post object, an event post ID or null to use the globally defined post object. * * @return string The absolute URL to export the whole recurring series in iCal format. */ function tribe_get_recurrence_ical_link($event_id = null) { $event_id = Tribe__Events__Main::postIdHelper($event_id); if (empty($event_id) || !tribe_is_event($event_id)) { return ''; } $event = get_post($event_id); $parent_id = empty($event->post_parent) ? $event_id : $event->post_parent; $url = get_permalink($parent_id); $url_vars = array('ical' => '1'); if (tribe_is_recurring_event($parent_id)) { $child_events_ids = tribe_get_events(array('fields' => 'ids', 'post_parent' => $parent_id)); $event_ids = array_merge(array($parent_id), $child_events_ids); $url_vars['event_ids'] = implode(',', $event_ids); } $url = add_query_arg($url_vars, $url); return apply_filters('tribe_get_recurrence_ical_link', $url, $event_id); }
/** * 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); }
/** * Alters the provided formatted time to include all recurrence times for the day * * @since 4.0.3 * * @param string $formatted_time Formatted time range for the given event * @param int $event_id Event ID * * @return string */ public function maybe_render_multiple_formatted_times($formatted_time, $event_id) { if (!tribe_is_recurring_event($event_id)) { return $formatted_time; } $date = tribe_get_start_date($event_id, false, Tribe__Date_Utils::DBDATEFORMAT); $time_format = get_option('time_format', Tribe__Date_Utils::TIMEFORMAT); $time_range_separator = tribe_get_option('timeRangeSeparator', ' - '); $events = $this->get_recurring_events_for_date($event_id, $date); $formatted_time = null; foreach ($events as $child) { $start_time = tribe_get_start_date($child->ID, false, $time_format); $end_time = tribe_get_end_date($child->ID, false, $time_format); $formatted_time .= '<div class="tribe-recurring-event-time">'; if ($start_time === $end_time) { $formatted_time .= esc_html($start_time); } else { $formatted_time .= esc_html($start_time . $time_range_separator . $end_time); } $formatted_time .= '</div>'; } return $formatted_time; }
public function add_duplicate_action($actions, $post) { // Not a post? Bail (we aren't using a typehint since some plugins may pass in something a stdClass object etc) if (!is_a($post, 'WP_Post')) { return $actions; } // Not an event? Don't add the link if (Tribe__Events__Main::POSTTYPE !== $post->post_type) { return $actions; } // Recurring event? Don't add the link either! if (function_exists('tribe_is_recurring_event') && tribe_is_recurring_event($post->ID)) { return $actions; } // Form the link $url = $this->duplication_link_url($post->ID); $text = __('Duplicate', 'event-rocket'); $date = tribe_get_start_date($post->ID, false, 'Y-m-d\\TH:i:s'); $title = $this->get_duplicate_post_title($post); $link = '<a href="' . $url . '" class="eventrocket_duplicate" ' . 'data-date="' . $date . '" ' . 'data-title="' . $title . '" ' . '>' . $text . '</a>'; // Add to the list of actions $actions['duplicate'] = $link; return $actions; }
/** * @param array $record * * @return bool */ public function is_valid_record(array $record) { $valid = parent::is_valid_record($record); if (empty($valid)) { return false; } $event = $this->get_event_from($record); if (empty($event)) { return false; } if (function_exists('tribe_is_recurring_event')) { $is_recurring = tribe_is_recurring_event($event->ID); if ($is_recurring) { $this->row_message = sprintf(esc_html__('Recurring event tickets are not supported, event %d.', 'event-tickets'), $event->post_title); } return !$is_recurring; } $this->row_message = false; return true; }
<?php /** * @var array $events */ $columns = array(_x('ID', 'csv-data', 'eventrocket'), _x('Title', 'csv-data', 'eventrocket'), _x('Description', 'csv-data', 'eventrocket'), _x('Start Date', 'csv-data', 'eventrocket'), _x('Start Time', 'csv-data', 'eventrocket'), _x('End Date', 'csv-data', 'eventrocket'), _x('End Time', 'csv-data', 'eventrocket'), _x('Venue', 'csv-data', 'eventrocket'), _x('Organizer', 'csv-data', 'eventrocket'), _x('All Day', 'csv-data', 'eventrocket'), _x('Recurring', 'csv-data', 'eventrocket')); echo join(', ', $columns) . "\n"; foreach ($events as $event) { $fields = array(absint($event->ID), get_the_title($event), $event->post_content, tribe_get_start_date($event->ID, false, 'Y-m-d'), tribe_get_start_date($event->ID, false, 'H:i:s'), tribe_get_end_date($event->ID, false, 'Y-m-d'), tribe_get_end_date($event->ID, false, 'H:i:s'), tribe_get_venue($event->ID), tribe_get_organizer($event->ID), tribe_event_is_all_day($event->ID) ? '1' : '0', tribe_is_recurring_event($event->ID) ? '1' : '0'); foreach ($fields as &$csv_field) { $csv_field = '"' . str_replace('"', '""', $csv_field) . '"'; } echo join(', ', $fields) . "\n"; }
/** * Add the date to the edit link for recurring events. * * @param string $link The current link. * @param int $eventId The event id. * @return string The modified link. */ public static function add_event_occurrance_to_edit_link($link, $eventId) { if (get_query_var('post_type') != TribeEvents::POSTTYPE) { return $link; } // if is a recurring event if (function_exists('tribe_is_recurring_event') && tribe_is_recurring_event($eventId) && isset(self::$events_list[0])) { $link = add_query_arg('eventDate', urlencode(TribeDateUtils::dateOnly(self::$events_list[0]->EventStartDate)), $link); } return $link; }
</a></dd> <?php } ?> <dt class="event-label event-label-updated"><?php _e('Updated:', 'tribe-events-calendar'); ?> </dt> <dd class="event-meta event-meta-updated"><span class="date updated"><?php the_date(); ?> </span></dd> <?php if (class_exists('TribeEventsRecurrenceMeta') && function_exists('tribe_get_recurrence_text') && tribe_is_recurring_event()) { ?> <dt class="event-label event-label-schedule"><?php _e('Schedule:', 'tribe-events-calendar'); ?> </dt> <dd class="event-meta event-meta-schedule"><?php echo tribe_get_recurrence_text(); ?> <?php if (class_exists('TribeEventsRecurrenceMeta') && function_exists('tribe_all_occurences_link')) { ?> (<a href='<?php tribe_all_occurences_link(); ?> '>See all</a>)<?php
/** * Event editing form. * * @param int $id the event's ID. * @return string The editing view markup. * @author Nick Ciske * @since 1.0 */ public function doEventForm($id = null) { if (class_exists('TribeEventsPro')) { // venue and organizer defaults- override ECP defaults add_filter('tribe_get_single_option', array($this, 'filter_default_venue_id'), 10, 3); add_filter('tribe_get_single_option', array($this, 'filter_default_organizer_id'), 10, 3); } add_filter('tribe-post-origin', array($this, 'filterPostOrigin')); $output = ''; $show_form = true; $event = null; if ($id) { $edit = true; $tribe_event_id = $id; } else { $edit = false; $tribe_event_id = null; } if ($tribe_event_id && class_exists('TribeEventsPro') && tribe_is_recurring_event($tribe_event_id)) { $this->enqueueOutputMessage(sprintf(__('%sWarning:%s You are editing a recurring event. All changes will be applied to the entire series.', 'tribe-events-community'), '<b>', '</b>'), 'error'); } // Delete the featured image, if there was a request to do so. if (isset($_GET['action']) && $_GET['action'] == 'deleteFeaturedImage' && wp_verify_nonce($_GET['_wpnonce'], 'tribe_community_events_featured_image_delete') && current_user_can('edit_post', $tribe_event_id)) { $featured_image_id = get_post_thumbnail_id($tribe_event_id); delete_post_meta($tribe_event_id, '_thumbnail_id'); wp_delete_attachment($featured_image_id, true); } if ($edit && $tribe_event_id) { $event = get_post(intval($tribe_event_id)); global $post; $old_post = $post; $post = $event; } if ($edit && (!$tribe_event_id || !isset($event->ID))) { $this->enqueueOutputMessage(__('Event not found.', 'tribe-events-community'), 'error'); $output = $this->outputMessage(null, false); $show_form = false; } // login check if (!$this->allowAnonymousSubmissions && !is_user_logged_in() || $edit && $tribe_event_id && !is_user_logged_in()) { do_action('tribe_ce_event_submission_login_form'); $output .= $this->login_form(__('Please log in first.', 'tribe-events-community')); return $output; } // security check if ($edit && $tribe_event_id && !current_user_can('edit_post', $tribe_event_id)) { $output .= '<p>' . __('You do not have permission to edit this event.', 'tribe-events-community') . '</p>'; return $output; } $this->loadScripts = true; do_action('tribe_ce_before_event_submission_page'); $output .= '<div id="tribe-community-events" class="form">'; if ($this->allowAnonymousSubmissions || is_user_logged_in()) { $current_user = wp_get_current_user(); if (class_exists('TribeEventsPro')) { $tribe_ecp = TribeEventsPro::instance(); } $submission = $this->get_submitted_event(); if (!empty($submission)) { // show no sympathy for spammers if (!is_user_logged_in()) { $this->spam_check($submission); } $submission['ID'] = $tribe_event_id; require_once 'tribe-community-events-submission-scrubber.php'; $scrubber = new TribeCommunityEvents_SubmissionScrubber($submission); $_POST = $scrubber->scrub(); // update the event if ($tribe_event_id && $this->validate_submission_has_required_fields($_POST)) { if ($this->saveEvent($tribe_event_id)) { $this->enqueueOutputMessage(__('Event updated.', 'tribe-events-community') . $this->get_view_edit_links($tribe_event_id)); $this->enqueueOutputMessage('<a href="' . $this->getUrl('add') . '">' . __('Submit another event', 'tribe-events-community') . '</a>'); delete_transient('tribe_community_events_today_page'); //clear cache } else { $this->enqueueOutputMessage($this->get_error_message($_POST, $tribe_event_id), 'error'); } } else { // or create a new one $_POST['post_status'] = $this->defaultStatus; if ($this->validate_submission_has_required_fields($_POST)) { $tribe_event_id = $this->createEvent(); } if ($tribe_event_id) { $this->enqueueOutputMessage(__('Event submitted.', 'tribe-events-community') . $this->get_view_edit_links($tribe_event_id)); $this->enqueueOutputMessage('<a href="' . $this->getUrl('add') . '">' . __('Submit another event', 'tribe-events-community') . '</a>'); // email alerts if ($this->emailAlertsEnabled) { $this->sendEmailAlerts($tribe_event_id); } } else { $this->enqueueOutputMessage($this->get_error_message($_POST, $tribe_event_id), 'error'); //get event info from POST $event = $this->getInfoFromPost(); } } } // are we editing an event? if (isset($tribe_event_id) && $edit) { // global $post; // $event = get_post(intval($tribe_event_id)); } else { if (empty($event)) { $event = new stdClass(); } if (isset($_POST['post_title'])) { $event->post_title = $_POST['post_title']; } if (isset($_POST['post_content'])) { $event->post_content = $_POST['post_content']; } } $show_form = apply_filters('tribe_community_events_show_form', $show_form); if ($show_form) { remove_filter('the_content', 'do_shortcode', 11); //get data from $_POST and override core function add_filter('tribe_get_hour_options', array($this, 'getHours'), 10, 3); add_filter('tribe_get_minute_options', array($this, 'getMinutes'), 10, 3); add_filter('tribe_get_meridian_options', array($this, 'getMeridians'), 10, 3); //turn off upsell -- this is public after all remove_action('tribe_events_cost_table', array(TribeEvents::instance(), 'maybeShowMetaUpsell')); if (class_exists('Event_Tickets_PRO')) { // Remove the eventbrite method hooked into the event form, if it exists. remove_action('tribe_events_cost_table', array(Event_Tickets_PRO::instance(), 'eventBriteMetaBox'), 1); } if (class_exists('TribeEventsPro')) { remove_action('tribe_events_date_display', array('TribeEventsRecurrenceMeta', 'loadRecurrenceData')); add_action('tribe_events_date_display', array($this, 'loadRecurrenceData')); } do_action('tribe_ce_before_event_submission_page_template'); $edit_template = TribeEventsTemplates::getTemplateHierarchy('community/edit-event', array('disable_view_check' => true)); ob_start(); if (empty($_POST) || $this->messageType == 'error') { do_action('tribe_events_community_form', $tribe_event_id, $event, $edit_template); } else { include TribeEventsTemplates::getTemplateHierarchy('community/modules/header-links'); } $output .= ob_get_clean(); } $output .= '</div>'; } wp_reset_query(); remove_filter('tribe-post-origin', array($this, 'filterPostOrigin')); return $output; }
/** * show the recurring event info in a tooltip * * return the details of the start/end date/time * * @since 3.5 * @param int $post_id * @return string */ function tribe_events_recurrence_tooltip($post_id = null) { if (empty($post_id)) { $post_id = get_the_ID(); } $tooltip = ''; if (tribe_is_recurring_event($post_id)) { $tooltip .= '<div class="recurringinfo">'; $tooltip .= '<div class="event-is-recurring">'; $tooltip .= '<span class="tribe-events-divider">|</span>'; $tooltip .= __('Recurring Event', 'tribe-events-calendar'); $tooltip .= sprintf(' <a href="%s">%s</a>', tribe_all_occurences_link($post_id, false), __('(See all)', 'tribe-events-calendar')); $tooltip .= '<div id="tribe-events-tooltip-' . $post_id . '" class="tribe-events-tooltip recurring-info-tooltip">'; $tooltip .= '<div class="tribe-events-event-body">'; $tooltip .= tribe_get_recurrence_text($post_id); $tooltip .= '</div>'; $tooltip .= '<span class="tribe-events-arrow"></span>'; $tooltip .= '</div>'; $tooltip .= '</div>'; $tooltip .= '</div>'; } $tooltip = apply_filters('tribe_events_event_recurring_info_tooltip', $tooltip); // for backwards-compat, will be removed return apply_filters('tribe_events_recurrence_tooltip', $tooltip); }
} } ?> </td> <td><?php echo TribeEventsAdminList::custom_columns('events-cats', $post->ID, false); ?> </td> <?php if (function_exists('tribe_is_recurring_event')) { ?> <td> <?php if (tribe_is_recurring_event($post->ID)) { _e('Yes', 'tribe-events-community'); } else { _e('No', 'tribe-events-community'); } ?> </td> <?php } ?> <td> <?php $start_date = strtotime($post->EventStartDate); echo tribe_event_format_date($start_date, false, TribeCommunityEvents::instance()->eventListDateFormat); ?>
/** * At the pre_get_post hook detect if we should redirect to a particular instance * for an invalid 404 recurrence entries. * * @return void */ public function detect_recurrence_redirect() { global $wp_query, $wp; if (!isset($wp_query->query_vars['eventDisplay'])) { return false; } $current_url = null; switch ($wp_query->query_vars['eventDisplay']) { case 'single-event': // a recurrence event with a bad date will throw 404 because of WP_Query limiting by date range if (is_404() || empty($wp_query->query['eventDate'])) { $recurrence_check = array_merge(array('posts_per_page' => -1), $wp_query->query); unset($recurrence_check['eventDate']); unset($recurrence_check['tribe_events']); // retrieve event object $get_recurrence_event = new WP_Query($recurrence_check); // if a reccurence event actually exists then proceed with redirection if (!empty($get_recurrence_event->posts) && tribe_is_recurring_event($get_recurrence_event->posts[0]->ID) && get_post_status($get_recurrence_event->posts[0]) == 'publish') { $current_url = Tribe__Events__Main::instance()->getLink('all', $get_recurrence_event->posts[0]->ID); } break; } // A child event should be using its parent's slug. If it's using its own, redirect. if (tribe_is_recurring_event(get_the_ID()) && '' !== get_option('permalink_structure')) { $event = get_post(get_the_ID()); if (!empty($event->post_parent)) { if (isset($wp_query->query['name']) && $wp_query->query['name'] == $event->post_name) { $current_url = get_permalink($event->ID); } } } break; } if (!empty($current_url)) { // redirect user with 301 $confirm_redirect = apply_filters('tribe_events_pro_detect_recurrence_redirect', true, $wp_query->query_vars['eventDisplay']); do_action('tribe_events_pro_detect_recurrence_redirect', $wp_query->query_vars['eventDisplay']); if ($confirm_redirect) { wp_safe_redirect($current_url, 301); exit; } } }
/** * Adds the dialog box for when you try to delete a specific instance of a recurring event. * * @return void */ public function addDeleteDialogForRecurringEvents() { global $current_screen, $post; if (is_admin() && isset($current_screen->post_type) && $current_screen->post_type == TribeEvents::POSTTYPE && (isset($current_screen->id) && $current_screen->id == 'edit-' . TribeEvents::POSTTYPE || isset($post->ID) && tribe_is_recurring_event($post->ID))) { // load the dialog require_once TribeEvents::instance()->pluginPath . 'admin-views/recurrence-dialog.php'; } }
/** * Filters the sample permalink to show a link to the first instance of recurring events. * * This is to match the real link pointing to a recurring events series first instance. * * @param string $permalink Sample permalink. * @param int $post_id Post ID. * * @return string The permalink to the first recurring event instance if the the event * is a recurring one, the original permalink otherwise. */ public function filter_sample_permalink($permalink, $post_id) { if (!empty($post_id) && tribe_is_recurring_event($post_id)) { // fetch the real post permalink, recurring event filters down the road will // append the date to it $permalink = get_post_permalink($post_id); } return $permalink; }
/** * We override the parent load_post_by_slug() method in order to better support recurring * events. * * It appears to an end user that a recurring event has a slug like "my-event", as they * have URLs in the form "example.com/events/my-event/(date)". However, the true slug/post * name is actually more like "my-event-yyyy-mm-dd". * * This causes a bit of a disconnect which this method tries to solve. * * @param $slug * @param $post_type * @return array */ protected function load_post_by_slug($slug, $post_type) { $event = parent::load_post_by_slug($slug, $post_type); // If PRO is not activated/there are no recurrence facilities, let's do nothing more if (!function_exists('tribe_is_recurring_event')) { return $event; } // If this specific event is not in fact recurring in nature, let's do nothing more if (!tribe_is_recurring_event($event->ID)) { return $event; } // Add to list of recurring events before returning parent ID $rec_id = $event->post_parent ? $event->post_parent : $event->ID; $this->recurring_events[] = $rec_id; return $event; }
/** * At the pre_get_post hook detect if we should redirect to a particular instance * for an invalid 404 recurrence entries. * * @return void * @author Timothy Wood * @since 3.0 */ function detect_recurrence_redirect() { global $wp_query, $wp; if (!isset($wp_query->query_vars['eventDisplay'])) { return false; } $current_url = null; switch ($wp_query->query_vars['eventDisplay']) { case 'single-event': // a recurrence event with a bad date will throw 404 because of WP_Query limiting by date range if (is_404() || empty($wp_query->query['eventDate'])) { $recurrence_check = array_merge(array('posts_per_page' => -1), $wp_query->query); unset($recurrence_check['eventDate']); unset($recurrence_check['tribe_events']); // retrieve event object $get_recurrence_event = new WP_Query($recurrence_check); // if a reccurence event actually exists then proceed with redirection if (!empty($get_recurrence_event->posts) && tribe_is_recurring_event($get_recurrence_event->posts[0]->ID) && get_post_status($get_recurrence_event->posts[0]) == 'publish') { // get next recurrence $next_recurrence = $this->get_last_recurrence($get_recurrence_event->posts); // set current url to the next available recurrence and await redirection if (empty($wp_query->query['eventDate'])) { $current_url = home_url($wp->request) . '/' . $next_recurrence; } else { $current_url = str_replace($wp_query->query['eventDate'], $next_recurrence, home_url($wp->request)); } } break; } // A child event should be using its parent's slug. If it's using its own, redirect. if (tribe_is_recurring_event(get_the_ID())) { $event = get_post(get_the_ID()); if (!empty($event->post_parent)) { if (isset($wp_query->query['name']) && $wp_query->query['name'] == $event->post_name) { $current_url = get_permalink($event->ID); } } } break; } if (!empty($current_url)) { // redirect user with 301 $confirm_redirect = apply_filters('tribe_events_pro_detect_recurrence_redirect', true, $wp_query->query_vars['eventDisplay']); do_action('tribe_events_pro_detect_recurrence_redirect', $wp_query->query_vars['eventDisplay']); if ($confirm_redirect) { wp_safe_redirect($current_url, 301); exit; } } }
/** * show the recurring event info in a tooltip * * return the details of the start/end date/time * * @since 3.0 * @param int $post_id * @return string */ function tribe_events_event_recurring_info_tooltip($post_id = null) { if (is_null($post_id)) { $post_id = get_the_ID(); } $tooltip = ''; if (class_exists('TribeEventsPro')) { // should this be a template tag? if (tribe_is_recurring_event($post_id)) { $tooltip .= '<div class="recurringinfo">'; $tooltip .= '<div class="event-is-recurring">'; $tooltip .= '<span class="tribe-events-divider">|</span>'; $tooltip .= __('Recurring Event', 'tribe-events-calendar'); $tooltip .= sprintf(' <a href="%s">%s</a>', tribe_all_occurences_link($post_id, false), __('(See all)', 'tribe-events-calendar')); $tooltip .= '<div id="tribe-events-tooltip-' . $post_id . '" class="tribe-events-tooltip recurring-info-tooltip">'; $tooltip .= '<div class="tribe-events-event-body">'; $tooltip .= tribe_get_recurrence_text($post_id); $tooltip .= '</div>'; $tooltip .= '<span class="tribe-events-arrow"></span>'; $tooltip .= '</div>'; $tooltip .= '</div>'; $tooltip .= '</div>'; } } return apply_filters('tribe_events_event_recurring_info_tooltip', $tooltip); }
public static function remove_child_thumbnails($meta_ids, $post_id, $meta_key, $meta_value) { static $recursing = false; if ($recursing || $meta_key != '_thumbnail_id' || !tribe_is_recurring_event($post_id)) { return; } $recursing = true; // don't repeat this for child events $children = self::children()->get_ids($post_id); foreach ($children as $child_id) { delete_post_meta($child_id, $meta_key, $meta_value); } $recursing = false; }
/** * At the pre_get_post hook detect if we should redirect to a particular instance * for an invalid 404 recurrence entries. * * @return mixed */ public function detect_recurrence_redirect() { global $wp_query, $wp; if (!isset($wp_query->query_vars['eventDisplay'])) { return false; } $current_url = null; $problem = _x('Unknown', 'debug recurrence', 'tribe-events-calendar-pro'); switch ($wp_query->query_vars['eventDisplay']) { case 'single-event': // a recurrence event with a bad date will throw 404 because of WP_Query limiting by date range if (is_404() || empty($wp_query->query['eventDate'])) { $recurrence_check = array_merge(array('posts_per_page' => -1), $wp_query->query); unset($recurrence_check['eventDate']); unset($recurrence_check['tribe_events']); // retrieve event object $get_recurrence_event = new WP_Query($recurrence_check); // if a reccurence event actually exists then proceed with redirection if (!empty($get_recurrence_event->posts) && tribe_is_recurring_event($get_recurrence_event->posts[0]->ID) && get_post_status($get_recurrence_event->posts[0]) == 'publish') { $problem = _x('invalid date', 'debug recurrence', 'tribe-events-calendar-pro') . empty($wp_query->query['eventDate']) ? '' : ': ' . $wp_query->query['eventDate']; $current_url = Tribe__Events__Main::instance()->getLink('all', $get_recurrence_event->posts[0]->ID); } break; } // A child event should be using its parent's slug. If it's using its own, redirect. if (tribe_is_recurring_event(get_the_ID()) && '' !== get_option('permalink_structure')) { $event = get_post(get_the_ID()); if (!empty($event->post_parent)) { if (isset($wp_query->query['name']) && $wp_query->query['name'] == $event->post_name) { $problem = _x('incorrect slug', 'debug recurrence', 'tribe-events-calendar-pro'); $current_url = get_permalink($event->ID); } } } break; } /** * Provides an opportunity to modify the redirection URL prior to the actual redirection. * * @param string $current_url */ $current_url = apply_filters('tribe_events_pro_recurrence_redirect_url', $current_url); if (!empty($current_url)) { // redirect user with 301 $confirm_redirect = apply_filters('tribe_events_pro_detect_recurrence_redirect', true, $wp_query->query_vars['eventDisplay']); do_action('tribe_events_pro_detect_recurrence_redirect', $wp_query->query_vars['eventDisplay']); if ($confirm_redirect) { Tribe__Main::instance()->log()->log_warning(sprintf(_x('Invalid instance of a recurring event was requested ($1%s) redirecting to $2%s', 'debug recurrence', 'tribe-events-calendar-pro'), $problem, $current_url), __METHOD__); wp_safe_redirect($current_url, 301); exit; } } }
/** * Filter call that returns the proper link for after a comment is submitted to a recurring event. * * @author PaulHughes01 * @since 2.0.8 * * @param string $content * @param object $comment the comment object * @return string the link */ public function newCommentLink($content, $comment) { if (class_exists('TribeEventsPro') && tribe_is_recurring_event(get_the_ID()) && isset($_REQUEST['eventDate'])) { $link = trailingslashit($this->getLink('single')) . $_REQUEST['eventDate'] . '#comment-' . $comment->comment_ID; } else { $link = $content; } return $link; }
/** * Shows the tickets form in the front end * * @param $content * * @return void */ public function front_end_tickets_form($content) { if ($this->is_frontend_tickets_form_done) { return $content; } $post = $GLOBALS['post']; // For recurring events (child instances only), default to loading tickets for the parent event if (!empty($post->post_parent) && function_exists('tribe_is_recurring_event') && tribe_is_recurring_event($post->ID)) { $post = get_post($post->post_parent); } $tickets = $this->get_tickets($post->ID); if (empty($tickets)) { return; } $rsvp_sent = empty($_GET['rsvp_sent']) ? false : true; $rsvp_error = empty($_GET['rsvp_error']) ? false : intval($_GET['rsvp_error']); if ($rsvp_sent) { $this->add_message(__('Your RSVP has been received! Check your email for your RSVP confirmation.', 'event-tickets'), 'success'); } if ($rsvp_error) { switch ($rsvp_error) { case 2: $this->add_message(__('You can\'t RSVP more than the total remaining tickets.', 'event-tickets'), 'error'); break; case 1: default: $this->add_message(__('In order to RSVP, you must enter your name and a valid email address.', 'event-tickets'), 'error'); break; } } $must_login = !is_user_logged_in() && $this->login_required(); include $this->getTemplateHierarchy('tickets/rsvp'); // It's only done when it's included $this->is_frontend_tickets_form_done = true; }
public static function enqueue_post_editor_notices() { if (!empty($_REQUEST['post']) && tribe_is_recurring_event($_REQUEST['post'])) { add_action('admin_notices', array(Tribe__Events__Pro__Recurrence__Admin_Notices::instance(), 'display_editing_all_recurrences_notice'), 10, 0); add_action('admin_notices', array(Tribe__Events__Pro__Recurrence__Admin_Notices::instance(), 'display_created_recurrences_notice'), 10, 0); } }
/** * show the recurring event info in a tooltip * * return the details of the start/end date/time * * @param int $post_id * * @return string * @todo remove tribe_events_event_recurring_info_tooltip filter in 3.11 */ function tribe_events_recurrence_tooltip($post_id = null) { if (empty($post_id)) { $post_id = get_the_ID(); } $tooltip = ''; if (tribe_is_recurring_event($post_id)) { $tooltip .= '<div class="recurringinfo">'; $tooltip .= '<div class="event-is-recurring">'; $tooltip .= '<span class="tribe-events-divider">|</span>'; $tooltip .= sprintf(__('Recurring %s', 'tribe-events-calendar-pro'), tribe_get_event_label_singular()); $tooltip .= sprintf(' <a href="%s">%s</a>', esc_url(tribe_all_occurences_link($post_id, false)), __('(See all)', 'tribe-events-calendar-pro')); $tooltip .= '<div id="tribe-events-tooltip-' . $post_id . '" class="tribe-events-tooltip recurring-info-tooltip">'; $tooltip .= '<div class="tribe-events-event-body">'; $tooltip .= tribe_get_recurrence_text($post_id); $tooltip .= '</div>'; $tooltip .= '<span class="tribe-events-arrow"></span>'; $tooltip .= '</div>'; $tooltip .= '</div>'; $tooltip .= '</div>'; } if (has_filter('tribe_events_event_recurring_info_tooltip')) { _deprecated_function("The 'tribe_get_related_events' filter", '3.9', " the 'tribe_events_recurrence_tooltip' filter"); $tooltip = apply_filters('tribe_events_event_recurring_info_tooltip', $tooltip); // for backwards-compat, will be removed } return apply_filters('tribe_events_recurrence_tooltip', $tooltip); }
<tr class="recurrence-row"> <td><?php _e('Recurrence:', 'tribe-events-calendar-pro'); ?> </td> <td> <?php $has_recurrences = tribe_is_recurring_event($postId); ?> <input type="hidden" name="is_recurring" value="<?php echo isset($recType) && $recType != "None" && $has_recurrences ? "true" : "false"; ?> " /> <select name="recurrence[type]"> <option data-plural="" value="None" <?php selected($recType, "None"); ?> ><?php _e('None', 'tribe-events-calendar-pro'); ?> </option> <option data-single="<?php _e('day', 'tribe-events-calendar-pro'); ?> " data-plural="<?php _e('days', 'tribe-events-calendar-pro'); ?> " value="Every Day" <?php selected($recType, "Every Day"); ?> ><?php
public static function enqueue_post_editor_notices() { if (!empty($_REQUEST['post']) && tribe_is_recurring_event($_REQUEST['post'])) { add_action('admin_notices', array(__CLASS__, 'display_post_editor_recurring_notice'), 10, 0); } }