File "class-acf-field-text.php"
Full path: /home/kosmetik/public_html/wp-content/plugins/advanced-custom-fields/includes/fields/class-acf-field-text.php
File
size: 2.65 B
MIME-type: text/x-php
Charset: utf-8
Download Open Edit Advanced Editor Back
<?php
if (!class_exists('acf_field_text')) {
class acf_field_text extends acf_field
{
function initialize()
{
$this->name = 'text';
$this->label = __('Text', 'acf');
$this->defaults = array('default_value' => '', 'maxlength' => '', 'placeholder' => '', 'prepend' => '', 'append' => '');
}
function render_field($field)
{
$html = '';
if ($field['prepend'] !== '') {
$field['class'] .= ' acf-is-prepended';
$html .= '<div class="acf-input-prepend">' . acf_esc_html($field['prepend']) . '</div>';
}
if ($field['append'] !== '') {
$field['class'] .= ' acf-is-appended';
$html .= '<div class="acf-input-append">' . acf_esc_html($field['append']) . '</div>';
}
$input_attrs = array();
foreach (array('type', 'id', 'class', 'name', 'value', 'placeholder', 'maxlength', 'pattern', 'readonly', 'disabled', 'required') as $k) {
if (isset($field[$k])) {
$input_attrs[$k] = $field[$k];
}
}
$html .= '<div class="acf-input-wrap">' . acf_get_text_input(acf_filter_attrs($input_attrs)) . '</div>';
echo $html;
}
function render_field_settings($field)
{
acf_render_field_setting($field, array('label' => __('Default Value', 'acf'), 'instructions' => __('Appears when creating a new post', 'acf'), 'type' => 'text', 'name' => 'default_value'));
acf_render_field_setting($field, array('label' => __('Placeholder Text', 'acf'), 'instructions' => __('Appears within the input', 'acf'), 'type' => 'text', 'name' => 'placeholder'));
acf_render_field_setting($field, array('label' => __('Prepend', 'acf'), 'instructions' => __('Appears before the input', 'acf'), 'type' => 'text', 'name' => 'prepend'));
acf_render_field_setting($field, array('label' => __('Append', 'acf'), 'instructions' => __('Appears after the input', 'acf'), 'type' => 'text', 'name' => 'append'));
acf_render_field_setting($field, array('label' => __('Character Limit', 'acf'), 'instructions' => __('Leave blank for no limit', 'acf'), 'type' => 'number', 'name' => 'maxlength'));
}
function validate_value($valid, $value, $field, $input)
{
if ($field['maxlength'] && acf_strlen($value) > $field['maxlength']) {
return sprintf(__('Value must not exceed %d characters', 'acf'), $field['maxlength']);
}
return $valid;
}
}
acf_register_field_type('acf_field_text');
}