acf_field::render_bindings_settingpublicACF 6.3.6

Renders the "Allow in Bindings" setting on the field type "Presentation" settings tab.

Метод класса: acf_field{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$acf_field = new acf_field();
$acf_field->render_bindings_setting( $field );
$field(массив) (обязательный)
The field type being rendered.

Список изменений

С версии 6.3.6 Введена.

Код acf_field::render_bindings_setting() ACF 6.4.2

public function render_bindings_setting( $field ) {
	$supports_bindings = acf_field_type_supports( $field['type'], 'bindings', true );

	// Only prevent rendering if explicitly disabled.
	if ( ! $supports_bindings ) {
		return;
	}

	/* translators: %s A "Learn More" link to documentation explaining the setting further. */
	$binding_string       = esc_html__( 'Allow content editors to access and display the field value in the editor UI using Block Bindings or the ACF Shortcode. %s', 'acf' );
	$binding_url          = '<a target="_blank" href="' . acf_add_url_utm_tags( 'https://www.advancedcustomfields.com/resources/bindings-security/', 'docs', 'field-settings' ) . '">' . esc_html__( 'Learn more.', 'acf' ) . '</a>';
	$binding_instructions = sprintf(
		$binding_string,
		$binding_url
	);

	// This field setting has unique behavior. If the value isn't defined on the field object, it defaults to true, but for new fields or when changing field types, it defaults to off.
	if ( ! isset( $field['allow_in_bindings'] ) ) {
		if ( empty( $field['ID'] ) || doing_action( 'wp_ajax_acf/field_group/render_field_settings' ) ) {
			$field['allow_in_bindings'] = false;
		} else {
			$field['allow_in_bindings'] = true;
		}
	}

	acf_render_field_setting(
		$field,
		array(
			'label'        => __( 'Allow Access to Value in Editor UI', 'acf' ),
			'instructions' => $binding_instructions,
			'type'         => 'true_false',
			'name'         => 'allow_in_bindings',
			'ui'           => 1,
			'class'        => 'field-show-in-bindings',
		),
		true
	);
}