Skip to content

Commit d6ff82b

Browse files
authored
adds a get_webfinger_identifier method (#397)
also `get_at_url` needed an update for the Blog User, who would throw an error otherwise
1 parent 14b91cf commit d6ff82b

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

includes/model/class-blog-user.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,15 @@ public function get_url() {
7777
return \esc_url( \trailingslashit( get_home_url() ) . '@' . $this->get_preferred_username() );
7878
}
7979

80+
/**
81+
* Returns the User-URL with @-Prefix for the username.
82+
*
83+
* @return string The User-URL with @-Prefix for the username.
84+
*/
85+
public function get_at_url() {
86+
return \esc_url( \trailingslashit( get_home_url() ) . '@' . $this->get_preferred_username() );
87+
}
88+
8089
/**
8190
* Generate a default Username.
8291
*

includes/model/class-user.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,24 @@ public function get_url() {
9898
return \esc_url( \get_author_posts_url( $this->_id ) );
9999
}
100100

101+
/**
102+
* Returns the User-URL with @-Prefix for the username.
103+
*
104+
* @return string The User-URL with @-Prefix for the username.
105+
*/
101106
public function get_at_url() {
102107
return \esc_url( \trailingslashit( get_home_url() ) . '@' . $this->get_username() );
103108
}
104109

110+
/**
111+
* Returns a user@domain type of identifier for the user.
112+
*
113+
* @return string The Webfinger-Identifier.
114+
*/
115+
public function get_webfinger_identifier() {
116+
return sprintf( '%s@%s', $this->get_preferred_username(), wp_parse_url( home_url(), PHP_URL_HOST ) );
117+
}
118+
105119
public function get_preferred_username() {
106120
return \esc_attr( \get_the_author_meta( 'login', $this->_id ) );
107121
}

0 commit comments

Comments
 (0)