LLMS_Admin_Export_Download::maybe_serve_export()
Serve an export file as a download
Return Return
(void)
Source Source
File: includes/admin/class-llms-admin-export-download.php
*/
public function maybe_serve_export() {
$export = llms_filter_input( INPUT_GET, 'llms-dl-export', FILTER_SANITIZE_FULL_SPECIAL_CHARS );
if ( ! $export ) {
return;
}
// Verify nonce.
if ( ! llms_verify_nonce( 'llms_dl_export_nonce', LLMS_Abstract_Exportable_Admin_Table::EXPORT_NONCE_ACTION, 'GET' ) ) {
wp_die( __( 'Cheatin’ huh?', 'lifterlms' ) );
}
// Only allow people who can view reports view exports.
if ( ! current_user_can( 'view_others_lifterlms_reports' ) && ! current_user_can( 'view_lifterlms_reports' ) ) {
wp_die( __( 'Cheatin’ huh?', 'lifterlms' ) );
}
$path = LLMS_TMP_DIR . basename( $export );
if ( ! file_exists( $path ) ) {
wp_die( __( 'Cheatin’ huh?', 'lifterlms' ) );
}
$info = pathinfo( $path );
if ( 'csv' !== $info['extension'] ) {
wp_die( __( 'Cheatin’ huh?', 'lifterlms' ) );
}
header( 'Content-Type: text/csv' );
header( 'Content-Disposition: attachment; filename="' . $export . '"' );
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 5.9.0 | Stop using deprecated FILTER_SANITIZE_STRING. |
| 3.28.1 | Introduced. |