Tribe_Events::enqueue_assets_before_template( string $file = null, array $name = null, Tribe__Template $template = null )

Allows us to print Scripts and Styles inside of the template but outside of the container.

Preventing Shortcodes from failing on Block Editor saving.

Hooked to tribe_template_before_include@P15 and will unhook itself after the first template called.


Parameters

$file

(string) (Optional) Complete path to include the PHP File.

Default value: null

$name

(array) (Optional) Template name.

Default value: null

$template

(Tribe__Template) (Optional) Current instance of the Tribe__Template.

Default value: null


Top ↑

Source

File: src/Tribe/Views/V2/Shortcodes/Tribe_Events.php

	public function enqueue_assets_before_template( $file = null, $name = null, $template = null ) {
		// Prevent other templates from triggering this.
		if ( ! $template instanceof \Tribe\Events\Views\V2\Template ) {
			return;
		}

		/*
		 * Make sure we aren't triggered before we expect to be.
		 * If this isn't true, our query info will be suspect and our checks will fail.
		 */
		if ( ! did_action( 'wp_print_scripts' ) ) {
			return;
		}

		/**
		 * Triggers an action to allow other plugins or extensions to load assets.
		 *
		 * @since 4.7.9
		 *
		 * @param self $shortcode Instance of this class.
		 */
		do_action( 'tribe_events_pro_shortcode_tribe_events_before_assets', $this );

		// Make sure to enqueue assets.
		tribe_asset_enqueue_group( Pro_Assets::$group_key );
		tribe_asset_enqueue_group( Event_Assets::$group_key );

		/**
		 * Triggers an action to allow other plugins or extensions to load assets.
		 *
		 * @since 4.7.9
		 *
		 * @param self $shortcode Instance of this class.
		 */
		do_action( 'tribe_events_pro_shortcode_tribe_events_after_assets', $this );

		// This action once triggered removes itself.
		remove_action( 'tribe_template_before_include', [ $this, 'enqueue_assets_before_template' ], 15 );
	}

Top ↑

Changelog

Changelog
Version Description
5.5.0 Introduced.