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

acf_field_flexible_content::render_field() public ACF 3.6

Create the HTML interface for your field

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

Возвращает

null. Ничего.

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

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

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

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

Код acf_field_flexible_content::render_field() ACF 5.9.1

<?php
function render_field( $field ) {

	// defaults
	if( empty($field['button_label']) ) {
	
		$field['button_label'] = $this->defaults['button_label'];
		
	}
	
	
	// sort layouts into names
	$layouts = array();
	
	foreach( $field['layouts'] as $k => $layout ) {
	
		$layouts[ $layout['name'] ] = $layout;
		
	}
	
	
	// vars
	$div = array(
		'class'		=> 'acf-flexible-content',
		'data-min'	=> $field['min'],
		'data-max'	=> $field['max']
	);
	
	// empty
	if( empty($field['value']) ) {
		$div['class'] .= ' -empty';
	}
	
	
	// no value message
	$no_value_message = __('Click the "%s" button below to start creating your layout','acf');
	$no_value_message = apply_filters('acf/fields/flexible_content/no_value_message', $no_value_message, $field);

?>
<div <?php acf_esc_attr_e( $div ); ?>>

<?php acf_hidden_input(array( 'name' => $field['name'] )); ?>

<div class="no-value-message">
	<?php printf( $no_value_message, $field['button_label'] ); ?>
</div>

<div class="clones">
	<?php foreach( $layouts as $layout ): ?>
		<?php $this->render_layout( $field, $layout, 'acfcloneindex', array() ); ?>
	<?php endforeach; ?>
</div>

<div class="values">
	<?php if( !empty($field['value']) ): 
		
		foreach( $field['value'] as $i => $value ):
			
			// validate
			if( empty($layouts[ $value['acf_fc_layout'] ]) ) continue;
			
			
			// render
			$this->render_layout( $field, $layouts[ $value['acf_fc_layout'] ], $i, $value );
			
		endforeach;
		
	endif; ?>
</div>

<div class="acf-actions">
	<a class="acf-button button button-primary" href="#" data-name="add-layout"><?php echo $field['button_label']; ?></a>
</div>

<script type="text-html" class="tmpl-popup"><?php 
	?><ul><?php foreach( $layouts as $layout ): 
		
		$atts = array(
			'href'			=> '#',
			'data-layout'	=> $layout['name'],
			'data-min' 		=> $layout['min'],
			'data-max' 		=> $layout['max'],
		);
		
		?><li><a <?php acf_esc_attr_e( $atts ); ?>><?php echo $layout['label']; ?></a></li><?php 
	
	endforeach; ?></ul>
</script>

</div>
<?php
	
}