ACF\AI\GEO
FieldSettings::render_field_schema_settings
Render the field-level schema settings.
Method of the class: FieldSettings{}
No Hooks.
Returns
null. Nothing (null).
Usage
$FieldSettings = new FieldSettings(); $FieldSettings->render_field_schema_settings( $field );
- $field(array) (required)
- The field being edited.
Changelog
| Since 6.8.0 | Introduced. |
FieldSettings::render_field_schema_settings() FieldSettings::render field schema settings code ACF 6.8.8
public function render_field_schema_settings( $field ) {
$field_type = $field['type'] ?? '';
// Check if field type supports JSON-LD output.
$supported_ranges = Schema::get_field_type_ranges( $field_type );
if ( empty( $supported_ranges ) ) {
// Field type doesn't support JSON-LD output (e.g., tab, accordion).
return;
}
// Get available Schema.org properties filtered by field type compatibility.
$parent_id = (int) ( $field['parent'] ?? 0 );
acf_render_field_setting(
$field,
array(
'label' => __( 'Schema.org Property', 'acf' ),
'instructions' => __( 'Map this field to a Schema.org property instead of using additionalProperty.', 'acf' ),
'type' => 'select',
'name' => 'schema_property',
'class' => 'acf-schema-property',
'wrapper' => array(
'class' => 'acf-field-meta-box',
),
'choices' => $this->get_schema_properties( $field_type, $parent_id ),
'allow_null' => 1,
'ui' => 1,
'experimental' => 1,
)
);
$output_choices = $this->get_output_format_choices( $field );
// Get the default format for this field type + property.
$qualified_property = $field['schema_property'] ?? '';
$property_name = Schema::get_property_name( $qualified_property );
$default_format = Schema::get_default_output_format( $field_type, $property_name );
acf_render_field_setting(
$field,
array(
'label' => __( 'Schema.org Output Format', 'acf' ),
'type' => 'select',
'name' => 'schema_output_format',
'class' => 'acf-schema-output-format',
'wrapper' => array(
'class' => 'acf-field-meta-box',
),
'choices' => $output_choices,
'default_value' => $default_format,
'ui' => 1,
'experimental' => 1,
'conditions' => array(
'field' => 'schema_property',
'operator' => '!=',
'value' => '',
),
)
);
}