Disables comments across entire WordPress site.
add_action( 'admin_init', function() {
global $pagenow;
if ( 'edit-comments.php' === $pagenow ) {
wp_redirect( admin_url() );
exit;
}
remove_meta_box( 'dashboard_recent_comments', 'dashboard', 'normal' );
foreach ( get_post_types() as $post_type ) {
if ( post_type_supports( $post_type, 'comments' ) ) {
remove_post_type_support( $post_type, 'comments' );
remove_post_type_support( $post_type, 'trackbacks' );
}
}
} );
add_filter( 'comments_open', '__return_false', 20, 2 );
add_filter( 'pings_open', '__return_false', 20, 2 );