コード例 #1
0
ファイル: Ajax_Maps.php プロジェクト: TakenCdosG/chefs
 public function handle()
 {
     $http = is_ssl() ? 'https' : 'http';
     $url = apply_filters('tribe_events_pro_google_maps_api', $http . '://maps.google.com/maps/api/js');
     wp_register_script('tribe-gmaps', $url, array('tribe-events-pro'));
     $path = Tribe__Events__Template_Factory::getMinFile(tribe_events_pro_resource_url('tribe-events-ajax-maps.js'), true);
     wp_register_script('tribe-events-pro-geoloc', $path, array('tribe-gmaps', Tribe__Events__Template_Factory::get_placeholder_handle()), apply_filters('tribe_events_pro_js_version', Tribe__Events__Pro__Main::VERSION));
     wp_enqueue_script('tribe-events-pro-geoloc');
     $geoloc = Tribe__Events__Pro__Geo_Loc::instance();
     $data = array('ajaxurl' => admin_url('admin-ajax.php', $http), 'nonce' => wp_create_nonce('tribe_geosearch'), 'map_view' => 'map' == Tribe__Events__Main::instance()->displaying ? true : false);
     wp_localize_script('tribe-events-pro-geoloc', 'GeoLoc', $data);
 }
コード例 #2
0
ファイル: Main.php プロジェクト: TravisSperry/mpa_website
 /**
  * filter Tribe__Events__Main::getLink for pro views
  *
  * @param  string $eventUrl
  * @param  string $type
  * @param  string $secondary
  * @param  string $term
  *
  * @return string
  */
 public function get_link($eventUrl, $type, $secondary, $term)
 {
     switch ($type) {
         case 'week':
             $eventUrl = trailingslashit(esc_url_raw($eventUrl . $this->weekSlug));
             if (!empty($secondary)) {
                 $eventUrl = esc_url_raw(trailingslashit($eventUrl) . $secondary);
             }
             break;
         case 'photo':
             $eventUrl = trailingslashit(esc_url_raw($eventUrl . $this->photoSlug));
             if (!empty($secondary)) {
                 $eventUrl = esc_url_raw(trailingslashit($eventUrl) . $secondary);
             }
             break;
         case 'map':
             $eventUrl = trailingslashit(esc_url_raw($eventUrl . Tribe__Events__Pro__Geo_Loc::instance()->rewrite_slug));
             if (!empty($secondary)) {
                 $eventUrl = esc_url_raw(trailingslashit($eventUrl) . $secondary);
             }
             break;
         case 'all':
             // Temporarily disable the post_type_link filter for recurring events
             $link_filter = array($this->permalink_editor, 'filter_recurring_event_permalinks');
             remove_filter('post_type_link', $link_filter, 10, 4);
             // Obtain the ID of the parent event
             $post_id = $secondary ? $secondary : get_the_ID();
             $parent_id = wp_get_post_parent_id($post_id);
             $event_id = 0 === $parent_id ? $post_id : $parent_id;
             $eventUrl = trailingslashit(get_permalink($event_id));
             $eventUrl = trailingslashit(esc_url_raw($eventUrl . 'all'));
             // Restore the temporarily disabled permalink filter
             add_filter('post_type_link', $link_filter, 10, 4);
             break;
         default:
             break;
     }
     return apply_filters('tribe_events_pro_get_link', $eventUrl, $type, $secondary, $term);
 }
