/**
  * Constructor!
  */
 protected function __construct()
 {
     $rewrite = Tribe__Events__Rewrite::instance();
     $this->singular_organizer_label = $this->get_organizer_label_singular();
     $this->singular_organizer_label_lowercase = $this->get_organizer_label_singular_lowercase();
     $this->plural_organizer_label = $this->get_organizer_label_plural();
     $this->plural_organizer_label_lowercase = $this->get_organizer_label_plural_lowercase();
     $this->post_type_args['rewrite']['slug'] = $rewrite->prepare_slug($this->singular_organizer_label, self::POSTTYPE, false);
     $this->post_type_args['show_in_nav_menus'] = class_exists('Tribe__Events__Pro__Main') ? true : false;
     $this->post_type_args['public'] = class_exists('Tribe__Events__Pro__Main') ? true : false;
     /**
      * Provides an opportunity to modify the labels used for the organizer post type.
      *
      * @param array
      */
     $this->post_type_args['labels'] = apply_filters('tribe_events_register_organizer_post_type_labels', array('name' => $this->plural_organizer_label, 'singular_name' => $this->singular_organizer_label, 'singular_name_lowercase' => $this->singular_organizer_label_lowercase, 'plural_name_lowercase' => $this->plural_organizer_label_lowercase, 'add_new' => esc_html__('Add New', 'the-events-calendar'), 'add_new_item' => sprintf(esc_html__('Add New %s', 'the-events-calendar'), $this->singular_organizer_label), 'edit_item' => sprintf(esc_html__('Edit %s', 'the-events-calendar'), $this->singular_organizer_label), 'new_item' => sprintf(esc_html__('New %s', 'the-events-calendar'), $this->singular_organizer_label), 'view_item' => sprintf(esc_html__('View %s', 'the-events-calendar'), $this->singular_organizer_label), 'search_items' => sprintf(esc_html__('Search %s', 'the-events-calendar'), $this->plural_organizer_label), 'not_found' => sprintf(esc_html__('No %s found', 'the-events-calendar'), strtolower($this->plural_organizer_label)), 'not_found_in_trash' => sprintf(esc_html__('No %s found in Trash', 'the-events-calendar'), strtolower($this->plural_organizer_label))));
     $this->register_post_type();
     add_filter('tribe_events_linked_post_type_args', array($this, 'filter_linked_post_type_args'), 10, 2);
     add_filter('tribe_events_linked_post_id_field_index', array($this, 'linked_post_id_field_index'), 10, 2);
     add_filter('tribe_events_linked_post_name_field_index', array($this, 'linked_post_name_field_index'), 10, 2);
     add_filter('tribe_events_linked_post_type_container', array($this, 'linked_post_type_container'), 10, 2);
     add_filter('tribe_events_linked_post_create_' . self::POSTTYPE, array($this, 'save'), 10, 5);
     add_filter('tribe_events_linked_post_default', array($this, 'linked_post_default'), 10, 2);
     add_action('tribe_events_linked_post_new_form', array($this, 'linked_post_new_form'));
 }
 /**
  * Static Singleton Factory Method
  *
  * @return Tribe__Events__Rewrite
  */
 public static function instance($wp_rewrite = null)
 {
     if (!isset(self::$instance)) {
         self::$instance = new self($wp_rewrite);
     }
     return self::$instance;
 }
