acf_get_field_label()ACF 5.0.0

acf_get_field_label

Returns the field's label with appropriate required label.

Hooks from the function

Returns

null. Nothing (null).

Usage

acf_get_field_label( $field, $context );
$field(array) (required)
The field array.
$context(string)
The output context (admin).
Default: ''

Changelog

Since 5.0.0 Introduced.

acf_get_field_label() code ACF 6.0.4

function acf_get_field_label( $field, $context = '' ) {

	// Get label.
	$label = $field['label'];

	// Display empty text when editing field.
	if ( $context == 'admin' && $label === '' ) {
		$label = __( '(no label)', 'acf' );
	}

	// Add required HTML.
	if ( $field['required'] ) {
		$label .= ' <span class="acf-required">*</span>';
	}

	/**
	 * Filters the field's label HTML.
	 *
	 * @date    21/1/19
	 * @since   5.7.10
	 *
	 * @param   string The label HTML.
	 * @param   array $field The field array.
	 * @param   string $context The output context (admin).
	 */
	$label = apply_filters( 'acf/get_field_label', $label, $field, $context );

	// Return label.
	return $label;
}