settings = $settings; $this->policy = $policy; $this->tdmrep = $tdmrep; } /** * Registers hooks. * * @return void */ public function register(): void { add_action( 'wp_footer', array( $this, 'print_badge' ), 100 ); } /** * Whether the badge is switched on. * * @return bool True when the user asked for it. */ public function is_enabled(): bool { $badge = $this->settings->get( 'badge', array() ); return is_array( $badge ) && ! empty( $badge['enabled'] ); } /** * Whether the site is actually doing what the badge claims. * * @return bool True when something real stands behind it. */ public function is_earned(): bool { if ( aiblackout_is_disabled() ) { return false; } if ( $this->tdmrep->is_enabled() ) { return true; } return ! empty( $this->policy->agents_with( array( Policy::BLOCK, Policy::SIGNAL_ONLY ) ) ); } /** * Prints the badge in the footer. * * @return void */ public function print_badge(): void { if ( ! $this->is_enabled() || ! $this->is_earned() ) { return; } echo wp_kses_post( $this->build() ); } /** * Builds the badge markup. * * @return string Badge HTML. */ public function build(): string { $text = __( 'Your content is not training data.', 'ai-blackout' ); $style = 'display:inline-flex;align-items:center;gap:.4em;padding:.35em .7em;' . 'border:1px solid currentColor;border-radius:3px;' . 'font-size:12px;line-height:1.4;text-decoration:none;color:inherit;opacity:.75;'; $mark = ''; return sprintf( '
%3$s%4$s
', esc_url( self::LINK ), esc_attr( $style ), $mark, esc_html( $text ) ); } }