acf_field_url::render_field
Create the HTML interface for your field
Метод класса: acf_field_url{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$acf_field_url = new acf_field_url(); $acf_field_url->render_field( $field );
- $field(массив) (обязательный)
- An array holding all the field's data.
Список изменений
| С версии 3.6 | Введена. |
Код acf_field_url::render_field() acf field url::render field ACF 6.4.2
public function render_field( $field ) {
$atts = array();
$keys = array( 'type', 'id', 'class', 'name', 'value', 'placeholder', 'pattern' );
$keys2 = array( 'readonly', 'disabled', 'required' );
// atts (value="123")
foreach ( $keys as $k ) {
if ( isset( $field[ $k ] ) ) {
$atts[ $k ] = $field[ $k ];
}
}
// atts2 (disabled="disabled")
foreach ( $keys2 as $k ) {
if ( ! empty( $field[ $k ] ) ) {
$atts[ $k ] = $k;
}
}
// remove empty atts
$atts = acf_clean_atts( $atts );
// render
$html = '<div class="acf-input-wrap acf-url">';
$html .= '<i class="acf-icon -globe -small"></i>' . acf_get_text_input( $atts );
$html .= '</div>';
// return
echo $html; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- safe HTML, escaped by acf_get_text_input.
}