acf_field_flexible_content::ajax_layout_titlepublicACF 5.3.2

Output the layout title for an AJAX response.

Method of the class: acf_field_flexible_content{}

No Hooks.

Returns

null. Nothing (null).

Usage

$acf_field_flexible_content = new acf_field_flexible_content();
$acf_field_flexible_content->ajax_layout_title();

Changelog

Since 5.3.2 Introduced.

acf_field_flexible_content::ajax_layout_title() code ACF 6.8.8

public function ajax_layout_title() {

	$options = acf_parse_args(
		$_POST, // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Verified below via acf_verify_ajax.
		array(
			'post_id'   => 0,
			'i'         => 0,
			'field_key' => '',
			'nonce'     => '',
			'layout'    => '',
			'value'     => array(),
		)
	);

	if ( ! acf_verify_ajax( $options['nonce'], $options['field_key'], true, 'flexible_content' ) ) {
		die();
	}

	// load field
	$field = acf_get_field( $options['field_key'] );
	if ( ! $field ) {
		die();
	}

	// vars
	$layout = $this->get_layout( $options['layout'], $field );
	if ( ! $layout ) {
		die();
	}

	// title
	$title = $this->get_layout_title( $field, $layout, $options['i'], $options['value'] );

	// echo
	echo acf_esc_html( $title );
	die;
}