/*

Theme Name: Pro &ndash; Child Theme
Theme URI: http://theme.co/pro/
Author: Themeco
Author URI: http://theme.co/
Description: Make all of your modifications to Pro in this child theme.
Version: 1.0.0
Template: pro

*/

// Disable support for comments and trackbacks on all post types
add_action('admin_init', function () {
    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');
        }
    }
});

// Close comments on the front-end
add_filter('comments_open', '__return_false', 20, 2);
add_filter('pings_open', '__return_false', 20, 2);

// Hide existing comments
add_filter('comments_array', '__return_empty_array', 10, 2);

// Remove comment-related menu items from admin
add_action('admin_menu', function () {
    remove_menu_page('edit-comments.php');
});

// Redirect users who try to access the comments page
add_action('admin_init', function () {
    if (is_admin() && isset($_GET['page']) && $_GET['page'] === 'edit-comments.php') {
        wp_redirect(admin_url());
        exit;
    }
});

// Remove the recent comments widget from the dashboard
add_action('admin_init', function () {
    remove_meta_box('dashboard_recent_comments', 'dashboard', 'normal');
});

// Remove comment links from the admin bar
add_action('init', function () {
    if (is_admin_bar_showing()) {
        remove_action('admin_bar_menu', 'wp_admin_bar_comments_menu', 60);
    }
});