| 1 |
<?php |
| 2 |
/** |
| 3 |
* Template for field checkbox |
| 4 |
* |
| 5 |
* @package Wow_Plugin |
| 6 |
* @copyright Copyright (c) 2018, Dmytro Lobov |
| 7 |
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 8 |
* @since 1.0 |
| 9 |
*/ |
| 10 |
|
| 11 |
if ( ! defined( 'ABSPATH' ) ) { |
| 12 |
exit; |
| 13 |
} |
| 14 |
|
| 15 |
$label = ! empty( $arg['label'] ) ? $arg['label'] : ''; |
| 16 |
$attr = ! empty( $arg['attr'] ) ? $arg['attr'] : ''; |
| 17 |
$help = ! empty( $arg['help'] ) ? $arg['help'] : ''; |
| 18 |
$icon = ! empty( $arg['icon'] ) ? $arg['icon'] : ''; |
| 19 |
$tooltip = ! empty( $arg['tooltip'] ) ? $arg['tooltip'] : ''; |
| 20 |
|
| 21 |
$add_field_class = ! empty( $arg['attr']['class'] ) ? ' ' . $arg['attr']['class'] : ''; |
| 22 |
$field_classes = 'is-radiusless ' . $add_field_class; |
| 23 |
|
| 24 |
$attributes = ''; |
| 25 |
foreach ( $attr as $key => $val ) { |
| 26 |
if ( $key == 'class' || $key == 'value' ) { |
| 27 |
continue; |
| 28 |
} |
| 29 |
$attributes .= esc_attr( $key ) . '="' . esc_attr( $val ) . '"'; |
| 30 |
} |
| 31 |
|
| 32 |
if ( ! empty( $arg['func'] ) ) { |
| 33 |
$attributes .= 'onclick="' . esc_attr( $arg['func'] ) . '();"'; |
| 34 |
} |
| 35 |
|
| 36 |
$checked = ! empty( $attr['value'] ) ? ' checked="checked"' : ''; |
| 37 |
|
| 38 |
?> |
| 39 |
|
| 40 |
<div class="field"> |
| 41 |
<label class="label checkbox" for="<?php echo esc_attr( $attr['id'] ); ?>"> |
| 42 |
<input type="hidden" name="<?php echo esc_attr( $attr['name'] ); ?>"> |
| 43 |
<input class="<?php echo esc_attr( $field_classes ); ?>" |
| 44 |
type="checkbox" <?php echo $attributes . $checked; ?> value="1"> |
| 45 |
<?php echo esc_attr( $label ); ?> |
| 46 |
<?php if ( ! empty( $tooltip ) ) : ?> |
| 47 |
<span class="is-primary has-tooltip-multiline has-tooltip-right" |
| 48 |
data-tooltip="<?php echo esc_attr( $tooltip ); ?>"> |
| 49 |
<span class="wow-help dashicons dashicons-editor-help"></span> |
| 50 |
</span> |
| 51 |
<?php endif; ?> |
| 52 |
</label> |
| 53 |
</div> |
| 54 |
<?php if ( ! empty( $help ) ) : ?> |
| 55 |
<p class="help is-info"><?php echo $help; ?></p> |
| 56 |
<?php endif; ?> |