/**
 * Define and treat custom error pages based on request status
 *
 * To use this feature, write:
 *
 *      add_action('wp', 'basicbootstrap_error_pages');
 *
 * @since WP_Basic_Bootstrap 1.0
 */
function basicbootstrap_error_pages()
{
    $status = basicbootstrap_get_status();
    if ($status == 404) {
        set_error_404(false, true);
    } elseif ($status == 403) {
        set_error_403(false, true);
    } elseif ($status == 401) {
        set_error_401(false, true);
    }
}
/**
 * Manage global redirections
 *
 * To use this feature, write:
 *
 *      add_action('template_redirect', 'basicbootstrap_template_redirect', 1);
 *
 */
function basicbootstrap_template_redirect()
{
    // disallow attachment page when it is disabled
    if (!is_admin() && is_attachment()) {
        global $post;
        $visibility = get_post_meta($post->ID, 'attachment-page-visibility', true);
        if ($visibility == 'disabled') {
            set_error_403(false, true);
        }
    }
}