Namespacing

We use namespacing to keep our plugin code distinct from other plugins, libraries, and themes.

Namespaces

Our plugins utilize a couple of namespaces. The PHP namespace is the namespacing that our new architecture uses. These namespaces are a relatively new development and we still have a lot of code using our legacy namespaces. Here are both namespacing approaches you will find within our codebase. The first can be found in src/TEC while the legacy can be found in src/Tribe.

ProductPHP namespaceLegacy namespace
Tribe CommonTEC\CommonTribe\Common
Event AggregatorTEC\Events\AggregatorTribe\Events\Aggregator
The Events CalendarTEC\EventsTribe\Events
The Events Calendar ProTEC\Events_ProTribe\Events_Pro
Virtual EventsTEC\Events_VirtualTribe\Events_Virtual
Community EventsTEC\Events_CommunityTribe\Events_Community
Community TicketsTEC\Events_Community_TicketsTribe\Events_Community_Tickets
Eventbrite TicketsTEC\Events_EventbriteTribe\Events_Eventbrite
Filter BarTEC\Events_Filter_BarTribe\Events_Filter_Bar
Event TicketsTEC\TicketsTribe\Tickets
Event Tickets PlusTEC\Tickets_PlusTribe\Tickets_Plus

Top ↑

Prefixes

Each plugin and major product area has its own prefix for hooks, container slugs, and PHP namespaces. The prefixes are as follows:

ProductHook prefixContainer prefix
Tribe Commontec_common.
Event Aggregatortec_aggregator_aggregator.
The Events Calendartec_events_tec.
The Events Calendar Protec_events_pro_pro.
Virtual Eventstec_events_virtual_events-virtual.
Community Eventstec_events_community_community.
Community Ticketstec_community_tickets_community-tickets.
Eventbrite Ticketstec_events_eventbrite_eventbrite.
Filter Bartec_events_filter_filterbar.
Event Ticketstec_tickets_tickets.
Event Tickets Plustec_tickets_plus_tickets-plus.
Image Widgettec_image_image.
Image Widget Plustec_image_plus_image-plus.

Despite being embedded within the-events-calendar, Event Aggregator deserves (and gets) its own prefix.

Top ↑

Hook examples

<?php
// hook in tribe common for firing the bacon action
do_action( 'tec_bacon' );

// hook in TEC for firing the potato action
do_action( 'tec_events_potato' );

// hook in the Event Aggregator section of TEC for firing the squid action
do_action( 'tec_aggregator_squid' );

Top ↑

Container slug examples

<?php
// declare singleton for the panda class in tribe-common, then call it
tribe_singleton( 'common.panda', 'TEC\\Common\\Panda' );
tribe( 'common.panda' );

// declare singleton for the squirrel admin class in TEC, then call it
tribe_singleton( 'tec.admin.squirrel', 'TEC\\Events\\Admin\\Squirrel' );
tribe( 'tec.admin.squirrel' );

// declare singleton for the baboon class in the Event Aggregator code within TEC, then call it
tribe_singleton( 'aggregator.baboon', 'TEC\\Events\\Aggregator\\Baboon' );
tribe( 'aggregator.baboon' );

Top ↑

Style and script slugs

When registering and enqueuing scripts and styles, we should append -css in the case of stylesheets. Example:

Asset slugAsset type
tec-post-editorJS
tec-post-editor-cssCSS

Note that in this instance we prefer hyphens over underscores.