settings = $settings; } public function get_id(): string { return 'Person'; } public function applies_to( \WP_Post $post ): bool { if ( 'post' !== $post->post_type || (int) $post->post_author <= 0 ) { return false; } return (bool) $this->settings->get( $post->post_type )['author_schema_enabled']; } public function build( \WP_Post $post ): array { $author_id = (int) $post->post_author; // Per-user overrides from the profile screen (UserProfileFields); // empty = fall back to the WP profile. $name_override = trim( (string) get_user_meta( $author_id, UserMetaFields::PERSON_NAME, true ) ); $url_override = trim( (string) get_user_meta( $author_id, UserMetaFields::PERSON_URL, true ) ); $data = array( '@type' => 'Person', '@id' => SchemaIds::person( $author_id ), 'name' => '' !== $name_override ? $name_override : get_the_author_meta( 'display_name', $author_id ), 'url' => '' !== $url_override ? $url_override : get_author_posts_url( $author_id ), ); /** * Filters the Person (author) schema node. * * @param array $data * @param \WP_Post $post */ return (array) apply_filters( 'acez_seo_person', $data, $post ); } }