banner_settings = $banner_settings; } public function register() { add_action( 'wp_enqueue_scripts', array( $this, 'enqueue' ) ); } public function enqueue() { $general = AlpineConsent_General_Settings::get(); if ( empty( $general['show_banner'] ) ) { return; } wp_enqueue_script( 'alpineconsent-loader', ALPINECONSENT_PLUGIN_URL . 'assets/js/alpineconsent.js', array(), ALPINECONSENT_VERSION, true ); wp_localize_script( 'alpineconsent-loader', 'AlpineConsentConfig', $this->build_config() ); } public function build_config() { // get_settings() is a static method, but called through the // constructor-injected instance rather than // AlpineConsent_Banner_Settings:: directly — keeps that // dependency real (and mockable in a test) instead of dead code // that's only ever assigned, never read. $settings = $this->banner_settings->get_settings(); $lang = AlpineConsent_Language::detect(); // Resolved together, once — see resolve_title_description()'s // own doc comment for why this can't just reuse 'strings' // below: title/description have their own real admin override // storage ($settings['title']/['description']), separate from // resolve_strings()'s STRING_KEYS-only override storage. $title_description = AlpineConsent_Banner_Settings::resolve_title_description( $settings, $lang ); return array( 'layout' => $settings['layout'], 'lang' => $lang, // The admin's own saved per-language button/label text // (Banner Settings -> "Button & banner text") wins first; // below that, the detected language's own curated // AlpineConsent_Strings::DICTIONARY translation; English // only as the last resort — see AlpineConsent_Banner_ // Settings::resolve_strings(). Always a full, non-blank // string set. 'strings' => AlpineConsent_Banner_Settings::resolve_strings( $settings, $lang ), // title/description are per-language maps (Banner Settings // -> Title & description) — a language with no saved // override here (unset OR blank) resolves to THAT // language's own dictionary default (or English, only if // the language isn't curated at all), never a hardcoded // English fallback. This is what makes a custom English // title no longer bleed into every other language's banner, // while a genuinely untouched language still shows its own // correct default text. 'title' => $title_description['title'], 'description' => $title_description['description'], // Site-wide, not per-language (Banner Settings' own Logo // field) — a brand asset, not text to translate. 'logo' => $settings['logo_url'], 'logoAlt' => $settings['logo_alt'], 'buttons' => AlpineConsent_Banner_Settings::build_widget_buttons( $settings ), // Site-wide, like logo above — colors/roundness/font apply // the same regardless of visitor language. See // build_widget_theme()'s own doc comment for why an unset // field is dropped entirely rather than sent as ''. 'theme' => AlpineConsent_Banner_Settings::build_widget_theme( $settings ), // Real bug fixed here: this key never existed before, so the // widget's "Powered by AlpineConsent" badge rendered on every // site regardless of plan, even though docs/PRICING.md and // the pricing page both advertise "Watermark Removal" // starting on Pro. An unconnected site has no known plan — // same safe "show the badge" default as the public Universal // Script Tag's own GET /config/:siteKey falls back to. // // `b`, not `hideBadge`: widget/alpineconsent.js ships as its // own literal, unminified source under a hard, CI-enforced // 5 KB gzipped budget (docs/TECHNICAL.md) with almost no // headroom — a single-letter wire property was a real, // deliberate concession to fit this feature in at all. Always // a genuine bool here, never a string — the widget does a // plain truthy check, not `=== true` (same budget reason). // // WordPress.org submission (2026-10-06): paid-plan-gating // this is exactly the "Trialware"/"Powered By" violation the // Plugins Team's own review flagged for the WordPress.org- // hosted build — a built-in feature locked behind payment, // AND attribution shown by default instead of opt-in. Left // UNCHANGED here on purpose: this is the direct-install // build's own real, already-shipped monetization. Reads // AlpineConsent_Connection::is_badge_hidden() — NOT // is_on_paid_plan() directly — see that method's own // docblock for why it's the one single patch point // scripts/cut-wordpress-org-release.sh targets for the // WordPress.org package (same packaging-time-split // precedent as the self-hosted updater), instead of this // call site specifically. 'b' => AlpineConsent_Connection::is_badge_hidden(), // AlpineConsent#318 — the widget itself only ever reports a // consent decision back to AlpineConsent (POST /consent) when // a real siteKey is present in this exact config; an // unconnected site correctly keeps sending nothing anywhere, // same "no visitor-facing data sent unless configured" claim // this plugin's own readme.txt already makes. // // Also gated on plan now, not just "connected" — centralized // cloud consent-log storage is a paid-plan feature // (docs/PRICING.md: Free = "stored in the visitor's browser", // Pro+ = "Centralized cloud consent logs"). This is a UI- // level courtesy only (skips the network call entirely for a // Free connected site); POST /consent itself re-checks the // real plan server-side regardless, since a client can never // be trusted to self-gate a paid feature. 'siteKey' => AlpineConsent_Connection::is_on_paid_plan() ? AlpineConsent_Connection::get_connection()['site_key'] : '', ); } }