TubePress Theme API reference: every global template variable, helper function and class available when building or customising a tube site theme.
This page is the complete reference for everything a theme can use: the global variables injected into every template, the variables specific to each template, and the helper classes available in theme code. If you are building or customising a theme, keep this page open alongside Theme development.
Every template is rendered by ThemeRenderer::render($template, $data). The renderer injects a set of global $_-prefixed variables, merges in the template-specific $data, runs the theme.template_data filter, buffers your template into $content, then loads layout.php.
Global variables
These are available in every template and in layout.php.
These are settings, not magic. Every $_card* and $_watch* value comes straight from the admin Appearance screen, so site owners can re-style your theme without touching code — as long as you read these variables instead of hard-coding.
Community
Variable
Type
Description
$_subscriptionsEnabled
bool
Channel subscriptions are on and the theme supports them
$_subscriptionsUnseen
int
New videos from the member's channels since their last visit (0 for guests)
$_memberUploadsEnabled
bool
Member uploads are on and the theme supports them
$_pwaEnabled
bool
The installable app is on
Template-specific variables
In addition to the globals, each template receives its own data.
home.php
Variable
Type
$videos
array — video rows
$pagination
Pagination object
$sort
string — current sort key
video.php
Variable
Type
$video
array — full video with categories, tags, performers, channels
$categories, $tags, $performers
array
$comments
array
$similar
array — similar videos
$recommended
array — recommended videos
$userVote
string|null — 'like', 'dislike' or null
$isFavorited
bool
$subscriptionsOn
bool — show the Subscribe button (setting on and theme support)
$channelSubscribed, $channelSubscribers
bool, int — the viewer's state and the count for the video's first channel
$ownerPreview
bool — the uploader is viewing their own unpublished video
Controller calls the renderer.ThemeRenderer::render('home', ['videos' => $videos, …]).
Globals are injected. The $_-prefixed site, appearance, locale and card/watch variables are added.
Plugins can modify the data.HookSystem::applyFilter('theme.template_data', $data, $templateName) runs.
The template renders. Your template file is buffered into $content.
The layout loads.layout.php receives $content plus all variables.
Impressions flush.ImpressionTracker::flush() sends the batched impression update (CTR).
Cron runs.CronManager::run() executes any due scheduled tasks.
layout.php requirements
A theme's layout.php must do all of the following:
Output the full HTML shell (<!DOCTYPE html> … </html>).
Include <?= ThemeRenderer::renderCSS() ?> in <head>.
Include <?= $_colorOverrides ?> in <head>.
Echo $content inside <main>.
Include <?= ThemeRenderer::renderJS() ?> before </body>.
Call <?php ImpressionTracker::flush(); ?> before </body> (for CTR).
Call <?php HookSystem::doAction('head.meta'); ?> in <head>.
Call <?php HookSystem::doAction('footer.scripts'); ?> before </body>.
Template fallback
If a template is missing from the active theme, TubePress falls back to the bundled Simply theme. A custom theme therefore only needs to override the templates it actually wants to change — start from one template and grow from there.