Tribe_Tickets_Rsvp::get_rsvp_block( WP_Post|int $post )

Gets the block template and return it.


Parameters #

$post

(WP_Post|int) (Required) the post/event we're viewing.


Top ↑

Return #

(string) HTML.


Top ↑

Source #

File: src/Tribe/Shortcode/Tribe_Tickets_Rsvp.php

	public function get_rsvp_block( $post ) {

		if ( empty( $post ) ) {
			return '';
		}

		if ( is_numeric( $post ) ) {
			$post = get_post( $post );
		}

		// If password protected, then do not display content.
		if ( post_password_required( $post ) ) {
			return '';
		}

		/** @var Tribe__Tickets__Editor__Template $template */
		$template = tribe( 'tickets.editor.template' );

		$post_id                  = $post->ID;
		$args['post_id']          = $post_id;
		$rsvps                    = $this->get_rsvps( $post_id );
		$args['active_rsvps']     = $this->get_active_tickets( $rsvps );
		$args['has_active_rsvps'] = ! empty( $args['active_rsvps'] );
		$args['has_rsvps']        = ! empty( $rsvps );
		$args['all_past']         = $this->get_all_tickets_past( $rsvps );

		// Add the rendering attributes into global context.
		$template->add_template_globals( $args );

		// enqueue assets.
		tribe_asset_enqueue( 'tribe-tickets-gutenberg-rsvp' );
		tribe_asset_enqueue( 'tribe-tickets-gutenberg-block-rsvp-style' );

		return $template->template( 'blocks/rsvp', $args, false );
	}