TempoLife › Features › Embeddable widgets › wordpress
WordPress plugin
A complete single-file WordPress plugin that adds a [tempolife] shortcode for any of the widgets above — given here in full, ready to paste.
Two ways to embed on WordPress
The simplest way needs no plugin at all: open the page in the block editor, add a Custom HTML block, and paste the iframe snippet from any widget's page. That is enough for most sites.
If you would rather write a shortcode — for example to reuse the same widget across many posts, or to let non-technical authors add it — install the one-file plugin below. It adds a [tempolife] shortcode and nothing else.
The plugin, in full
Create a file called tempolife-embeds.php, paste everything below into it, and either upload it to wp-content/plugins/ or zip it and install it from Plugins → Add New → Upload. Then activate it. This is the complete plugin — there is nothing else to download.
<?php
/**
* Plugin Name: TempoLife Embeds
* Description: Adds a [tempolife] shortcode that embeds a free TempoLife widget
* (calorie calculator, recipe nutrition, fasting timer, food search).
* Version: 1.0.0
* License: MIT
* Author: TempoLife
*/
if (!defined('ABSPATH')) {
exit; // No direct access.
}
add_shortcode('tempolife', function ($atts) {
$a = shortcode_atts(array(
'widget' => 'calorie-calculator',
'height' => '520',
'theme' => 'dark',
'q' => '',
'hours' => '16',
'items' => '',
'servings' => '1',
), $atts, 'tempolife');
$allowed = array('calorie-calculator', 'recipe-nutrition', 'fasting-timer', 'food-search');
$widget = in_array($a['widget'], $allowed, true) ? $a['widget'] : 'calorie-calculator';
$params = array(
'w' => $widget,
'theme' => ($a['theme'] === 'light') ? 'light' : 'dark',
);
if ($widget === 'food-search' && $a['q'] !== '') {
$params['q'] = $a['q'];
}
if ($widget === 'fasting-timer') {
$params['h'] = max(1, min(48, (int) $a['hours']));
}
if ($widget === 'recipe-nutrition') {
if ($a['items'] !== '') {
$params['items'] = $a['items'];
}
$params['servings'] = max(1, min(50, (int) $a['servings']));
}
$src = 'https://tempolife.app/embed.php?' . http_build_query($params);
$height = max(240, min(1200, (int) $a['height']));
return sprintf(
'<iframe src="%s" width="100%%" height="%d" style="border:1px solid #e2e5ee;border-radius:12px;max-width:520px" title="TempoLife %s widget" loading="lazy" referrerpolicy="no-referrer"></iframe>',
esc_url($src),
$height,
esc_attr($widget)
);
});Using the shortcode
Once the plugin is active, drop a shortcode into any post or page:
[tempolife widget="calorie-calculator"] [tempolife widget="food-search" q="banana"] [tempolife widget="fasting-timer" hours="18"] [tempolife widget="recipe-nutrition" items="apple:150,oats:50" servings="2"] [tempolife widget="calorie-calculator" theme="light" height="560"]
Shortcode attributes
| Attribute | Values | What it does |
|---|---|---|
widget | one of the four | Which widget to embed. Defaults to calorie-calculator. |
height | 240–1200 | Iframe height in pixels. |
theme | dark or light | Colour scheme. |
q | text | Search term (food-search only). |
hours | 1–48 | Window length (fasting-timer only). |
items | slug:grams,… | Recipe items (recipe-nutrition only). |
servings | 1–50 | Servings (recipe-nutrition only). |
What the plugin does — and does not — do
The plugin registers a single shortcode that outputs one sandboxed iframe pointing at https://tempolife.app/embed.php. It escapes every attribute with WordPress's own esc_url() and esc_attr(), whitelists the widget name, and clamps the height to a sane range. It sets no cookies, adds no database tables, enqueues no scripts or styles, and phones nothing home — it is a thin, auditable wrapper around the same iframe you could paste by hand. It is offered under the MIT licence, so you are free to read it, change it and ship it.
Read any plugin before you install it. This one is short on purpose so you can — it is a single shortcode that renders an iframe, with no other behaviour.
Source: Mifflin-St Jeor equation and USDA FoodData Central via the TempoLife food database · checked 2026-09-02
Frequently asked questions
Where do I put the file?
Either upload tempolife-embeds.php into wp-content/plugins/, or zip it and use Plugins → Add New → Upload Plugin. Then activate it like any plugin.
Does it need the block editor?
No. The shortcode works in the classic editor, the block editor (in a Shortcode block) and in most page builders that accept shortcodes.
Is it safe?
It is a single shortcode that outputs one escaped iframe and does nothing else — no database writes, no external scripts, no cookies. The whole source is on this page for you to read first.
All widgets · Calorie calculator
More than a widget
TempoLife is a free app that logs meals from a photo and tracks steps, sleep and weight. The widgets are just the doorway.