acf_field_flexible_content::render_field_settings()publicACF 3.6

Create extra options for your field. This is rendered when editing a field. The value of $field['name'] can be used (like bellow) to save extra data to the $field

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

Хуков нет.

Возвращает

null. Ничего (null).

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

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

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

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

Код acf_field_flexible_content::render_field_settings() ACF 6.0.4

<?php
function render_field_settings( $field ) {

	// load default layout
	if ( empty( $field['layouts'] ) ) {

		$field['layouts'] = array(
			array(),
		);

	}

	// loop through layouts
	foreach ( $field['layouts'] as $layout ) {

		// get valid layout
		$layout = $this->get_valid_layout( $layout );

		// vars
		$layout_prefix = "{$field['prefix']}[layouts][{$layout['key']}]";

		?>
		<div class="acf-field acf-field-setting-fc_layout" data-name="fc_layout" data-setting="flexible_content" data-id="<?php echo esc_attr( $layout['key'] ); ?>">
			<div class="acf-label acf-field-settings-fc_head">
				<label><?php _e( 'Layout', 'acf' ); ?></label>
				<ul class="acf-bl acf-fl-actions">
					<li><a class="reorder-layout" href="#" title="<?php _e( 'Reorder Layout', 'acf' ); ?>"><?php _e( 'Reorder', 'acf' ); ?></a></li>
					<li><a class="delete-layout" href="#" title="<?php _e( 'Delete Layout', 'acf' ); ?>"><?php _e( 'Delete', 'acf' ); ?></a></li>
					<li><a class="duplicate-layout" href="#" title="<?php _e( 'Duplicate Layout', 'acf' ); ?>"><?php _e( 'Duplicate', 'acf' ); ?></a></li>
					<li><a class="add-layout" href="#" title="<?php _e( 'Add New Layout', 'acf' ); ?>"><?php _e( 'Add New', 'acf' ); ?></a></li>
				</ul>
			</div>
			<div class="acf-input">
				<?php

				acf_hidden_input(
					array(
						'id'    => acf_idify( $layout_prefix . '[key]' ),
						'name'  => $layout_prefix . '[key]',
						'class' => 'layout-key',
						'value' => $layout['key'],
					)
				);

				?>
			<ul class="acf-fc-meta acf-bl">
				<li class="acf-fc-meta-label">
					<?php

					acf_render_field(
						array(
							'type'    => 'text',
							'name'    => 'label',
							'class'   => 'layout-label',
							'prefix'  => $layout_prefix,
							'value'   => $layout['label'],
							'prepend' => __( 'Label', 'acf' ),
						)
					);

					?>
				</li>
				<li class="acf-fc-meta-name">
						<?php

						acf_render_field(
							array(
								'type'    => 'text',
								'name'    => 'name',
								'class'   => 'layout-name',
								'prefix'  => $layout_prefix,
								'value'   => $layout['name'],
								'prepend' => __( 'Name', 'acf' ),
							)
						);

						?>
				</li>
				<li class="acf-fc-meta-display">
					<div class="acf-input-prepend"><?php _e( 'Layout', 'acf' ); ?></div>
					<div class="acf-input-wrap">
						<?php

						acf_render_field(
							array(
								'type'    => 'select',
								'name'    => 'display',
								'prefix'  => $layout_prefix,
								'value'   => $layout['display'],
								'class'   => 'acf-is-prepended',
								'choices' => array(
									'table' => __( 'Table', 'acf' ),
									'block' => __( 'Block', 'acf' ),
									'row'   => __( 'Row', 'acf' ),
								),
							)
						);

						?>
					</div>
				</li>
				<li class="acf-fc-meta-min">
						<?php

						acf_render_field(
							array(
								'type'    => 'text',
								'name'    => 'min',
								'prefix'  => $layout_prefix,
								'value'   => $layout['min'],
								'prepend' => __( 'Min', 'acf' ),
							)
						);

						?>
				</li>
				<li class="acf-fc-meta-max">
						<?php

						acf_render_field(
							array(
								'type'    => 'text',
								'name'    => 'max',
								'prefix'  => $layout_prefix,
								'value'   => $layout['max'],
								'prepend' => __( 'Max', 'acf' ),
							)
						);

						?>
				</li>
			</ul>
			<div class="acf-input-sub">
			<?php

			// vars
			$args = array(
				'fields'      => $layout['sub_fields'],
				'parent'      => $field['ID'],
				'is_subfield' => true,
			);

			acf_get_view( 'field-group-fields', $args );

			?>
			</div>
		</div>
	</div>
		<?php

	}
	// endforeach
}