Example #1
0
 /**
  * AJAX handler for the Map view
  */
 public function ajax_response()
 {
     $tribe_paged = !empty($_POST['tribe_paged']) ? $_POST['tribe_paged'] : 1;
     Tribe__Events__Query::init();
     $post_status = array('publish');
     if (is_user_logged_in()) {
         $post_status[] = 'private';
     }
     $defaults = array('post_type' => Tribe__Events__Main::POSTTYPE, 'posts_per_page' => tribe_get_option('postsPerPage', 10), 'paged' => $tribe_paged, 'post_status' => $post_status, 'eventDisplay' => 'map', 'tribe_geoloc' => true);
     $view_state = 'map';
     /* if past view */
     if (!empty($_POST['tribe_event_display']) && $_POST['tribe_event_display'] == 'past') {
         $view_state = 'past';
         $defaults['eventDisplay'] = 'past';
         $defaults['order'] = 'DESC';
     }
     if (isset($_POST['tribe_event_category'])) {
         $defaults[Tribe__Events__Main::TAXONOMY] = $_POST['tribe_event_category'];
     }
     if (isset($_POST[Tribe__Events__Main::TAXONOMY])) {
         $defaults[Tribe__Events__Main::TAXONOMY] = $_POST[Tribe__Events__Main::TAXONOMY];
     }
     $query = Tribe__Events__Query::getEvents($defaults, true);
     $have_events = 0 < $query->found_posts;
     if ($have_events && Tribe__Events__Pro__Geo_Loc::instance()->is_geoloc_query()) {
         $lat = isset($_POST['tribe-bar-geoloc-lat']) ? $_POST['tribe-bar-geoloc-lat'] : 0;
         $lng = isset($_POST['tribe-bar-geoloc-lng']) ? $_POST['tribe-bar-geoloc-lng'] : 0;
         Tribe__Events__Pro__Geo_Loc::instance()->assign_distance_to_posts($query->posts, $lat, $lng);
     } elseif (!$have_events && isset($_POST['tribe-bar-geoloc'])) {
         Tribe__Notices::set_notice('event-search-no-results', sprintf(__('No results were found for events in or near <strong>"%s"</strong>.', 'tribe-events-calendar-pro'), esc_html($_POST['tribe-bar-geoloc'])));
     } elseif (!$have_events && isset($_POST['tribe_event_category'])) {
         Tribe__Notices::set_notice('events-not-found', sprintf(__('No matching events listed under %s. Please try viewing the full calendar for a complete list of events.', 'tribe-events-calendar-pro'), esc_html($_POST['tribe_event_category'])));
     } elseif (!$have_events) {
         Tribe__Notices::set_notice('event-search-no-results', __('There were no results found.', 'tribe-events-calendar-pro'));
     }
     $response = array('html' => '', 'markers' => array(), 'success' => true, 'tribe_paged' => $tribe_paged, 'max_pages' => $query->max_num_pages, 'total_count' => $query->found_posts, 'view' => $view_state);
     // @TODO: clean this up / refactor the following conditional
     if ($have_events) {
         global $wp_query, $post;
         $data = $query->posts;
         $post = $query->posts[0];
         $wp_query = $query;
         Tribe__Events__Main::instance()->displaying = 'map';
         ob_start();
         tribe_get_view('pro/map/content');
         $response['html'] .= ob_get_clean();
         $response['markers'] = Tribe__Events__Pro__Geo_Loc::instance()->generate_markers($data);
     } else {
         global $wp_query;
         $wp_query = $query;
         Tribe__Events__Main::instance()->setDisplay();
         ob_start();
         tribe_get_view('pro/map/content');
         $response['html'] .= ob_get_clean();
     }
     $response = apply_filters('tribe_events_ajax_response', $response);
     header('Content-type: application/json');
     echo json_encode($response);
     exit;
 }
Example #2
0
 /**
  * Set up the notices for this template
  *
  **/
 public function set_notices()
 {
     parent::set_notices();
     $events_label_singular_lowercase = tribe_get_event_label_singular_lowercase();
     if (!tribe_is_showing_all() && tribe_is_past_event()) {
         Tribe__Notices::set_notice('event-past', sprintf(esc_html__('This %s has passed.', 'the-events-calendar'), $events_label_singular_lowercase));
     }
 }
