/**
         * Print the metabox to upload a file
         */
        public function print_upload_meta_box()
        {
            global $post;
            wp_nonce_field(plugin_basename(__FILE__), 'wp_cuar_nonce_file');
            $current_file = get_post_meta($post->ID, 'cuar_private_file_file', true);
            do_action("cuar/private-content/files/before-upload-meta-box");
            ?>
		
<?php 
            if (!empty($current_file) && isset($current_file['file'])) {
                ?>
		<div id="cuar-current-file" class="metabox-row">
			<h4><?php 
                _e('File currently associated to this post', 'cuar');
                ?>
</h4>
			<p><?php 
                _e('Current file:', 'cuar');
                ?>
 
				<a href="<?php 
                cuar_the_file_link($post->ID, 'download');
                ?>
" target="_blank">
					<?php 
                echo basename($current_file['file']);
                ?>
</a>
			</p>
		</div>		
<?php 
            }
            ?>
 
	
<?php 
            $ftp_dir = trailingslashit($this->private_file_addon->get_ftp_path());
            ?>
		<div>
			<hr>
			<h4><?php 
            _e('Change the associated file', 'cuar');
            ?>
</h4>
			<span class="label"><label for="cuar_file_select_method"><?php 
            _e('How to add the file?', 'cuar');
            ?>
</label></span> 	
			<span class="field">
				<select id="cuar_file_select_method" name="cuar_file_select_method">
					<option value="cuar_direct_upload"><?php 
            _e('Direct upload', 'cuar');
            ?>
&nbsp;&nbsp;</option>
					<option value="cuar_from_ftp_folder"><?php 
            _e('Copy from FTP folder', 'cuar');
            ?>
&nbsp;&nbsp;</option>
				</select>
			</span>
		</div>

		<div id="cuar_direct_upload" class="metabox-row file-select-method">
			<span class="label"><label for="cuar_private_file_file"><?php 
            _e('Pick a file', 'cuar');
            ?>
</label></span> 	
			<span class="field"><input type="file" name="cuar_private_file_file" id="cuar_private_file_file" /></span>
		</div>	
			
<?php 
            if (file_exists($ftp_dir)) {
                $ftp_files = scandir($ftp_dir);
            }
            ?>
		<div id="cuar_from_ftp_folder" class="metabox-row file-select-method" style="display: none;">
			<span class="label"><label for="cuar_selected_ftp_file"><?php 
            _e('Pick a file', 'cuar');
            ?>
</label></span> 	
			<span class="field">
<?php 
            if (!file_exists($ftp_dir)) {
                _e("The FTP upload folder does not exist.", 'cuar');
            } else {
                if ($this->is_dir_empty($ftp_dir)) {
                    _e("The FTP upload folder is empty.", 'cuar');
                } else {
                    echo '<select id="cuar_selected_ftp_file" name="cuar_selected_ftp_file">';
                    echo '<option value="">' . __('Select a file', 'cuar') . '</option>';
                    foreach ($ftp_files as $filename) {
                        $filepath = $ftp_dir . '/' . $filename;
                        if (is_file($filepath)) {
                            echo '<option value="' . esc_attr($filename) . '">' . esc_html($filename) . '</option>';
                        }
                    }
                    echo '</select>';
                }
            }
            ?>
			</span>
			<br/>
			<br/>
<?php 
            if (file_exists($ftp_dir)) {
                ?>
			<span class="label"><label for="cuar_selected_ftp_file"><?php 
                _e('Copy file or move it?', 'cuar');
                ?>
</label></span>	
			<span class="field">
				<input id="cuar_ftp_delete_file_after_copy" name="cuar_ftp_delete_file_after_copy" type="checkbox" value="1" /> &nbsp;
				<span><?php 
                _e("If checked, the file will be deleted after it has been copied to the owner's private storage directory", "cuar");
                ?>
</span>
			</span>
<?php 
            }
            ?>
		</div>
				
		<script type="text/javascript">
		<!--
			jQuery( document ).ready( function($) {
				$( '#cuar_file_select_method' ).change(function() {
					var selection = $(this).val();

					// Do nothing if already visible
					if ( $( '#' + selection ).is(":visible") ) return;

					// Hide previous and then show new
					if ( $('.file-select-method:visible').length<=0 ) {
						$( '#' + selection ).fadeToggle();
					} else {
						$('.file-select-method:visible').fadeToggle("fast", function () {
							$( '#' + selection ).fadeToggle();
						});
					}
				});
			});
		//-->
		</script>
<?php 
            do_action("cuar/private-content/files/after-upload-meta-box");
        }
echo $date;
?>
</p>
			</div>
		</div>
	</div>
	
	<div class="meta-category file-meta">
		<div class="row">
			<div class="meta-block file">
				<h4><span class="dashicons dashicons-admin-links"></span> <?php 
_e('Attachment', 'cuar');
?>
</h4>
				<p><a href="<?php 
cuar_the_file_link(get_the_ID(), 'download');
?>
" title="<?php 
esc_attr_e('Download', 'cuar');
?>
">
					<?php 
cuar_the_file_name(get_the_ID());
?>
 (<?php 
cuar_the_file_size(get_the_ID());
?>
)
				</a></p>
			</div>
		</div>