Example #3
0
 /**
  * Add rewrite routes for custom PRO stuff and views.
  *
  * @param Tribe__Events__Rewrite $rewrite The Tribe__Events__Rewrite object
  *
  * @return void
  */
 public function filter_add_routes($rewrite)
 {
     $rewrite->archive(array('{{ week }}'), array('eventDisplay' => 'week'))->archive(array('{{ week }}', '(\\d{2})'), array('eventDisplay' => 'week', 'eventDate' => '%1'))->archive(array('{{ week }}', '(\\d{4}-\\d{2}-\\d{2})'), array('eventDisplay' => 'week', 'eventDate' => '%1'))->tax(array('{{ week }}'), array('eventDisplay' => 'week'))->tax(array('{{ week }}', '(\\d{4}-\\d{2}-\\d{2})'), array('eventDisplay' => 'week', 'eventDate' => '%2'))->tag(array('{{ week }}'), array('eventDisplay' => 'week'))->tag(array('{{ week }}', '(\\d{4}-\\d{2}-\\d{2})'), array('eventDisplay' => 'week', 'eventDate' => '%2'))->archive(array('{{ photo }}'), array('eventDisplay' => 'photo'))->archive(array('{{ photo }}', '(\\d{4}-\\d{2}-\\d{2})'), array('eventDisplay' => 'photo', 'eventDate' => '%1'))->tax(array('{{ photo }}'), array('eventDisplay' => 'photo'))->tag(array('{{ photo }}'), array('eventDisplay' => 'photo'));
 }