Example #3
0
 /**
  * Set up the notices for this template
  **/
 public function set_notices()
 {
     parent::set_notices();
     $events_label_singular_lowercase = tribe_get_event_label_singular_lowercase();
     global $post;
     // Check if event has passed
     $gmt_offset = get_option('gmt_offset') >= '0' ? ' +' . get_option('gmt_offset') : ' ' . get_option('gmt_offset');
     $gmt_offset = str_replace(array('.25', '.5', '.75'), array(':15', ':30', ':45'), $gmt_offset);
     if (!tribe_is_showing_all() && strtotime(tribe_get_end_date($post, false, 'Y-m-d G:i') . $gmt_offset) <= time()) {
         Tribe__Notices::set_notice('event-past', sprintf(esc_html__('This %s has passed.', 'the-events-calendar'), $events_label_singular_lowercase));
     }
 }
 /**
  * Returns the requested date as a Y-m (yyyy-mm) formatted string.
  *
  * If the requested date is invalid (such as 1984-25) the current month is returned instead and
  * an appropriate notice presented to the user.
  *
  * @return string
  */
 protected function requested_date()
 {
     // We expect the date to be Y-m (yyyy-mm) format, ie year and date only
     $date = isset($this->args['eventDate']) ? $this->args['eventDate'] : tribe_get_month_view_date();
     // Test and return unmodified if valid
     if (false !== strtotime($date . '-01')) {
         return $date;
     } else {
         Tribe__Notices::set_notice('requested-date-invalid', sprintf(esc_html__('The requested date "%s" was not valid &ndash; showing the current month instead', 'the-events-calendar'), esc_html($date)));
         return date_i18n('Y-m');
     }
 }
Example #5
0
 /**
  * Display the text that shows when there were no events found on this view
  *
  * @return void
  */
 protected function nothing_found_notice()
 {
     list($search_term, $tax_term, $geographic_term) = $this->get_search_terms();
     if (!empty($search_term)) {
         Tribe__Notices::set_notice('event-search-no-results', sprintf(__('There were no results found for <strong>"%s"</strong> this week. Try searching another week.', 'tribe-events-calendar-pro'), esc_html($search_term)));
     } elseif (!empty($geographic_term)) {
         Tribe__Notices::set_notice('event-search-no-results', sprintf(__('No results were found for events in or near <strong>"%s"</strong> this week. Try searching another week.', 'tribe-events-calendar-pro'), esc_html($geographic_term)));
     } elseif (!empty($tax_term)) {
         Tribe__Notices::set_notice('events-not-found', sprintf(__('No matching events listed under %s. Please try viewing the full calendar for a complete list of events.', 'tribe-events-calendar-pro'), $tax_term));
     } else {
         Tribe__Notices::set_notice('event-search-no-results', __('No results were found for this week. Try searching another week.', 'tribe-events-calendar-pro'));
     }
 }
Example #6
0
 /**
  * Get the admin notices
  *
  * @return array
  */
 public static function getNotices()
 {
     _deprecated_function(__METHOD__, '4.0', 'Tribe__Notices::get');
     return Tribe__Notices::get();
 }
 /**
  * Include the List view
  *
  * Accepts an array of query arguments, retrieves them, and returns the html for those events in list view
  *
  * Optional inline example:
  * < code >
  * <?php
  * echo myfunction();
  * ?>
  * </ code >
  *
  * @category Events
  *
  * @param array $args       Args to be passed to Tribe__Events__Query::getEvents()
  * @param bool  $initialize Whether the list view template class needs to be included and initialized
  *
  * @return string
  **/
 function tribe_include_view_list($args = null, $initialize = true)
 {
     global $wp_query;
     // hijack the main query to load the events via provided $args
     if (!is_null($args) || !($wp_query->tribe_is_event || $wp_query->tribe_is_event_category)) {
         $reset_q = $wp_query;
         $wp_query = Tribe__Events__Query::getEvents($args, true);
     }
     // single-event notices are jumping in on this init when loading as a module
     Tribe__Notices::remove_notice('event-past');
     // get the list view template
     ob_start();
     if ($initialize) {
         tribe_initialize_view('Tribe__Events__Template__List');
     }
     tribe_get_view('list/content');
     $list_view_html = ob_get_clean();
     // fix the error of our ways
     if (!empty($reset_q)) {
         $wp_query = $reset_q;
     }
     // return the parsed template
     return $list_view_html;
 }
