Yoast\WP\SEO\Generators\Schema
Person::build_person_data()
Builds our array of Schema Person data for a given user ID.
Метод класса: Person{}
Хуки из метода
Возвращает
Массив<Строку|Строку[]>
. An array of Schema Person data.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->build_person_data( $user_id, $add_hash );
- $user_id(int) (обязательный)
- The user ID to use.
- $add_hash(true|false)
- Wether or not the person's image url hash should be added to the image id.
По умолчанию: false
Код Person::build_person_data() Person::build person data Yoast 24.0
protected function build_person_data( $user_id, $add_hash = false ) { $user_data = \get_userdata( $user_id ); $data = [ '@type' => $this->type, '@id' => $this->helpers->schema->id->get_user_schema_id( $user_id, $this->context ), ]; // Safety check for the `get_userdata` WP function, which could return false. if ( $user_data === false ) { return $data; } $data['name'] = $this->helpers->schema->html->smart_strip_tags( $user_data->display_name ); $data = $this->add_image( $data, $user_data, $add_hash ); if ( ! empty( $user_data->description ) ) { $data['description'] = $this->helpers->schema->html->smart_strip_tags( $user_data->description ); } if ( \is_array( $this->context->schema_page_type ) && \in_array( 'ProfilePage', $this->context->schema_page_type, true ) ) { $data['mainEntityOfPage'] = [ '@id' => $this->context->main_schema_id, ]; } $data = $this->add_same_as_urls( $data, $user_data, $user_id ); /** * Filter: 'wpseo_schema_person_data' - Allows filtering of schema data per user. * * @param array $data The schema data we have for this person. * @param int $user_id The current user we're collecting schema data for. */ $data = \apply_filters( 'wpseo_schema_person_data', $data, $user_id ); return $data; }