/**
 * Function used to load the the Filters View addon.
 *
 * @since 3.4
 * @author PaulHughes01
 *
 * @return void
 */
function TribeEventsFilterViewsLoad()
{
    if (class_exists('TribeEvents') && defined('TribeEvents::VERSION')) {
        require_once dirname(__FILE__) . '/lib/tribe-filter-view.class.php';
        TribeEventsFilterView::init(__FILE__);
    } else {
        add_action('admin_notices', 'tribe_events_filter_view_show_fail_message');
    }
}
 public function render_active_filters_box()
 {
     $filters = TribeEventsFilterView::instance()->get_registered_filters();
     $sorted_filters = array();
     foreach (TribeEventsFilterView::instance()->get_active_filters() as $slug) {
         if (isset($filters[$slug])) {
             $sorted_filters[$slug] = $filters[$slug];
             unset($filters[$slug]);
         }
     }
     $filters = array_merge($sorted_filters, $filters);
     include TribeEventsFilterView::plugin_path('admin-views/settings-field-active-filters.php');
 }
 /**
  * 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
  * @author Timothy Wood
  * @since 3.0
  */
 function wp_ajax_tribe_event_day()
 {
     if (isset($_POST["eventDate"]) && $_POST["eventDate"]) {
         if (class_exists('TribeEventsFilterView')) {
             TribeEventsFilterView::instance()->createFilters(null, true);
         }
         TribeEventsQuery::init();
         add_filter('tribe_events_pre_get_posts', array($this, 'pre_get_posts'));
         $args = array('post_status' => array('publish', 'private', 'future'), 'eventDate' => $_POST["eventDate"], 'eventDisplay' => 'day');
         if (isset($_POST['tribe_event_category'])) {
             $args[TribeEvents::TAXONOMY] = $_POST['tribe_event_category'];
         }
         $query = TribeEventsQuery::getEvents($args, true);
         global $wp_query, $post;
         $wp_query = $query;
         if (have_posts()) {
             the_post();
             // TODO: why is this here?
             rewind_posts();
             // so we don't skip the first post when rendering
         }
         add_filter('tribe_is_day', '__return_true');
         // simplest way to declare that this is a day view
         TribeEventsTemplates::getTemplateHierarchy('day', '', 'pro', $this->pluginPath);
         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;
     }
 }
示例#4
0
 protected function get_priority()
 {
     $current_active_slugs = TribeEventsFilterView::instance()->get_active_filters();
     $priority = array_search($this->slug, $current_active_slugs);
     if ($priority !== false) {
         $priority = ++$priority;
     } else {
         $priority = 0;
     }
     return apply_filters('tribe_events_filter_priority', $priority, $this->slug);
 }