Example #4
0
 /**
  * Add filters and actions
  */
 protected function addHooks()
 {
     // Load Rewrite
     add_action('plugins_loaded', array(Tribe__Events__Rewrite::instance(), 'hooks'));
     add_action('init', array($this, 'init'), 10);
     add_action('admin_init', array($this, 'admin_init'));
     // Frontend Javascript
     add_action('wp_enqueue_scripts', array($this, 'loadStyle'));
     add_filter('tribe_events_before_html', array($this, 'before_html_data_wrapper'));
     add_filter('tribe_events_after_html', array($this, 'after_html_data_wrapper'));
     // Styling
     add_filter('post_class', array($this, 'post_class'));
     add_filter('body_class', array($this, 'body_class'));
     add_filter('admin_body_class', array($this, 'admin_body_class'));
     add_filter('post_type_archive_link', array($this, 'event_archive_link'), 10, 2);
     add_filter('query_vars', array($this, 'eventQueryVars'));
     add_filter('bloginfo_rss', array($this, 'add_space_to_rss'));
     add_filter('post_updated_messages', array($this, 'updatePostMessage'));
     /* Add nav menu item - thanks to http://wordpress.org/extend/plugins/cpt-archives-in-nav-menus/ */
     add_filter('nav_menu_items_' . self::POSTTYPE, array($this, 'add_events_checkbox_to_menu'), null, 3);
     add_filter('wp_nav_menu_objects', array($this, 'add_current_menu_item_class_to_events'), null, 2);
     add_filter('template_redirect', array($this, 'redirect_past_upcoming_view_urls'), 11);
     /* Setup Tribe Events Bar */
     add_filter('tribe-events-bar-views', array($this, 'setup_listview_in_bar'), 1, 1);
     add_filter('tribe-events-bar-views', array($this, 'setup_gridview_in_bar'), 5, 1);
     add_filter('tribe-events-bar-views', array($this, 'setup_dayview_in_bar'), 15, 1);
     add_filter('tribe-events-bar-filters', array($this, 'setup_date_search_in_bar'), 1, 1);
     add_filter('tribe-events-bar-filters', array($this, 'setup_keyword_search_in_bar'), 1, 1);
     add_filter('tribe-events-bar-views', array($this, 'remove_hidden_views'), 9999, 2);
     /* End Setup Tribe Events Bar */
     add_action('admin_menu', array($this, 'addEventBox'));
     add_action('wp_insert_post', array($this, 'addPostOrigin'), 10, 2);
     add_action('save_post', array($this, 'addEventMeta'), 15, 2);
     /* Registers the list widget */
     add_action('widgets_init', array($this, 'register_list_widget'), 90);
     add_action('save_post_' . self::VENUE_POST_TYPE, array($this, 'save_venue_data'), 16, 2);
     add_action('save_post_' . self::ORGANIZER_POST_TYPE, array($this, 'save_organizer_data'), 16, 2);
     add_action('save_post_' . self::POSTTYPE, array($this, 'maybe_update_known_range'));
     add_action('tribe_events_csv_import_complete', array($this, 'rebuild_known_range'));
     add_action('publish_' . self::POSTTYPE, array($this, 'publishAssociatedTypes'), 25, 2);
     add_action('delete_post', array($this, 'maybe_rebuild_known_range'));
     add_action('parse_query', array($this, 'setDisplay'), 51, 0);
     add_action('tribe_events_post_errors', array('Tribe__Events__Post_Exception', 'displayMessage'));
     add_action('tribe_settings_top', array('Tribe__Events__Options_Exception', 'displayMessage'));
     add_action('admin_enqueue_scripts', array($this, 'add_admin_assets'));
     add_filter('tribe_events_register_event_type_args', array($this, 'setDashicon'));
     add_action('trash_' . self::VENUE_POST_TYPE, array($this, 'cleanupPostVenues'));
     add_action('trash_' . self::ORGANIZER_POST_TYPE, array($this, 'cleanupPostOrganizers'));
     add_action('wp_ajax_tribe_event_validation', array($this, 'ajax_form_validate'));
     add_action('tribe_debug', array($this, 'renderDebug'), 10, 2);
     add_action('tribe_debug', array($this, 'renderDebug'), 10, 2);
     add_action('plugins_loaded', array('Tribe__Events__Cache_Listener', 'instance'));
     add_action('plugins_loaded', array('Tribe__Events__Cache', 'setup'));
     add_action('plugins_loaded', array('Tribe__Events__Support', 'getInstance'));
     add_action('plugins_loaded', array($this, 'set_meta_factory_global'));
     add_action('plugins_loaded', array('Tribe__Events__App_Shop', 'instance'));
     add_action('current_screen', array($this, 'init_admin_list_screen'));
     // Load organizer and venue editors
     add_action('admin_menu', array($this, 'addVenueAndOrganizerEditor'));
     add_action('tribe_venue_table_top', array($this, 'displayEventVenueDropdown'));
     add_action('tribe_venue_table_top', array($this, 'display_rich_snippets_helper'), 5);
     add_action('template_redirect', array($this, 'template_redirect'));
     add_action('add_meta_boxes', array('Tribe__Events__Tickets__Metabox', 'maybe_add_meta_box'));
     add_action('admin_enqueue_scripts', array('Tribe__Events__Tickets__Metabox', 'add_admin_scripts'));
     add_action('wp', array($this, 'issue_noindex'));
     add_action('plugin_row_meta', array($this, 'addMetaLinks'), 10, 2);
     // organizer and venue
     if (!defined('TRIBE_HIDE_UPSELL') || !TRIBE_HIDE_UPSELL) {
         add_action('wp_dashboard_setup', array($this, 'dashboardWidget'));
         add_action('tribe_events_cost_table', array($this, 'maybeShowMetaUpsell'));
     }
     // option pages
     add_action('_network_admin_menu', array($this, 'initOptions'));
     add_action('_admin_menu', array($this, 'initOptions'));
     add_action('tribe_settings_do_tabs', array($this, 'doSettingTabs'));
     add_action('tribe_settings_do_tabs', array($this, 'doNetworkSettingTab'), 400);
     add_action('tribe_settings_content_tab_help', array($this, 'doHelpTab'));
     add_action('tribe_settings_validate_tab_network', array($this, 'saveAllTabsHidden'));
     add_action('load-tribe_events_page_tribe-events-calendar', array('Tribe__Events__Amalgamator', 'listen_for_migration_button'), 10, 0);
     add_action('tribe_settings_after_save', array($this, 'flushRewriteRules'));
     add_action('load-edit-tags.php', array($this, 'prepare_to_fix_tagcloud_links'), 10, 0);
     add_action('update_option_' . self::OPTIONNAME, array($this, 'fix_all_day_events'), 10, 2);
     // Check for a page that might conflict with events archive
     add_action('admin_init', array(Tribe__Events__Admin__Notice__Archive_Slug_Conflict::instance(), 'maybe_add_admin_notice'));
     // add-on compatibility
     if (is_multisite()) {
         add_action('network_admin_notices', array($this, 'checkAddOnCompatibility'));
     } else {
         add_action('admin_notices', array($this, 'checkAddOnCompatibility'));
     }
     add_action('wp_before_admin_bar_render', array($this, 'addToolbarItems'), 10);
     add_action('all_admin_notices', array($this, 'addViewCalendar'));
     add_action('admin_head', array($this, 'setInitialMenuMetaBoxes'), 500);
     add_action('plugin_action_links_' . trailingslashit($this->pluginDir) . 'the-events-calendar.php', array($this, 'addLinksToPluginActions'));
     add_action('admin_menu', array($this, 'addHelpAdminMenuItem'), 50);
     // override default wp_terms_checklist arguments to prevent checked items from bubbling to the top. Instead, retain hierarchy.
     add_filter('wp_terms_checklist_args', array($this, 'prevent_checked_on_top_terms'), 10, 2);
     add_action('tribe_events_pre_get_posts', array($this, 'set_tribe_paged'));
     // Upgrade material.
     add_action('init', array($this, 'run_updates'), 0, 0);
     if (defined('WP_LOAD_IMPORTERS') && WP_LOAD_IMPORTERS) {
         add_filter('wp_import_post_data_raw', array($this, 'filter_wp_import_data_before'), 10, 1);
         add_filter('wp_import_post_data_processed', array($this, 'filter_wp_import_data_after'), 10, 1);
     }
     add_action('plugins_loaded', array($this, 'init_ical'), 2, 0);
     add_action('plugins_loaded', array($this, 'init_day_view'), 2);
     add_action('plugins_loaded', array('Tribe__Events__Bar', 'instance'));
     add_action('plugins_loaded', array('Tribe__Events__Templates', 'init'));
     add_action('init', array($this, 'filter_cron_schedules'));
 }