Example #8
0
 /**
  * Generates html for any notices that have been queued on the current view
  *
  * @category Events
  *
  * @param bool $echo Whether or not to echo the notices html
  *
  * @return void | string
  * @see Tribe__Notices::get()
  **/
 function tribe_the_notices($echo = true)
 {
     $notices = Tribe__Notices::get();
     $html = !empty($notices) ? '<div class="tribe-events-notices"><ul><li>' . implode('</li><li>', $notices) . '</li></ul></div>' : '';
     /**
      * Deprecated the tribe_events_the_notices filter in 4.0 in favor of tribe_the_notices. Remove in 5.0
      */
     $the_notices = apply_filters('tribe_events_the_notices', $html, $notices);
     /**
      * filters the notices HTML
      */
     $the_notices = apply_filters('tribe_the_notices', $html, $notices);
     if ($echo) {
         echo $the_notices;
     } else {
         return $the_notices;
     }
 }
Example #9
0
 protected function nothing_found_notice()
 {
     $events_label_plural_lowercase = tribe_get_event_label_plural_lowercase();
     list($search_term, $tax_term, $geographic_term) = $this->get_search_terms();
     if (empty($search_term) && empty($geographic_term) && !empty($tax_term)) {
         Tribe__Notices::set_notice('events-not-found', sprintf(esc_html__('No matching %1$s listed under %2$s scheduled for %3$s. Please try another day.', 'the-events-calendar'), $events_label_plural_lowercase, $tax_term, '<strong>' . date_i18n(tribe_get_date_format(true), strtotime(get_query_var('eventDate'))) . '</strong>'));
     } elseif (empty($search_term) && empty($geographic_term)) {
         Tribe__Notices::set_notice('events-not-found', sprintf(esc_html__('No %1$s scheduled for %2$s. Please try another day.', 'the-events-calendar'), $events_label_plural_lowercase, '<strong>' . date_i18n(tribe_get_date_format(true), strtotime(get_query_var('eventDate'))) . '</strong>'));
     } else {
         parent::nothing_found_notice();
     }
 }
 /**
  * Sets an appropriate no results found message. This may be overridden in child classes.
  */
 protected function nothing_found_notice()
 {
     $events_label_plural = strtolower(tribe_get_event_label_plural());
     list($search_term, $tax_term, $geographic_term) = $this->get_search_terms();
     $tribe = Tribe__Events__Main::instance();
     if (!empty($search_term)) {
         Tribe__Notices::set_notice('event-search-no-results', sprintf(esc_html__('There were no results found for %s.', 'the-events-calendar'), '<strong>"' . esc_html($search_term) . '"</strong>'));
     } elseif (!empty($geographic_term)) {
         Tribe__Notices::set_notice('event-search-no-results', sprintf(esc_html__('No results were found for %1$s in or near %2$s.', 'the-events-calendar'), $events_label_plural, '<strong>"' . esc_html($geographic_term) . '"</strong>'));
     } elseif (!empty($tax_term) && tribe_is_upcoming() && date('Y-m-d') === date('Y-m-d', strtotime($tribe->date))) {
         Tribe__Notices::set_notice('events-not-found', sprintf(esc_html__('No upcoming %1$s listed under %2$s. Check out upcoming %3$s for this category or view the full calendar.', 'the-events-calendar'), $events_label_plural, $tax_term, $events_label_plural));
     } elseif (!empty($tax_term) && tribe_is_upcoming()) {
         Tribe__Notices::set_notice('events-not-found', sprintf(esc_html__('No matching %1$s listed under %2$s. Please try viewing the full calendar for a complete list of %3$s.', 'the-events-calendar'), $events_label_plural, $tax_term, $events_label_plural));
     } elseif (!empty($tax_term) && tribe_is_past()) {
         Tribe__Notices::set_notice('events-past-not-found', sprintf(esc_html__('No previous %s ', 'the-events-calendar'), $events_label_plural));
     } elseif (!empty($tax_term)) {
         Tribe__Notices::set_notice('events-not-found', sprintf(esc_html__('No matching %1$s listed under %2$s. Please try viewing the full calendar for a complete list of %3$s.', 'the-events-calendar'), $events_label_plural, $tax_term, $events_label_plural));
     } else {
         Tribe__Notices::set_notice('event-search-no-results', esc_html__('There were no results found.', 'the-events-calendar'));
     }
 }