block — a saved value that is not a hex color (e.g. // `red; }` style injections) falls back to the hard-coded default so // the stylesheet can never carry arbitrary CSS or HTML. $hex = static function ( $key, $default ) { $raw = Helper::get_settings( $key, $default ); $ok = sanitize_hex_color( $raw ); return $ok ? $ok : $default; }; $primary_color = $hex( 'primary_color', '#7b68ee' ); $secondary_color = $hex( 'secondary_color', '#f2f0fd' ); $text_color = $hex( 'text_color', '#1d2939' ); $border_color = $hex( 'border_color', '#e4e7ec' ); $gray_color = $hex( 'gray_color', '#f2f4f7' ); $surface_color = $hex( 'surface_color', '#ffffff' ); // Dark mode palette — only ever applied inside `.academy-lessons[data-academy-theme="dark"]` // (site default) or `.academy-lessons[data-academy-user-theme="dark"]` (learner override on // the Learn page). Scoping to that selector keeps these values from ever leaking into // wp-admin or any other frontend page. See openspec/changes/learn-page-dark-mode/design.md. $dark_primary_color = $hex( 'dark_primary_color', '#7b68ee' ); $dark_secondary_color = $hex( 'dark_secondary_color', '#252140' ); $dark_text_color = $hex( 'dark_text_color', '#e6e9ef' ); $dark_border_color = $hex( 'dark_border_color', '#333d4b' ); $dark_gray_color = $hex( 'dark_gray_color', '#1f2632' ); $dark_surface_color = $hex( 'dark_surface_color', '#161c26' ); // Fixed (non-admin-configurable) dark counterparts for the auxiliary shell // tokens defined in assets/scss/common/_global.scss (--academy-text-color-black, // --academy-dark-gray-color, --academy-secondary-gray-color, // --academy-background-gray-color). These aren't Brand & Style fields — adding // six more color pickers for a "core surfaces only" pass was judged not worth // the settings-UI weight — but the shell (drawer headings, meta text, page // canvas) uses them, so they need *some* legible dark value. $dark_text_color_black = '#f5f7fa'; $dark_secondary_gray_color = '#a9b0bc'; $dark_gray_color_muted = '#7c8594'; $dark_background_gray_color = '#0e131b'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Every interpolated value above is sanitize_hex_color()-validated with a safe fallback; the rest of the "; // Backend (wp-admin) dark mode — gated to Academy's own admin screens only, so // the #wpcontent/#wpbody-content override below never bleeds into other // plugins' admin pages. Scoped to (not or #academywrap): // #academywrap is a DESCENDANT of #wpcontent/#wpbody-content, not an ancestor, // so a selector on #academywrap can't restyle its own parents — and // doesn't exist yet when this runs (admin_head fires inside ), so the // bootstrap script below targets document.documentElement (, available // immediately) to avoid a flash of light mode on every page load. See // openspec/changes/backend-dashboard-dark-mode/design.md decision 2. if ( is_admin() && Helper::is_academy_admin_page() ) { // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- All interpolations are sanitize_hex_color()-validated above; the rest of the "; }//end if } }