store->get( $post->ID, false ); $base = array( 'detail' => '', 'can_regenerate' => false, 'can_clear' => null !== $entry, ); $env_reason = $this->environment->reason(); if ( null !== $env_reason ) { return array_merge( $base, $this->unavailable( $this->environment->describe( $env_reason ) ) ); } $reason = $this->eligibility->reason( $post ); if ( null !== $reason ) { return array_merge( $base, $this->unavailable( $this->eligibility->describe( $reason ) ) ); } $base['can_regenerate'] = true; $state = Freshness::classify( $entry, AGENTWELCOME_VERSION ); if ( null === $entry || Freshness::MISSING === $state ) { return array_merge( $base, array( 'state' => Freshness::MISSING, 'label' => __( 'Not generated yet. It is created on the first request.', 'agentwelcome' ), ) ); } $labels = array( Freshness::FRESH => __( 'Up to date.', 'agentwelcome' ), Freshness::STALE => RenderResult::FALLBACK === $entry->source ? __( 'Built from the post content only. A new attempt is made later.', 'agentwelcome' ) : __( 'Out of date. The old copy is served while a new one is built.', 'agentwelcome' ), Freshness::OUTDATED => __( 'Built by an older plugin version. It is rebuilt on the next request.', 'agentwelcome' ), ); return array_merge( $base, array( 'state' => $state, 'label' => $labels[ $state ], 'detail' => sprintf( /* translators: 1: date and time, 2: how the page was read. */ __( 'Generated %1$s. Source: %2$s.', 'agentwelcome' ), wp_date( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $entry->timestamp() ), RenderResult::LOOPBACK === $entry->source ? __( 'rendered page', 'agentwelcome' ) : __( 'post content', 'agentwelcome' ) ), ) ); } /** * Status of a page that is not served. * * @param string $label Reason, as a sentence. * @return array{state: string, label: string} The unavailable state with the reason. */ private function unavailable( string $label ): array { return array( 'state' => self::UNAVAILABLE, 'label' => sprintf( /* translators: %s: reason. */ __( 'Not served. %s', 'agentwelcome' ), $label ), ); } }