PluginProbe
ActivityPub / 4.1.1
ActivityPub v4.1.1
9.3.1 9.3.0 9.2.2 9.2.1 9.2.0 9.1.0 9.0.2 9.0.1 9.0.0 8.3.0 8.2.1 8.2.0 8.1.1 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.2.0 1.3.0 2.0.0 2.0.1 2.1.0 2.1.1 All 160 releases
activitypub / includes / class-admin.php

class-admin.php in ActivityPub 4.1.1, at includes/class-admin.php

794 lines 22.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Admin Class.
4 *
5 * @package Activitypub
6 */
7
8 namespace Activitypub;
9
10 use WP_User_Query;
11 use Activitypub\Model\Blog;
12 use Activitypub\Collection\Users;
13 use Activitypub\Collection\Extra_Fields;
14
15 /**
16 * ActivityPub Admin Class.
17 *
18 * @author Matthias Pfefferle
19 */
20 class Admin {
21 /**
22 * Initialize the class, registering WordPress hooks,
23 */
24 public static function init() {
25 \add_action( 'admin_menu', array( self::class, 'admin_menu' ) );
26 \add_action( 'admin_init', array( self::class, 'register_settings' ) );
27 \add_action( 'load-comment.php', array( self::class, 'edit_comment' ) );
28 \add_action( 'load-post.php', array( self::class, 'edit_post' ) );
29 \add_action( 'load-edit.php', array( self::class, 'list_posts' ) );
30 \add_action( 'personal_options_update', array( self::class, 'save_user_settings' ) );
31 \add_action( 'admin_enqueue_scripts', array( self::class, 'enqueue_scripts' ) );
32 \add_action( 'admin_notices', array( self::class, 'admin_notices' ) );
33
34 \add_filter( 'comment_row_actions', array( self::class, 'comment_row_actions' ), 10, 2 );
35 \add_filter( 'manage_edit-comments_columns', array( static::class, 'manage_comment_columns' ) );
36 \add_action( 'manage_comments_custom_column', array( static::class, 'manage_comments_custom_column' ), 9, 2 );
37
38 \add_filter( 'manage_posts_columns', array( static::class, 'manage_post_columns' ), 10, 2 );
39 \add_action( 'manage_posts_custom_column', array( self::class, 'manage_posts_custom_column' ), 10, 2 );
40
41 \add_filter( 'manage_users_columns', array( self::class, 'manage_users_columns' ) );
42 \add_action( 'manage_users_custom_column', array( self::class, 'manage_users_custom_column' ), 10, 3 );
43 \add_filter( 'bulk_actions-users', array( self::class, 'user_bulk_options' ) );
44 \add_filter( 'handle_bulk_actions-users', array( self::class, 'handle_bulk_request' ), 10, 3 );
45
46 if ( ! is_user_disabled( get_current_user_id() ) ) {
47 \add_action( 'show_user_profile', array( self::class, 'add_profile' ) );
48 }
49
50 \add_filter( 'dashboard_glance_items', array( self::class, 'dashboard_glance_items' ) );
51 }
52
53 /**
54 * Add admin menu entry.
55 */
56 public static function admin_menu() {
57 $settings_page = \add_options_page(
58 'Welcome',
59 'ActivityPub',
60 'manage_options',
61 'activitypub',
62 array( self::class, 'settings_page' )
63 );
64
65 \add_action(
66 'load-' . $settings_page,
67 array( self::class, 'add_settings_help_tab' )
68 );
69
70 // User has to be able to publish posts.
71 if ( ! is_user_disabled( get_current_user_id() ) ) {
72 $followers_list_page = \add_users_page(
73 \__( '⁂ Followers', 'activitypub' ),
74 \__( '⁂ Followers', 'activitypub' ),
75 'read',
76 'activitypub-followers-list',
77 array(
78 self::class,
79 'followers_list_page',
80 )
81 );
82
83 \add_action(
84 'load-' . $followers_list_page,
85 array( self::class, 'add_followers_list_help_tab' )
86 );
87
88 \add_users_page(
89 \__( '⁂ Extra Fields', 'activitypub' ),
90 \__( '⁂ Extra Fields', 'activitypub' ),
91 'read',
92 \esc_url( \admin_url( '/edit.php?post_type=ap_extrafield' ) )
93 );
94 }
95 }
96
97 /**
98 * Display admin menu notices about configuration problems or conflicts.
99 */
100 public static function admin_notices() {
101 $permalink_structure = \get_option( 'permalink_structure' );
102 if ( empty( $permalink_structure ) ) {
103 $admin_notice = \__( 'You are using the ActivityPub plugin with a permalink structure of "plain". This will prevent ActivityPub from working. Please go to "Settings" / "Permalinks" and choose a permalink structure other than "plain".', 'activitypub' );
104 self::show_admin_notice( $admin_notice, 'error' );
105 }
106
107 $current_screen = get_current_screen();
108 if ( ! $current_screen ) {
109 return;
110 }
111 if ( 'edit' === $current_screen->base && Extra_Fields::is_extra_fields_post_type( $current_screen->post_type ) ) {
112 ?>
113 <div class="notice" style="margin: 0; background: none; border: none; box-shadow: none; padding: 15px 0 0 0; font-size: 14px;">
114 <?php
115 esc_html_e( 'These are extra fields that are used for your ActivityPub profile. You can use your homepage, social profiles, pronouns, age, anything you want.', 'activitypub' );
116 ?>
117 </div>
118 <?php
119 }
120 }
121
122 /**
123 * Display one admin menu notice about configuration problems or conflicts.
124 *
125 * @param string $admin_notice The notice to display.
126 * @param string $level The level of the notice (error, warning, success, info).
127 */
128 private static function show_admin_notice( $admin_notice, $level ) {
129 ?>
130
131 <div class="notice notice-<?php echo esc_attr( $level ); ?>">
132 <p><?php echo wp_kses( $admin_notice, 'data' ); ?></p>
133 </div>
134
135 <?php
136 }
137
138 /**
139 * Load settings page.
140 */
141 public static function settings_page() {
142 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
143 if ( empty( $_GET['tab'] ) ) {
144 $tab = 'welcome';
145 } else {
146 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
147 $tab = sanitize_key( $_GET['tab'] );
148 }
149
150 switch ( $tab ) {
151 case 'settings':
152 \load_template( ACTIVITYPUB_PLUGIN_DIR . 'templates/settings.php' );
153 break;
154 case 'blog-profile':
155 wp_enqueue_media();
156 wp_enqueue_script( 'activitypub-header-image' );
157
158 \load_template( ACTIVITYPUB_PLUGIN_DIR . 'templates/blog-settings.php' );
159 break;
160 case 'followers':
161 \load_template( ACTIVITYPUB_PLUGIN_DIR . 'templates/blog-followers-list.php' );
162 break;
163 case 'welcome':
164 default:
165 wp_enqueue_script( 'plugin-install' );
166 add_thickbox();
167 wp_enqueue_script( 'updates' );
168
169 \load_template( ACTIVITYPUB_PLUGIN_DIR . 'templates/welcome.php' );
170 break;
171 }
172 }
173
174 /**
175 * Load user settings page
176 */
177 public static function followers_list_page() {
178 // User has to be able to publish posts.
179 if ( ! is_user_disabled( get_current_user_id() ) ) {
180 \load_template( ACTIVITYPUB_PLUGIN_DIR . 'templates/user-followers-list.php' );
181 }
182 }
183
184 /**
185 * Register ActivityPub settings
186 */
187 public static function register_settings() {
188 \register_setting(
189 'activitypub',
190 'activitypub_post_content_type',
191 array(
192 'type' => 'string',
193 'description' => \__( 'Use title and link, summary, full or custom content', 'activitypub' ),
194 'show_in_rest' => array(
195 'schema' => array(
196 'enum' => array(
197 'title',
198 'excerpt',
199 'content',
200 ),
201 ),
202 ),
203 'default' => 'content',
204 )
205 );
206 \register_setting(
207 'activitypub',
208 'activitypub_custom_post_content',
209 array(
210 'type' => 'string',
211 'description' => \__( 'Define your own custom post template', 'activitypub' ),
212 'show_in_rest' => true,
213 'default' => ACTIVITYPUB_CUSTOM_POST_CONTENT,
214 )
215 );
216 \register_setting(
217 'activitypub',
218 'activitypub_max_image_attachments',
219 array(
220 'type' => 'integer',
221 'description' => \__( 'Number of images to attach to posts.', 'activitypub' ),
222 'default' => ACTIVITYPUB_MAX_IMAGE_ATTACHMENTS,
223 )
224 );
225 \register_setting(
226 'activitypub',
227 'activitypub_object_type',
228 array(
229 'type' => 'string',
230 'description' => \__( 'The Activity-Object-Type', 'activitypub' ),
231 'show_in_rest' => array(
232 'schema' => array(
233 'enum' => array(
234 'note',
235 'wordpress-post-format',
236 ),
237 ),
238 ),
239 'default' => ACTIVITYPUB_DEFAULT_OBJECT_TYPE,
240 )
241 );
242 \register_setting(
243 'activitypub',
244 'activitypub_use_hashtags',
245 array(
246 'type' => 'boolean',
247 'description' => \__( 'Add hashtags in the content as native tags and replace the #tag with the tag-link', 'activitypub' ),
248 'default' => '0',
249 )
250 );
251 \register_setting(
252 'activitypub',
253 'activitypub_use_opengraph',
254 array(
255 'type' => 'boolean',
256 'description' => \__( 'Automatically add "fediverse:creator" OpenGraph tags for Authors and the Blog-User.', 'activitypub' ),
257 'default' => '1',
258 )
259 );
260 \register_setting(
261 'activitypub',
262 'activitypub_support_post_types',
263 array(
264 'type' => 'string',
265 'description' => \esc_html__( 'Enable ActivityPub support for post types', 'activitypub' ),
266 'show_in_rest' => true,
267 'default' => array( 'post' ),
268 )
269 );
270 \register_setting(
271 'activitypub',
272 'activitypub_actor_mode',
273 array(
274 'type' => 'integer',
275 'description' => \__( 'Choose your preferred Actor-Mode.', 'activitypub' ),
276 'default' => '1',
277 )
278 );
279
280 \register_setting(
281 'activitypub',
282 'activitypub_attribution_domains',
283 array(
284 'type' => 'string',
285 'description' => \__( 'Websites allowed to credit you.', 'activitypub' ),
286 'default' => home_host(),
287 'sanitize_callback' => function ( $value ) {
288 $value = explode( PHP_EOL, $value );
289 $value = array_filter( array_map( 'trim', $value ) );
290 $value = array_filter( array_map( 'esc_attr', $value ) );
291 $value = implode( PHP_EOL, $value );
292
293 return $value;
294 },
295 )
296 );
297
298 // Blog-User Settings.
299 \register_setting(
300 'activitypub_blog',
301 'activitypub_blog_description',
302 array(
303 'type' => 'string',
304 'description' => \esc_html__( 'The Description of the Blog-User', 'activitypub' ),
305 'show_in_rest' => true,
306 'default' => '',
307 )
308 );
309 \register_setting(
310 'activitypub_blog',
311 'activitypub_blog_identifier',
312 array(
313 'type' => 'string',
314 'description' => \esc_html__( 'The Identifier of the Blog-User', 'activitypub' ),
315 'show_in_rest' => true,
316 'default' => Blog::get_default_username(),
317 'sanitize_callback' => function ( $value ) {
318 // Hack to allow dots in the username.
319 $parts = explode( '.', $value );
320 $sanitized = array();
321
322 foreach ( $parts as $part ) {
323 $sanitized[] = \sanitize_title( $part );
324 }
325
326 $sanitized = implode( '.', $sanitized );
327
328 // Check for login or nicename.
329 $user = new WP_User_Query(
330 array(
331 'search' => $sanitized,
332 'search_columns' => array( 'user_login', 'user_nicename' ),
333 'number' => 1,
334 'hide_empty' => true,
335 'fields' => 'ID',
336 )
337 );
338
339 if ( $user->results ) {
340 add_settings_error(
341 'activitypub_blog_identifier',
342 'activitypub_blog_identifier',
343 \esc_html__( 'You cannot use an existing author\'s name for the blog profile ID.', 'activitypub' ),
344 'error'
345 );
346
347 return Blog::get_default_username();
348 }
349
350 return $sanitized;
351 },
352 )
353 );
354 \register_setting(
355 'activitypub_blog',
356 'activitypub_header_image',
357 array(
358 'type' => 'integer',
359 'description' => \__( 'The Attachment-ID of the Sites Header-Image', 'activitypub' ),
360 'default' => null,
361 )
362 );
363 }
364
365 /**
366 * Adds the ActivityPub settings to the Help tab.
367 */
368 public static function add_settings_help_tab() {
369 require_once ACTIVITYPUB_PLUGIN_DIR . 'includes/help.php';
370 }
371
372 /**
373 * Adds the follower list to the Help tab.
374 */
375 public static function add_followers_list_help_tab() {
376 // todo.
377 }
378
379 /**
380 * Add the profile.
381 *
382 * @param \WP_User $user The user object.
383 */
384 public static function add_profile( $user ) {
385 $description = \get_user_option( 'activitypub_description', $user->ID );
386
387 wp_enqueue_media();
388 wp_enqueue_script( 'activitypub-header-image' );
389
390 \load_template(
391 ACTIVITYPUB_PLUGIN_DIR . 'templates/user-settings.php',
392 true,
393 array(
394 'description' => $description,
395 )
396 );
397 }
398
399 /**
400 * Save the user settings.
401 *
402 * Handles the saving of the ActivityPub settings.
403 *
404 * @param int $user_id The user ID.
405 */
406 public static function save_user_settings( $user_id ) {
407 if ( ! isset( $_REQUEST['_apnonce'] ) ) {
408 return;
409 }
410
411 $nonce = sanitize_text_field( wp_unslash( $_REQUEST['_apnonce'] ) );
412 if (
413 ! wp_verify_nonce( $nonce, 'activitypub-user-settings' ) ||
414 ! current_user_can( 'edit_user', $user_id )
415 ) {
416 return;
417 }
418
419 $description = ! empty( $_POST['activitypub_description'] ) ? sanitize_textarea_field( wp_unslash( $_POST['activitypub_description'] ) ) : false;
420 if ( $description ) {
421 \update_user_option( $user_id, 'activitypub_description', $description );
422 } else {
423 \delete_user_option( $user_id, 'activitypub_description' );
424 }
425
426 $header_image = ! empty( $_POST['activitypub_header_image'] ) ? sanitize_text_field( wp_unslash( $_POST['activitypub_header_image'] ) ) : false;
427 if ( $header_image && \wp_attachment_is_image( $header_image ) ) {
428 \update_user_option( $user_id, 'activitypub_header_image', $header_image );
429 } else {
430 \delete_user_option( $user_id, 'activitypub_header_image' );
431 }
432 }
433
434 /**
435 * Enqueue the admin scripts and styles.
436 *
437 * @param string $hook_suffix The current page.
438 */
439 public static function enqueue_scripts( $hook_suffix ) {
440 wp_register_script(
441 'activitypub-header-image',
442 plugins_url(
443 'assets/js/activitypub-header-image.js',
444 ACTIVITYPUB_PLUGIN_FILE
445 ),
446 array( 'jquery' ),
447 get_plugin_version(),
448 false
449 );
450
451 if ( false !== strpos( $hook_suffix, 'activitypub' ) ) {
452 wp_enqueue_style(
453 'activitypub-admin-styles',
454 plugins_url(
455 'assets/css/activitypub-admin.css',
456 ACTIVITYPUB_PLUGIN_FILE
457 ),
458 array(),
459 get_plugin_version()
460 );
461 wp_enqueue_script(
462 'activitypub-admin-script',
463 plugins_url(
464 'assets/js/activitypub-admin.js',
465 ACTIVITYPUB_PLUGIN_FILE
466 ),
467 array( 'jquery' ),
468 get_plugin_version(),
469 false
470 );
471 }
472
473 if ( 'index.php' === $hook_suffix ) {
474 wp_enqueue_style(
475 'activitypub-admin-styles',
476 plugins_url(
477 'assets/css/activitypub-admin.css',
478 ACTIVITYPUB_PLUGIN_FILE
479 ),
480 array(),
481 get_plugin_version()
482 );
483 }
484 }
485
486 /**
487 * Hook into the edit_comment functionality.
488 *
489 * Disables the edit_comment capability for federated comments.
490 */
491 public static function edit_comment() {
492 // Disable the edit_comment capability for federated comments.
493 \add_filter(
494 'user_has_cap',
495 function ( $allcaps, $caps, $arg ) {
496 if ( 'edit_comment' !== $arg[0] ) {
497 return $allcaps;
498 }
499
500 if ( was_comment_received( $arg[2] ) ) {
501 return false;
502 }
503
504 return $allcaps;
505 },
506 1,
507 3
508 );
509 }
510
511 /**
512 * Hook into the edit_post functionality.
513 *
514 * Disables the edit_post capability for federated posts.
515 */
516 public static function edit_post() {
517 // Disable the edit_post capability for federated posts.
518 \add_filter(
519 'user_has_cap',
520 function ( $allcaps, $caps, $arg ) {
521 if ( 'edit_post' !== $arg[0] ) {
522 return $allcaps;
523 }
524
525 $post = get_post( $arg[2] );
526
527 if ( ! Extra_Fields::is_extra_field_post_type( $post->post_type ) ) {
528 return $allcaps;
529 }
530
531 if ( (int) get_current_user_id() !== (int) $post->post_author ) {
532 return false;
533 }
534
535 return $allcaps;
536 },
537 1,
538 3
539 );
540 }
541
542 /**
543 * Add ActivityPub specific actions/filters to the post list view.
544 */
545 public static function list_posts() {
546 // Show only the user's extra fields.
547 \add_action(
548 'pre_get_posts',
549 function ( $query ) {
550 if ( $query->get( 'post_type' ) === 'ap_extrafield' ) {
551 $query->set( 'author', get_current_user_id() );
552 }
553 }
554 );
555
556 // Remove all views for the extra fields.
557 $screen_id = get_current_screen()->id;
558
559 add_filter(
560 "views_{$screen_id}",
561 function ( $views ) {
562 if ( Extra_Fields::is_extra_fields_post_type( get_current_screen()->post_type ) ) {
563 return array();
564 }
565
566 return $views;
567 }
568 );
569 }
570
571 /**
572 * Comment row actions.
573 *
574 * @param array $actions The existing actions.
575 * @param int|\WP_Comment $comment The comment object or ID.
576 *
577 * @return array The modified actions.
578 */
579 public static function comment_row_actions( $actions, $comment ) {
580 if ( was_comment_received( $comment ) ) {
581 unset( $actions['edit'] );
582 unset( $actions['quickedit'] );
583 }
584
585 return $actions;
586 }
587
588 /**
589 * Add a column "activitypub".
590 *
591 * This column shows if the user has the capability to use ActivityPub.
592 *
593 * @param array $columns The columns.
594 *
595 * @return array The columns extended by the activitypub.
596 */
597 public static function manage_users_columns( $columns ) {
598 $columns['activitypub'] = __( 'ActivityPub', 'activitypub' );
599 return $columns;
600 }
601
602 /**
603 * Add "comment-type" and "protocol" as column in WP-Admin.
604 *
605 * @param array $columns The list of column names.
606 *
607 * @return array The extended list of column names.
608 */
609 public static function manage_comment_columns( $columns ) {
610 $columns['comment_type'] = esc_attr__( 'Comment-Type', 'activitypub' );
611 $columns['comment_protocol'] = esc_attr__( 'Protocol', 'activitypub' );
612
613 return $columns;
614 }
615
616 /**
617 * Add "post_content" as column for Extra-Fields in WP-Admin.
618 *
619 * @param array $columns The list of column names.
620 * @param string $post_type The post type.
621 *
622 * @return array The extended list of column names.
623 */
624 public static function manage_post_columns( $columns, $post_type ) {
625 if ( Extra_Fields::is_extra_fields_post_type( $post_type ) ) {
626 $after_key = 'title';
627 $index = array_search( $after_key, array_keys( $columns ), true );
628 $columns = array_slice( $columns, 0, $index + 1 ) + array( 'extra_field_content' => esc_attr__( 'Content', 'activitypub' ) ) + $columns;
629 }
630
631 return $columns;
632 }
633
634 /**
635 * Add "comment-type" and "protocol" as column in WP-Admin.
636 *
637 * @param array $column The column to implement.
638 * @param int $comment_id The comment id.
639 */
640 public static function manage_comments_custom_column( $column, $comment_id ) {
641 if ( 'comment_type' === $column && ! defined( 'WEBMENTION_PLUGIN_DIR' ) ) {
642 echo esc_attr( ucfirst( get_comment_type( $comment_id ) ) );
643 } elseif ( 'comment_protocol' === $column ) {
644 $protocol = get_comment_meta( $comment_id, 'protocol', true );
645
646 if ( $protocol ) {
647 echo esc_attr( ucfirst( str_replace( 'activitypub', 'ActivityPub', $protocol ) ) );
648 } else {
649 esc_attr_e( 'Local', 'activitypub' );
650 }
651 }
652 }
653
654 /**
655 * Return the results for the activitypub column.
656 *
657 * @param string $output Custom column output. Default empty.
658 * @param string $column_name Column name.
659 * @param int $user_id ID of the currently-listed user.
660 *
661 * @return string The column contents.
662 */
663 public static function manage_users_custom_column( $output, $column_name, $user_id ) {
664 if ( 'activitypub' !== $column_name ) {
665 return $output;
666 }
667
668 if ( \user_can( $user_id, 'activitypub' ) ) {
669 return '<span aria-hidden="true">&#x2713;</span><span class="screen-reader-text">' . esc_html__( 'ActivityPub enabled for this author', 'activitypub' ) . '</span>';
670 } else {
671 return '<span aria-hidden="true">&#x2717;</span><span class="screen-reader-text">' . esc_html__( 'ActivityPub disabled for this author', 'activitypub' ) . '</span>';
672 }
673 }
674
675 /**
676 * Add a column "extra_field_content" to the post list view.
677 *
678 * @param string $column_name The column name.
679 * @param int $post_id The post ID.
680 *
681 * @return void
682 */
683 public static function manage_posts_custom_column( $column_name, $post_id ) {
684 if ( 'extra_field_content' === $column_name ) {
685 $post = get_post( $post_id );
686 if ( Extra_Fields::is_extra_fields_post_type( $post->post_type ) ) {
687 echo esc_attr( wp_strip_all_tags( $post->post_content ) );
688 }
689 }
690 }
691
692 /**
693 * Add options to the Bulk dropdown on the users page.
694 *
695 * @param array $actions The existing bulk options.
696 *
697 * @return array The extended bulk options.
698 */
699 public static function user_bulk_options( $actions ) {
700 $actions['add_activitypub_cap'] = __( 'Enable for ActivityPub', 'activitypub' );
701 $actions['remove_activitypub_cap'] = __( 'Disable for ActivityPub', 'activitypub' );
702
703 return $actions;
704 }
705
706 /**
707 * Handle bulk activitypub requests.
708 *
709 * * `add_activitypub_cap` - Add the activitypub capability to the selected users.
710 * * `remove_activitypub_cap` - Remove the activitypub capability from the selected users.
711 *
712 * @param string $sendback The URL to send the user back to.
713 * @param string $action The requested action.
714 * @param array $users The selected users.
715 *
716 * @return string The URL to send the user back to.
717 */
718 public static function handle_bulk_request( $sendback, $action, $users ) {
719 if (
720 'remove_activitypub_cap' !== $action &&
721 'add_activitypub_cap' !== $action
722 ) {
723 return $sendback;
724 }
725
726 foreach ( $users as $user_id ) {
727 $user = new \WP_User( $user_id );
728 if (
729 'add_activitypub_cap' === $action &&
730 user_can( $user_id, 'publish_posts' )
731 ) {
732 $user->add_cap( 'activitypub' );
733 } elseif ( 'remove_activitypub_cap' === $action ) {
734 $user->remove_cap( 'activitypub' );
735 }
736 }
737
738 return $sendback;
739 }
740
741 /**
742 * Add ActivityPub infos to the dashboard glance items.
743 *
744 * @param array $items The existing glance items.
745 *
746 * @return array The extended glance items.
747 */
748 public static function dashboard_glance_items( $items ) {
749 \add_filter( 'number_format_i18n', '\Activitypub\custom_large_numbers', 10, 3 );
750
751 if ( ! is_user_disabled( get_current_user_id() ) ) {
752 $follower_count = sprintf(
753 // translators: %s: number of followers.
754 _n(
755 '%s Follower',
756 '%s Followers',
757 count_followers( \get_current_user_id() ),
758 'activitypub'
759 ),
760 \number_format_i18n( count_followers( \get_current_user_id() ) )
761 );
762 $items['activitypub-followers-user'] = sprintf(
763 '<a class="activitypub-followers" href="%1$s" title="%2$s">%3$s</a>',
764 \esc_url( \admin_url( 'users.php?page=activitypub-followers-list' ) ),
765 \esc_attr__( 'Your followers', 'activitypub' ),
766 \esc_html( $follower_count )
767 );
768 }
769
770 if ( ! is_user_type_disabled( 'blog' ) && current_user_can( 'manage_options' ) ) {
771 $follower_count = sprintf(
772 // translators: %s: number of followers.
773 _n(
774 '%s Follower (Blog)',
775 '%s Followers (Blog)',
776 count_followers( Users::BLOG_USER_ID ),
777 'activitypub'
778 ),
779 \number_format_i18n( count_followers( Users::BLOG_USER_ID ) )
780 );
781 $items['activitypub-followers-blog'] = sprintf(
782 '<a class="activitypub-followers" href="%1$s" title="%2$s">%3$s</a>',
783 \esc_url( \admin_url( 'options-general.php?page=activitypub&tab=followers' ) ),
784 \esc_attr__( 'The Blog\'s followers', 'activitypub' ),
785 \esc_html( $follower_count )
786 );
787 }
788
789 \remove_filter( 'number_format_i18n', '\Activitypub\custom_large_numbers' );
790
791 return $items;
792 }
793 }
794