ACF\Blocks\AutoInlineEditing

populate_auto_inline_editing_values()ACF 1.0

This function populates a global variable called acf_fields_used_in_block_render_template, which is an array where each key is the value entered for the field, and the value is the field data, including the current value.

No Hooks.

Returns

Mixed.

Usage

populate_auto_inline_editing_values( $field_value, $post_id, $field );
$field_value(mixed) (required)
The field_value.
$post_id(string) (required)
The post ID for this value.
$field(array) (required)
The field array.

populate_auto_inline_editing_values() code ACF 6.8.8

function populate_auto_inline_editing_values( $field_value, $post_id, $field ) {

	global $acf_fields_used_in_block_render_template, $acf_blocks_doing_auto_inline_editing, $acf_blocks_doing_auto_inline_editing_block_id;

	if ( ! $acf_blocks_doing_auto_inline_editing || ! empty( $field['parent_repeater'] ) ) {
		return $field_value;
	}

	// Only modify values for fields fetched against the current block's own post id.
	// Calls like get_field( 'foo', $other_post_id ) target a different post and must be returned unmodified
	// so block templates can rely on real values (e.g. for conditional logic) instead of placeholder strings.
	if ( ! empty( $acf_blocks_doing_auto_inline_editing_block_id )
		&& (string) $post_id !== (string) $acf_blocks_doing_auto_inline_editing_block_id ) {
		return $field_value;
	}

	// Add this field and its value to the global variable so we can grab it when rendering later in apply_inline_editing_attributes_to_render_template.
	if ( ! is_array( $field_value ) ) {
		if ( empty( $field_value ) ) {
			$field_value = 'acf_auto_inline_editing_field_name_' . $field['name'];
		}

		$field['value'] = $field_value;

		// Note: If 2 fields happen to have the exact same value it's most-likely fine, but there are edge cases.
		// Because in the DOM they get applied top-to-bottom, we also check top-to-bottom when pulling them from this array.
		//
		// A small, known edge case exists here if someone calls $a = get_field('a') and $b = get_field('b'), but then renders $b before $a.
		// If BOTH field $a and field $b have the exact same value AND are rendered in a different order than they were called, you would end up
		// with a scenario where editing the inline value of $a actually edits the value for $b.
		// Regardless, it would likely be obvious to the block developer because you would see it,
		// both in the field value in the block sidebar, and also inline/preview, wherever field a/b are used.
		$acf_fields_used_in_block_render_template[] = $field;
	}

	return $field_value;
}