Skip to content
Docs
Get RestroPress

Building template packs

Updated 17 min read
On this page

A template pack changes how the RestroPress storefront looks. You register it from your own plugin or theme, say which pack it builds on, and ship only what you change. This guide covers RestroPress 3.5.1, which added parent packs, the layout and component settings, and stable class names. The settings a store owner sees are under RestroPress › Settings › Styles.

What a pack is made of#

A pack has four layers. Use the lightest one that does the job.

  1. Tokens: colours and fonts, as --rpc-* CSS custom properties.
  2. Layout: where things go, such as the store header, category navigation, card shape, cart style and the order of the parts above the menu items.
  3. Components: how shared pieces look, such as card borders, photo size and tab style. RestroPress writes the CSS from these settings.
  4. Stylesheet and templates: your own CSS, and template files for markup changes the other layers cannot make.

RestroPress registers two packs itself, classic and modern. The active pack is the saved template_pack option. If that pack is not registered, for example because its plugin was deactivated, or if Legacy Ordering Flow is on, RestroPress uses Classic.

Register a pack#

Call rpress_register_template_pack() on the rpress_register_template_packs action. The action fires once, on init at priority 5, after Classic and Modern are registered.

add_action( 'rpress_register_template_packs', function () {
	rpress_register_template_pack( array(
		'id'         => 'harbour',
		'label'      => __( 'Harbour', 'my-pack' ),
		'extends'    => 'modern',
		'tokens'     => array( 'ink' => '#10202B', 'font-display' => "'Fraunces', serif" ),
		'layout'     => array( 'masthead' => 'cover', 'cart_style' => 'drawer' ),
		'components' => array( 'card' => array( 'radius' => '16px' ) ),
	) );
} );

The function returns true on success. If id or label is empty it returns false and raises a _doing_it_wrong notice. Registering an id that already exists replaces the earlier pack, so use an id of your own.

Arguments#

ArgumentDefaultWhat it does
idEmpty (required)Pack key, passed through sanitize_key(). The page body gets the class rp-pack-{id}.
labelEmpty (required)Name shown in the pack picker.
descriptionEmptyText shown on the picker card.
version1.0.0Your version number. With the file's modification time, it forms the stylesheet's cache-busting version.
previewEmptyImage URL for the picker card. Without one, a placeholder drawing is shown.
dirEmptyServer path of the folder with your template overrides.
urlEmptyURL of the folder that holds your stylesheet file.
stylesheetEmptyAbsolute path to your CSS file, or the handle of a style you registered.
tokensEmpty arrayValues for --rpc-* properties, with or without the prefix.
fontsEmptyURL of a font stylesheet to load with the pack.
variantsEmpty arrayA list of layout variants (key and label). Classic and Modern pass list and grid. RestroPress 3.5.1 does not read this value; the Menu Layout setting is separate from the pack.
profalseMarks a paid pack. The picker shows its card locked unless the rpress_template_pack_entitled filter returns true for it. See below.
extendsEmptyId of the parent pack. New in 3.5.1.
layoutEmpty arrayThe storefront layout your pack recommends. New in 3.5.1.
componentsEmpty arrayComponent settings. New in 3.5.1.

The pro argument and its filter control the pack picker. A plugin that sells a pack should also check its own license when it registers, and when the check fails, register only the details the picker needs (id, label, description, preview, version and pro). When a locked pack is the saved choice, the Styles screen tells the store owner that customers are seeing the Classic design, keeps the choice when the settings are saved, and shows a Check license link. Change that link with rpress_template_pack_locked_url.

Parent packs#

With extends, your pack is a child of another pack. These are inherited:

  • Templates: your dir is searched first, then each parent's.
  • Layout: merged key by key, from the oldest parent down to your pack. A list such as rails or sections is replaced as a whole.
  • Components: merged setting by setting, in the same order.

tokens, fonts and stylesheet are not inherited. Only the active pack's values are used. A pack can name a parent that is registered later. A parent that is not registered ends the chain, and a chain stops at five packs, counting your own. A pack that names itself has no parent.

