acf_render_field_setting()
acf_render_field_setting
Renders a field setting used in the admin edit screen.
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
acf_render_field_setting( $field, $setting, $global );
- $field(массив) (обязательный)
- The field array.
- $setting(массив) (обязательный)
- The settings field array.
- $global(true|false)
- Whether this setting is a global or field type specific one.
По умолчанию: false
Список изменений
С версии 5.7.10 | Введена. |
Код acf_render_field_setting() acf render field setting ACF 6.0.4
function acf_render_field_setting( $field, $setting, $global = false ) { // Validate field. $setting = acf_validate_field( $setting ); // Add custom attributes to setting wrapper. $setting['wrapper']['data-key'] = $setting['name']; $setting['wrapper']['class'] .= ' acf-field-setting-' . $setting['name']; if ( ! $global ) { $setting['wrapper']['data-setting'] = $field['type']; } // Add classes for appended and prepended fields. if ( ! empty( $setting['append'] ) ) { $setting['wrapper']['class'] .= ' acf-field-appended'; } if ( ! empty( $setting['prepend'] ) ) { $setting['wrapper']['class'] .= ' acf-field-prepended'; } // Copy across prefix. $setting['prefix'] = $field['prefix']; // Find setting value from field. if ( $setting['value'] === null ) { // Name. if ( isset( $field[ $setting['name'] ] ) ) { $setting['value'] = $field[ $setting['name'] ]; // Default value. } elseif ( isset( $setting['default_value'] ) ) { $setting['value'] = $setting['default_value']; } } // Add append attribute used by JS to join settings. if ( isset( $setting['_append'] ) ) { $setting['wrapper']['data-append'] = $setting['_append']; } // If we're using a hint, set the label location as field so it appears after. $label_location = ! empty( $setting['instructions'] ) ? 'field' : 'label'; // If we're a true false field, force label location to label. if ( $setting['type'] === 'true_false' ) { $label_location = 'label'; } // Render setting. acf_render_field_wrap( $setting, 'div', $label_location ); }