Skip to content
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

Fix the "display every comment ever" bug (and add bookmark support) #8

Merged
merged 2 commits into from Jan 13, 2020
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Next

Account for bookmarks as a Webmention type

  • Loading branch information
jeremyfelt committed Jan 13, 2020
commit 27b12685d3d95eea4f701ea5d9cf8d633e16cdc8
@@ -55,6 +55,7 @@

$typed_comments = array(
'reply' => array(),
'bookmark' => array(),
'like' => array(),
'mention' => array(),
'other' => array(),
@@ -117,6 +118,45 @@

?>

<h3>Bookmarks</h3>
<?php

foreach ( $typed_comments['bookmark'] as $bookmark_id ) {
$like = get_comment( $bookmark_id );
$url = get_comment_meta( $bookmark_id, 'webmention_source_url', true );
$avatar = get_comment_meta( $bookmark_id, 'avatar', true );
$author_url = get_comment_meta( $bookmark_id, 'semantic_linkbacks_author_url', true );

if ( '' === $author_url ) {
$author_url = $url;
}

if ( '' === $avatar ) {
$avatar = get_template_directory_uri() . '/images/mystery-person.png';
}

?>

<!-- Markup inspired by https://indieweb.org/like -->
<article class="p-bookmark h-cite">
<!-- The loading attribute is only supported by Chrome right now, but I'd like to not use JavaScript for this. -->
<img src="<?php echo esc_url( $avatar ); ?>" width=40 alt="" loading="lazy" />

<!-- This span is my lazy way of enabling a vertically aligned flex display on the article element. -->
<span>
<a class="p-author h-card" href="<?php echo esc_url( $author_url ); ?>"><?php echo esc_html( $like->comment_author ); ?></a>
bookmarked this on
<a class="u-url" href="<?php echo esc_url( $url ); ?>">
<time class="dt-published"><?php echo get_comment_date( 'F j, Y \a\t g:i a', $like ); ?></time>
</a>
</span>
</article>

<?php
}

?>

<h3>Mentions</h3>
<?php
foreach ( $typed_comments['mention'] as $mention_id ) {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.