Skip to content

Commit 7f1ef19

Browse files
pfefferlematticbot
andauthored
Add Dashboard widgets for ActivityPub profiles (#1658)
Co-authored-by: Automattic Bot <[email protected]>
1 parent 3a3fdda commit 7f1ef19

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: minor
2+
Type: added
3+
4+
Profile sections have been moved from the Welcome page to new Dashboard widgets for easier access.

includes/wp-admin/class-admin.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
use Activitypub\Comment;
1111
use Activitypub\Collection\Actors;
1212
use Activitypub\Collection\Extra_Fields;
13+
use Activitypub\Model\Blog;
14+
1315
use function Activitypub\count_followers;
1416
use function Activitypub\get_content_visibility;
1517
use function Activitypub\is_user_type_disabled;
@@ -674,6 +676,12 @@ function ( $id ) {
674676
*/
675677
public static function add_dashboard_widgets() {
676678
\wp_add_dashboard_widget( 'activitypub_blog', \__( 'ActivityPub Plugin News', 'activitypub' ), array( self::class, 'blog_dashboard_widget' ) );
679+
if ( user_can_activitypub( \get_current_user_id() ) && ! is_user_type_disabled( 'user' ) ) {
680+
\wp_add_dashboard_widget( 'activitypub_profile', \__( 'ActivityPub Author profile', 'activitypub' ), array( self::class, 'profile_dashboard_widget' ) );
681+
}
682+
if ( ! is_user_type_disabled( 'blog' ) ) {
683+
\wp_add_dashboard_widget( 'activitypub_blog_profile', \__( 'ActivityPub Blog profile', 'activitypub' ), array( self::class, 'blogprofile_dashboard_widget' ) );
684+
}
677685
}
678686

679687
/**
@@ -692,4 +700,46 @@ public static function blog_dashboard_widget() {
692700
);
693701
echo '</div>';
694702
}
703+
704+
/**
705+
* Add the ActivityPub Author profile as a Dashboard widget.
706+
*/
707+
public static function profile_dashboard_widget() {
708+
$user = Actors::get_by_id( \get_current_user_id() );
709+
?>
710+
<p>
711+
<?php \esc_html_e( 'People can follow you by using your author name:', 'activitypub' ); ?>
712+
</p>
713+
<p><label for="activitypub-user-identifier"><?php \esc_html_e( 'Username', 'activitypub' ); ?></label><input type="text" class="large-text code" id="activitypub-user-identifier" value="<?php echo \esc_attr( $user->get_webfinger() ); ?>" readonly /></p>
714+
<p><label for="activitypub-user-url"><?php \esc_html_e( 'Profile URL', 'activitypub' ); ?></label><input type="text" class="large-text code" id="activitypub-user-url" value="<?php echo \esc_attr( $user->get_url() ); ?>" readonly /></p>
715+
<p>
716+
<?php \esc_html_e( 'Authors who can not access this settings page will find their username on the "Edit Profile" page.', 'activitypub' ); ?>
717+
<a href="<?php echo \esc_url( \admin_url( '/profile.php#activitypub' ) ); ?>">
718+
<?php \esc_html_e( 'Customize username on "Edit Profile" page.', 'activitypub' ); ?>
719+
</a>
720+
</p>
721+
<?php
722+
}
723+
724+
/**
725+
* Add the ActivityPub Blog profile as a Dashboard widget.
726+
*/
727+
public static function blogprofile_dashboard_widget() {
728+
$user = new Blog();
729+
?>
730+
<p>
731+
<?php \esc_html_e( 'People can follow your blog by using:', 'activitypub' ); ?>
732+
</p>
733+
<p><label for="activitypub-user-identifier"><?php \esc_html_e( 'Username', 'activitypub' ); ?></label><input type="text" class="large-text code" id="activitypub-user-identifier" value="<?php echo \esc_attr( $user->get_webfinger() ); ?>" readonly /></p>
734+
<p><label for="activitypub-user-url"><?php \esc_html_e( 'Profile URL', 'activitypub' ); ?></label><input type="text" class="large-text code" id="activitypub-user-url" value="<?php echo \esc_attr( $user->get_url() ); ?>" readonly /></p>
735+
<p>
736+
<?php \esc_html_e( 'This blog profile will federate all posts written on your blog, regardless of the author who posted it.', 'activitypub' ); ?>
737+
<?php if ( current_user_can( 'manage_options' ) ) : ?>
738+
<a href="<?php echo \esc_url( \admin_url( '/options-general.php?page=activitypub&tab=blog-profile' ) ); ?>">
739+
<?php \esc_html_e( 'Customize the blog profile.', 'activitypub' ); ?>
740+
</a>
741+
<?php endif; ?>
742+
</p>
743+
<?php
744+
}
695745
}

0 commit comments

Comments
 (0)