Function
Render a checkbox setting field.
tml_admin_setting_callback_checkbox_field( array $args )
Parameters
-
$argsarray -
Optional. An array of arguments for rendering a checkbox.
-
$label_forstring - The checkbox name/ID.
-
$labelstirng - The checkbox label text.
-
$valuestring - The checkbox value.
-
$checkedbool - Whether the checkbox is checked or not.
-
$descriptionstring - A short description of the checkbox.
-
Source
function tml_admin_setting_callback_checkbox_field( $args ) {
$args = wp_parse_args(
$args,
array(
'label_for' => '',
'label' => '',
'value' => '1',
'checked' => '',
'description' => '',
)
);
?>
<input type="checkbox" name="<?php echo esc_attr( $args['label_for'] ); ?>" id="<?php echo esc_attr( $args['label_for'] ); ?>" value="<?php echo esc_attr( $args['value'] ); ?>" <?php checked( ! empty( $args['checked'] ) ); ?> /> <label for="<?php echo esc_attr( $args['label_for'] ); ?>"><?php echo esc_html( $args['label'] ); ?></label>
<?php if ( ! empty( $args['description'] ) ) : ?>
<p class="description"><?php echo wp_kses_post( $args['description'] ); ?></p>
<?php endif; ?>
<?php
}
Uses
Changelog
| Version | Description |
|---|---|
| 7.0 | Introduced. |