WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Авторские Темы для WordPress
функция не описана

acf_field_file::render_field() public ACF 3.6

Create the HTML interface for your field

{} Это метод класса: acf_field_file{}

Хуков нет.

Возвращает

null. Ничего.

Использование

$acf_field_file = new acf_field_file();
$acf_field_file->render_field( $field );
$field (обязательный)
-

Список изменений

С версии 3.6 Введена.

Код acf_field_file::render_field() ACF 5.9.1

<?php
function render_field( $field ) {
	
	// vars
	$uploader = acf_get_setting('uploader');
	
	
	// allow custom uploader
	$uploader = acf_maybe_get($field, 'uploader', $uploader);
	
	
	// enqueue
	if( $uploader == 'wp' ) {
		acf_enqueue_uploader();
	}
	
	
	// vars
	$o = array(
		'icon'		=> '',
		'title'		=> '',
		'url'		=> '',
		'filename'	=> '',
		'filesize'	=> ''
	);
	
	$div = array(
		'class'				=> 'acf-file-uploader',
		'data-library' 		=> $field['library'],
		'data-mime_types'	=> $field['mime_types'],
		'data-uploader'		=> $uploader
	);
	
	
	// has value?
	if( $field['value'] ) {
		
		$attachment = acf_get_attachment($field['value']);
		if( $attachment ) {
			
			// has value
			$div['class'] .= ' has-value';
			
			// update
			$o['icon'] = $attachment['icon'];
			$o['title']	= $attachment['title'];
			$o['url'] = $attachment['url'];
			$o['filename'] = $attachment['filename'];
			if( $attachment['filesize'] ) {
				$o['filesize'] = size_format($attachment['filesize']);
			}
		}		
	}
			
?>
<div <?php acf_esc_attr_e( $div ); ?>>
<?php acf_hidden_input(array( 'name' => $field['name'], 'value' => $field['value'], 'data-name' => 'id' )); ?>
<div class="show-if-value file-wrap">
	<div class="file-icon">
		<img data-name="icon" src="<?php echo esc_url($o['icon']); ?>" alt=""/>
	</div>
	<div class="file-info">
		<p>
			<strong data-name="title"><?php echo esc_html($o['title']); ?></strong>
		</p>
		<p>
			<strong><?php _e('File name', 'acf'); ?>:</strong>
			<a data-name="filename" href="<?php echo esc_url($o['url']); ?>" target="_blank"><?php echo esc_html($o['filename']); ?></a>
		</p>
		<p>
			<strong><?php _e('File size', 'acf'); ?>:</strong>
			<span data-name="filesize"><?php echo esc_html($o['filesize']); ?></span>
		</p>
	</div>
	<div class="acf-actions -hover">
		<?php if( $uploader != 'basic' ): ?>
		<a class="acf-icon -pencil dark" data-name="edit" href="#" title="<?php _e('Edit', 'acf'); ?>"></a>
		<?php endif; ?>
		<a class="acf-icon -cancel dark" data-name="remove" href="#" title="<?php _e('Remove', 'acf'); ?>"></a>
	</div>
</div>
<div class="hide-if-value">
	<?php if( $uploader == 'basic' ): ?>
		
		<?php if( $field['value'] && !is_numeric($field['value']) ): ?>
			<div class="acf-error-message"><p><?php echo acf_esc_html($field['value']); ?></p></div>
		<?php endif; ?>
		
		<label class="acf-basic-uploader">
			<?php acf_file_input(array( 'name' => $field['name'], 'id' => $field['id'] )); ?>
		</label>
		
	<?php else: ?>
		
		<p><?php _e('No file selected','acf'); ?> <a data-name="add" class="acf-button button" href="#"><?php _e('Add File','acf'); ?></a></p>
		
	<?php endif; ?>
	
</div>
</div>
<?php
	
}