This commit is contained in:
Matt Batchelder
2026-02-20 21:28:00 -05:00
commit 19ee98c68d
37 changed files with 9405 additions and 0 deletions

View File

@@ -0,0 +1,111 @@
<?php
/**
* Theme Defaults — Provides default values for all customizable design tokens.
*
* These defaults match the original hardcoded values so existing sites
* see no visual change when upgrading.
*
* @package OTS_Theme
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Return the full array of default design-token values.
*
* Keys mirror the theme-mod names used throughout the customisation system.
*
* @return array<string,string>
*/
function oribi_get_theme_defaults() {
return [
/* ── Light-mode colour palette ──────────────────────── */
'color_primary' => '#D83302',
'color_primary_dk' => '#B52B02',
'color_primary_lt' => '#FEF0EB',
'color_accent' => '#00757c',
'color_accent_dk' => '#005a60',
'color_accent_lt' => '#E6F4F5',
'color_dark' => '#0D1321',
'color_dark_2' => '#1A2236',
'color_text' => '#2D3748',
'color_text_muted' => '#718096',
'color_border' => '#E2E8F0',
'color_bg' => '#FFFFFF',
'color_bg_alt' => '#FFF8F5',
/* ── Dark-mode colour palette ───────────────────────── */
'dark_primary' => '#FF6B3D',
'dark_primary_dk' => '#D83302',
'dark_primary_lt' => 'rgba(216,51,2,0.15)',
'dark_accent' => '#00757c',
'dark_accent_dk' => '#005a60',
'dark_accent_lt' => 'rgba(0,117,124,0.15)',
'dark_dark' => '#E2E8F0',
'dark_dark_2' => '#CBD5E0',
'dark_text' => '#CBD5E0',
'dark_text_muted' => '#A0AEC0',
'dark_border' => '#2D3748',
'dark_bg' => '#0F1724',
'dark_bg_alt' => '#151F30',
'dark_bg_dark' => '#0A0F1A',
'dark_heading' => '#F7FAFC',
'dark_card_bg' => '#151F30',
/* ── Typography ─────────────────────────────────────── */
'font_family' => 'inter', // slug from WP Font Library
'font_heading' => '', // empty = same as body
/* ── Border radii ───────────────────────────────────── */
'radius_sm' => '6',
'radius_md' => '12',
'radius_lg' => '20',
'radius_xl' => '32',
/* ── Spacing / layout ───────────────────────────────── */
'container_max' => '1200',
'container_pad_min' => '1',
'container_pad_max' => '2',
'wide_size' => '1536',
];
}
/**
* Retrieve a single design-token value, respecting saved theme-mod overrides.
*
* @param string $key Token name (e.g. 'color_primary').
* @return string
*/
function oribi_get_setting( $key ) {
$defaults = oribi_get_theme_defaults();
$default = isset( $defaults[ $key ] ) ? $defaults[ $key ] : '';
return get_theme_mod( 'oribi_' . $key, $default );
}
/**
* Persist the current set of defaults into theme-mods (one-time migration).
*
* Called the first time the settings page is loaded, so that existing sites
* start with their current visual identity already stored.
*/
function oribi_maybe_seed_defaults() {
if ( get_theme_mod( 'oribi_defaults_seeded' ) ) {
return;
}
$defaults = oribi_get_theme_defaults();
foreach ( $defaults as $key => $value ) {
// Only set if the user hasn't already saved a value.
if ( false === get_theme_mod( 'oribi_' . $key, false ) ) {
set_theme_mod( 'oribi_' . $key, $value );
}
}
set_theme_mod( 'oribi_defaults_seeded', true );
}