Skip to content

Commit

Permalink
Merge pull request #320 from raamdev/fix/319
Browse files Browse the repository at this point in the history
Fixes bug where webmentions were hidden when comments are disabled
  • Loading branch information
raamdev authored Jan 5, 2021
2 parents 79ec16d + 8519044 commit 5b7dee7
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
<div id="commentform-bottom"></div> <!-- do not remove; used by jQuery to move the comment reply form here -->
<?php endif; ?>

<?php if ( independent_publisher_comment_count_mentions() ) { // If we have mentions, let's show them ?>
<?php if ( independent_publisher_comment_count_mentions() && !independent_publisher_hide_mentions() ) { // If we have mentions, let's show them ?>
<div id="webmentions" class="mentions-list">
<h3><?php echo apply_filters( 'independent_publisher_webmentions_title', __( 'Webmentions', 'independent-publisher' ) ); ?></h3>
<?php independent_publisher_mentions(); ?>
Expand Down
2 changes: 1 addition & 1 deletion content.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
<?php $separator = apply_filters( 'independent_publisher_entry_meta_separator', '|' ); ?>

<?php /* Show webmentions link only when post is not password-protected AND pings open AND there are mentions on this post */ ?>
<?php if ( !post_password_required() && pings_open() && independent_publisher_comment_count_mentions() ) : ?>
<?php if ( !post_password_required() && pings_open() && independent_publisher_comment_count_mentions() && !independent_publisher_hide_mentions() ) : ?>
<?php $mention_count = independent_publisher_comment_count_mentions(); ?>
<?php $mention_label = (independent_publisher_comment_count_mentions() > 1 ? __( 'Webmentions', 'independent-publisher' ) : __( 'Webmention', 'independent-publisher' ) ); ?>
<span class="mentions-link"><a href="<?php the_permalink(); ?>#webmentions"><?php echo $mention_count . ' ' . $mention_label; ?></a></span><span class="sep"><?php echo (comments_open() && !independent_publisher_hide_comments()) ? ' '.$separator : '' ?></span>
Expand Down
9 changes: 9 additions & 0 deletions inc/template-tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,15 @@ function independent_publisher_hide_comments() {
}
endif;

if ( !function_exists( 'independent_publisher_hide_mentions' ) ):
/**
* Determines if webmentions should be hidden altogether.
*/
function independent_publisher_hide_mentions() {
return false;
}
endif;

if ( !function_exists( 'independent_publisher_footer_credits' ) ):
/**
* Echoes the theme footer credits. Overriding this function in a Child Theme also
Expand Down
9 changes: 6 additions & 3 deletions page.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@
<?php get_template_part( 'content', 'page' ); ?>

<?php
// If comments are open or we have at least one comment, load up the comment template
if ( comments_open() || '0' != get_comments_number() && !independent_publisher_hide_comments() ) :
// If comments are open or we have at least one comment and comments are not hidden, or
// if we have webmentions and webmentions are not hidden,
// load up the comment template
if ( ( comments_open() || '0' != get_comments_number() && !independent_publisher_hide_comments() ) ||
( independent_publisher_comment_count_mentions() > 0 && !independent_publisher_hide_mentions() ) ) {
comments_template( '', true );
endif;
}
?>

<?php endwhile; // end of the loop. ?>
Expand Down
7 changes: 5 additions & 2 deletions single.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@
<?php get_template_part( 'content', 'single' ); ?>

<?php
// If comments are open or we have at least one comment, load up the comment template
if ( comments_open() || '0' != get_comments_number() && !independent_publisher_hide_comments() ) {
// If comments are open or we have at least one comment and comments are not hidden, or
// if we have webmentions and webmentions are not hidden,
// load up the comment template
if ( ( comments_open() || '0' != get_comments_number() && !independent_publisher_hide_comments() ) ||
( independent_publisher_comment_count_mentions() > 0 && !independent_publisher_hide_mentions() ) ) {
comments_template( '', true );
}
?>
Expand Down

0 comments on commit 5b7dee7

Please sign in to comment.