acf_field::render_bindings_setting
Renders the "Allow in Bindings" setting on the field type "Presentation" settings tab.
Method of the class: acf_field{}
No Hooks.
Returns
void. Nothing (null).
Usage
$acf_field = new acf_field(); $acf_field->render_bindings_setting( $field );
- $field(array) (required)
- The field type being rendered.
Changelog
| Since 6.3.6 | Introduced. |
acf_field::render_bindings_setting() acf field::render bindings setting code ACF 6.8.8
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
);
}