/**
  * 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__Notice::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__Notice::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__Notice::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;
 }
Exemplo n.º 2
0
 /**
  * List view ajax handler
  *
  */
 public function ajax_response()
 {
     Tribe__Events__Query::init();
     $tribe_paged = !empty($_POST['tribe_paged']) ? intval($_POST['tribe_paged']) : 1;
     $post_status = array('publish');
     if (is_user_logged_in()) {
         $post_status[] = 'private';
     }
     $args = array('eventDisplay' => 'list', 'post_type' => Tribe__Events__Main::POSTTYPE, 'post_status' => $post_status, 'paged' => $tribe_paged);
     // check & set display
     if (isset($_POST['tribe_event_display'])) {
         if ($_POST['tribe_event_display'] == 'past') {
             $args['eventDisplay'] = 'past';
             $args['order'] = 'DESC';
         } elseif ('all' == $_POST['tribe_event_display']) {
             $args['eventDisplay'] = 'all';
         }
     }
     // check & set event category
     if (isset($_POST['tribe_event_category'])) {
         $args[Tribe__Events__Main::TAXONOMY] = $_POST['tribe_event_category'];
     }
     $args = apply_filters('tribe_events_listview_ajax_get_event_args', $args, $_POST);
     $query = tribe_get_events($args, true);
     // $hash is used to detect whether the primary arguments in the query have changed (i.e. due to a filter bar request)
     // if they have, we want to go back to page 1
     $hash = $query->query_vars;
     $hash['paged'] = null;
     $hash['start_date'] = null;
     $hash['end_date'] = null;
     $hash_str = md5(maybe_serialize($hash));
     if (!empty($_POST['hash']) && $hash_str !== $_POST['hash']) {
         $tribe_paged = 1;
         $args['paged'] = 1;
         $query = Tribe__Events__Query::getEvents($args, true);
     }
     $response = array('html' => '', 'success' => true, 'max_pages' => $query->max_num_pages, 'hash' => $hash_str, 'tribe_paged' => $tribe_paged, 'total_count' => $query->found_posts, 'view' => 'list');
     global $wp_query, $post, $paged;
     $wp_query = $query;
     if (!empty($query->posts)) {
         $post = $query->posts[0];
     }
     $paged = $tribe_paged;
     Tribe__Events__Main::instance()->displaying = apply_filters('tribe_events_listview_ajax_event_display', 'list', $args);
     if (!empty($_POST['tribe_event_display']) && $_POST['tribe_event_display'] == 'past') {
         $response['view'] = 'past';
     }
     ob_start();
     tribe_get_view('list/content');
     $response['html'] .= ob_get_clean();
     apply_filters('tribe_events_ajax_response', $response);
     header('Content-type: application/json');
     echo json_encode($response);
     die;
 }
 /**
  * AJAX handler for Photo view
  *
  * @return void
  */
 public function ajax_response()
 {
     $tec = Tribe__Events__Main::instance();
     Tribe__Events__Query::init();
     $tribe_paged = !empty($_POST['tribe_paged']) ? intval($_POST['tribe_paged']) : 1;
     $post_status = array('publish');
     if (is_user_logged_in()) {
         $post_status[] = 'private';
     }
     $args = array('eventDisplay' => 'list', 'post_type' => Tribe__Events__Main::POSTTYPE, 'post_status' => $post_status, 'paged' => $tribe_paged);
     $view_state = 'photo';
     if (isset($_POST['tribe_event_category'])) {
         $args[Tribe__Events__Main::TAXONOMY] = $_POST['tribe_event_category'];
     }
     /* if past view */
     if (!empty($_POST['tribe_event_display']) && $_POST['tribe_event_display'] == 'past') {
         $view_state = 'past';
         $args['eventDisplay'] = 'past';
         $args['order'] = 'DESC';
     }
     $query = Tribe__Events__Query::getEvents($args, true);
     $hash = $query->query_vars;
     $hash['paged'] = null;
     $hash['start_date'] = null;
     $hash_str = md5(maybe_serialize($hash));
     if (!empty($_POST['hash']) && $hash_str !== $_POST['hash']) {
         $tribe_paged = 1;
         $args['paged'] = 1;
         $query = Tribe__Events__Query::getEvents($args, true);
     }
     $response = array('html' => '', 'success' => true, 'max_pages' => $query->max_num_pages, 'hash' => $hash_str, 'tribe_paged' => $tribe_paged, 'view' => $view_state);
     global $wp_query, $post;
     $wp_query = $query;
     if (!empty($query->posts)) {
         $post = $query->posts[0];
     }
     add_filter('tribe_events_list_pagination', array('Tribe__Events__Main', 'clear_module_pagination'), 10);
     $tec->displaying = 'photo';
     ob_start();
     tribe_get_view('pro/photo/content');
     $response['html'] .= ob_get_clean();
     apply_filters('tribe_events_ajax_response', $response);
     header('Content-type: application/json');
     echo json_encode($response);
     die;
 }
 /**
  * Month View Ajax Handler
  *
  */
 public function ajax_response()
 {
     if (isset($_POST['eventDate']) && $_POST['eventDate']) {
         Tribe__Events__Query::init();
         Tribe__Events__Main::instance()->displaying = 'month';
         global $wp_query;
         $wp_query = tribe_get_events($this->args, true);
         ob_start();
         tribe_get_view('month/content');
         $response = array('html' => ob_get_clean(), 'success' => true, 'view' => 'month');
         apply_filters('tribe_events_ajax_response', $response);
         header('Content-type: application/json');
         echo json_encode($response);
         die;
     }
 }
