Fix WebFinger resources for Blog-User and updated settings.

This commit is contained in:
Matthias Pfefferle 2023-05-31 08:45:14 +02:00
parent 4d8170413b
commit 913b60c7c7
6 changed files with 52 additions and 9 deletions

View file

@ -245,6 +245,11 @@ class Activitypub {
\flush_rewrite_rules();
}
/**
* Theme compatibility stuff
*
* @return void
*/
public static function theme_compat() {
$site_icon = get_theme_support( 'custom-logo' );

View file

@ -24,12 +24,12 @@ class Webfinger {
return \get_webfinger_resource( $user_id, false );
}
$user = \get_user_by( 'id', $user_id );
$user = User_Factory::get_by_id( $user_id );
if ( ! $user ) {
return '';
}
return $user->user_login . '@' . \wp_parse_url( \home_url(), \PHP_URL_HOST );
return $user->get_resource();
}
/**

View file

@ -24,7 +24,7 @@ class Blog_User extends User {
*
* @param int $user_id The User-ID.
*/
public function __construct( $user_id ) {
public function __construct( $user_id = null ) {
add_filter( 'activitypub_json_author_array', array( $this, 'add_api_endpoints' ), 10, 2 );
}

View file

@ -247,4 +247,8 @@ class User {
return $array;
}
public function get_resource() {
return $this->get_username() . '@' . \wp_parse_url( \home_url(), \PHP_URL_HOST );
}
}

View file

@ -42,10 +42,19 @@
</th>
<td>
<div class="header-image" style="background-image: url('<?php echo esc_url( get_header_image() ); ?>');">
<img class="logo" src="<?php echo get_site_icon_url(); ?>" />
<img class="logo" src="<?php echo esc_url( get_site_icon_url() ); ?>" />
</div>
<p class="description">
<?php esc_html_e( 'Change cover and avatar in the customizer.', 'activitypub' ); ?>
<?php
echo \wp_kses(
\sprintf(
// translators: %s is the link is to the customizer.
\__( 'Change the Avatar and the Cover using the <a href="%s">Customizer</a>.', 'activitypub' ),
\esc_url_raw( \admin_url( 'customize.php' ) )
),
'default'
);
?>
</p>
</td>
</tr>

View file

@ -13,29 +13,54 @@
<h2><?php \esc_html_e( 'Welcome', 'activitypub' ); ?></h2>
<p><?php \esc_html_e( 'With ActivityPub your blog becomes part of a federated social network. This means you can share and talk to everyone using the ActivityPub protocol, including users of Friendica, Pleroma and Mastodon.', 'activitypub' ); ?></p>
<h3><?php \esc_html_e( 'Blog Account', 'activitypub' ); ?></h3>
<p>
<?php
$blog_user = new \Activitypub\Model\Blog_User();
echo wp_kses(
\sprintf(
// translators:
\__(
'People can follow you by using the username <code>%1$s</code> or the URL <code>%2$s</code>. Users who can not access this settings page will find their username on the <a href="%3$s">Edit Profile</a> page.',
'People can follow your Blog by using the username <code>%1$s</code> or the URL <code>%2$s</code>. This Blog-User will federate all posts written on your Blog, regardless of the User who posted it. You can customize the Blog-User on the <a href="%3$s">Settings Page</a>.',
'activitypub'
),
\esc_attr( \Activitypub\get_webfinger_resource( wp_get_current_user()->ID ) ),
\esc_url_raw( \get_author_posts_url( wp_get_current_user()->ID ) ),
\esc_attr( $blog_user->get_resource() ),
\esc_url_raw( $blog_user->get_url() ),
\esc_url_raw( \admin_url( '/options-general.php?page=activitypub&tab=settings' ) )
),
'default'
);
?>
</p>
<h3><?php \esc_html_e( 'Personal Account', 'activitypub' ); ?></h3>
<p>
<?php
$user = \Activitypub\User_Factory::get_by_id( wp_get_current_user()->ID );
echo wp_kses(
\sprintf(
// translators:
\__(
'People can also follow you by using your Username <code>%1$s</code> or your Author-URL <code>%2$s</code>. Users who can not access this settings page will find their username on the <a href="%3$s">Edit Profile</a> page.',
'activitypub'
),
\esc_attr( $user->get_resource() ),
\esc_url_raw( $user->get_url() ),
\esc_url_raw( \admin_url( 'profile.php#activitypub' ) )
),
'default'
);
?>
</p>
<h3><?php \esc_html_e( 'Troubleshooting', 'activitypub' ); ?></h3>
<p>
<?php
echo wp_kses(
\sprintf(
// translators:
\__( 'If you have problems using this plugin, please check the <a href="%s">Site Health</a> to ensure that your site is compatible and/or use the "Help" tab (in the top right of the settings pages).', 'activitypub' ),
\__(
'If you have problems using this plugin, please check the <a href="%s">Site Health</a> to ensure that your site is compatible and/or use the "Help" tab (in the top right of the settings pages).',
'activitypub'
),
\esc_url_raw( admin_url( 'site-health.php' ) )
),
'default'