Controller::register_blocks()

Register the blocks after plugins are fully loaded.

Contents


Source

File: src/Tickets/Blocks/Controller.php

	public function register_blocks() {
		if ( is_admin() ) {
			// In admin context, do not register the blocks if the post type is not ticketable.
			$post      = get_post() ?: get_post( tribe_get_request_var( 'post' ) );
			$post_type = get_post_type( $post ) ?: tribe_get_request_var( 'post_type' );
			if ( ! in_array( $post_type, (array) tribe_get_option( 'ticket-enabled-post-types', [] ), true ) ) {
				// Register the Blocks only on ticket-enabled post types.
				return;
			}
		}

		// Register blocks.
		add_action( 'tribe_editor_register_blocks', [ tribe( 'tickets.editor.blocks.rsvp' ), 'register' ] );
		add_action( 'tribe_editor_register_blocks', [ tribe( 'tickets.editor.blocks.tickets' ), 'register' ] );
		add_action( 'tribe_editor_register_blocks', [ tribe( 'tickets.editor.blocks.tickets-item' ), 'register' ] );
		add_action( 'tribe_editor_register_blocks', [ tribe( 'tickets.editor.blocks.attendees' ), 'register' ] );
	}

Top ↑

Changelog

Changelog
Version Description
5.8.4 Correctly get post type when creating a new post or page.
5.3.0 Introduced.