Update theme defaults seeding logic and regenerate CSS on palette change. Bump version to 1.1.0.
This commit is contained in:
@@ -94,18 +94,21 @@ function oribi_get_setting( $key ) {
|
||||
*/
|
||||
function oribi_maybe_seed_defaults() {
|
||||
|
||||
if ( get_theme_mod( 'oribi_defaults_seeded' ) ) {
|
||||
$defaults = oribi_get_theme_defaults();
|
||||
$hash = md5( wp_json_encode( $defaults ) );
|
||||
$stored = get_theme_mod( 'oribi_defaults_hash', '' );
|
||||
|
||||
if ( $stored === $hash ) {
|
||||
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_' . $key, $value );
|
||||
}
|
||||
|
||||
set_theme_mod( 'oribi_defaults_hash', $hash );
|
||||
set_theme_mod( 'oribi_defaults_seeded', true );
|
||||
|
||||
// Force CSS regeneration on next check.
|
||||
set_theme_mod( 'oribi_css_theme_version', '' );
|
||||
}
|
||||
|
||||
@@ -227,11 +227,11 @@ function oribi_build_css() {
|
||||
--color-bg-alt: {$dk_bg_alt};
|
||||
--color-bg-dark: {$dk_bg_dark};
|
||||
--color-heading: {$dk_heading};
|
||||
--header-scrolled-bg: rgba(15,23,36,.97);
|
||||
--header-scrolled-bg: rgba(26,26,26,.97);
|
||||
--header-scrolled-text: {$dk_text};
|
||||
--card-bg: {$dk_card_bg};
|
||||
--form-bg: {$dk_card_bg};
|
||||
--form-bg-focus: #1A2538;
|
||||
--form-bg-focus: {$dk_card_bg};
|
||||
}
|
||||
|
||||
/* ── Typography application ────────────────────────────────────── */
|
||||
@@ -295,12 +295,32 @@ function oribi_write_generated_css() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Regenerate the CSS file if it doesn't exist yet (e.g. first page load).
|
||||
* Regenerate the CSS file when it is missing or the theme version has changed.
|
||||
*
|
||||
* Hooked early so the file is ready before wp_enqueue_scripts fires.
|
||||
* Also re-seeds defaults if the palette has changed, so the generated
|
||||
* CSS always reflects the current default values.
|
||||
*/
|
||||
add_action( 'init', function () {
|
||||
if ( ! file_exists( oribi_generated_css_path() ) ) {
|
||||
|
||||
// Re-seed defaults if the defaults array has changed (e.g. new palette).
|
||||
if ( function_exists( 'oribi_maybe_seed_defaults' ) ) {
|
||||
oribi_maybe_seed_defaults();
|
||||
}
|
||||
|
||||
$needs_regen = ! file_exists( oribi_generated_css_path() );
|
||||
|
||||
if ( ! $needs_regen && defined( 'ORIBI_VERSION' ) ) {
|
||||
$stored = get_theme_mod( 'oribi_css_theme_version', '' );
|
||||
if ( $stored !== ORIBI_VERSION ) {
|
||||
$needs_regen = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $needs_regen ) {
|
||||
oribi_write_generated_css();
|
||||
if ( defined( 'ORIBI_VERSION' ) ) {
|
||||
set_theme_mod( 'oribi_css_theme_version', ORIBI_VERSION );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
@@ -4,7 +4,7 @@ Theme URI: https://oribi-tech.com
|
||||
Author: Oribi Technology Services
|
||||
Author URI: https://oribi-tech.com
|
||||
Description: Custom marketing theme for Oribi Technology Services - Managed IT, 365Care, EndpointCare, NetCare, ServerCare.
|
||||
Version: 1.0.0
|
||||
Version: 1.1.0
|
||||
Requires at least: 6.4
|
||||
Tested up to: 6.7
|
||||
Requires PHP: 7.4
|
||||
|
||||
Reference in New Issue
Block a user