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
$categories — each has video_count and, unless it has its own image, best_video_thumbnail: its most-viewed video, or its best-ranked one when CTR Ranking is active
performers.php
$performers — video_count and, unless a photo is set, best_video_thumbnail; $pagination. When CTR Ranking is active, the Trending order ranks them by engagement
channels.php
Same shape as performers
search.php
$query, $videos, $pagination
upload.php
Variable
Type
$uploadGate
array — ok, or the reason the member cannot upload (disabled, signed out, daily limit)
$uploadConfig
array — what the upload script needs: endpoints, CSRF token, size and chunk limits, accepted formats
$uploadCategories, $uploadTypes
array — the categories and video types the member can pick
$uploadGuidelines, $uploadModerated
string, bool — your upload rules, and whether uploads are reviewed
auth/profile.php
Variable
Type
$subscriptionsTab, $uploadsTab
bool — show the Subscriptions and My uploads tabs
$subChannels, $subVideos, $subNewSince
array, array, string|null — the followed channels, their latest videos and the cut-off for the New badge
$uploadItems
array — the member's uploads, each with its status
Helper classes
These static helpers are available in every template.
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.
Plugins add their scripts.footer.scripts fires before </body>; this is where CTR Ranking loads its tracker.
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>.
Include <?= SEO::renderHead(get_defined_vars()) ?> in <head> (canonical URL, hreflang, Open Graph and JSON-LD).
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.