Block::assets()

Register block assets


Return

(void)


Top ↑

Source

File: src/Tickets/Blocks/Tickets/Block.php

	public function assets() {
		// Check whether we use v1 or v2. We need to update this when we deprecate tickets v1.
		$tickets_js = tribe_tickets_new_views_is_enabled() ? 'v2/tickets-block.js' : 'tickets-block.js';

		$plugin = Tickets_Main::instance();

		tribe_asset(
			$plugin,
			'tribe-tickets-block',
			$tickets_js,
			[
				'jquery',
				'wp-util',
				'wp-i18n',
				'tribe-common',
			],
			null,
			[
				'type'     => 'js',
				'groups'   => [ 'tribe-tickets-block-assets' ],
				'localize' => [
					[
						'name' => 'TribeTicketOptions',
						'data' => [ 'Tribe__Tickets__Tickets', 'get_asset_localize_data_for_ticket_options' ],
					],
					[
						'name' => 'TribeCurrency',
						'data' => [ 'Tribe__Tickets__Tickets', 'get_asset_localize_data_for_currencies' ],
					],
					[
						'name' => 'TribeCartEndpoint',
						'data' => static function () {
							return [ 'url' => tribe_tickets_rest_url( '/cart/' ) ];
						}
					],
					[
						'name' => 'TribeMessages',
						'data' => [ $this, 'set_messages' ],
					],
					[
						'name' => 'TribeTicketsURLs',
						'data' => [ 'Tribe__Tickets__Tickets', 'get_asset_localize_data_for_cart_checkout_urls' ],
					],
				],
			]
		);

		Tickets::$frontend_script_enqueued = true;
	}

Top ↑

Changelog

Changelog
Version Description
4.9 Introduced.