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

acf_field_flexible_content::render_layout() public ACF 5.0.0

description

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

Хуков нет.

Возвращает

$post_id. (int)

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

$acf_field_flexible_content = new acf_field_flexible_content();
$acf_field_flexible_content->render_layout( $field, $layout, $i, $value );
$field (обязательный)
-
$layout (обязательный)
-
$i (обязательный)
-
$value (обязательный)
-

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

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

Код acf_field_flexible_content::render_layout() ACF 5.9.1

<?php
function render_layout( $field, $layout, $i, $value ) {
	
	// vars
	$order = 0;
	$el = 'div';
	$sub_fields = $layout['sub_fields'];
	$id = ( $i === 'acfcloneindex' ) ? 'acfcloneindex' : "row-$i";
	$prefix = $field['name'] . '[' . $id .  ']';
	
	
	// div
	$div = array(
		'class'			=> 'layout',
		'data-id'		=> $id,
		'data-layout'	=> $layout['name']
	);
	
	
	// clone
	if( is_numeric($i) ) {
		
		$order = $i + 1;
		
	} else {
		
		$div['class'] .= ' acf-clone';
		
	}
	
	
	// display
	if( $layout['display'] == 'table' ) {
		
		$el = 'td';
		
	}
	
	
	// title
	$title = $this->get_layout_title( $field, $layout, $i, $value );
	
	
	// remove row
	reset_rows();
	
?>
<div <?php echo acf_esc_attr($div); ?>>
		
<?php acf_hidden_input(array( 'name' => $prefix.'[acf_fc_layout]', 'value' => $layout['name'] )); ?>

<div class="acf-fc-layout-handle" title="<?php _e('Drag to reorder','acf'); ?>" data-name="collapse-layout"><?php echo $title; ?></div>

<div class="acf-fc-layout-controls">
	<a class="acf-icon -plus small light acf-js-tooltip" href="#" data-name="add-layout" title="<?php _e('Add layout','acf'); ?>"></a>
	<a class="acf-icon -duplicate small light acf-js-tooltip" href="#" data-name="duplicate-layout" title="<?php _e('Duplicate layout','acf'); ?>"></a>
	<a class="acf-icon -minus small light acf-js-tooltip" href="#" data-name="remove-layout" title="<?php _e('Remove layout','acf'); ?>"></a>
	<a class="acf-icon -collapse small -clear acf-js-tooltip" href="#" data-name="collapse-layout" title="<?php _e('Click to toggle','acf'); ?>"></a>
</div>

<?php if( !empty($sub_fields) ): ?>

<?php if( $layout['display'] == 'table' ): ?>
<table class="acf-table">
	
	<thead>
		<tr>
			<?php foreach( $sub_fields as $sub_field ): 
				
				// prepare field (allow sub fields to be removed)
				$sub_field = acf_prepare_field($sub_field);
				
				
				// bail ealry if no field
				if( !$sub_field ) continue;
				
				
				// vars
				$atts = array();
				$atts['class'] = 'acf-th';
				$atts['data-name'] = $sub_field['_name'];
				$atts['data-type'] = $sub_field['type'];
				$atts['data-key'] = $sub_field['key'];
				
				
				// Add custom width
				if( $sub_field['wrapper']['width'] ) {
				
					$atts['data-width'] = $sub_field['wrapper']['width'];
					$atts['style'] = 'width: ' . $sub_field['wrapper']['width'] . '%;';
					
				}
				
				?>
				<th <?php echo acf_esc_attr( $atts ); ?>>
					<?php echo acf_get_field_label( $sub_field ); ?>
					<?php if( $sub_field['instructions'] ): ?>
						<p class="description"><?php echo $sub_field['instructions']; ?></p>
					<?php endif; ?>
				</th>
				
			<?php endforeach; ?> 
		</tr>
	</thead>
	
	<tbody>
		<tr class="acf-row">
<?php else: ?>
<div class="acf-fields <?php if($layout['display'] == 'row'): ?>-left<?php endif; ?>">
<?php endif; ?>

	<?php
		
	// loop though sub fields
	foreach( $sub_fields as $sub_field ) {
		
		// add value
		if( isset($value[ $sub_field['key'] ]) ) {
			
			// this is a normal value
			$sub_field['value'] = $value[ $sub_field['key'] ];
			
		} elseif( isset($sub_field['default_value']) ) {
			
			// no value, but this sub field has a default value
			$sub_field['value'] = $sub_field['default_value'];
			
		}
		
		
		// update prefix to allow for nested values
		$sub_field['prefix'] = $prefix;
		
		
		// render input
		acf_render_field_wrap( $sub_field, $el );
	
	}
	
	?>
		
<?php if( $layout['display'] == 'table' ): ?>
		</tr>
	</tbody>
</table>
<?php else: ?>
</div>
<?php endif; ?>

<?php endif; ?>

</div>
<?php
	
}