get_webfinger();
return $metadata;
}
if ( \is_author() ) {
// Use the Author of the Archive-Page.
$user_id = \get_queried_object_id();
} elseif ( \is_singular() ) {
// Use the Author of the Post.
$user_id = \get_post_field( 'post_author', \get_queried_object_id() );
} elseif ( ! is_user_type_disabled( 'blog' ) ) {
// Use the Blog-User for any other page, if the Blog-User is not disabled.
$user_id = Users::BLOG_USER_ID;
} else {
// Do not add any metadata otherwise.
return $metadata;
}
$user = Users::get_by_id( $user_id );
if ( ! $user || \is_wp_error( $user ) ) {
return $metadata;
}
// Add WebFinger resource.
$metadata['fediverse:creator'] = $user->get_webfinger();
return $metadata;
}
/**
* Output Open Graph tags in the page header.
*/
public static function add_meta_tags() {
$metadata = apply_filters( 'opengraph_metadata', array() );
foreach ( $metadata as $key => $value ) {
if ( empty( $key ) || empty( $value ) ) {
continue;
}
$value = (array) $value;
foreach ( $value as $v ) {
printf(
'' . PHP_EOL,
esc_attr( $key ),
esc_attr( $v )
);
}
}
}
}