10
10
use Activitypub \Comment ;
11
11
use Activitypub \Collection \Actors ;
12
12
use Activitypub \Collection \Extra_Fields ;
13
+ use Activitypub \Model \Blog ;
14
+
13
15
use function Activitypub \count_followers ;
14
16
use function Activitypub \get_content_visibility ;
15
17
use function Activitypub \is_user_type_disabled ;
@@ -674,6 +676,12 @@ function ( $id ) {
674
676
*/
675
677
public static function add_dashboard_widgets () {
676
678
\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
+ }
677
685
}
678
686
679
687
/**
@@ -692,4 +700,46 @@ public static function blog_dashboard_widget() {
692
700
);
693
701
echo '</div> ' ;
694
702
}
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
+ }
695
745
}
0 commit comments