Exemplo n.º 5
0
 /**
  * Month View Ajax Handler
  *
  * @return void
  */
 function ajax_response()
 {
     if (isset($_POST['eventDate']) && $_POST['eventDate']) {
         Tribe__Events__Query::init();
         $post_status = array('publish');
         if (is_user_logged_in()) {
             $post_status[] = 'private';
         }
         // set the global query var for eventDisplay
         $query_args = array('post_type' => Tribe__Events__Main::POSTTYPE, 'eventDisplay' => 'month', 'eventDate' => $_POST['eventDate'], 'post_status' => $post_status);
         Tribe__Events__Main::instance()->displaying = 'month';
         if (isset($_POST['tribe_event_category'])) {
             $query_args['tribe_events_cat'] = $_POST['tribe_event_category'];
         }
         query_posts($query_args);
         ob_start();
         tribe_get_view('month/content');
         $response = array('html' => ob_get_clean(), 'success' => true, 'view' => 'month');
         apply_filters('tribe_events_ajax_response', $response);
         header('Content-type: application/json');
         echo json_encode($response);
         die;
     }
 }
Exemplo n.º 6
0
 /**
  * Run on applied action init
  */
 public function init()
 {
     $this->pluginName = __('The Events Calendar', 'the-events-calendar');
     $this->rewriteSlug = $this->getRewriteSlug();
     $this->rewriteSlugSingular = $this->getRewriteSlugSingular();
     $this->taxRewriteSlug = $this->getTaxRewriteSlug();
     $this->tagRewriteSlug = $this->getTagRewriteSlug();
     $this->monthSlug = sanitize_title(__('month', 'the-events-calendar'));
     $this->listSlug = sanitize_title(__('list', 'the-events-calendar'));
     $this->upcomingSlug = sanitize_title(__('upcoming', 'the-events-calendar'));
     $this->pastSlug = sanitize_title(__('past', 'the-events-calendar'));
     $this->daySlug = sanitize_title(__('day', 'the-events-calendar'));
     $this->todaySlug = sanitize_title(__('today', 'the-events-calendar'));
     $this->singular_venue_label = $this->get_venue_label_singular();
     $this->plural_venue_label = $this->get_venue_label_plural();
     $this->singular_organizer_label = $this->get_organizer_label_singular();
     $this->plural_organizer_label = $this->get_organizer_label_plural();
     $this->singular_event_label = $this->get_event_label_singular();
     $this->plural_event_label = $this->get_event_label_plural();
     $this->postTypeArgs['rewrite']['slug'] = sanitize_title($this->rewriteSlugSingular);
     $this->postVenueTypeArgs['rewrite']['slug'] = sanitize_title($this->singular_venue_label);
     $this->postVenueTypeArgs['show_in_nav_menus'] = class_exists('Tribe__Events__Pro__Main') ? true : false;
     $this->postOrganizerTypeArgs['rewrite']['slug'] = sanitize_title($this->singular_organizer_label);
     $this->postOrganizerTypeArgs['show_in_nav_menus'] = class_exists('Tribe__Events__Pro__Main') ? true : false;
     $this->postVenueTypeArgs['public'] = class_exists('Tribe__Events__Pro__Main') ? true : false;
     $this->postOrganizerTypeArgs['public'] = class_exists('Tribe__Events__Pro__Main') ? true : false;
     $this->currentDay = '';
     $this->errors = '';
     $this->default_values = apply_filters('tribe_events_default_value_strategy', new Tribe__Events__Default_Values());
     Tribe__Events__Query::init();
     Tribe__Events__Backcompat::init();
     Tribe__Events__Credits::init();
     Tribe__Events__Timezones::init();
     $this->registerPostType();
     self::debug(sprintf(__('Initializing Tribe Events on %s', 'the-events-calendar'), date('M, jS \\a\\t h:m:s a')));
     $this->maybeSetTECVersion();
 }
