Telemetry::calculate_modal_status()
Calculate the optin status for the TEC plugins from various sources.
Return
(bool) $show If the modal should show
Source
File: src/Common/Telemetry/Telemetry.php
public static function calculate_modal_status(): bool {
// If we've already opted in, don't show the modal.
$option = tribe_get_option( 'opt-in-status', null );
if ( tribe_is_truthy( $option ) ) {
return false;
}
// If they have already interacted with a modal, find out.
$shows = array_flip( static::$base_parent_slugs );
$optin = Config::get_container()->get( Opt_In_Template::class );
foreach ( static::$base_parent_slugs as $slug ) {
$show = get_option( $optin->get_option_name( $slug ), null );
// Remove unset entries from the array.
if ( is_null( $show ) ) {
unset( $shows[ $slug ] );
continue;
}
$shows[ $slug ] = (int) $show;
}
// No entries - show modal.
if ( count( $shows ) < 1 ) {
return true;
}
$shows = array_filter(
$shows,
function( $val ) {
// remove all the truthy values from the array.
return ! tribe_is_truthy( $val );
}
);
// If we have interacted with any modals, don't show this one.
return empty( $shows );
}
Changelog
| Version | Description |
|---|---|
| 5.1.1.1 | Introduced. |