Skip to content

Commit

Permalink
add function to hide the block theme comment section to prevent it fr…
Browse files Browse the repository at this point in the history
…om showing briefly before disqus loads. this function is tied to the comment_form_before wordpress action.
  • Loading branch information
Debian committed Feb 15, 2024
1 parent f98985e commit 6e63e72
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions disqus/includes/class-disqus.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ private function define_public_hooks() {
$this->loader->add_filter( 'comments_number', $plugin_public, 'dsq_comments_link_template' );
$this->loader->add_filter( 'comments_template', $plugin_public, 'dsq_comments_template' );
$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_comment_count' );
$this->loader->add_action( 'comment_form_before', $plugin_public, 'hide_block_theme_comment_section');
$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_comment_embed' );
$this->loader->add_action( 'show_user_profile', $plugin_public, 'dsq_close_window_template' );
}
Expand Down
16 changes: 16 additions & 0 deletions disqus/public/class-disqus-public.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,22 @@ public function enqueue_comment_embed() {
}
}

/**
* Hides the comment section block for WP block themes.
* This prevents the WP block comment section from appearing briefly before being replaced by Disqus.
*
* @since 3.0
*/
public function hide_block_theme_comment_section() {
?>
<style>
.wp-block-comments {
display: none;
}
</style>
<?php
}

/**
* Determines if Disqus is configured and can load on a given page.
*
Expand Down

0 comments on commit 6e63e72

Please sign in to comment.