Skip to content

Commit 166e54b

Browse files
authored
Reply block: Improve fallback embed (#1560)
1 parent d02a311 commit 166e54b

File tree

6 files changed

+27
-19
lines changed

6 files changed

+27
-19
lines changed

assets/css/activitypub-embed.css

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@
66
background: #fff;
77
border: 1px solid #e6e6e6;
88
border-radius: 12px;
9-
margin: 1em 0;
109
padding: 0;
1110
max-width: 100%;
1211
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
1312
}
1413

14+
.activitypub-reply-block .activitypub-embed {
15+
margin: 1em 0;
16+
}
17+
1518
.activitypub-embed-header {
1619
padding: 15px;
1720
display: flex;
@@ -93,6 +96,7 @@
9396
}
9497

9598
.activitypub-embed-meta a.ap-stat {
99+
color: inherit;
96100
text-decoration: none;
97101
}
98102

build/reply/index-rtl.css

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/reply/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-compose', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives', 'wp-url'), 'version' => 'f07b381ebbd367924395');
1+
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives', 'wp-url'), 'version' => '8ff5f0e6ab1e101a6c99');

build/reply/index.css

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

includes/functions.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,15 +1636,15 @@ function get_embed_html( $url, $inline_css = true ) {
16361636
$title = $object['name'] ?? '';
16371637
$content = $object['content'] ?? '';
16381638
$published = isset( $object['published'] ) ? gmdate( get_option( 'date_format' ) . ', ' . get_option( 'time_format' ), strtotime( $object['published'] ) ) : '';
1639-
$boosts = isset( $object['shares']['totalItems'] ) ? (int) $object['shares']['totalItems'] : 0;
1640-
$favorites = isset( $object['likes']['totalItems'] ) ? (int) $object['likes']['totalItems'] : 0;
1639+
$boosts = isset( $object['shares']['totalItems'] ) ? (int) $object['shares']['totalItems'] : null;
1640+
$favorites = isset( $object['likes']['totalItems'] ) ? (int) $object['likes']['totalItems'] : null;
16411641

16421642
$image = '';
16431643
if ( isset( $object['image']['url'] ) ) {
16441644
$image = $object['image']['url'];
16451645
} elseif ( isset( $object['attachment'] ) ) {
16461646
foreach ( $object['attachment'] as $attachment ) {
1647-
if ( isset( $attachment['type'] ) && 'Document' === $attachment['type'] ) {
1647+
if ( isset( $attachment['type'] ) && in_array( $attachment['type'], array( 'Image', 'Document' ), true ) ) {
16481648
$image = $attachment['url'];
16491649
break;
16501650
}

templates/reply-embed.php

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
'image' => '',
1818
'published' => '',
1919
'url' => '',
20-
'boosts' => '',
21-
'favorites' => '',
20+
'boosts' => null,
21+
'favorites' => null,
2222
'webfinger' => '',
2323
)
2424
);
@@ -60,18 +60,22 @@
6060
<a href="<?php echo \esc_url( $args['url'] ); ?>" class="ap-stat ap-date dt-published u-in-reply-to"><?php echo \esc_html( $args['published'] ); ?></a>
6161
<?php endif; ?>
6262

63+
<?php if ( null !== $args['boosts'] ) : ?>
6364
<span class="ap-stat">
64-
<?php
65-
/* translators: %s: number of boosts */
66-
printf( \esc_html__( '%s boosts', 'activitypub' ), '<strong>' . \esc_html( $args['boosts'] ) . '</strong>' );
67-
?>
68-
</span>
65+
<?php
66+
/* translators: %s: number of boosts */
67+
printf( \esc_html__( '%s boosts', 'activitypub' ), '<strong>' . \esc_html( $args['boosts'] ) . '</strong>' );
68+
?>
69+
</span>
70+
<?php endif; ?>
6971

72+
<?php if ( null !== $args['favorites'] ) : ?>
7073
<span class="ap-stat">
71-
<?php
72-
/* translators: %s: number of favorites */
73-
printf( \esc_html__( '%s favorites', 'activitypub' ), '<strong>' . \esc_html( $args['favorites'] ) . '</strong>' );
74-
?>
75-
</span>
74+
<?php
75+
/* translators: %s: number of favorites */
76+
printf( \esc_html__( '%s favorites', 'activitypub' ), '<strong>' . \esc_html( $args['favorites'] ) . '</strong>' );
77+
?>
78+
</span>
79+
<?php endif; ?>
7680
</div>
7781
</div>

0 commit comments

Comments
 (0)