Skip to content

Commit

Permalink
Update disable-comments.php
Browse files Browse the repository at this point in the history
  • Loading branch information
alimuzzaman committed Jan 9, 2024
1 parent 12b897c commit 0dd3acd
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions disable-comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -389,10 +389,6 @@ public function init_wploaded_filters()
remove_post_type_support($type, 'trackbacks');
}
}
add_filter('comments_array', array($this, 'filter_existing_comments'), 20, 2);
add_filter('comments_open', array($this, 'filter_comment_status'), 20, 2);
add_filter('pings_open', array($this, 'filter_comment_status'), 20, 2);
add_filter('get_comments_number', array($this, 'filter_comments_number'), 20, 2);
} elseif (is_admin() && !$this->is_configured()) {
/**
* It is possible that $disabled_post_types is empty if other
Expand All @@ -403,6 +399,13 @@ public function init_wploaded_filters()
add_action('all_admin_notices', array($this, 'setup_notice'));
}

if ($this->is_remove_everywhere() || (!empty($disabled_post_types) && !$this->is_exclude_by_role())) {
add_filter('comments_array', array($this, 'filter_existing_comments'), 20, 2);
add_filter('comments_open', array($this, 'filter_comment_status'), 20, 2);
add_filter('pings_open', array($this, 'filter_comment_status'), 20, 2);
add_filter('get_comments_number', array($this, 'filter_comments_number'), 20, 2);
}

// Filters for the admin only.
if (is_admin()) {
add_action( 'all_admin_notices', array( $this, 'admin_notice' ) );
Expand Down

0 comments on commit 0dd3acd

Please sign in to comment.