Check these points if you extend modern:

  • You inherit Modern's templates (the list menu item row, list and grid images, the cart item, the category list and the item popup) and its band store header value.
  • Modern's stylesheet does not load, and its rules are scoped to body.rp-pack-modern. Test the inherited markup with your own styles. Modern has no component settings.
  • With masthead set to band, RestroPress shows the store card by default only when the active pack id is modern. Choose cover, strip or editorial for your pack, or return true for your pack id from the rpress_mobile_ordering_show_store_card filter.

Tokens#

Core styles read these properties. Set any of them in tokens: ink, body, muted, border-subtle, border-strong, surface, panel, page, veg, nonveg, font-body and font-display. Checkout headings use font-head. Some component styles use accent and accent-ink and fall back to the primary colour when they are not set. Other keys are printed too, for use in your own CSS. A value that contains a semicolon is skipped.

The primary colour follows the store owner's Theme Color:

  • A primary token, given as a hex colour, applies only while Theme Color is at its default (#ED5575).
  • Your primary and primary-* tokens are not printed directly. RestroPress works out the shades from the colour in use. On the menu these are --rpc-primary, -hover, -press, -tint, -tint-border, -shadow, -rgb, -text (darkened where needed to read as text on white), and --rpc-on-primary (text on a primary fill). Use them instead of fixed colours.
  • An on-primary token is kept only while the colour in use matches your pack's primary. Otherwise RestroPress picks white or a near-black.

Tokens apply to the menu, the item and time popups, and checkout. The order tracking stylesheet uses its own --rp-track-* properties, so style that screen in your pack stylesheet.

Layout#

The layout in effect is built in this order: core defaults, each parent pack (oldest first), your pack, then the saved storefront_layout option. RestroPress 3.5.1 reads that option but has no settings screen for it. The rpress_storefront_layout filter runs last. Unknown keys and values are dropped.

Layout applies to pages that contain the [fooditems] shortcode or the rpress/food-menu block. It does not apply with Legacy Ordering Flow on.

KeyAllowed valuesDefaultNotes
mastheadnone, band, cover, strip, editorialnonecover has a cover image area, strip is compact, and editorial is a centred header without the logo or initials mark. none and band add no new header; they leave the existing store card or Modern header behaviour in place.
nav_styletopbar, sidebar, tabs, accordion, dropdownsidebartopbar puts the category bar above the menu from 768px wide. Core has no styles of its own for tabs, accordion or dropdown: they only add a body class.
nav_medianone, icons, imagesnoneimages adds photo tiles to the category bar. Core adds nothing but a body class for icons.
columns1, 2, 3, 41Menu item card columns.
card_stylebeside, top, overlay, textbesidePhoto beside the text, on top, behind the text, or hidden.
show_imagetrue, falsetruefalse hides menu item photos on the cards.
cart_stylesidebar, drawersidebarThe drawer applies from 1025px wide.
item_stylemodal, side_sheetmodalThe side sheet applies from 768px wide.
railsList of popular, order_again, dealsEmptyRows of menu items, in the order given.
sectionsList of rails, nav, servicerails, nav, serviceOrder of the parts above the menu items.

popular lists menu items with recorded sales, most sold first. order_again lists menu items from a logged-in customer's completed orders. deals lists menu items with the tag whose slug is deals. Each row shows up to eight published menu items that can be ordered now. A row with no menu items is not printed. Tapping an item in a row opens the same popup as in the menu, and items that are not on that menu page are removed from the row.

The sections value#

Give the parts in the order you want:

'sections' => array( 'service', 'nav', 'rails' ),

service is the row with delivery or pickup, time and search. nav is the category bar. A part you leave out is put back at its default position. The store header always comes first and the menu items come last. When rails is first, the rows span the full width above the menu and cart. Otherwise they print inside the menu column.

The list menu template follows the whole order. The grid templates keep the category bar and service row where they are, and only move the rows: above everything when rails is first, or below the service row when it is not. On wide screens the sidebar keeps its own column and the category bar is hidden, so moving nav shows where that bar is visible, for example with topbar or on phones.

The rpress_menu_section_order filter changes the order at run time. Return all three names; the list template does not print a part that is missing from the filtered result.

Layout body classes#

On menu pages, a value that differs from the core default adds a body class, together with the class rp-sf. Underscores in values become hyphens.

KeyBody class
mastheadrp-sf-masthead-cover, rp-sf-masthead-strip, rp-sf-masthead-editorial (none for band)
nav_stylerp-sf-nav-{value}
nav_mediarp-sf-media-{value}
columnsrp-sf-cols-{number}
card_stylerp-sf-card-{value}
show_imagerp-sf-noimg when false
cart_stylerp-sf-cart-drawer
item_stylerp-sf-item-side-sheet

rails and sections add no body class.

Components#

The components argument is an array of component names, each with its settings. RestroPress checks the values, merges them through the parent packs, and prints CSS for the active pack on menu pages only (not with Legacy Ordering Flow). The CSS uses !important and loads late, so to change something a component setting controls, change the setting. Every setting is optional.

While the active pack has any component setting, its own or inherited, the storefront uses the list templates even if Menu Layout is set to Grid.

Value types#

  • CSS: one CSS value, up to 120 characters. It is rejected if it contains a semicolon, braces, angle brackets, a backslash or the start of a comment, or if it has unmatched parentheses or quotes. HTML tags are stripped.
  • px and number: a numeric value, stored as a whole number without a sign. Write 96, not '96px'. Do not use negative numbers. 0 works like leaving the setting out.
  • bool: use real true or false. The value is cast, so the string 'false' counts as true.
  • Choice: one of the listed strings. A choice of default adds no CSS.

Unknown components, unknown settings and invalid values are dropped without a notice.

card#

SettingType or choicesEffect
border, radius, background, paddingCSSThe card box. Setting any of them removes core's inner card box.
shadowCSSCard shadow, kept on hover.
photo_sizepxPhoto size when the photo is beside the text.
photo_radiusCSSPhoto corner radius.
photo_ratio1/1, 4/3, 16/10Photo shape with card_style top.
photo_sideright, leftleft moves a beside photo to the left.
title_sizepxMenu item name size.
title_weight, price_weightnumberFont weight.
title_font, price_font, desc_fontbody, displayUses the matching font token.
price_sizepxPrice size.
price_colorCSSPrice colour.
price_firstboolPrice directly under the name, above the description.
descshow, hidehide removes the description from the card.
desc_linesnumberMaximum description lines.
desc_italicboolItalic description.
add_buttondefault, corner, block, ringcorner: a round plus button, on the photo's corner when the photo is beside the text. block: a full-width button along the bottom of the card. ring: a round outlined plus button at the top right of the row (top left in right-to-left layouts).
stepperphone, alwaysalways shows the quantity stepper on cards on desktop too. add_button ring shows no card stepper.
leaderboolName, dotted leader and price on one line. On phones the price goes under the name.
phonedefault, rowsrows shows plain rows separated by lines on phones (up to 767px).

Other components#

Component and settingType or choicesEffect
menu.max_widthpxA centred menu column with this maximum width.
section.styledefault, rulesrules: centred capital headings between two lines, with the category description in italics.
tabs.styledefault, underline, smallcapsStyle of the category bar links. smallcaps puts a dot under the current category.
tabs.countsboolfalse hides the item counts in the category bar.
rail.card_widthpxWidth of the cards in a menu item row. Phones use a smaller width.
rail.photo_ratio4/3, 16/10, 1/1Photo shape in menu item rows.
rail.bareboolRemoves the card box in menu item rows.
rail.plusboolDraws a decorative plus on row photos. The whole row card opens the menu item.
masthead.cover_heightpxCover height. Phones and headers without a cover image use a smaller height.
masthead.cover_filternone, grayscaleFilter on the cover image.
masthead.monogram_sizepxSize of the logo or initials mark in the cover header.
masthead.name_sizepxStore name size on the store card inside a cover, strip or editorial header.
masthead.metachips, texttext shows the status and store details as plain text instead of chips.
service.styledefault, segmentedsegmented: delivery and pickup as a rounded switch, with matching time and search fields.
sheet.groupsdefault, cardscards boxes each option group in the item popup.
sheet.cta_casedefault, nonenone stops the popup's main button text being capitalised by CSS.
allergens.styledefault, mono, textmono uses neutral colours for allergen codes and the popup's allergen box. text shows card codes as plain text.

The ring button, the rules headings and the smallcaps dot use --rpc-accent when your pack sets an accent token, and the primary colour otherwise. On a dark pack, set accent so a dark Theme Color stays visible.

Stylesheet#

Your stylesheet loads after core's on the menu, checkout and order tracking screens while your pack is active. When you give a file path, also set url: RestroPress builds the address from url and the file name only, so the file must sit directly in that folder. When you give a style handle, register it before RestroPress enqueues its styles on wp_enqueue_scripts (priority 10). With Disable RestroPress Styles on, RestroPress does not load the pack's stylesheet, tokens or fonts.

Scope every rule to your pack:

body.rp-pack-harbour .rpress-menu-v2 .rp-card__title { letter-spacing: -0.01em; }

Stable class names#

RestroPress 3.5.1 added these names for packs to target. They are intended to stay the same across releases. Other class names come from older templates and may change.

ClassWhat it marks
rp-cardA menu item card.
rp-card__mediaThe photo and Add button column in list cards.
rp-card__photoThe photo holder in the core list and grid image templates. Modern's image templates, and so packs that inherit them, do not print it.
rp-card__text, rp-card__title, rp-card__desc, rp-card__price, rp-card__addText block, name, description, price and Add button area.
rp-menu-sectionA category heading block on the menu, with rp-menu-section__title and, when the category has a description, rp-menu-section__desc.
rp-menu-navThe category bar wrapper in the list menu template.
rp-service-rowThe delivery or pickup, time and search row, with rp-service-row__service, rp-service-row__time and rp-service-row__search. The first two are not printed with Legacy Ordering Flow.

Template overrides#

For markup changes, set dir and copy only the templates you change into it, keeping their paths, for example list/single.php. For templates loaded with rpress_get_template_part() while a pack other than Classic is active, RestroPress first looks for a pack-specific copy at {pack-id}/{template} in each location, then for the plain file. Locations are searched in this order:

  1. Child theme restropress/ folder.
  2. Parent theme restropress/ folder.
  3. Your pack's dir.
  4. Each parent pack's dir, nearest first.
  5. The RestroPress templates/ folder.

So a theme can override one file for one pack at yourtheme/restropress/{pack-id}/{template}. A theme file at the plain path also takes priority over the same file in your pack. Only the active pack's id is used for the pack-specific path, not a parent's. A file that RestroPress includes directly, without the template loader, cannot be overridden this way.

Copied templates do not receive core fixes. Compare the @version line, where a file has one, and the file itself after each RestroPress update. In 3.5.1 the list menu template changed to print its parts in the sections order, so an older copy does not follow that value.

Hooks#

HookType and argumentsUse
rpress_register_template_packsActionRegister packs.
rpress_template_pack_entitledFilter: bool, packUnlock a pro pack in the picker. Default false.
rpress_template_pack_locked_urlFilter: URL, packLink in the notice for a locked saved pack.
rpress_storefront_layout_schemaFilter: schemaLayout keys and allowed values. Values are checked at registration, so add this before packs register.
rpress_storefront_layoutFilter: layout, active packChange the layout in effect.
rpress_pack_component_schemaFilter: schemaAdd component settings, typed css, px, int, bool or an array of choices. Add it before packs register. You write the CSS for your own settings.
rpress_pack_componentsFilter: components, packChange the merged component settings. The result is checked again.
rpress_menu_section_orderFilter: orderOrder of rails, nav and service.
rpress_menu_page_topActionPrint above the menu.
rpress_menu_section_railsActionFired by the menu templates where the menu item rows go when they are not first. Keep it in a copied menu template.
rpress_storefront_cover_imageFilter: URLCover image for the cover header. The default comes from the Store Cover Image setting.
rpress_category_image_urlFilter: URL, term IDCategory tile image. Core uses the term's thumbnail_id, then the photo of a menu item in that category, and caches the result for up to an hour in the object cache. Without an image the tile shows the first letter.
rpress_storefront_rail_itemsFilter: menu item IDs, row keyMenu items in a row.
rpress_storefront_rail_limitFilter: number, row keyMenu items per row. Default 8.
rpress_storefront_rail_titleFilter: title, row keyRow heading.
rpress_storefront_deals_tagFilter: slugTag used by the Deals row. Default deals.
rpress_mobile_ordering_show_store_cardFilter: bool, pack IDShow the standalone store card above the menu.
rpress_store_header_delivery_chipFilter: text, contextDelivery text in the store header. Context is header or store_card. Return an empty string for no chip.
rpress_template_pathsFilter: paths keyed by priorityTemplate search locations.

Functions#

  • rpress_get_template_packs(): all registered packs.
  • rpress_get_active_template_pack(): the active pack.
  • rpress_get_storefront_layout(): the layout in effect.
  • rpress_get_pack_components( $pack = null ): component settings in effect, for the active pack by default.
  • rpress_menu_section_order(): the order of the parts above the menu items. It uses the layout of the current menu page.
  • rpress_storefront_renders_masthead(): true when core prints a cover, strip or editorial header on the current page. A pack that prints its own header should then print nothing.

A working example#

RestroPress includes an example pack in its docs/example-pack/ folder. The version below is based on it, with one addition, 'nav_style' => 'topbar', so that the underlined tabs and the position of the category bar also show on desktop. Without that line the sidebar is used on wide screens.

To try it, create wp-content/plugins/rp-example-pack/ with the two files below (or copy docs/example-pack/ into wp-content/plugins/), activate the plugin, then choose Example under RestroPress › Settings › Styles and save.

example-pack.php

<?php
/**
 * Plugin Name: RestroPress Example Pack
 * Description: A minimal RestroPress template pack.
 * Version:     1.0.0
 * Requires Plugins: restropress
 * Text Domain: rp-example-pack
 */

defined( 'ABSPATH' ) || exit;

add_action( 'rpress_register_template_packs', function () {
	rpress_register_template_pack( array(
		'id'          => 'example',
		'label'       => __( 'Example', 'rp-example-pack' ),
		'description' => __( 'A calm, rounded pack built on Modern.', 'rp-example-pack' ),
		'version'     => '1.0.0',
		'extends'     => 'modern',

		'fonts'       => 'https://fonts.googleapis.com/css2?family=DM+Sans:opsz,wght@9..40,400;9..40,600;9..40,700&display=swap',
		'tokens'      => array(
			'ink'           => '#15232D',
			'body'          => '#3B4A54',
			'muted'         => '#6B7780',
			'border-subtle' => '#E6ECEF',
			'border-strong' => '#CBD5DA',
			'surface'       => '#F2F6F8',
			'font-body'     => "'DM Sans', sans-serif",
			'font-display'  => "'DM Sans', sans-serif",
		),

		'layout'      => array(
			'masthead'   => 'cover',
			'nav_style'  => 'topbar',
			'cart_style' => 'drawer',
			'item_style' => 'side_sheet',
			'rails'      => array( 'popular' ),
			'sections'   => array( 'service', 'nav', 'rails' ),
		),

		'components'  => array(
			'card' => array(
				'radius'      => '16px',
				'border'      => '1px solid var(--rpc-border-subtle)',
				'padding'     => '16px',
				'photo_size'  => 96,
				'add_button'  => 'corner',
				'price_first' => true,
			),
			'tabs'    => array( 'style' => 'underline' ),
			'service' => array( 'style' => 'segmented' ),
		),

		'stylesheet'  => __DIR__ . '/example-pack.css',
		'url'         => plugins_url( '', __FILE__ ),
	) );
} );

example-pack.css

body.rp-pack-example .rpress-menu-v2 .rp-menu-section__title {
	letter-spacing: -0.01em;
}

body.rp-pack-example .rpress-menu-v2 .rp-card__price {
	color: var(--rpc-primary-press, var(--rpc-primary));
}
The storefront menu with the Example template pack active

Checklist before release#

  • Scope all CSS to body.rp-pack-{id}.
  • Test phones (up to 767px), tablets and desktop. Some layout values start at 768px and the cart drawer at 1025px.
  • Check the menu, item popup, cart, checkout and order tracking.
  • Try a Theme Color other than the default, including a light one and a dark one.
  • Prefer tokens, layout and components. Copy templates only when you need to.

For other extension points, see the actions and filters references.

Was this page helpful?