_acf_log_escaped_html()ACF 6.2.5

Logs instances of ACF successfully escaping unsafe HTML.

Internal function — this function is designed to be used by the kernel itself. It is not recommended to use this function in your code.

Hooks from the function

Returns

null. Nothing (null).

Usage

_acf_log_escaped_html( $function, $selector, $field, $post_id );
$function(string) (required)
The function that resulted in HTML being escaped.
$selector(string) (required)
The selector (field key, name, etc.) passed to that function.
$field(array) (required)
The field being queried when HTML was escaped.
$post_id(mixed) (required)
The post ID the function was called on.

Changelog

Since 6.2.5 Introduced.

_acf_log_escaped_html() code ACF 6.8.8

function _acf_log_escaped_html( $function, $selector, $field, $post_id ) {
	// If the notice isn't shown, no use in logging the errors.
	if ( apply_filters( 'acf/admin/prevent_escaped_html_notice', true ) ) {
		return;
	}

	// If the notice has been dismissed, don't log further errors.
	if ( get_option( 'acf_escaped_html_notice_dismissed' ) ) {
		return;
	}

	// If the field isn't set, we've output a non-ACF field, so don't log anything.
	if ( ! is_array( $field ) ) {
		return;
	}

	$escaped = _acf_get_escaped_html_log();

	// Only store up to 100 results at a time.
	if ( count( $escaped ) >= 100 ) {
		return;
	}

	// Bail if we already logged an error for this field.
	if ( isset( $escaped[ $field['key'] ] ) ) {
		return;
	}

	$escaped[ $field['key'] ] = array(
		'selector' => $selector,
		'function' => $function,
		'field'    => $field['label'],
		'post_id'  => $post_id,
	);

	_acf_update_escaped_html_log( $escaped );
}