Example #1
0
function mb_handler_topic_toggle_trash()
{
    if (!isset($_GET['action']) || 'mb_toggle_trash' !== $_GET['action'] || !isset($_GET['topic_id'])) {
        return;
    }
    $topic_id = mb_get_topic_id($_GET['topic_id']);
    /* Verify nonce. */
    if (!isset($_GET['mb_nonce']) || !wp_verify_nonce($_GET['mb_nonce'], "trash_topic_{$topic_id}")) {
        return;
    }
    if (!current_user_can('delete_topic', $topic_id)) {
        return;
    }
    $updated = mb_is_topic_trash($topic_id) ? wp_untrash_post($topic_id) : wp_trash_post($topic_id);
    $redirect = remove_query_arg(array('action', 'topic_id', 'mb_nonce'));
    wp_safe_redirect(esc_url($redirect));
}
Example #2
0
function mb_get_topic_toggle_trash_link($topic_id = 0)
{
    $topic_id = mb_get_topic_id($topic_id);
    if (!current_user_can('delete_topic', $topic_id)) {
        return '';
    }
    $topic_id = mb_get_topic_id($topic_id);
    $text = mb_is_topic_trash($topic_id) ? __('Restore', 'message-board') : get_post_status_object(mb_get_trash_post_status())->label;
    $link = sprintf('<a class="toggle-trash-link" href="%s">%s</a>', mb_get_topic_toggle_trash_url($topic_id), $text);
    return $link;
}