LLMS_Admin_Import::upload_import()
Handle form submission
Return Return
(boolean|WP_Error) false for nonce or permission errors, WP_Error when an error is encountered, true on success.
Source Source
File: includes/admin/class.llms.admin.import.php
public function upload_import() {
if ( ! llms_verify_nonce( 'llms_importer_nonce', 'llms-importer' ) || ! current_user_can( 'manage_lifterlms' ) || empty( $_FILES['llms_import'] ) ) {
return false;
}
// Fixes an issue where hooks are loaded in an unexpected order causing template functions required to parse an import aren't available.
llms()->include_template_functions();
// phpcs:disable WordPress.Security.ValidatedSanitizedInput.MissingUnslash
// phpcs:disable WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
$validate = $this->validate_upload( $_FILES['llms_import'] );
// File upload error.
if ( is_wp_error( $validate ) ) {
return $this->show_error( $validate );
}
$raw = ! empty( $_FILES['llms_import']['tmp_name'] ) ? file_get_contents( sanitize_text_field( $_FILES['llms_import']['tmp_name'] ) ) : array(); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
// phpcs:enable WordPress.Security.ValidatedSanitizedInput.MissingUnslash
// phpcs:enable WordPress.Security.ValidatedSanitizedInput.InputNotSanitizedr
return $this->handle_generation( $raw );
}
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 4.8.0 | Use helper methods show_error() and handle_generation(). |
| 3.37.3 | Don't unslash uploaded file tmp_name. |
| 3.36.3 | Fixed a typo where "$generator" was spelled "$generater". |
| 3.35.0 | Validate nonce and user permissions before processing import data. Moved statistic localization into its own function. Updated return signature. |
| 3.30.1 | Explicitly include template functions. |
| 3.3.0 | Introduced. |