function bp_checkins_place_delete()
{
    // Bail if not a POST action
    if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
        return;
    }
    // Check the nonce
    check_admin_referer('bp_checkins_place_delete_link');
    if (!is_user_logged_in()) {
        echo '-1';
        return false;
    }
    if (empty($_POST['place_id']) || !is_numeric($_POST['place_id'])) {
        echo '-1';
        return false;
    }
    $place = new BP_Checkins_Place((int) $_POST['place_id']);
    if (empty($place->query->post->post_author) || !bp_checkins_places_user_can_delete($place->query->post)) {
        echo '-1';
        return false;
    }
    do_action('bp_checkins_before_place_delete', $place->query->post->ID);
    $notice = bp_checkins_delete_place($place->query->post->ID);
    if (!$notice || $notice['type'] != 'updated') {
        echo '-1<div id="message" class="error"><p>' . $notice['message'] . '</p></div>';
        return false;
    }
    do_action('bp_checkins_after_place_delete', $place->query->post->ID);
    return true;
    exit;
}
function bp_checkins_places_delete_content()
{
    if (bp_is_current_component('checkins') && bp_is_current_action('comments') && 'delete' == bp_action_variable(0)) {
        $redirect = esc_url(wp_get_referer());
        if (!bp_action_variable(1) || !is_numeric(bp_action_variable(1))) {
            bp_core_add_message(__('No comment to delete', 'bp-checkins'), 'error');
            bp_core_redirect($redirect);
        }
        check_admin_referer('bp_checkins_comment_delete_link');
        $comment_id = (int) bp_action_variable(1);
        $notice = bp_checkins_delete_place_comment($comment_id);
        if (empty($notice)) {
            bp_core_add_message(__('No comment id was given, please try again', 'bp-checkins'), 'error');
        } else {
            if (is_array($notice) && $notice['type'] == 'updated') {
                bp_core_add_message($notice['message']);
            } else {
                bp_core_add_message($notice['message'], $notice['type']);
            }
        }
        bp_core_redirect($redirect);
    }
    if (bp_is_current_component('checkins') && bp_is_current_action('places') && 'delete' == bp_action_variable(0)) {
        $redirect = bp_get_checkins_places_home();
        if (!bp_action_variable(1) || !is_numeric(bp_action_variable(1))) {
            bp_core_add_message(__('No place to delete', 'bp-checkins'), 'error');
            bp_core_redirect($redirect);
        }
        check_admin_referer('bp_checkins_place_delete_link');
        $place_id = (int) bp_action_variable(1);
        do_action('bp_checkins_before_place_delete', $place_id);
        $notice = bp_checkins_delete_place($place_id);
        if (empty($notice)) {
            bp_core_add_message(__('No place id was given, please try again', 'bp-checkins'), 'error');
        } else {
            if (is_array($notice) && $notice['type'] == 'updated') {
                bp_core_add_message($notice['message']);
            } else {
                bp_core_add_message($notice['message'], $notice['type']);
            }
        }
        do_action('bp_checkins_after_place_delete', $place_id);
        bp_core_redirect($redirect);
    }
}