reason( $post ); } /** * Finds why a page is not served. * * @param WP_Post $post The page. * @return string|null A reason code, or null when the page is served. */ public function reason( WP_Post $post ): ?string { if ( 'publish' !== $post->post_status ) { return 'not_published'; } if ( '' !== $post->post_password ) { return 'password_protected'; } if ( ! $this->post_types->is_enabled( $post->post_type ) ) { return 'excluded_post_type'; } if ( null === $this->urls->permalink( $post ) ) { return 'plain_permalink'; } $excluded = $this->exclusions->matched( $post ); if ( null !== $excluded ) { return $excluded; } return apply_filters( 'agentwelcome_is_eligible', true, $post ) ? null : 'filtered'; } /** * Turns a reason code into a sentence. * * @param string $reason Code from reason(). * @return string Sentence for people, or the code when it is unknown. */ public function describe( string $reason ): string { $labels = array( 'not_published' => __( 'The page is not published.', 'agentwelcome' ), 'password_protected' => __( 'The page is password protected.', 'agentwelcome' ), 'excluded_post_type' => __( 'Its post type is excluded in the settings.', 'agentwelcome' ), 'plain_permalink' => __( 'It has no pretty permalink. Plain permalinks are not supported.', 'agentwelcome' ), 'excluded_page' => __( 'The page is hidden from AgentWelcome in the editor.', 'agentwelcome' ), 'excluded_pattern' => __( 'It matches an ID or URL pattern in the exclusion list.', 'agentwelcome' ), 'excluded_term' => __( 'It belongs to an excluded taxonomy term.', 'agentwelcome' ), 'noindex' => __( 'An SEO plugin marks the page as noindex. Untick "Leave out pages set to noindex" in the settings to include it.', 'agentwelcome' ), 'filtered' => __( 'A filter excluded it.', 'agentwelcome' ), ); return $labels[ $reason ] ?? $reason; } }