Yoast_Form::textinput_extra_content
Creates a text input field with with the ability to add content after the label.
Метод класса: Yoast_Form{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$Yoast_Form = new Yoast_Form(); $Yoast_Form->textinput_extra_content( $variable, $label, $attr );
- $variable(строка) (обязательный)
- The variable within the option to create the text input field for.
- $label(строка) (обязательный)
- The label to show for the variable.
- $attr(массив)
- Extra attributes to add to the input field.
По умолчанию: []
Код Yoast_Form::textinput_extra_content() Yoast Form::textinput extra content Yoast 26.5
public function textinput_extra_content( $variable, $label, $attr = [] ) {
$type = 'text';
$defaults = [
'class' => 'yoast-field-group__inputfield',
'disabled' => false,
];
$attr = wp_parse_args( $attr, $defaults );
$val = $this->get_field_value( $variable, '' );
if ( isset( $attr['type'] ) && $attr['type'] === 'url' ) {
$val = urldecode( $val );
$type = 'url';
}
echo '<div class="yoast-field-group__title">';
$this->label(
$label,
[
'for' => $variable,
'class' => $attr['class'] . '--label',
]
);
if ( isset( $attr['extra_content'] ) ) {
// phpcs:ignore WordPress.Security.EscapeOutput -- Reason: may contain HTML that should not be escaped.
echo $attr['extra_content'];
}
echo '</div>';
$aria_attributes = Yoast_Input_Validation::get_the_aria_invalid_attribute( $variable );
$aria_attributes .= Yoast_Input_Validation::get_the_aria_describedby_attribute( $variable );
// phpcs:disable WordPress.Security.EscapeOutput -- Reason: output is properly escaped or hardcoded.
printf(
'<input type="%1$s" name="%2$s" id="%3$s" class="%4$s"%5$s%6$s%7$s value="%8$s"%9$s>',
$type,
esc_attr( $this->option_name . '[' . $variable . ']' ),
esc_attr( $variable ),
esc_attr( $attr['class'] ),
isset( $attr['placeholder'] ) ? ' placeholder="' . esc_attr( $attr['placeholder'] ) . '"' : '',
isset( $attr['autocomplete'] ) ? ' autocomplete="' . esc_attr( $attr['autocomplete'] ) . '"' : '',
$aria_attributes,
esc_attr( $val ),
$this->get_disabled_attribute( $variable, $attr )
);
// phpcs:enable
// phpcs:ignore WordPress.Security.EscapeOutput -- Reason: output is properly escaped.
echo Yoast_Input_Validation::get_the_error_description( $variable );
}