Tribe__Events__Community__Main::__construct()

Class constructor Sets all the class vars up and such

Contents


Source

File: src/Tribe/Main.php

		public function __construct() {
			$tec = Tribe__Events__Main::instance();

			// Load multisite defaults
			if ( is_multisite() ) {
				$tribe_community_events_mu_defaults = array();

				if ( file_exists( WP_CONTENT_DIR . '/tribe-events-mu-defaults.php' ) ) {
					include_once( WP_CONTENT_DIR . '/tribe-events-mu-defaults.php' );
				}

				self::$tribeCommunityEventsMuDefaults = apply_filters( 'tribe_community_events_mu_defaults', $tribe_community_events_mu_defaults );
			}

			// get options
			$this->defaultStatus                 = $this->getOption( 'defaultStatus' );
			$this->allowAnonymousSubmissions     = $this->getOption( 'allowAnonymousSubmissions' );
			$this->allowUsersToEditSubmissions   = $this->getOption( 'allowUsersToEditSubmissions' );
			$this->allowUsersToDeleteSubmissions = $this->getOption( 'allowUsersToDeleteSubmissions' );
			$this->trashItemsVsDelete            = $this->getOption( 'trashItemsVsDelete' );
			$this->useVisualEditor               = $this->getOption( 'useVisualEditor' );
			$this->eventsPerPage                 = $this->getOption( 'eventsPerPage', 10 );
			$this->eventListDateFormat           = $this->getOption( 'eventListDateFormat' );
			$this->paginationRange               = 3;
			$this->defaultStatus                 = $this->getOption( 'defaultStatus' );

			/**
			 * By default both PostTypes are true
			 */

			$this->users_can_create[ Tribe__Events__Venue::POSTTYPE ]     = ! (bool) $this->getOption( 'prevent_new_venues', false );
			$this->users_can_create[ Tribe__Events__Organizer::POSTTYPE ] = ! (bool) $this->getOption( 'prevent_new_organizers', false );

			$this->emailAlertsEnabled            = $this->getOption( 'emailAlertsEnabled' );
			$emailAlertsList                     = $this->getOption( 'emailAlertsList' );

			$this->emailAlertsList = explode( "\n", $emailAlertsList );

			$this->blockRolesFromAdmin = $this->getOption( 'blockRolesFromAdmin' );
			$this->blockRolesList      = $this->getOption( 'blockRolesList' );
			$this->blockRolesRedirect  = $this->getOption( 'blockRolesRedirect', get_home_url() ) == '' ? get_home_url() : $this->getOption( 'blockRolesRedirect', get_home_url() );

			$this->maybeFlushRewrite   = $this->getOption( 'maybeFlushRewrite' );

			if ( $this->blockRolesFromAdmin ) {
				add_action( 'init', array( $this, 'blockRolesFromAdmin' ) );
			}

			$this->pluginPath = trailingslashit( dirname( dirname( dirname( __FILE__ ) ) ) );
			$this->pluginDir  = trailingslashit( basename( $this->pluginPath ) );
			$this->pluginUrl = plugins_url() . '/' . $this->pluginDir;
			$this->pluginSlug = 'events-community';

			$this->register_active_plugin();

			$this->isMyEvents = false;
			$this->isEditPage = false;

			add_shortcode( 'tribe_community_events', array( $this, 'doShortCode' ) );
			add_shortcode( 'tribe_community_events_title', array( $this, 'doShortCodeTitle' ) );

			//allow shortcodes for dynamic titles
			add_filter( 'the_title', 'do_shortcode' );
			add_filter( 'wp_title', 'do_shortcode' );

			if ( '' == get_option( 'permalink_structure' ) ) {
				add_action( 'template_redirect', array( $this, 'maybeRedirectMyEvents' ) );
			} else {
				add_action( 'template_redirect', array( $this, 'redirectUglyUrls' ) );
			}

			/**
			 * In 3.5 this is causing an error moved self::maybeLoadAssets(); into function init()...
			 * Also is important to remember that using methods with Params we need to make sure the Hook doesn't pass any params.
			 * In the case of `wp` it passes an instance of the class WP which was breaking how maybeLoadAssets works.
			 *
			 * @central #71943
			 */
			add_action( 'wp', array( $this, 'maybeLoadAssets' ), 10, 0 );

			add_action( 'init', array( $this, 'loadTextDomain' ), 1 );

			add_action( 'init', array( $this, 'init' ), 5 );

			add_action( 'init', array( $this, 'load_captcha_plugin' ), 11 );

			add_action( 'admin_init', array( $this, 'maybeFlushRewriteRules' ) );

			add_action( 'wp_before_admin_bar_render', array( $this, 'addCommunityToolbarItems' ), 20 );

			add_filter( 'tribe_tickets_user_can_manage_attendees', array( $this, 'user_can_manage_own_event_attendees' ), 10, 3 );

			// Tribe common resources
			include_once(  $this->pluginPath . 'vendor/jbrinley/wp-router/wp-router.php' );

			add_action( 'tribe_settings_save_field_allowAnonymousSubmissions', array( $this, 'flushRewriteOnAnonymous' ), 10, 2 );

			add_filter( 'query_vars', array( $this, 'communityEventQueryVars' ) );

			add_action( 'admin_head', array( $this, 'possibly_show_event_cost' ) );

			// Priority set to 11 so some core body_class items can be removed after added.
			add_filter( 'body_class', array( $this, 'setBodyClasses' ), 11 );

			// Hook into templates class and add theme body classes
			add_filter( 'body_class', array( 'Tribe__Events__Templates', 'theme_body_class' ) );

			// ensure that we don't include tabindexes in our form fields
			add_filter( 'tribe_events_tab_index', '__return_null' );

			// options page hook
			add_action( 'tribe_settings_do_tabs', array( $this, 'doSettings' ), 10, 1 );

			add_action( 'wp_router_generate_routes', array( $this, 'addRoutes' ) );

			add_action( 'plugin_action_links_' . trailingslashit( $this->pluginDir ) . 'Main.php', array( $this, 'addLinksToPluginActions' ) );

			add_filter( 'tribe-events-pro-support', array( $this, 'support_info' ) );

			add_action( 'tribe_community_before_event_page', array( $this, 'maybe_delete_featured_image' ), 10, 1 );
			add_filter( 'tribe_help_tab_forums_url', array( $this, 'helpTabForumsLink' ), 100 );

			add_action( 'save_post', array( $this, 'flushPageIdTransient' ), 10, 1 );

			add_filter( 'user_has_cap', array( $this, 'filter_user_caps' ), 10, 3 );

			if ( is_multisite() ) {
				add_action( 'tribe_settings_get_option_value_pre_display', array( $this, 'multisiteDefaultOverride' ), 10, 3 );
			}

			add_filter( 'tribe_events_multiple_organizer_template', array( $this, 'overwrite_multiple_organizers_template' ) );

			add_action( 'plugins_loaded', array( $this, 'register_resources' ) );

			add_action( 'admin_init', array( $this, 'run_updates' ), 10, 0 );

			add_action( 'wp_ajax_tribe_ce_delete_post', [ $this, 'ajaxDoDelete'] );

			// Binding the Implementations needs to happen to plugins_loaded
			$this->bind_implementations();
		}

Top ↑

Changelog

Changelog
Version Description
1.0 Introduced.