Exemplo n.º 7
0
 /**
  * AJAX handler for Week view
  * This loads up the week view shard with all the appropriate events for the week
  *
  * @return void
  */
 public function ajax_response()
 {
     if (isset($_POST['eventDate']) && $_POST['eventDate']) {
         Tribe__Events__Query::init();
         $post_status = array('publish');
         if (is_user_logged_in()) {
             $post_status[] = 'private';
         }
         $args = array('post_status' => $post_status, 'eventDate' => $_POST['eventDate'], 'eventDisplay' => 'week');
         if (isset($_POST['tribe_event_category'])) {
             $args[Tribe__Events__Main::TAXONOMY] = $_POST['tribe_event_category'];
         }
         global $wp_query;
         $wp_query = Tribe__Events__Query::getEvents($args, true);
         Tribe__Events__Main::instance()->setDisplay();
         $response = array('html' => '', 'success' => true, 'view' => 'week');
         add_filter('tribe_is_week', '__return_true');
         // simplest way to declare that this is a week view
         ob_start();
         tribe_get_view('pro/week/content');
         $response['html'] .= ob_get_clean();
         apply_filters('tribe_events_ajax_response', $response);
         header('Content-type: application/json');
         echo json_encode($response);
         die;
     }
 }
Exemplo n.º 8
0
 /**
  * AJAX handler for tribe_event_day (dayview navigation)
  * This loads up the day view shard with all the appropriate events for the day
  *
  * @return void
  */
 function ajax_response()
 {
     if (isset($_POST['eventDate']) && $_POST['eventDate']) {
         Tribe__Events__Query::init();
         $post_status = array('publish');
         if (is_user_logged_in()) {
             $post_status[] = 'private';
         }
         $args = array('post_status' => $post_status, 'eventDate' => $_POST["eventDate"], 'eventDisplay' => 'day');
         Tribe__Events__Main::instance()->displaying = 'day';
         if (isset($_POST['tribe_event_category'])) {
             $args[Tribe__Events__Main::TAXONOMY] = $_POST['tribe_event_category'];
         }
         $query = Tribe__Events__Query::getEvents($args, true);
         global $wp_query, $post;
         $wp_query = $query;
         add_filter('tribe_is_day', '__return_true');
         // simplest way to declare that this is a day view
         ob_start();
         tribe_get_view('day/content');
         $response = array('html' => ob_get_clean(), 'success' => true, 'total_count' => $query->found_posts, 'view' => 'day');
         apply_filters('tribe_events_ajax_response', $response);
         header('Content-type: application/json');
         echo json_encode($response);
         die;
     }
 }
Exemplo n.º 9
0
 /**
  * Run on applied action init
  */
 public function init()
 {
     $rewrite = Tribe__Events__Rewrite::instance();
     $venue = Tribe__Events__Venue::instance();
     $organizer = Tribe__Events__Organizer::instance();
     $this->postVenueTypeArgs = $venue->post_type_args;
     $this->postOrganizerTypeArgs = $organizer->post_type_args;
     $this->pluginName = $this->plugin_name = esc_html__('The Events Calendar', 'the-events-calendar');
     $this->rewriteSlug = $this->getRewriteSlug();
     $this->rewriteSlugSingular = $this->getRewriteSlugSingular();
     $this->category_slug = $this->get_category_slug();
     $this->tag_slug = $this->get_tag_slug();
     $this->taxRewriteSlug = $this->rewriteSlug . '/' . $this->category_slug;
     $this->tagRewriteSlug = $this->rewriteSlug . '/' . $this->tag_slug;
     $this->monthSlug = sanitize_title(__('month', 'the-events-calendar'));
     $this->listSlug = sanitize_title(__('list', 'the-events-calendar'));
     $this->upcomingSlug = sanitize_title(__('upcoming', 'the-events-calendar'));
     $this->pastSlug = sanitize_title(__('past', 'the-events-calendar'));
     $this->daySlug = sanitize_title(__('day', 'the-events-calendar'));
     $this->todaySlug = sanitize_title(__('today', 'the-events-calendar'));
     $this->singular_venue_label = $this->get_venue_label_singular();
     $this->plural_venue_label = $this->get_venue_label_plural();
     $this->singular_organizer_label = $this->get_organizer_label_singular();
     $this->plural_organizer_label = $this->get_organizer_label_plural();
     $this->singular_event_label = $this->get_event_label_singular();
     $this->plural_event_label = $this->get_event_label_plural();
     $this->singular_event_label_lowercase = tribe_get_event_label_singular_lowercase();
     $this->plural_event_label_lowercase = tribe_get_event_label_plural_lowercase();
     $this->postTypeArgs['rewrite']['slug'] = $rewrite->prepare_slug($this->rewriteSlugSingular, self::POSTTYPE, false);
     $this->currentDay = '';
     $this->errors = '';
     $this->default_values = apply_filters('tribe_events_default_value_strategy', new Tribe__Events__Default_Values());
     Tribe__Events__Query::init();
     Tribe__Events__Backcompat::init();
     Tribe__Credits::init();
     Tribe__Events__Timezones::init();
     $this->registerPostType();
     Tribe__Debug::debug(sprintf(esc_html__('Initializing Tribe Events on %s', 'the-events-calendar'), date('M, jS \\a\\t h:m:s a')));
     $this->maybeSetTECVersion();
     // Start the integrations manager
     Tribe__Events__Integrations__Manager::instance()->load_integrations();
 }