acf_inline_text_editing_attrs()ACF 1.0

Helper function that returns the HTML attributes required for inline text editing as a string, escaped and ready for output.

No Hooks.

Returns

String. A string containing the attributes.

Usage

acf_inline_text_editing_attrs( $field_name, $args ): string;
$field_name(string) (required)
A string which is the name of the field to update when the user types into the HTML element.
$args(array)
Array { Optional. An array of additional args which can control how the popover identifier is displayed.
@type string $toolbar_icon  Optional. An html tag, can be an svg, to be used as the toolbar icon. If not passed, the icon of the first field will be used.
@type string $toolbar_title Optional. A string to be used as the toolbar title. If not passed, the name of the first field will be used.
@type string $placeholder   Optional. Optional. A string which will be used as the placeholder in the typable text area.

}.
Default: array()

acf_inline_text_editing_attrs() code ACF 6.8.8

function acf_inline_text_editing_attrs( $field_name, $args = array() ): string {

	if ( empty( $field_name ) ) {
		return '';
	}

	$acf_block_version = acf_get_data( 'acf_current_block_version' );

	if ( ! $acf_block_version || $acf_block_version <= 2 ) {
		return '';
	}

	$default_args = array(
		'toolbar_icon'  => null,
		'toolbar_title' => null,
		'placeholder'   => null,
	);

	$args = wp_parse_args( $args, $default_args );

	$render = acf_get_data( 'acf_doing_block_preview' );

	if ( ! $render ) {
		return '';
	}

	if ( ! empty( $args['toolbar_icon'] ) ) {
		$args['toolbar_icon'] = 'data-acf-toolbar-icon="' . esc_attr( $args['toolbar_icon'] ) . '" ';
	}

	if ( ! empty( $args['toolbar_title'] ) ) {
		$args['toolbar_title'] = 'data-acf-toolbar-title="' . esc_attr( $args['toolbar_title'] ) . '" ';
	}

	if ( ! $args['placeholder'] ) {
		$args['placeholder'] = __( 'Type to edit...', 'acf' );
	}

	return 'data-acf-inline-contenteditable="1" data-acf-inline-contenteditable-field-slug="' . esc_attr( $field_name ) . '" data-acf-placeholder="' . esc_attr( $args['placeholder'] ) . '" ' . $args['toolbar_icon'] . $args['toolbar_title'];
}