LLMS_Post_Model::export()
Trigger an export download of the given post type
Contents
Return Return
(void)
Source Source
File: includes/abstracts/abstract.llms.post.model.php
public function export() { // If post type doesn't support exporting don't proceed. if ( ! $this->is_exportable() ) { return; } $title = str_replace( ' ', '-', $this->get( 'title' ) ); $title = preg_replace( '/[^a-zA-Z0-9-]/', '', $title ); /** * Filters the export file name * * @since Unknown * * @param string $title The exported file name. Doesn't include the extension. * @param LLMS_Post_Model $llms_post The LLMS_Post_Model instance. */ $filename = apply_filters( 'llms_post_model_export_filename', $title . '_' . current_time( 'Ymd' ), $this ); header( 'Content-type: application/json' ); header( 'Content-Disposition: attachment; filename="' . $filename . '.json"' ); header( 'Pragma: no-cache' ); header( 'Expires: 0' ); $this->allowed_post_tags_set(); add_filter( 'llms_post_model_to_array_add_extras', '__return_true', 99 ); $arr = $this->toArray(); remove_filter( 'llms_post_model_to_array_add_extras', '__return_true', 99 ); $arr['_generator'] = 'LifterLMS/Single' . ucwords( $this->model_post_type ) . 'Exporter'; $arr['_source'] = get_site_url(); $arr['_version'] = llms()->version; ksort( $arr ); echo json_encode( $arr ); $this->allowed_post_tags_unset(); die(); }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
4.8.0 | Made sure extra data are added to the posts model array representation during export. |
3.3.0 | |
3.19.2 | Introduced. |