Yoast_Form::file_upload PHP Method

file_upload() public method

Create a File upload field.
public file_upload ( string $var, string $label )
$var string The variable within the option to create the file upload field for.
$label string The label to show for the variable.
    public function file_upload($var, $label)
    {
        $val = '';
        if (isset($this->options[$var]) && is_array($this->options[$var])) {
            $val = $this->options[$var]['url'];
        }
        $var_esc = esc_attr($var);
        $this->label($label . ':', array('for' => $var, 'class' => 'select'));
        echo '<input type="file" value="' . esc_attr($val) . '" class="textinput" name="' . esc_attr($this->option_name) . '[' . $var_esc . ']" id="' . $var_esc . '"/>';
        // Need to save separate array items in hidden inputs, because empty file inputs type will be deleted by settings API.
        if (!empty($this->options[$var])) {
            $this->hidden('file', $this->option_name . '_file');
            $this->hidden('url', $this->option_name . '_url');
            $this->hidden('type', $this->option_name . '_type');
        }
        echo '<br class="clear"/>';
    }