コード例 #3
0
ファイル: iCal.php プロジェクト: AC85/musikschule-wp-theme
 /**
  * Generates the iCal file
  *
  * @static
  *
  * @param int|null $post If you want the ical file for a single event
  */
 public static function generate_ical_feed($post = null)
 {
     $tec = Tribe__Events__Main::instance();
     $events = '';
     $blogHome = get_bloginfo('url');
     $blogName = get_bloginfo('name');
     if ($post) {
         $events_posts = is_array($post) ? $post : array($post);
     } else {
         if (tribe_is_month()) {
             $events_posts = self::get_month_view_events();
         } else {
             global $wp_query;
             $events_posts = $wp_query->posts;
         }
     }
     $event_ids = wp_list_pluck($events_posts, 'ID');
     foreach ($events_posts as $event_post) {
         // add fields to iCal output
         $item = array();
         $full_format = 'Ymd\\THis';
         $time = (object) array('start' => self::wp_strtotime($event_post->EventStartDate), 'end' => self::wp_strtotime($event_post->EventEndDate), 'modified' => self::wp_strtotime($event_post->post_modified), 'created' => self::wp_strtotime($event_post->post_date));
         if ('yes' == get_post_meta($event_post->ID, '_EventAllDay', true)) {
             $type = 'DATE';
             $format = 'Ymd';
         } else {
             $type = 'DATE-TIME';
             $format = $full_format;
         }
         $tzoned = (object) array('start' => date($format, $time->start), 'end' => date($format, $time->end), 'modified' => date($format, $time->modified), 'created' => date($format, $time->created));
         if ('DATE' === $type) {
             $item[] = "DTSTART;VALUE={$type}:" . $tzoned->start;
             $item[] = "DTEND;VALUE={$type}:" . $tzoned->end;
         } else {
             $tz = get_option('timezone_string');
             $item[] = 'DTSTART;TZID="' . $tz . '":' . $tzoned->start;
             $item[] = 'DTEND;TZID="' . $tz . '":' . $tzoned->end;
         }
         $item[] = 'DTSTAMP:' . date($full_format, time());
         $item[] = 'CREATED:' . $tzoned->created;
         $item[] = 'LAST-MODIFIED:' . $tzoned->modified;
         $item[] = 'UID:' . $event_post->ID . '-' . $time->start . '-' . $time->end . '@' . parse_url(home_url('/'), PHP_URL_HOST);
         $item[] = 'SUMMARY:' . str_replace(array(',', "\n", "\r", "\t"), array('\\,', '\\n', '', '\\t'), html_entity_decode(strip_tags($event_post->post_title), ENT_QUOTES));
         $item[] = 'DESCRIPTION:' . str_replace(array(',', "\n", "\r", "\t"), array('\\,', '\\n', '', '\\t'), html_entity_decode(strip_tags($event_post->post_content), ENT_QUOTES));
         $item[] = 'URL:' . get_permalink($event_post->ID);
         // add location if available
         $location = $tec->fullAddressString($event_post->ID);
         if (!empty($location)) {
             $str_location = str_replace(array(',', "\n"), array('\\,', '\\n'), html_entity_decode($location, ENT_QUOTES));
             $item[] = 'LOCATION:' . $str_location;
         }
         // add geo coordinates if available
         if (class_exists('Tribe__Events__Pro__Geo_Loc')) {
             $long = Tribe__Events__Pro__Geo_Loc::instance()->get_lng_for_event($event_post->ID);
             $lat = Tribe__Events__Pro__Geo_Loc::instance()->get_lat_for_event($event_post->ID);
             if (!empty($long) && !empty($lat)) {
                 $item[] = sprintf('GEO:%s;%s', $lat, $long);
                 $str_title = str_replace(array(',', "\n"), array('\\,', '\\n'), html_entity_decode(tribe_get_address($event_post->ID), ENT_QUOTES));
                 if (!empty($str_title) && !empty($str_location)) {
                     $item[] = 'X-APPLE-STRUCTURED-LOCATION;VALUE=URI;X-ADDRESS=' . str_replace('\\,', '', trim($str_location)) . ';' . 'X-APPLE-RADIUS=500;' . 'X-TITLE=' . trim($str_title) . ':geo:' . $long . ',' . $lat;
                 }
             }
         }
         // add categories if available
         $event_cats = (array) wp_get_object_terms($event_post->ID, Tribe__Events__Main::TAXONOMY, array('fields' => 'names'));
         if (!empty($event_cats)) {
             $item[] = 'CATEGORIES:' . html_entity_decode(join(',', $event_cats), ENT_QUOTES);
         }
         // add featured image if available
         if (has_post_thumbnail($event_post->ID)) {
             $thumbnail_id = get_post_thumbnail_id($event_post->ID);
             $thumbnail_url = wp_get_attachment_url($thumbnail_id);
             $thumbnail_mime_type = get_post_mime_type($thumbnail_id);
             $item[] = apply_filters('tribe_ical_feed_item_thumbnail', sprintf('ATTACH;FMTTYPE=%s:%s', $thumbnail_mime_type, $thumbnail_url), $event_post->ID);
         }
         // add organizer if available
         $organizer_email = tribe_get_organizer_email($event_post->ID);
         if ($organizer_email) {
             $organizer_id = tribe_get_organizer_id($event_post->ID);
             $organizer = get_post($organizer_id);
             if ($organizer_id) {
                 $item[] = sprintf('ORGANIZER;CN="%s":MAILTO:%s', rawurlencode($organizer->post_title), $organizer_email);
             } else {
                 $item[] = sprintf('ORGANIZER:MAILTO:%s', $organizer_email);
             }
         }
         $item = apply_filters('tribe_ical_feed_item', $item, $event_post);
         $events .= "BEGIN:VEVENT\r\n" . implode("\r\n", $item) . "\r\nEND:VEVENT\r\n";
     }
     header('Content-type: text/calendar; charset=UTF-8');
     header('Content-Disposition: attachment; filename="ical-event-' . implode($event_ids) . '.ics"');
     $content = "BEGIN:VCALENDAR\r\n";
     $content .= "VERSION:2.0\r\n";
     $content .= 'PRODID:-//' . $blogName . ' - ECPv' . Tribe__Events__Main::VERSION . "//NONSGML v1.0//EN\r\n";
     $content .= "CALSCALE:GREGORIAN\r\n";
     $content .= "METHOD:PUBLISH\r\n";
     $content .= 'X-WR-CALNAME:' . apply_filters('tribe_ical_feed_calname', $blogName) . "\r\n";
     $content .= 'X-ORIGINAL-URL:' . $blogHome . "\r\n";
     $content .= 'X-WR-CALDESC:Events for ' . $blogName . "\r\n";
     $content = apply_filters('tribe_ical_properties', $content);
     $content .= $events;
     $content .= 'END:VCALENDAR';
     echo $content;
     exit;
 }
