<?php 

function cp_view_material_cb() {
	if(!isset($_GET['id'])) return_method();
	$post = new post;
	$material = $post->get_post_meta($_GET['id']);
	if($material['type'] === 'cp_lesson_material') {
		do_action("ViewerJS_from_library", [
			'ref' => $material['ref']
		]);
	}
	if($material['type'] === 'cp_lesson_material_link') {
		?>
		<div class="row">
			<div class="col">
				<a type="button" class="btn-icon-clipboard" href="<?php echo $material['material-url'] ?>" target="_blank" data-clipboard-text="cloud-download-95" title="" data-original-title="Click to download lesson note and other attachments">
	                <div>
	                  <i class="fa fa-globe"></i>
	                  <span>Click here to visit the website</span>
	                </div>
	            </a>
			</div>
		</div>
		<?php
	}
	do_action("comments_api", [
		'obj' => $material['id'],
		'label' => 'Contribution',
		'label_plu' => 'Contributions',
		'submit_text' => 'Post Contribution',
		'editor' => "",
		'key' => 'cp_view_material'
	]);
	// global $post_meta;
	// add_page_javascript('app/assets/js/page-scripts/js-functions.js');
}