LLMS_Admin_Import::upload_import()
Handle form submission
Description Description
Return Return
(void)
Source Source
File: includes/admin/class.llms.admin.import.php
public function upload_import() { if ( ! isset( $_FILES['llms_import'] ) || ! $_FILES['llms_import'] ) { return; } // Fixes an issue where hooks are loaded out of order causing template functions required to parse an import aren't available? LLMS()->include_template_functions(); $validate = $this->validate_upload( $_FILES['llms_import'] ); if ( is_wp_error( $validate ) ) { return LLMS_Admin_Notices::flash_notice( $validate->get_error_message(), 'error' ); } $raw = file_get_contents( $_FILES['llms_import']['tmp_name'] ); $generator = new LLMS_Generator( $raw ); if ( is_wp_error( $generator->set_generator() ) ) { return LLMS_Admin_Notices::flash_notice( $generator->error->get_error_message(), 'error' ); } else { $generator->generate(); if ( $generator->is_error( ) ) { return LLMS_Admin_Notices::flash_notice( $generator->error->get_error_message(), 'error' ); } else { $msg = '<strong>' . __( 'Import Successful', 'lifterlms' ) . '</strong><br>'; $msg .= '<ul>'; foreach ( $generator->get_results() as $stat => $count ) { // translate like a boss ya'll switch ( $stat ) { case 'authors': $name = __( 'Authors', 'lifterlms' ); break; case 'courses': $name = __( 'Courses', 'lifterlms' ); break; case 'sections': $name = __( 'Sections', 'lifterlms' ); break; case 'lessons': $name = __( 'Lessons', 'lifterlms' ); break; case 'plans': $name = __( 'Plans', 'lifterlms' ); break; case 'quizzes': $name = __( 'Quizzes', 'lifterlms' ); break; case 'questions': $name = __( 'Questions', 'lifterlms' ); break; case 'terms': $name = __( 'Terms', 'lifterlms' ); break; } $msg .= '<li>' . sprintf( '%s: %d', $name, $count ) . '</li>'; }// End foreach(). $msg .= '</ul>'; return LLMS_Admin_Notices::flash_notice( $msg, 'success' ); }// End if(). }// End if(). }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
3.30.1 | Explicitly include template functions. |
3.3.0 | Introduced. |
User Contributed Notes User Contributed Notes
Permalink: