dozent_checkbox( string $name = '', string $desc = '', string $old_value = '', int $value = 1, string|bool $name_is_id = true )
Generate checkbox looks like WordPress UI switch field
Description
Example usage:
dozent_checkbox();
See also
Parameters
- $name
-
(string) (Optional) Checkbox Name
Default value: ''
- $desc
-
(string) (Optional)
Default value: ''
- $old_value
-
(string) (Optional)
Default value: ''
- $value
-
(int) (Optional) Value of the checkbox
Default value: 1
- $name_is_id
-
(string|bool) (Optional) is name should be id. pass false to remove id;
Default value: true
Return
(string)
Source
File: includes/form-functions.php
function dozent_checkbox( $name = '', $desc = '', $old_value = '', $value = 1, $name_is_id = true ) { $id = null; if ( $name_is_id === true ) { $id = $name; } elseif ( $name_is_id ) { $id = $name_is_id; } if ( $id ){ $id = " id='{$id}' "; } $desc = $desc ? "<span class='description'> {$desc} </span>" : ""; $field_html = " <div class='dozent-checkbox'> <input type='checkbox' name='{$name}' $id value='{$value}' " . checked( $value, $old_value, false ) . "> <label for='{$name}'> {$desc} </label> </div>"; return $field_html; }
Changelog
Version | Description |
---|---|
DozentLMS 1.0.0 | Introduced. |