Example #5
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();
 }
Example #6
0
 /**
  * Sets up the rules required by The Events Calendar.
  *
  * This should be called during tribe_events_pre_rewrite, which means other plugins needing to add rules
  * of their own can do so on the same hook at a lower or higher priority, according to how specific
  * those rules are.
  *
  * @param Tribe__Events__Rewrite $rewrite
  */
 public function generate_core_rules(Tribe__Events__Rewrite $rewrite)
 {
     $options = array('default_view' => Tribe__Settings_Manager::get_option('viewOption', 'month'));
     $rewrite->single(array('(\\d{4}-\\d{2}-\\d{2})'), array(Tribe__Events__Main::POSTTYPE => '%1', 'eventDate' => '%2'))->single(array('{{ all }}'), array(Tribe__Events__Main::POSTTYPE => '%1', 'post_type' => Tribe__Events__Main::POSTTYPE, 'eventDisplay' => 'all'))->single(array('(\\d{4}-\\d{2}-\\d{2})', 'ical'), array(Tribe__Events__Main::POSTTYPE => '%1', 'eventDate' => '%2', 'ical' => 1))->single(array('ical'), array('ical' => 1, 'name' => '%1', 'post_type' => Tribe__Events__Main::POSTTYPE))->archive(array('{{ page }}', '(\\d+)'), array('eventDisplay' => 'list', 'paged' => '%1'))->archive(array('(feed|rdf|rss|rss2|atom)'), array('eventDisplay' => 'list', 'feed' => '%1'))->archive(array('{{ month }}'), array('eventDisplay' => 'month'))->archive(array('{{ list }}', '{{ page }}', '(\\d+)'), array('eventDisplay' => 'list', 'paged' => '%1'))->archive(array('{{ list }}'), array('eventDisplay' => 'list'))->archive(array('{{ today }}'), array('eventDisplay' => 'day'))->archive(array('(\\d{4}-\\d{2})'), array('eventDisplay' => 'month', 'eventDate' => '%1'))->archive(array('(\\d{4}-\\d{2}-\\d{2})'), array('eventDisplay' => 'day', 'eventDate' => '%1'))->archive(array(), array('eventDisplay' => 'default'))->archive(array('ical'), array('ical' => 1))->archive(array('(\\d{4}-\\d{2}-\\d{2})', 'ical'), array('ical' => 1, 'eventDisplay' => 'day', 'eventDate' => '%1'))->tax(array('{{ page }}', '(\\d+)'), array('eventDisplay' => 'list', 'paged' => '%2'))->tax(array('{{ month }}'), array('eventDisplay' => 'month'))->tax(array('{{ list }}', '{{ page }}', '(\\d+)'), array('eventDisplay' => 'list', 'paged' => '%2'))->tax(array('{{ list }}'), array('eventDisplay' => 'list'))->tax(array('{{ today }}'), array('eventDisplay' => 'day'))->tax(array('{{ day }}', '(\\d{4}-\\d{2}-\\d{2})'), array('eventDisplay' => 'day', 'eventDate' => '%2'))->tax(array('(\\d{4}-\\d{2})'), array('eventDisplay' => 'month', 'eventDate' => '%2'))->tax(array('(\\d{4}-\\d{2}-\\d{2})'), array('eventDisplay' => 'day', 'eventDate' => '%2'))->tax(array('feed'), array('eventDisplay' => 'list', 'feed' => 'rss2'))->tax(array('ical'), array('ical' => 1))->tax(array('feed', '(feed|rdf|rss|rss2|atom)'), array('feed' => '%2'))->tax(array(), array('eventDisplay' => $options['default_view']))->tag(array('{{ page }}', '(\\d+)'), array('eventDisplay' => 'list', 'paged' => '%2'))->tag(array('{{ month }}'), array('eventDisplay' => 'month'))->tag(array('{{ list }}', '{{ page }}', '(\\d+)'), array('eventDisplay' => 'list', 'paged' => '%2'))->tag(array('{{ list }}'), array('eventDisplay' => 'list'))->tag(array('{{ today }}'), array('eventDisplay' => 'day'))->tag(array('{{ day }}', '(\\d{4}-\\d{2}-\\d{2})'), array('eventDisplay' => 'day', 'eventDate' => '%2'))->tag(array('(\\d{4}-\\d{2})'), array('eventDisplay' => 'month', 'eventDate' => '%2'))->tag(array('(\\d{4}-\\d{2}-\\d{2})'), array('eventDisplay' => 'day', 'eventDate' => '%2'))->tag(array('feed'), array('eventDisplay' => 'list', 'feed' => 'rss2'))->tag(array('ical'), array('ical' => 1))->tag(array('feed', '(feed|rdf|rss|rss2|atom)'), array('feed' => '%2'))->tag(array(), array('eventDisplay' => $options['default_view']));
 }
