tdmrep = $tdmrep; $this->signals = $signals; $this->meta = $meta; $this->history = $history; } /** * Returns the check identifier. * * @return string Identifier. */ public function get_id(): string { return 'declarations'; } /** * Whether a loopback request is required. * * @return bool False. */ public function needs_loopback(): bool { return false; } /** * Runs the check. * * @return Result The finding. */ public function run(): Result { $label = __( 'Legal declarations', 'ai-blackout' ); $published = array(); if ( $this->tdmrep->is_enabled() ) { $published[] = __( 'a reservation of text and data mining rights', 'ai-blackout' ); } if ( '' !== $this->signals->build_block() ) { $published[] = __( 'content signals in robots.txt', 'ai-blackout' ); } if ( $this->meta->is_enabled() ) { $published[] = __( 'noai and noimageai directives', 'ai-blackout' ); } $since = $this->history->first_published( Tdmrep::TYPE ); $detail = array( 'tdmrep_enabled' => $this->tdmrep->is_enabled(), 'tdmrep_url' => $this->tdmrep->get_url(), 'tdmrep_document' => $this->tdmrep->preview(), 'signals' => $this->signals->get_signals(), 'directives' => $this->meta->get_directives(), 'first_published' => $since, 'entries' => count( $this->history->all() ), ); if ( aiblackout_is_disabled() ) { return new Result( $this->get_id(), $label, Result::INACTIVE, __( 'AI Blackout is switched off by the AIBLACKOUT_DISABLE setting in wp-config.php.', 'ai-blackout' ), __( 'No declarations are being published. Your previously recorded declaration history is kept.', 'ai-blackout' ), __( 'Remove the AIBLACKOUT_DISABLE line from wp-config.php to publish them again.', 'ai-blackout' ), $detail ); } if ( empty( $published ) ) { return new Result( $this->get_id(), $label, Result::INACTIVE, __( 'You are not declaring any rights over your content.', 'ai-blackout' ), __( 'Blocking a crawler stops it taking your content today. A declaration states, in a form a court can read, that you never gave permission. That is what matters if content has already been taken.', 'ai-blackout' ), __( 'Turn on the rights reservation. It publishes a legal statement, changes nothing a visitor sees, and cannot affect your search ranking.', 'ai-blackout' ), $detail ); } return new Result( $this->get_id(), $label, Result::DECLARED, sprintf( /* translators: %s: Comma-separated list of published declarations. */ __( 'You are publishing %s.', 'ai-blackout' ), $this->join( $published ) ), $this->describe_standing( $since ), '', $detail ); } /** * Explains what the declaration is worth and since when. * * @param int|null $since Unix timestamp of first publication. * @return string Human-readable explanation. */ private function describe_standing( ?int $since ): string { $base = __( 'This does not block anything. Under EU copyright law a machine-readable reservation removes the permission that would otherwise let anyone mine your content for AI training, so scraping it becomes an infringement rather than something allowed by default.', 'ai-blackout' ); if ( null === $since ) { return $base; } $days = (int) floor( ( time() - $since ) / DAY_IN_SECONDS ); if ( $days < 1 ) { return $base . ' ' . __( 'It was published today. It applies from now on, not to anything taken before.', 'ai-blackout' ); } return $base . ' ' . sprintf( /* translators: 1: Number of days, 2: Date the declaration was first published. */ _n( 'It has stood for %1$d day, since %2$s. It applies to what happened after that date, not before.', 'It has stood for %1$d days, since %2$s. It applies to what happened after that date, not before.', $days, 'ai-blackout' ), $days, date_i18n( get_option( 'date_format' ), $since ) ); } /** * Joins a list into a readable sentence fragment. * * @param string[] $items Items to join. * @return string Joined string. */ private function join( array $items ): string { if ( count( $items ) < 2 ) { return (string) reset( $items ); } $last = array_pop( $items ); return implode( ', ', $items ) . __( ' and ', 'ai-blackout' ) . $last; } }