Beispiel #1
0
function wpsc_delete_file()
{
    $product_id = absint($_REQUEST['product_id']);
    $file_name = basename($_REQUEST['file_name']);
    check_admin_referer('delete_file_' . $file_name);
    _wpsc_delete_file($product_id, $file_name);
    $sendback = wp_get_referer();
    wp_redirect($sendback);
    exit;
}
Beispiel #2
0
/**
 * Delete an attached downloadable file via AJAX.
 *
 * @since 3.8.9
 * @access private
 *
 * @uses _wpsc_delete_file()    Deletes files associated with a product
 * @uses WP_Error               WordPress error class
 *
 * @return array|WP_Error   $return     Response args if successful, WP_Error if otherwise
 */
function _wpsc_ajax_delete_file()
{
    $product_id = absint($_REQUEST['product_id']);
    $file_name = basename($_REQUEST['file_name']);
    $result = _wpsc_delete_file($product_id, $file_name);
    if (!$result) {
        return new WP_Error('wpsc_cannot_delete_file', __("Couldn't delete the file. Please try again.", 'wpsc'));
    }
    $return = array('product_id' => $product_id, 'file_name' => $file_name);
    return $return;
}