Example #7
0
 /**
  * Run on applied action init
  */
 public function init()
 {
     $rewrite = Tribe__Events__Rewrite::instance();
     $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->postTypeArgs['rewrite']['slug'] = $rewrite->prepare_slug($this->rewriteSlugSingular, self::POSTTYPE);
     $this->postVenueTypeArgs['rewrite']['slug'] = $rewrite->prepare_slug($this->singular_venue_label, self::VENUE_POST_TYPE);
     $this->postVenueTypeArgs['show_in_nav_menus'] = class_exists('Tribe__Events__Pro__Main') ? true : false;
     $this->postOrganizerTypeArgs['rewrite']['slug'] = $rewrite->prepare_slug($this->singular_organizer_label, self::ORGANIZER_POST_TYPE);
     $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__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();
 }
Example #8
0
 /**
  * Adds the Permalink for the tickets end point
  *
  * @param Tribe__Events__Rewrite $rewrite
  */
 public function add_permalink(Tribe__Events__Rewrite $rewrite)
 {
     // Adds the 'tickets' endpoint for single event pages.
     $rewrite->single(array('{{ tickets }}'), array(Tribe__Events__Main::POSTTYPE => '%1', 'post_type' => Tribe__Events__Main::POSTTYPE, 'eventDisplay' => 'tickets'));
     // Adds the `tickets` endpoint for recurring events
     $rewrite->single(array('(\\d{4}-\\d{2}-\\d{2})', '{{ tickets }}'), array(Tribe__Events__Main::POSTTYPE => '%1', 'eventDate' => '%2', 'post_type' => Tribe__Events__Main::POSTTYPE, 'eventDisplay' => 'tickets'));
 }