tribe_events_widgets_v2_is_enabled()

Checks whether to disable V2 widgets.

In order the function will check the TRIBE_EVENTS_WIDGETS_V2_DISABLED constant, the TRIBE_EVENTS_WIDGETS_V2_DISABLED environment variable.

Note the internal logic is inverted, as the name of the function is "…is_enabled" while the names of the constant/env_var are "…DISABLED".


Return #

(bool) Whether Widgets v2 should load.


Top ↑

Source #

File: src/functions/views/provider.php

function tribe_events_widgets_v2_is_enabled() {
	// Must have v2 views active.
	if ( ! tribe_events_views_v2_is_enabled() ) {
		return false;
	}

	// If the constant is defined, returns the opposite of the constant.
	if ( defined( 'TRIBE_EVENTS_WIDGETS_V2_DISABLED' ) ) {
		return (bool) ! TRIBE_EVENTS_WIDGETS_V2_DISABLED;
	}

	// Allow env_var to short-circuit for testing.
	$env_var = (bool) getenv( 'TRIBE_EVENTS_WIDGETS_V2_DISABLED' );
	if ( false !== $env_var ) {
		return ! $env_var;
	}

	/**
	 * Allows toggling of the v2 widget views via a filter. Defaults to true.
	 *
	 * @since 5.3.0
	 *
	 * @return boolean Do we enable the widget views?
	 */
	return apply_filters( 'tribe_events_widgets_v2_is_enabled', true );
}

Top ↑

Changelog #

Changelog
Version Description
5.3.0 Introduced.