Tribe__Events__Main::setDisplay( $query = null )

Set the displaying class property.


Source

File: src/Tribe/Main.php

		public function setDisplay( $query = null ) {
			// If we didn't get a Query Instance we fetch from the globals
			if ( ! $query instanceof WP_Query ) {
				$query = $GLOBALS['wp_query'];
			}

			// If we are in Admin and Not inside of the Default WP AJAX request
			if ( is_admin() && ! tribe( 'context' )->doing_ajax() ) {
				$this->displaying = 'admin';
				return;
			}

			// Bail if we are not dealing with the main WP Query or a non-event Query
			if ( ! $query->is_main_query() || empty( $query->tribe_is_event_query ) ) {
				return;
			}

			// If we have an embed we just set it and bail
			$embed = $query->get( 'embed' );
			if ( ! empty( $embed ) ) {
				$this->displaying = 'embed';
				return;
			}

			// Fetch what ever display we have so far
			$display = $query->get( 'eventDisplay', false );

			// If we don't have a Permalink structure we see if we have something on the _GET param
			if ( ! get_option( 'permalink_structure' ) ) {
				$display = Tribe__Utils__Array::get( $_GET, 'tribe_event_display', $display );
			}

			// Fetch the default if we have nothing
			if ( false === $display ) {
				$display = tribe_get_option( 'viewOption', 'list' );
			}

			// If single and not All for Recurring events From Pro
			if ( $query->is_single() && 'all' !== $display ) {
				$display = 'single-event';
			}

			// Only do this by the end
			$this->displaying = filter_var( $display, FILTER_SANITIZE_STRING );
		}