コード例 #4
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__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;
 }
コード例 #5
0
 /**
  * filter Tribe__Events__Main::getLink for pro views
  *
  * @param  string $eventUrl
  * @param  string $type
  * @param  string $secondary
  * @param  string $term
  *
  * @return string
  */
 public function get_link($eventUrl, $type, $secondary, $term)
 {
     switch ($type) {
         case 'week':
             $eventUrl = trailingslashit(esc_url_raw($eventUrl . $this->weekSlug));
             if (!empty($secondary)) {
                 $eventUrl = esc_url_raw(trailingslashit($eventUrl) . $secondary);
             }
             break;
         case 'photo':
             $eventUrl = trailingslashit(esc_url_raw($eventUrl . $this->photoSlug));
             if (!empty($secondary)) {
                 $eventUrl = esc_url_raw(trailingslashit($eventUrl) . $secondary);
             }
             break;
         case 'map':
             $eventUrl = trailingslashit(esc_url_raw($eventUrl . Tribe__Events__Pro__Geo_Loc::instance()->rewrite_slug));
             if (!empty($secondary)) {
                 $eventUrl = esc_url_raw(trailingslashit($eventUrl) . $secondary);
             }
             break;
         case 'all':
             remove_filter('post_type_link', array($this->permalink_editor, 'filter_recurring_event_permalinks'), 10, 4);
             $post_id = $secondary ? $secondary : get_the_ID();
             $post_id = wp_get_post_parent_id($post_id);
             $eventUrl = trailingslashit(get_permalink($post_id));
             $eventUrl = trailingslashit(esc_url_raw($eventUrl . 'all'));
             add_filter('post_type_link', array($this->permalink_editor, 'filter_recurring_event_permalinks'), 10, 4);
             break;
         default:
             break;
     }
     return apply_filters('tribe_events_pro_get_link', $eventUrl, $type, $secondary, $term);
 }
