import.php 2.57 KB
Newer Older
cyrille's avatar
cyrille committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
<?php
/**
 * Import & Export LLMS Content
 *
 * @since 3.3.0
 * @version 4.8.0
 */

defined( 'ABSPATH' ) || exit;

$courses = LLMS_Export_API::list();
?>

<div class="wrap lifterlms llms-import-export">

	<h1 class="wp-heading-inline"><?php _e( 'Import Courses', 'lifterlms' ); ?></h1>
	<button class="page-title-action" role="button"><?php _e( 'Upload', 'lifterlms' ); ?></button>

	<hr class="wp-header-end">

	<div class="llms-widget" style="display: none;" id="llms-import-uploader">

		<form action="" enctype="multipart/form-data" method="POST">

			<table class="form-table">

				<tr>
					<th><label for="llms-import-file"><?php _e( 'Import Course(s)', 'lifterlms' ); ?></label></th>
					<td>
						<p><?php _e( 'Upload export files generated by LifterLMS. Must be a ".json" file.', 'lifterlms' ); ?></p>
						<div class="llms-import-file-wrap">
							<input accept="application/json" name="llms_import" id="llms-import-file" type="file">
							<button class="button" id="llms-import-file-submit" type="submit"><?php _e( 'Import', 'lifterlms' ); ?></button>
						</div>
					</td>
				</tr>

				<?php
					/**
					 * Fires after core importer(s) on the "Import screen".
					 *
					 * Allows 3rd parties to add their own importers to the table.
					 *
					 * @since 3.3.0
					 */
					do_action( 'lifterlms_importer_tr' );
				?>

			</table>

			<?php wp_nonce_field( 'llms-importer', 'llms_importer_nonce' ); ?>

		</form>

	</div>

	<form action="" method="POST">

		<p>
			<?php
				// Translators: %s = anchor link HTML to LifterLMS.com.
				printf( __( 'Download and import courses, templates, and more from %s.', 'lifterlms' ), '<a href="https://lifterlms.com" target="_blank">LifterLMS.com</a>' );
			?>
			<button class="llms-cloud-import-help button-link" type="button" title="<?php esc_attr_e( 'Help', 'lifterlms' ); ?>">
				<span class="screen-reader-text"><?php _e( 'Help', 'lifterlms' ); ?></span>
				<span class="dashicons dashicons-editor-help"></span>
			</button>
		</p>

		<?php require LLMS_PLUGIN_DIR . 'includes/admin/views/importable-courses.php'; ?>
		<?php wp_nonce_field( 'llms-cloud-importer', 'llms_cloud_importer_nonce' ); ?>

	</form>

</div>

<script>
( function() {
	document.querySelector( '.page-title-action' ).addEventListener( 'click', function() {
		const el = document.getElementById( 'llms-import-uploader' );
		el.style.display = 'none' === el.style.display ? 'block' : 'none';
	} );
	document.querySelector( '.llms-cloud-import-help' ).addEventListener( 'click', function( e ) {
		document.getElementById( 'contextual-help-link' ).click();
	} );
} )();
</script>