Skip to content

Follow Me: Improve MU compatibility #1777

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Jun 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/changelog/1777-from-description
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: fixed

Avoids the button block breaking for users that don't have the `unfiltered_html` capability.
Blog users now get their correct post count displayed in the Editor and the front-end.
2 changes: 1 addition & 1 deletion build/follow-me/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://schemas.wp.org/trunk/block.json",
"name": "activitypub/follow-me",
"apiVersion": 3,
"version": "2.1.0",
"version": "2.2.0",
"title": "Follow me on the Fediverse",
"category": "widgets",
"description": "Display your Fediverse profile so that visitors can follow you.",
Expand Down
2 changes: 1 addition & 1 deletion build/follow-me/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => 'd10a4c1f7765f3cb91d3');
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => '2784cdb631a09f797fab');
4 changes: 2 additions & 2 deletions build/follow-me/index.js

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions build/follow-me/render.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@

if ( empty( $content ) ) {
$button_text = $attributes['buttonText'] ?? __( 'Follow', 'activitypub' );
$content = '<div class="wp-block-button"><button class="wp-block-button__link wp-element-button">' . esc_html( $button_text ) . '</button></div>';
$content = '<div class="wp-block-button"><a class="wp-element-button wp-block-button__link">' . esc_html( $button_text ) . '</a></div>';
} else {
$content = implode( PHP_EOL, wp_list_pluck( $block->parsed_block['innerBlocks'], 'innerHTML' ) );
}
Expand All @@ -87,18 +87,21 @@
array( 'class_name' => 'wp-element-button' ),
array(
'data-wp-on--click' => 'actions.toggleModal',
'data-wp-on-async--keydown' => 'actions.onKeydown',
'data-wp-bind--aria-expanded' => 'context.modal.isOpen',
'aria-label' => __( 'Follow me on the Fediverse', 'activitypub' ),
'aria-haspopup' => 'dialog',
'aria-controls' => 'modal-heading',
'role' => 'button',
'tabindex' => '0',
)
);

$header_image = $actor->get_image();
$has_header = ! empty( $header_image['url'] ) && str_contains( $attributes['className'] ?? '', 'is-style-profile' );

$stats = array(
'posts' => count_user_posts( $user_id, 'post', true ),
'posts' => $user_id ? count_user_posts( $user_id, 'post', true ) : (int) wp_count_posts()->publish,
'followers' => Followers::count_followers( $user_id ),
);

Expand All @@ -122,7 +125,8 @@ class="activitypub-profile__avatar u-photo"
<div class="activitypub-profile__content">
<div class="activitypub-profile__info">
<div class="activitypub-profile__name p-name"><?php echo esc_html( $actor->get_name() ); ?></div>
<div class="activitypub-profile__handle p-nickname p-x-webfinger"><?php echo esc_html( '@' . $actor->get_webfinger() ); ?></div>
<?php /** Using `data-wp-text` to avoid @see enrich_content_data() turning it into a mention. */ ?>
<div class="activitypub-profile__handle p-nickname p-x-webfinger" data-wp-text="context.webfinger"></div>
</div>

<?php echo $content; // phpcs:ignore WordPress.Security.EscapeOutput ?>
Expand Down
2 changes: 1 addition & 1 deletion build/follow-me/view.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('@wordpress/interactivity'), 'version' => '98b2215b2ba2b12a4251', 'type' => 'module');
<?php return array('dependencies' => array('@wordpress/interactivity'), 'version' => '1bdc53d1581dc837c6e5', 'type' => 'module');
2 changes: 1 addition & 1 deletion build/follow-me/view.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/followers/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://schemas.wp.org/trunk/block.json",
"name": "activitypub/followers",
"apiVersion": 3,
"version": "2.0.0",
"version": "2.0.1",
"title": "Fediverse Followers",
"category": "widgets",
"description": "Display your followers from the Fediverse on your website.",
Expand Down
2 changes: 1 addition & 1 deletion build/followers/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives', 'wp-url'), 'version' => 'f38e37997a68878f3e6a');
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives', 'wp-url'), 'version' => '6b9807dcd5804f1f470a');
Loading
Loading