Tribe__Events__Main::default_view()

Returns the default view, providing a fallback if the default is no longer available.

This can be useful is for instance a view added by another plugin (such as PRO) is stored as the default but can no longer be generated due to the plugin being deactivated.


Return

(string) $view The slug of the default view.


Top ↑

Source

File: src/Tribe/Main.php

		public function default_view() {
			// Compare the stored default view option to the list of available views
			$default         = Tribe__Settings_Manager::instance()->get_option( 'viewOption', 'month' );
			$available_views = (array) apply_filters( 'tribe-events-bar-views', array(), false );

			foreach ( $available_views as $view ) {
				if ( $default === $view['displaying'] ) {
					return $default;
				}
			}

			// If the stored option is no longer available, pick the first available one instead
			$first_view = array_shift( $available_views );
			$view       = $first_view['displaying'];

			// Update the saved option
			Tribe__Settings_Manager::instance()->set_option( 'viewOption', $view );

			return $view;
		}

Top ↑

Changelog

Changelog
Version Description
5.12.3 - Add a filter to the default view determination.
3.3 Introduced.