acf_get_empty_block_form_html()ACF 6.0.0

Render the empty block form for when a block has no fields assigned.

Hooks from the function

Returns

String. The html that makes up a block form with no fields.

Usage

acf_get_empty_block_form_html( $block_name );
$block_name(string) (required)
The block name current being rendered.

Changelog

Since 6.0.0 Introduced.

acf_get_empty_block_form_html() code ACF 6.8.8

function acf_get_empty_block_form_html( $block_name ) {

	$message = __( 'This block contains no editable fields.', 'acf' );

	if ( acf_current_user_can_admin() ) {
		$message .= ' ';
		$message .= sprintf(
			/* translators: %s: an admin URL to the field group edit screen */
			__( 'Assign a <a href="%s" target="_blank">field group</a> to add fields to this block.', 'acf' ),
			admin_url( 'edit.php?post_type=acf-field-group' )
		);
	}

	$message = apply_filters( 'acf/blocks/no_fields_assigned_message', $message, $block_name );

	if ( ! is_string( $message ) ) {
		$message = '';
	}

	if ( empty( $message ) ) {
		return acf_esc_html( '<div class="acf-empty-block-fields"></div>' );
	} else {
		return acf_esc_html( '<div class="acf-block-fields acf-fields acf-empty-block-fields">' . $message . '</div>' );
	}
}