$value ) { set_theme_mod( 'oribi_' . $key, $value ); } } else { // Sanitize & save each setting. foreach ( $defaults as $key => $default ) { $posted = isset( $_POST[ 'oribi_' . $key ] ) ? wp_unslash( $_POST[ 'oribi_' . $key ] ) // phpcs:ignore : $default; // Determine sanitisation method by key prefix/type. if ( strpos( $key, 'color_' ) === 0 || strpos( $key, 'dark_' ) === 0 ) { // Colour values (hex or rgba). $posted = oribi_sanitize_color( $posted ); } elseif ( strpos( $key, 'font_' ) === 0 ) { $posted = sanitize_text_field( $posted ); } elseif ( strpos( $key, 'radius_' ) === 0 || strpos( $key, 'container_' ) === 0 || $key === 'wide_size' ) { $posted = sanitize_text_field( $posted ); } else { $posted = sanitize_text_field( $posted ); } set_theme_mod( 'oribi_' . $key, $posted ); } } // Regenerate CSS. $result = oribi_write_generated_css(); if ( is_wp_error( $result ) ) { add_settings_error( 'oribi_settings', 'css_error', $result->get_error_message(), 'error' ); } else { $msg = 'reset' === $action ? __( 'Settings reset to defaults. CSS regenerated.', 'ots-theme' ) : __( 'Settings saved. CSS regenerated.', 'ots-theme' ); add_settings_error( 'oribi_settings', 'saved', $msg, 'success' ); } // Store errors/notices in transient so they survive the redirect. set_transient( 'oribi_settings_notices', get_settings_errors( 'oribi_settings' ), 30 ); // PRG redirect. wp_safe_redirect( admin_url( 'themes.php?page=oribi-theme-settings' ) ); exit; } ); /** * Sanitize a colour value (hex or rgba). * * @param string $value Raw colour value. * @return string Sanitized colour. */ function oribi_sanitize_color( $value ) { $value = trim( $value ); // Allow rgba(...) values (used for dark mode light tints). if ( preg_match( '/^rgba?\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}\s*(,\s*[\d.]+\s*)?\)$/', $value ) ) { return $value; } // Standard hex. return sanitize_hex_color( $value ) ?? '#000000'; } /* ── Render the settings page ──────────────────────────────────── */ function oribi_render_settings_page() { // Seed defaults on first visit. oribi_maybe_seed_defaults(); // Show any saved notices. $notices = get_transient( 'oribi_settings_notices' ); if ( $notices ) { delete_transient( 'oribi_settings_notices' ); foreach ( $notices as $notice ) { printf( '

%s

', esc_attr( $notice['type'] ), esc_html( $notice['message'] ) ); } } $s = 'oribi_get_setting'; $fonts = oribi_get_available_fonts(); ?>

__( 'Primary', 'ots-theme' ), 'color_primary_dk' => __( 'Primary Dark', 'ots-theme' ), 'color_primary_lt' => __( 'Primary Light', 'ots-theme' ), 'color_accent' => __( 'Accent', 'ots-theme' ), 'color_accent_dk' => __( 'Accent Dark', 'ots-theme' ), 'color_accent_lt' => __( 'Accent Light', 'ots-theme' ), 'color_dark' => __( 'Dark', 'ots-theme' ), 'color_dark_2' => __( 'Dark 2', 'ots-theme' ), 'color_text' => __( 'Text', 'ots-theme' ), 'color_text_muted' => __( 'Text Muted', 'ots-theme' ), 'color_border' => __( 'Border', 'ots-theme' ), 'color_bg' => __( 'Background', 'ots-theme' ), 'color_bg_alt' => __( 'Background Alt', 'ots-theme' ), ]; foreach ( $light_colors as $key => $label ) : $val = $s( $key ); ?>

__( 'Primary', 'ots-theme' ), 'dark_primary_dk' => __( 'Primary Dark', 'ots-theme' ), 'dark_primary_lt' => __( 'Primary Light', 'ots-theme' ), 'dark_accent' => __( 'Accent', 'ots-theme' ), 'dark_accent_dk' => __( 'Accent Dark', 'ots-theme' ), 'dark_accent_lt' => __( 'Accent Light', 'ots-theme' ), 'dark_dark' => __( 'Dark (Text)', 'ots-theme' ), 'dark_dark_2' => __( 'Dark 2 (Text)', 'ots-theme' ), 'dark_text' => __( 'Body Text', 'ots-theme' ), 'dark_text_muted' => __( 'Text Muted', 'ots-theme' ), 'dark_border' => __( 'Border', 'ots-theme' ), 'dark_bg' => __( 'Background', 'ots-theme' ), 'dark_bg_alt' => __( 'Background Alt', 'ots-theme' ), 'dark_bg_dark' => __( 'Background Darker', 'ots-theme' ), 'dark_heading' => __( 'Heading', 'ots-theme' ), 'dark_card_bg' => __( 'Card Background', 'ots-theme' ), ]; foreach ( $dark_colors as $key => $label ) : $val = $s( $key ); $is_rgba = ( strpos( $val, 'rgba' ) !== false ); ?>

' . esc_html__( 'Font Library', 'ots-theme' ) . '' ); ?>

The quick brown fox jumps over the lazy dog
The quick brown fox jumps over the lazy dog. 0123456789

[ 'SM', __( 'Buttons, badges, small elements', 'ots-theme' ) ], 'radius_md' => [ 'MD', __( 'Cards, inputs, mid-size components', 'ots-theme' ) ], 'radius_lg' => [ 'LG', __( 'Sections, larger surfaces', 'ots-theme' ) ], 'radius_xl' => [ 'XL', __( 'Pills, fully rounded elements', 'ots-theme' ) ], ]; foreach ( $radii as $key => $info ) : ?>