Tribe__Events__Editor::block_categories_all( array<array> $categories, WP_Block_Editor_Context $context )

Add “Event Blocks” category to the editor.


Parameters

$categories

(<span class="array<array>">array<array>) (Required) An array of categories each an array. in the format property => value.

$context

(WP_Block_Editor_Context) (Required) The Block Editor Context object. In WP versions prior to 5.8 this was the post object.


Top ↑

Return

(array<array<string,string>>) The block categories, filtered to add the Event Categories if applicable.


Top ↑

Source

File: src/Tribe/Editor.php

	public function block_categories_all( $categories, $context ) {
		if ( ! $context instanceof WP_Block_Editor_Context ) {
			return $categories;
		}

		// Make sure we have the post available.
		if ( empty( $context->post ) ) {
			return $categories;
		}

		// Make sure it's an event post.
		if ( ! tribe_is_event( $context->post ) ) {
			return $categories;
		}

		return array_merge(
			$categories,
			[
				[
					'slug'  => 'tribe-events',
					'title' => __( 'Event Blocks', 'the-events-calendar' ),
				],
			]
		);
	}

Top ↑

Changelog

Changelog
Version Description
5.8.2 Introduced.