// 1. Close comment and pingback status on the frontend
add_filter('comments_open', '__return_false', 20, 2);
add_filter('pings_open', '__return_false', 20, 2);

// 2. Hide existing comments from displaying on the frontend
add_filter('comments_array', '__return_empty_array', 10, 2);

// 3. Remove the Comments menu page from the admin dashboard sidebar
add_action('admin_menu', function () {
    remove_menu_page('edit-comments.php');
});

// 4. Redirect any direct URL requests to the admin comments page
add_action('admin_init', function () {
    global $pagenow;
    if ($pagenow === 'edit-comments.php') {
        wp_redirect(admin_url());
        exit;
    });
});

// 5. Remove the comments icon/link from the top Admin Bar
add_action('wp_before_admin_bar_render', function () {
    global $wp_admin_bar;
    $wp_admin_bar->remove_menu('comments');
});