示例#5
0
 /**
  * The class constructor.
  *
  * @author PaulHughes01
  * @since 3.4
  * @return void
  */
 function __construct()
 {
     $this->pluginDir = trailingslashit(basename(dirname(dirname(__FILE__))));
     $this->pluginPath = trailingslashit(dirname(dirname(__FILE__)));
     $this->pluginUrl = trailingslashit(plugins_url('', dirname(__FILE__)));
     $this->sidebarDisplayed = false;
     add_action('wp', array($this, 'setSidebarDisplayed'));
     add_action('parse_query', array($this, 'maybe_initialize_filters_for_query'), 10, 1);
     add_action('current_screen', array($this, 'maybe_initialize_filters_for_screen'), 10, 0);
     add_filter('body_class', array($this, 'addBodyClass'));
     add_filter('tribe_events_template_paths', array($this, 'template_paths'));
     add_action('wp_enqueue_scripts', array($this, 'enqueueStylesAndScripts'), 11);
     add_action('admin_enqueue_scripts', array($this, 'enqueueAdminScripts'));
     require_once 'TribeEventsFilter_Settings.php';
     $settings_page = new TribeEventsFilter_Settings();
     $settings_page->set_hooks();
     add_action('init', array($this, 'loadTextDomain'));
     // Load multisite defaults
     if (is_multisite()) {
         $tribe_events_filters_default_mu_filters = array();
         if (file_exists(WP_CONTENT_DIR . '/tribe-events-mu-defaults.php')) {
             include WP_CONTENT_DIR . '/tribe-events-mu-defaults.php';
         }
         self::$defaultMuFilters = apply_filters('tribe_events_mu_filters_default_filters', $tribe_events_filters_default_mu_filters);
     }
 }
 /**
  * The Calendar View AJAX Handler.
  *
  * @return void
  * @since 3.0
  */
 function calendar_ajax_call()
 {
     if (isset($_POST["eventDate"]) && $_POST["eventDate"]) {
         TribeEventsQuery::init();
         global $wp_query;
         // set the global query var for eventDisplay
         $wp_query->set('eventDisplay', 'month');
         if (!empty($_REQUEST['eventDate'])) {
             $wp_query->set('eventDate', $_REQUEST['eventDate']);
         }
         if (isset($_POST['tribe_event_category'])) {
             $wp_query->set(TribeEvents::TAXONOMY, $_POST['tribe_event_category']);
         }
         if (class_exists('TribeEventsFilterView')) {
             TribeEventsFilterView::instance()->createFilters(null, true);
         }
         $wp_query->tribe_is_event_query = true;
         $this->setDisplay();
         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;
     }
 }
 /**
  * AJAX handler for the Map view
  */
 function ajax_tribe_geosearch()
 {
     if (class_exists('TribeEventsFilterView')) {
         TribeEventsFilterView::instance()->createFilters(null, true);
         $this->setup_geoloc_filter_in_filters();
     }
     $tribe_paged = !empty($_POST["tribe_paged"]) ? $_POST["tribe_paged"] : 1;
     TribeEventsQuery::init();
     $defaults = array('post_type' => TribeEvents::POSTTYPE, 'orderby' => 'event_date', 'order' => 'ASC', 'posts_per_page' => tribe_get_option('postsPerPage', 10), 'paged' => $tribe_paged, 'post_status' => array('publish'), 'eventDisplay' => 'map');
     $view_state = 'map';
     /* if past view */
     if (!empty($_POST['tribe_event_display']) && $_POST['tribe_event_display'] == 'past') {
         $view_state = 'past';
         add_filter('tribe_events_pre_get_posts', array($this, 'set_past_events_query'));
     }
     $query = TribeEventsQuery::getEvents($defaults, true);
     if ($this->is_geoloc_query() && $query->found_posts > 0) {
         $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;
         $this->order_posts_by_distance($query->posts, $lat, $lng);
     }
     $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);
     if ($query->found_posts > 0) {
         global $wp_query, $post;
         $data = $query->posts;
         $post = $query->posts[0];
         $wp_query = $query;
         TribeEvents::instance()->setDisplay();
         ob_start();
         tribe_get_view('map/content');
         $response['html'] .= ob_get_clean();
         $response['markers'] = $this->generate_markers($data);
     } else {
         global $wp_query;
         $wp_query = $query;
         TribeEvents::instance()->setDisplay();
         ob_start();
         tribe_get_view('map/content');
         $response['html'] .= ob_get_clean();
     }
     apply_filters('tribe_events_ajax_response', $response);
     header('Content-type: application/json');
     echo json_encode($response);
     exit;
 }
 /**
  * The Calendar View AJAX Handler.
  *
  * @return void
  * @since 3.0
  */
 function calendar_ajax_call()
 {
     if (isset($_POST["eventDate"]) && $_POST["eventDate"]) {
         TribeEventsQuery::init();
         // set the global query var for eventDisplay
         $query_args = array('post_type' => self::POSTTYPE, 'eventDisplay' => 'month', 'eventDate' => $_POST['eventDate']);
         $this->displaying = 'month';
         if (isset($_POST['tribe_event_category'])) {
             $query_args['tribe_events_cat'] = $_POST['tribe_event_category'];
         }
         if (class_exists('TribeEventsFilterView')) {
             TribeEventsFilterView::instance()->createFilters(null, true);
         }
         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;
     }
 }
示例#9
0
 protected function free_logic()
 {
     $settings = TribeEventsFilterView::instance()->get_filter_settings();
     $this->free = isset($settings[$this->slug]['free']) && self::EXPLICITLY_FREE === $settings[$this->slug]['free'] ? self::EXPLICITLY_FREE : self::IMPLICITLY_FREE;
 }