Yoast_Form::radio PHP Метод

radio() публичный Метод

Create a Radio input field.
public radio ( string $var, array $values, string $legend = '', array $legend_attr = [] )
$var string The variable within the option to create the radio button for.
$values array The radio options to choose from.
$legend string Optional. The legend to show for the field set, if any.
$legend_attr array Optional. The attributes for the legend, if any.
    public function radio($var, $values, $legend = '', $legend_attr = array())
    {
        if (!is_array($values) || $values === array()) {
            return;
        }
        if (!isset($this->options[$var])) {
            $this->options[$var] = false;
        }
        $var_esc = esc_attr($var);
        echo '<fieldset class="yoast-form-fieldset wpseo_radio_block" id="' . $var_esc . '">';
        if (is_string($legend) && '' !== $legend) {
            $legend_attr = wp_parse_args($legend_attr, array('id' => '', 'class' => 'radiogroup'));
            $this->legend($legend, $legend_attr);
        }
        foreach ($values as $key => $value) {
            $key_esc = esc_attr($key);
            echo '<input type="radio" class="radio" id="' . $var_esc . '-' . $key_esc . '" name="' . esc_attr($this->option_name) . '[' . $var_esc . ']" value="' . $key_esc . '" ' . checked($this->options[$var], $key_esc, false) . ' />';
            $this->label($value, array('for' => $var_esc . '-' . $key_esc, 'class' => 'radio'));
        }
        echo '</fieldset>';
    }