File "class-acf-field-url.php"

Full path: /home/kosmetik/public_html/wp-content/plugins/advanced-custom-fields/includes/fields/class-acf-field-url.php
File size: 1.98 B
MIME-type: text/x-php
Charset: utf-8

Download   Open   Edit   Advanced Editor   Back

<?php

if (!class_exists('acf_field_url')) {
    class acf_field_url extends acf_field
    {
        function initialize()
        {
            $this->name = 'url';
            $this->label = __('Url', 'acf');
            $this->defaults = array('default_value' => '', 'placeholder' => '');
        }
        function render_field($field)
        {
            $atts = array();
            $keys = array('type', 'id', 'class', 'name', 'value', 'placeholder', 'pattern');
            $keys2 = array('readonly', 'disabled', 'required');
            $html = '';
            foreach ($keys as $k) {
                if (isset($field[$k])) {
                    $atts[$k] = $field[$k];
                }
            }
            foreach ($keys2 as $k) {
                if (!empty($field[$k])) {
                    $atts[$k] = $k;
                }
            }
            $atts = acf_clean_atts($atts);
            $html .= '<div class="acf-input-wrap acf-url">';
            $html .= '<i class="acf-icon -globe -small"></i>' . acf_get_text_input($atts);
            $html .= '</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'));
        }
        function validate_value($valid, $value, $field, $input)
        {
            if (empty($value)) {
                return $valid;
            }
            if (strpos($value, '://') !== false) {
            } elseif (strpos($value, '//') === 0) {
            } else {
                $valid = __('Value must be a valid URL', 'acf');
            }
            return $valid;
        }
    }
    acf_register_field_type('acf_field_url');
}