Add new helper for comma-separated setting inputs

This commit is contained in:
Tetrakern 2024-04-27 16:12:03 +02:00
parent 01b884dd29
commit 0558a0c357

View File

@ -493,6 +493,28 @@ function fictioneer_settings_text_input( $option, $type = 'text' ) {
<?php // <--- End HTML
}
/**
* Renders a label-wrapped setting text field for comma-separated values
*
* @since 5.15.0
*
* @param string $option The name of the setting option.
*/
function fictioneer_settings_array_input( $option ) {
// Setup
$value = get_option( $option, [] ) ?: [];
$value = is_array( $value ) ? $value : [];
$value = implode( ', ', $value );
// Start HTML ---> ?>
<label class="fictioneer-label-textfield" for="<?php echo $option; ?>">
<input name="<?php echo $option; ?>" placeholder="<?php echo FICTIONEER_OPTIONS['strings'][ $option ]['placeholder']; ?>" type="text" id="<?php echo $option; ?>" value="<?php echo esc_attr( $value ); ?>" autocomplete="off">
<p class="fictioneer-sub-label"><?php echo FICTIONEER_OPTIONS['strings'][ $option ]['label']; ?></p>
</label>
<?php // <--- End HTML
}
/**
* Renders a setting textarea
*