} $overrides Settings to use instead of the saved ones. * @param bool $coverage Also check the page text against the Markdown. * @param int $paged Number of the paginated view, 1 for the page itself. * @return VerifyResult The outcome. */ public function verify( WP_Post $post, array $overrides = array(), bool $coverage = true, int $paged = 1 ): VerifyResult { $reason = $this->eligibility->reason( $post ); if ( null !== $reason ) { return new VerifyResult( VerifyResult::NOT_SERVED, $this->eligibility->describe( $reason ) ); } $render = $this->renderer->render( $post, $paged ); $page = $this->generator->build( $post, $render, $overrides, $paged ); if ( $this->eligibility->hides_restricted( $page->restricted ) ) { return new VerifyResult( VerifyResult::NOT_SERVED, $this->eligibility->describe_restricted( (string) $page->restricted ) ); } if ( $this->eligibility->hides_result( $page->noindex ) ) { $sources = array( Robots::META => __( 'the robots meta tag', 'agentwelcome' ), Robots::HEADER => __( 'the X-Robots-Tag header', 'agentwelcome' ), 'filter' => __( 'a filter', 'agentwelcome' ), ); return new VerifyResult( VerifyResult::NOT_SERVED, $this->eligibility->describe( 'noindex' ) . ' ' . sprintf( /* translators: %s: where noindex was found, such as the robots meta tag. */ __( 'Found in %s.', 'agentwelcome' ), $sources[ $page->noindex_source ] ?? $page->noindex_source ) ); } $entry = $this->store->get( $post->ID, true, $paged ); $blocks = $coverage ? $this->generator->text_blocks( $render, $overrides ) : null; $result = new VerifyResult( VerifyResult::NOT_STORED, '', $entry, $page, array(), 0, null === $blocks ? null : Comparison::coverage( $blocks['kept'], $page->markdown ), null === $blocks ? array() : $blocks['excluded'] ); if ( null === $entry ) { return $result; } $ignore = array_map( 'strval', (array) apply_filters( 'agentwelcome_compare_ignore', array(), $post ) ); $stored_text = Comparison::normalise( $entry->markdown, $ignore ); $fresh_text = Comparison::normalise( $page->markdown, $ignore ); $result->state = $stored_text === $fresh_text ? VerifyResult::IN_SYNC : VerifyResult::DIFFERS; if ( VerifyResult::DIFFERS === $result->state ) { $result->diff = Comparison::diff( $stored_text, $fresh_text ); $result->changed = Comparison::changed( $result->diff ); } return $result; } }