Yoast_Form::checkbox_list()
Creates a Checkbox input field list.
Метод класса: Yoast_Form{}
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
$Yoast_Form = new Yoast_Form(); $Yoast_Form->checkbox_list( $variable, $labels, $attr );
- $variable(строка) (обязательный)
- The variables within the option to create the checkbox list for.
- $labels(строка) (обязательный)
- The labels to show for the variable.
- $attr(массив)
- Extra attributes to add to the checkbox list.
По умолчанию: []
Список изменений
С версии 12.8 | Введена. |
Код Yoast_Form::checkbox_list() Yoast Form::checkbox list Yoast 24.9
public function checkbox_list( $variable, $labels, $attr = [] ) { $defaults = [ 'disabled' => false, ]; $attr = wp_parse_args( $attr, $defaults ); $values = $this->get_field_value( $variable, [] ); foreach ( $labels as $name => $label ) { printf( '<input class="checkbox double" id="%1$s" type="checkbox" name="%2$s" %3$s %5$s value="%4$s"/>', esc_attr( $variable . '-' . $name ), esc_attr( $this->option_name . '[' . $variable . '][' . $name . ']' ), checked( ! empty( $values[ $name ] ), true, false ), esc_attr( $name ), disabled( ( isset( $attr['disabled'] ) && $attr['disabled'] ), true, false ) ); printf( '<label class="checkbox" for="%1$s">%2$s</label>', esc_attr( $variable . '-' . $name ), // #1 esc_html( $label ) ); echo '<br class="clear">'; } }