Yoast\WP\SEO\Introductions\User_Interface
Introductions_Integration::update_user_introductions
Updates the user metadata to have "seen" the introductions.
Метод класса: Introductions_Integration{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
// private - только в коде основоного (родительского) класса $result = $this->update_user_introductions( $user_id, $introductions );
- $user_id(int) (обязательный)
- The user ID.
- $introductions(массив) (обязательный)
- The introductions.
Код Introductions_Integration::update_user_introductions() Introductions Integration::update user introductions Yoast 27.5
private function update_user_introductions( $user_id, $introductions ) {
$metadata = $this->user_helper->get_meta( $user_id, Introductions_Seen_Repository::USER_META_KEY, true );
if ( ! \is_array( $metadata ) ) {
$metadata = [];
}
if ( empty( $introductions ) || ! \is_array( $introductions ) ) {
return;
}
// Find the introduction with the highest priority, because JS will only show that one.
$highest_priority_intro = \array_reduce(
$introductions,
static function ( $carry, $item ) {
return ( $carry === null || $item['priority'] < $carry['priority'] ) ? $item : $carry;
},
null,
);
if ( $highest_priority_intro === null ) {
return;
}
// Mark the introduction with the highest priority as seen.
$metadata[ $highest_priority_intro['id'] ]['is_seen'] = true;
$metadata[ $highest_priority_intro['id'] ]['seen_on'] = \time();
$this->user_helper->update_meta( $user_id, Introductions_Seen_Repository::USER_META_KEY, $metadata );
}