Utilities
URLs
cleanUrl(string $type, string $slug = null, int $page = null, string $category = null): string
Single source of truth for all front-end URLs.
cleanUrl('home') // https://example.com/
cleanUrl('article', 'my-article') // https://example.com/article/my-article/
cleanUrl('articles', null, 2) // https://example.com/articles/page/2/
cleanUrl('category', null, null, 'news') // https://example.com/category/news/
getBaseUrl(): string
Returns the base URL with a trailing slash.
url_slug(string $type): string
Returns the localised URL prefix for a content type from the active locale.
url_slug('category') // 'category' (en), 'categorie' (fr)
Supported types: article, articles, project, projects, page, pages, category, tag.
getThemeResourcePath(string $resource, string $file = ''): string
Returns the relative path to a resource inside the active theme directory.
getThemeResourcePath('css', 'print.css') // 'theme/my-theme/css/print.css'
loadThemePartial(string $name, array $vars = []): ?string
Loads theme/{active}/partials/{name}.php, returns buffered output. Returns null if not found — caller uses its own fallback.
loadThemeTemplate(string $template, array $params = []): void
Includes theme/{active}/{template}.php with cascade fallback to theme/default/ then the CMS root.
SEO & data
generateSEO(string $pageTitle, string $type, string $slug, array $data, array $settings): array
Resolves final meta title and description, merging item-level overrides with site defaults.
Returns ['title' => string, 'description' => string].
getCategoryPath(string $categorySlug, array $data): string
Resolves the full hierarchical slug path of a category.
getCategoryPath('supplements', $data) // 'naturopathy/supplements'
getCategories(string $contentType, array $data): array
Returns all unique categories used by a content type.
getTags(string $contentType, array $data): array
Returns all unique tags used by a content type.
output_canonical_url(array $pageData = null): string
Returns a <link rel="canonical"> tag. Uses $pageData['canonical_url'] if set, otherwise auto-generates from the current URI.
Settings & themes
loadSettings(): array
Loads and merges settings.json with defaults. Handles the theme preview token (_tp) to override active_theme per-request without touching disk. Sets the configured timezone for all date() calls.
getAvailableThemes(): array
Scans /theme/ and returns names of valid theme folders (those containing css/style.css).
Page detection
is_home(): bool
Returns true if the current page is the homepage.
is_current_page(string $type, string $slug = ''): bool
Returns true if the current page matches the given type and optional slug.
if (is_home()) {
echo '<div class="hero">…</div>';
}
if (is_current_page('article', 'my-article')) {
// Article-specific logic
}
Formatting
format_date(string $date): string
Formats a Y-m-d date string using the format defined in site settings.
sanitizeSlug(string $text, bool $allowSpecialChars = false): string
Converts a string to a URL-safe slug. Transliterates accented characters.
decodeHtmlEntities(string $text): string
Decodes HTML entities (ENT_QUOTES | ENT_HTML5, UTF-8).
get_social_icon(string $platform): string
Returns an inline SVG icon. Supported: instagram, twitter, x, github, linkedin, youtube, facebook.
_clean_excerpt(string $html, int $length = 150): string
Strips shortcodes and HTML tags, truncates at word boundary. Use get_article_summary() in partials — this is the raw primitive.
_shortcode_parse_attrs(string $str): array
Parses shortcode attribute strings. Supports key="value", key='value', and key=value.
_asset_version(string $absPath): string
Returns a ?v=<mtime> cache-busting query string for a file based on its modification time. Returns empty string if the file does not exist. Used internally by render_header_scripts().
i18n
__t(string $key, string $fallback = ''): string
Returns the translated string for the active locale.
$label = __t('read_more'); // 'Read more' / 'Lire la suite'
_e(string $key): void
Direct echo of __t().
