PluginProbe
Counter Box – Add Countdowns, Timers & Dynamic Counters to WordPress / 1.2
Counter Box – Add Countdowns, Timers & Dynamic Counters to WordPress v1.2
2.0.14 trunk 1.0 1.2 1.2.1 1.2.2 1.2.3 1.2.4 2.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9
counter-box / admin / fields / input.php

input.php in Counter Box – Add Countdowns, Timers & Dynamic Counters to WordPress 1.2, at admin/fields/input.php

115 lines 4.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Template for field input
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 $check_id = '';
22 $checkbox_class = '';
23 $checkbox = '';
24 if ( ! empty( $arg['checkbox'] ) ) {
25 $checkbox_class = ' checkbox';
26 $check_name = $arg['checkbox']['name'];
27 $check_val = $arg['checkbox']['value'];
28 $check_id = $arg['checkbox']['id'];
29 $disabled = isset( $arg['checkbox']['disabled'] ) ? ' disabled="disabled"' : '';
30 $check_class = isset( $arg['checkbox']['class'] ) ? ' ' . $arg['checkbox']['class'] : '';
31 $cheched = ! empty( $arg['checkbox']['value'] ) ? ' checked="checked"' : '';
32 $checkbox = '<input type="hidden" name="' . esc_attr( $check_name ) . '" value="">';
33 $checkbox .= '<input type="checkbox" class="is-radiusless' . esc_attr( $check_class ) . '" id="' . esc_attr( $check_id ) . '" name="' . esc_attr( $check_name ) . '" value="1"' . $cheched . $disabled . '>';
34 }
35
36 $addon_class = '';
37 $addon = '';
38 if ( ! empty( $arg['addon'] ) ) {
39 $addon_class = ' has-addons';
40
41 if ( ! empty( $arg['addon']['unit'] ) ) {
42 $addon = '<div class="control ">';
43 $addon .= '<span class="button is-info is-radiusless is-size-6">';
44 $addon .= $arg['addon']['unit'];
45 $addon .= '</span>';
46 $addon .= '</div>';
47 } else {
48 $addon_attr = '';
49 foreach ( $arg['addon'] as $key => $val ) {
50 if ( $key == 'value' || $key == 'options' || $key == 'class' ) {
51 continue;
52 }
53 $addon_attr .= esc_attr( $key ) . '="' . esc_attr( $val ) . '"';
54 }
55 $addon_options = '';
56 foreach ( $arg['addon']['options'] as $key => $val ) {
57 $selected = ( $arg['addon']['value'] == $key ) ? 'selected="selected"' : '';
58 $addon_options .= '<option value="' . esc_attr( $key ) . '" ' . $selected . '>' . esc_attr( $val ) . '</option>';
59 }
60 $add_addon_class = ! empty( $arg['addon']['class'] ) ? ' ' . $arg['addon']['class'] : '';
61 $addon_field_classes = 'is-radiusless' . esc_attr( $add_addon_class );
62
63 $addon = '<div class="control ">';
64 $addon .= '<span class="select is-primary">';
65 $addon .= '<select class="' . esc_attr( $addon_field_classes ) . '" ' . $addon_attr . '>';
66 $addon .= $addon_options;
67 $addon .= '</select>';
68 $addon .= '</span>';
69 $addon .= '</div>';
70 }
71
72 }
73
74
75 $add_control_class = ! empty( $icon ) ? ' ' . $icon : '';
76 $control_classes = 'control' . $add_control_class;
77
78 $add_field_class = ! empty( $arg['attr']['class'] ) ? ' ' . $arg['attr']['class'] : '';
79 $field_classes = 'input is-primary is-radiusless' . $add_field_class;
80
81 $attributes = '';
82 foreach ( $attr as $key => $val ) {
83 if ( $key == 'class' ) {
84 continue;
85 }
86 $attributes .= esc_attr( $key ) . '="' . esc_attr( $val ) . '"';
87 }
88 ?>
89
90 <label class="label<?php echo esc_attr( $checkbox_class ); ?>" for="<?php echo esc_attr( $check_id ); ?>">
91 <?php echo $checkbox; ?>
92 <?php echo esc_attr( $label ); ?>
93 <?php if ( ! empty( $tooltip ) ) : ?>
94 <span class="is-primary has-tooltip-multiline has-tooltip-right"
95 data-tooltip="<?php echo esc_attr( $tooltip ); ?>">
96 <span class="wow-help dashicons dashicons-editor-help"></span>
97 </span>
98 <?php endif; ?>
99 </label>
100 <div class="field<?php echo esc_attr( $addon_class ); ?>">
101 <div class="<?php echo esc_attr( $control_classes ); ?> is-expanded">
102 <input class="<?php echo esc_attr( $field_classes ); ?>" type="text" <?php echo $attributes; ?>>
103 <?php if ( ! empty( $icon ) ) : ?>
104 <span class="icon is-small is-left">
105 <i class="<?php echo esc_attr( $icon ); ?>"></i>
106 </span>
107 <?php endif; ?>
108 </div>
109 <?php if ( ! empty( $addon ) ) : ?>
110 <?php echo $addon; ?>
111 <?php endif; ?>
112 </div>
113 <?php if ( ! empty( $help ) ) : ?>
114 <p class="help is-info"><?php echo esc_attr( $help ); ?></p>
115 <?php endif; ?>