Skip to content

Commit 2e2093d

Browse files
authored
Follow Me: Improve MU compatibility (#1777)
1 parent fa231c0 commit 2e2093d

File tree

15 files changed

+133
-37
lines changed

15 files changed

+133
-37
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Significance: patch
2+
Type: fixed
3+
4+
Avoids the button block breaking for users that don't have the `unfiltered_html` capability.
5+
Blog users now get their correct post count displayed in the Editor and the front-end.

build/follow-me/block.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"$schema": "https://schemas.wp.org/trunk/block.json",
33
"name": "activitypub/follow-me",
44
"apiVersion": 3,
5-
"version": "2.1.0",
5+
"version": "2.2.0",
66
"title": "Follow me on the Fediverse",
77
"category": "widgets",
88
"description": "Display your Fediverse profile so that visitors can follow you.",

build/follow-me/index.asset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +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');
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' => '2784cdb631a09f797fab');

build/follow-me/index.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/follow-me/render.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777

7878
if ( empty( $content ) ) {
7979
$button_text = $attributes['buttonText'] ?? __( 'Follow', 'activitypub' );
80-
$content = '<div class="wp-block-button"><button class="wp-block-button__link wp-element-button">' . esc_html( $button_text ) . '</button></div>';
80+
$content = '<div class="wp-block-button"><a class="wp-element-button wp-block-button__link">' . esc_html( $button_text ) . '</a></div>';
8181
} else {
8282
$content = implode( PHP_EOL, wp_list_pluck( $block->parsed_block['innerBlocks'], 'innerHTML' ) );
8383
}
@@ -87,18 +87,21 @@
8787
array( 'class_name' => 'wp-element-button' ),
8888
array(
8989
'data-wp-on--click' => 'actions.toggleModal',
90+
'data-wp-on-async--keydown' => 'actions.onKeydown',
9091
'data-wp-bind--aria-expanded' => 'context.modal.isOpen',
9192
'aria-label' => __( 'Follow me on the Fediverse', 'activitypub' ),
9293
'aria-haspopup' => 'dialog',
9394
'aria-controls' => 'modal-heading',
95+
'role' => 'button',
96+
'tabindex' => '0',
9497
)
9598
);
9699

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

100103
$stats = array(
101-
'posts' => count_user_posts( $user_id, 'post', true ),
104+
'posts' => $user_id ? count_user_posts( $user_id, 'post', true ) : (int) wp_count_posts()->publish,
102105
'followers' => Followers::count_followers( $user_id ),
103106
);
104107

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

128132
<?php echo $content; // phpcs:ignore WordPress.Security.EscapeOutput ?>

build/follow-me/view.asset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array('@wordpress/interactivity'), 'version' => '98b2215b2ba2b12a4251', 'type' => 'module');
1+
<?php return array('dependencies' => array('@wordpress/interactivity'), 'version' => '1bdc53d1581dc837c6e5', 'type' => 'module');

build/follow-me/view.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/followers/block.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"$schema": "https://schemas.wp.org/trunk/block.json",
33
"name": "activitypub/followers",
44
"apiVersion": 3,
5-
"version": "2.0.0",
5+
"version": "2.0.1",
66
"title": "Fediverse Followers",
77
"category": "widgets",
88
"description": "Display your followers from the Fediverse on your website.",

build/followers/index.asset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +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');
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' => '6b9807dcd5804f1f470a');

0 commit comments

Comments
 (0)