コード例 #6
0
ファイル: Geo_Loc.php プロジェクト: TravisSperry/mpa_website
 /**
 * Static Singleton Factory Method
 *
 *@return Tribe__Events__Pro__Geo_Loc
 */
 public static function instance()
 {
     if (!isset(self::$instance)) {
         $className = __CLASS__;
         self::$instance = new $className();
     }
     return self::$instance;
 }
 /**
  * The Events Calendar Pro offers geolocation for venues. While we'll use that, we don't want
  * to show a notice on every page of the admin when geopoints need to be generated.
  */
 public function remove_events_calendar_actions()
 {
     if (class_exists('Tribe__Events__Pro__Geo_Loc')) {
         $tribe_events = Tribe__Events__Pro__Geo_Loc::instance();
         remove_action('admin_init', array($tribe_events, 'maybe_generate_geopoints_for_all_venues'));
         remove_action('admin_init', array($tribe_events, 'maybe_offer_generate_geopoints'));
     }
 }
コード例 #8
0
ファイル: Main.php プロジェクト: TakenCdosG/chefs
 /**
  * filter Tribe__Events__Main::getLink for pro views
  *
  * @param  string $event_url
  * @param  string $type
  * @param  string $secondary
  * @param  string $term
  *
  * @return string
  */
 public function get_link($event_url, $type, $secondary, $term)
 {
     switch ($type) {
         case 'week':
             $event_url = trailingslashit(esc_url_raw($event_url . $this->weekSlug));
             if (!empty($secondary)) {
                 $event_url = esc_url_raw(trailingslashit($event_url) . $secondary);
             }
             break;
         case 'photo':
             $event_url = trailingslashit(esc_url_raw($event_url . $this->photoSlug));
             if (!empty($secondary)) {
                 $event_url = esc_url_raw(trailingslashit($event_url) . $secondary);
             }
             break;
         case 'map':
             $event_url = trailingslashit(esc_url_raw($event_url . Tribe__Events__Pro__Geo_Loc::instance()->rewrite_slug));
             if (!empty($secondary)) {
                 $event_url = esc_url_raw(trailingslashit($event_url) . $secondary);
             }
             break;
         case 'all':
             // Temporarily disable the post_type_link filter for recurring events
             $link_filter = array($this->permalink_editor, 'filter_recurring_event_permalinks');
             remove_filter('post_type_link', $link_filter, 10, 4);
             // Obtain the ID of the parent event
             $post_id = $secondary ? $secondary : get_the_ID();
             $parent_id = wp_get_post_parent_id($post_id);
             $event_id = 0 === $parent_id ? $post_id : $parent_id;
             /**
              * Filters the "all" part of the all recurrences link for a recurring event.
              *
              * @param string $all_frag  Defaults to the localized versions of the "all" word.
              * @param int    $post_id   The event post object ID.
              * @param int    $parent_id The event post object parent ID; this value will be the same as
              *                          `$post_id` if the event has no parent.
              */
             $all_frag = apply_filters('tribe_events_pro_all_link_frag', __('all', 'tribe-events-calendar-pro'), $event_id, $parent_id);
             $permalink = get_permalink($event_id);
             $event_url = tribe_append_path($permalink, $all_frag);
             // Restore the temporarily disabled permalink filter
             add_filter('post_type_link', $link_filter, 10, 4);
             /**
              * Filters the link to the "all" recurrences view for a recurring event.
              *
              * @param string $event_url The link to the "all" recurrences view for the event
              * @param int $event_id The recurring event post ID
              */
             $event_url = apply_filters('tribe_events_pro_get_all_link', $event_url, $event_id);
             break;
         default:
             break;
     }
     return apply_filters('tribe_events_pro_get_link', $event_url, $type, $secondary, $term);
 }