PluginProbe
CoolClock / 4.3.9
CoolClock v4.3.9
4.3.9 4.3.8 trunk 0.1 2.0 2.9.8 3.0 3.1 3.2 3.3 4.0 4.1 4.2 4.3.3 4.3.4 4.3.5 4.3.6 4.3.7
← All changes | includes/class-coolclock-widget.php +224 -147 4.04.3.9 View file →
@@ -1,6 +1,5 @@
1 1 <?php
2 -
3 2 /**
4 3 * CoolClock Widget Class
5 4 */
6 5
@@ -8,88 +7,123 @@
8 7
9 8 /** PHP5+ constructor */
10 9 public function __construct() {
11 10 parent::__construct(
12 - 'coolclock-widget',
13 - __('Analog Clock', 'coolclock'),
14 - array(
15 - 'classname' => 'coolclock',
16 - 'description' => __('Add an analog clock to your sidebar.', 'coolclock')
17 - ),
18 - array(
19 - 'width' => 300,
20 - 'id_base' => 'coolclock-widget'
21 - )
22 - );
11 + 'coolclock-widget',
12 + __('Analog Clock', 'coolclock'),
13 + array(
14 + 'classname' => 'coolclock',
15 + 'description' => __('Add an analog clock to your sidebar.', 'coolclock')
16 + ),
17 + array(
18 + 'width' => 300,
19 + 'id_base' => 'coolclock-widget'
20 + )
21 + );
23 22 }
24 23
25 24 /** @see WP_Widget::widget -- do not rename this */
26 25 public function widget( $args, $instance ) {
27 26 extract( $args );
28 - $title = apply_filters( 'widget_title', $instance['title'] );
29 - $number = $this->number;
30 27
28 + $defaults = array_merge( array('title'=>'','custom_skin'=>''), CoolClock::$defaults, CoolClock::$advanced_defaults );
29 +
30 + // backward compat
31 + if ( isset($instance['digitalcolor']) && !isset($instance['fontcolor']) ) $instance['fontcolor'] = $instance['digitalcolor'];
32 +
33 + $title = !empty($instance['title']) ? apply_filters( 'widget_title', $instance['title'] ) : '';
34 + //$number = $this->number;
35 +
36 + // set footer script flags
37 + CoolClock::$add_script = true;
38 +
31 39 // Print output
32 - echo $before_widget;
40 + echo wp_kses_post( $before_widget );
33 41
34 - if ( $title )
35 - echo $before_title . $title . $after_title;
42 + if ( $title ) {
43 + echo wp_kses_post( $before_title ) . esc_html( $title ) . wp_kses_post( $after_title );
44 + }
36 45
37 46 // set skin
38 - $skin = ( isset( $instance['skin'] ) )
39 - ? $instance['skin'] : CoolClock::$defaults['skin'];
47 + $instance['skin'] = CoolClock::parse_skin(
48 + ! empty( $instance['skin'] ) ? $instance['skin'] : $defaults['skin'],
49 + ! empty( $instance['custom_skin'] ) ? $instance['custom_skin'] : ''
50 + );
40 51
41 - // add custom skin parameters to the plugin skins array
42 - if ( 'custom_'.$number == $skin )
43 - CoolClock::$advanced_skins_config[$skin] = wp_strip_all_tags( $instance['custom_skin'], true );
52 + // radius, used in wrapper style and coolclock fields
53 + $instance['radius'] = !empty( $instance['radius'] ) && is_numeric( $instance['radius'] ) ? (int) $instance['radius'] : $defaults['radius'];
54 + if ( 10 > $instance['radius'] ) $instance['radius'] = 10; // absolute minimum size 20x20
44 55
45 - // set footer script flags
46 - CoolClock::$add_script = true;
56 + $align = !empty( $instance['align'] ) ? $instance['align'] : $defaults['align'];
57 + $styles = array(
58 + 'width' => 2 * $instance['radius'] . 'px',
59 + 'height' => 'auto',
60 + );
61 + if ( in_array( $align, array('left','center') ) ) {
62 + $styles['margin-right'] = 'auto';
63 + if ( 'left' == $align ) $styles['margin-left'] = '0';
64 + }
65 + if ( in_array( $align, array('right','center') ) ) {
66 + $styles['margin-left'] = 'auto';
67 + if ( 'right' == $align ) $styles['margin-right'] = '0';
68 + }
69 + $styles = apply_filters( 'coolclock_container_styles', $styles, $instance, $defaults );
47 70
48 - if ( in_array( $skin, CoolClock::$more_skins ) )
49 - CoolClock::$add_moreskins = true;
71 + // Build output
72 + // begin wrapper
73 + $output = '<div class="coolclock-container"' . CoolClock::inline_style( $styles ) . '>';
74 + // add canvas
75 + $output .= CoolClock::canvas( $instance );
76 + // end wrapper
77 + $output .= '</div>';
50 78
51 - $output = CoolClock::canvas( array(
52 - 'skin' => $skin,
53 - 'radius' => $instance['radius'],
54 - 'noseconds' => $instance['noseconds'],
55 - 'gmtoffset' => $instance['gmtoffset'],
56 - 'showdigital' => $instance['showdigital'],
57 - 'scale' => $instance['scale'],
58 - 'align' => $instance['align'],
59 - 'subtext' => apply_filters('widget_text', $instance['subtext'], $instance)
60 - ) );
79 + // Print filtered output. wp_kses_post() strips <canvas>, so extend its
80 + // allowed tags rather than using it directly (which would silently
81 + // remove the clock).
82 + $allowed_html = array_merge(
83 + wp_kses_allowed_html( 'post' ),
84 + array(
85 + 'canvas' => array(
86 + 'class' => true,
87 + 'style' => true,
88 + 'width' => true,
89 + 'height' => true,
90 + ),
91 + )
92 + );
93 + echo wp_kses( apply_filters( 'coolclock_widget', $output, $args, $instance ), $allowed_html );
61 94
62 - echo apply_filters( 'coolclock_widget_advanced', $output, $args, $instance );
63 -
64 - echo $after_widget;
95 + echo wp_kses_post( $after_widget );
65 96 }
66 97
67 98 /** @see WP_Widget::update -- do not rename this */
68 99 public function update( $new_instance, $old_instance ) {
69 - $instance['title'] = strip_tags( $new_instance['title'] );
70 - $instance['skin'] = strip_tags( $new_instance['skin'] );
71 - $instance['custom_skin'] = strip_tags( $new_instance['custom_skin'] );
72 - $instance['radius'] = ( (int) $new_instance['radius'] < 5 ) ? 5 : (int) $new_instance['radius'];
73 - $instance['noseconds'] = (bool) $new_instance['noseconds'];
74 - $instance['gmtoffset'] = ( $new_instance['gmtoffset'] == '' ) ? '' : (float) $new_instance['gmtoffset'];
75 - $instance['showdigital'] = strip_tags( $new_instance['showdigital'] );
76 - $instance['scale'] = strip_tags( $new_instance['scale'] );
77 - $instance['align'] = strip_tags( $new_instance['align'] );
100 + // parse custom skin code
101 + $skin_array = !empty($new_instance['custom_skin']) ? CoolClock::skin_array( wp_strip_all_tags( $new_instance['custom_skin'] ) ) : array();
78 102
79 - if ( current_user_can('unfiltered_html') )
80 - $instance['subtext'] = $new_instance['subtext'];
81 - else
82 - // wp_filter_post_kses() expects slashed
83 - $instance['subtext'] = stripslashes( wp_filter_post_kses( addslashes($new_instance['subtext']) ) );
103 + $instance['title'] = !empty($new_instance['title']) ? wp_strip_all_tags( $new_instance['title'] ) : '';
104 + $instance['skin'] = !empty($new_instance['skin']) ? wp_strip_all_tags( $new_instance['skin'] ) : '';
105 + $instance['custom_skin'] = !empty($skin_array) ? wp_json_encode( $skin_array ) : '';
106 + $instance['radius'] = ( empty($new_instance['radius']) || (int) $new_instance['radius'] < 5 ) ? 5 : (int) $new_instance['radius'];
107 + $instance['noseconds'] = !empty($new_instance['noseconds']) ? '1' : '';
108 + $instance['gmtoffset'] = isset($new_instance['gmtoffset']) && $new_instance['gmtoffset'] !== '' ? (float) $new_instance['gmtoffset'] : '';
109 + $instance['showdigital'] = !empty($new_instance['showdigital']) ? wp_strip_all_tags( $new_instance['showdigital'] ) : '';
110 + $instance['fontcolor'] = !empty($new_instance['fontcolor']) ? CoolClock::colorval( $new_instance['fontcolor'] ) : '';
111 + $instance['scale'] = !empty($new_instance['scale']) ? wp_strip_all_tags( $new_instance['scale'] ) : '';
112 + $instance['align'] = !empty($new_instance['align']) ? wp_strip_all_tags( $new_instance['align'] ) : '';
113 + $instance['subtext'] = wp_kses( $new_instance['subtext'], CoolClock::$allowed_tags );
84 114
85 - return apply_filters( 'coolclock_widget_update_advanced', $instance, $new_instance );
115 + return apply_filters( 'coolclock_widget_update_advanced', $instance, $new_instance );
86 116 }
87 117
88 118 /** @see WP_Widget::form -- do not rename this */
89 119 public function form( $instance ) {
90 - // Print output
91 - //echo CoolClock::form( $this, $instance );
120 + $output = '';
121 + $advanced = '';
122 +
123 + // backward compat
124 + if ( isset($instance['digitalcolor']) && !isset($instance['fontcolor']) ) $instance['fontcolor'] = $instance['digitalcolor'];
125 +
92 126 $defaults = array_merge( array('title'=>'','custom_skin'=>''), CoolClock::$defaults, CoolClock::$advanced_defaults );
93 127
94 128 $instance = wp_parse_args( (array) $instance, $defaults );
95 129
@@ -98,71 +132,71 @@
98 132 $custom_skin = esc_attr( $instance['custom_skin'] );
99 133
100 134 // Translatable skin names go here
101 135 $skin_names = array (
102 - 'swissRail' => __('Swiss Rail','coolclock'),
103 - 'chunkySwiss' => __('Chunky Swiss','coolclock'),
104 - 'chunkySwissOnBlack' => __('Chunky Swiss White','coolclock'),
105 - 'fancy' => __('Fancy','coolclock'),
106 - 'machine' => __('Machine','coolclock'),
107 - 'simonbaird_com' => __('SimonBaird.com','coolclock'),
108 - 'classic' => __('Classic by Bonstio','coolclock'),
109 - 'modern' => __('Modern by Bonstio','coolclock'),
110 - 'simple' => __('Simple by Bonstio','coolclock'),
111 - 'securephp' => __('SecurePHP','coolclock'),
112 - 'Tes2' => __('Tes2','coolclock'),
113 - 'Lev' => __('Lev','coolclock'),
114 - 'Sand' => __('Sand','coolclock'),
115 - 'Sun' => __('Sun','coolclock'),
116 - 'Tor' => __('Tor','coolclock'),
117 - 'Cold' => __('Cold','coolclock'),
118 - 'Babosa' => __('Babosa','coolclock'),
119 - 'Tumb' => __('Tumb','coolclock'),
120 - 'Stone' => __('Stone','coolclock'),
121 - 'Disc' => __('Disc','coolclock'),
122 - 'watermelon' => __('Watermelon by Yoo Nhe','coolclock'),
123 - 'mister' => __('Mister by Carl Lister','coolclock'),
124 - 'minimal' => __('Minimal','coolclock')
125 - );
136 + 'swissrail' => __('Swiss Rail','coolclock'),
137 + 'chunkyswiss' => __('Chunky Swiss','coolclock'),
138 + 'chunkyswissonblack' => __('Chunky Swiss White','coolclock'),
139 + 'fancy' => __('Fancy','coolclock'),
140 + 'machine' => __('Machine','coolclock'),
141 + 'simonbaird_com' => __('SimonBaird.com','coolclock'),
142 + 'classic' => __('Classic by Bonstio','coolclock'),
143 + 'modern' => __('Modern by Bonstio','coolclock'),
144 + 'simple' => __('Simple by Bonstio','coolclock'),
145 + 'securephp' => __('SecurePHP','coolclock'),
146 + 'tes2' => __('Tes2','coolclock'),
147 + 'lev' => __('Lev','coolclock'),
148 + 'sand' => __('Sand','coolclock'),
149 + 'sun' => __('Sun','coolclock'),
150 + 'tor' => __('Tor','coolclock'),
151 + 'cold' => __('Cold','coolclock'),
152 + 'babosa' => __('Babosa','coolclock'),
153 + 'tumb' => __('Tumb','coolclock'),
154 + 'stone' => __('Stone','coolclock'),
155 + 'disc' => __('Disc','coolclock'),
156 + 'watermelon' => __('Watermelon by Yoo Nhe','coolclock'),
157 + 'mister' => __('Mister by Carl Lister','coolclock'),
158 + 'minimal' => __('Minimal','coolclock')
159 + );
126 160
127 - $skins = array_merge( CoolClock::$default_skins, CoolClock::$more_skins, CoolClock::$advanced_skins );
128 -
129 161 // Translatable type names go here
130 162 $type_names = array (
131 - 'linear' => __('Linear','coolclock'),
132 - 'logClock' => __('Logarithmic','coolclock'),
133 - 'logClockRev' => __('Logarithmic reversed','coolclock')
134 - );
163 + 'linear' => __('Linear','coolclock'),
164 + 'logclock' => __('Logarithmic','coolclock'),
165 + 'logclockrev' => __('Logarithmic reversed','coolclock')
166 + );
135 167
136 - // Translatable show options go here
168 + // Translatable show digital options go here
137 169 $showdigital_names = array (
138 - '' => __('none','coolclock'),
139 - 'digital12' => __('time (am/pm)','coolclock'),
140 - 'digital24' => __('time (24h)','coolclock'),
141 - 'date' => __('date','coolclock')
142 - );
170 + '' => __( 'No', 'coolclock' ),
171 + 'digital12' => __('time (am/pm)','coolclock'),
172 + 'digital24' => __('time (24h)','coolclock'),
173 + 'date' => __('date','coolclock'),
174 + 'digital12+' => __('time + seconds (am/pm)','coolclock'),
175 + 'digital24+' => __('time + seconds (24h)','coolclock'),
176 + 'text' => __('custom text','coolclock')
177 + );
143 178
144 - // Misc translations
145 - $stray = array(
146 - 'extra_settings' => __('Extra settings for the CoolClock widget.', 'coolclock')
147 - );
148 -
149 179 // Title
150 - $output = '<p><label for="' . $this->get_field_id('title') . '">' . __('Title:') . '</label> ';
180 + $output .= '<style type="text/css">#available-widgets [class*=clock] .widget-title:before{content:"\f469"}</style>
181 + <p><label for="' . $this->get_field_id('title') . '">' . __( 'Title:', 'coolclock' ) . '</label> ';
151 182 $output .= '<input class="widefat" id="' . $this->get_field_id('title') . '" name="' . $this->get_field_name('title') . '" type="text" value="' . $title . '" /></p>';
152 183
153 184 // Clock settings
154 - $output .= '<p><strong>' . __('Clock', 'coolclock') . '</strong></p>';
185 + $output .= '<fieldset><legend>' . __('Clock', 'coolclock') . '</legend>';
186 + $output .= '<p class="description"><a href="https://premium.status301.com/coolclock-widget-settings/" target="_blank">' . __('CoolClock widget instructions &raquo;', 'coolclock') . '</a></p>';
187 +
155 188 $output .= '<p><label for="' . $this->get_field_id('skin') . '">' . __('Skin:', 'coolclock') . '</label> ';
156 189 $output .= '<select class="select" id="' . $this->get_field_id('skin') . '" name="' . $this->get_field_name('skin') . '">';
157 - foreach ($skins as $value) {
158 - $output .= '<option value="' . $value . '"';
159 - $output .= ( $value == $instance['skin'] ) ? ' selected="selected">' : '>';
160 - $output .= ( isset($skin_names[$value]) ) ? $skin_names[$value] : $value;
190 + $output .= '<option value="' . $defaults['skin'] . '" ' . selected( $defaults['skin'], $instance['skin'], false ) . '>';
191 + $output .= ( isset($skin_names[$defaults['skin']]) ) ? $skin_names[$defaults['skin']] : $defaults['skin'];
192 + $output .= '</option>';
193 + foreach ( CoolClock::get_all_skins() as $skin => $parms ) {
194 + $output .= '<option value="' . $skin . '" ' . selected( $skin, $instance['skin'], false ) . '>';
195 + $output .= ( isset($skin_names[$skin]) ) ? $skin_names[$skin] : $skin;
161 196 $output .= '</option>';
162 - } unset($value);
163 - $output .= '<option value="custom_' . $this->number . '"';
164 - $output .= ( 'custom_'.$this->number == $instance['skin'] ) ? ' selected="selected">' : '>';
197 + }
198 + $output .= '<option value="custom_' . $this->number . '" ' . selected( 'custom_'.$this->number, $instance['skin'], false ) . '>';
165 199 $output .= __('Custom (define below)', 'coolclock') . '</option></select></p>';
166 200
167 201 // Custom skin field
168 202 $output .= '<p><label for="' . $this->get_field_id('custom_skin') . '">' . __('Custom skin parameters:', 'coolclock') . '</label> ';
@@ -167,8 +201,14 @@
167 201 // Custom skin field
168 202 $output .= '<p><label for="' . $this->get_field_id('custom_skin') . '">' . __('Custom skin parameters:', 'coolclock') . '</label> ';
169 203 $output .= '<textarea class="widefat" id="' . $this->get_field_id('custom_skin') . '" name="' . $this->get_field_name('custom_skin') . '">' . $custom_skin . '</textarea></p>';
170 204
205 + $output .= '<p class="description"><em>' . sprintf(
206 + /* translators: %s: link to the JSON parameters documentation */
207 + __( '(set Skin to Custom above, then add %s here)', 'coolclock' ),
208 + '<a href="https://premium.status301.com/coolclock-custom-skin/" target="_blank">' . __( 'parameters in JSON format', 'coolclock' ) . '</a>'
209 + ) . '</em></p>';
210 +
171 211 // Radius
172 212 $output .= '<p><label for="' . $this->get_field_id('radius') . '">' . __('Radius:', 'coolclock') . '</label> ';
173 213 $output .= '<input class="small-text" id="' . $this->get_field_id('radius') . '" name="' . $this->get_field_name('radius') . '" type="number" min="10" value="' . $instance['radius'] . '" /></p>';
174 214
@@ -176,67 +216,104 @@
176 216 $output .= '<p><input id="' . $this->get_field_id('noseconds') . '" name="' . $this->get_field_name('noseconds') . '" type="checkbox" value=';
177 217 $output .= ( $instance['noseconds'] ) ? '"true" checked="checked" />' : '"false" />';
178 218 $output .= ' <label for="' . $this->get_field_id('noseconds') . '">' . __('Hide second hand', 'coolclock') . '</label></p>';
179 219
180 - // Show digital
181 - if ( $instance['showdigital'] == 'true' || $instance['showdigital'] == '1' )
182 - $instance['showdigital'] = 'digital12'; // backward compat
220 + // Align
221 + $output .= '<p><label for="' . $this->get_field_id('align') . '">' . __('Align:', 'coolclock') . '</label> ';
222 + $output .= '<select class="select" id="' . $this->get_field_id('align') . '" name="' . $this->get_field_name('align') . '">';
223 + $output .= '<option value="">';
224 + $output .= __( 'none', 'coolclock' ) . '</option>';
225 + $output .= '<option value="left" ' . selected( $instance['align'], 'left', false ) . '>';
226 + $output .= __('left', 'coolclock') . '</option>';
227 + $output .= '<option value="right" ' . selected( $instance['align'], 'right', false ) . '>';
228 + $output .= __('right', 'coolclock') . '</option>';
229 + $output .= '<option value="center" ' . selected( $instance['align'], 'center', false ) . '>';
230 + $output .= __('center', 'coolclock') . '</option>';
231 + $output .= '</select></p>';
183 232
184 - $output .= '<p><label for="' . $this->get_field_id('showdigital') . '">' . __('Show digital:', 'coolclock') . '</label> ';
185 - $output .= '<select class="select" id="' . $this->get_field_id('showdigital') . '" name="' . $this->get_field_name('showdigital') . '">';
186 - foreach ( CoolClock::$showdigital_options as $key => $value ) {
187 - $output .= '<option value="' . $key . '"';
188 - $output .= ( $key == $instance['showdigital'] ) ? ' selected="selected">' : '>';
189 - $output .= ( isset($showdigital_names[$key]) ) ? $showdigital_names[$key] : $value;
190 - $output .= '</option>';
191 - } unset($value);
192 - $output .= '</select></p>';
233 + // Subtext
234 + $output .= '<p><label for="' . $this->get_field_id('subtext') . '">' . __('Subtext:', 'coolclock') . '</label> ';
235 + $output .= '<input class="widefat" id="' . $this->get_field_id('subtext') . '" name="' . $this->get_field_name('subtext') . '" type="text" value="' . $subtext . '" /> <span class="description"><em>' . __('(basic HTML allowed)', 'coolclock') . '</em></span></p>';
193 236
194 - // USe GMT offset
237 + $output .= '</fieldset>'; //<div class="coolclock-advanced" style="background-color:rgba(0,0,0,.03);padding:1px 7px;border-radius:5px;margin-bottom:10px">';
238 +
239 + $output .= '<fieldset><legend>' . __( 'Advanced', 'coolclock' ) . '</legend>';
240 +
241 + // Use GMT offset
195 242 $output .= '<p><label for="' . $this->get_field_id('gmtoffset') . '">' . __('GMT offset:', 'coolclock') . '</label> ';
196 - $output .= '<input class="small-text" id="' . $this->get_field_id('gmtoffset') . '" name="' . $this->get_field_name('gmtoffset') . '" type="number" step="0.5" value="' . $instance['gmtoffset'] . '" /> ' . __('(leave blank for local time)', 'coolclock') . '</p>';
243 + $output .= '<input class="small-text" id="' . $this->get_field_id('gmtoffset') . '" name="' . $this->get_field_name('gmtoffset') . '" type="number" step="0.5" value="' . $instance['gmtoffset'] . '" /> <span class="description"><em>' . __('(leave blank for visitor local time)', 'coolclock') . '</em></span></p>';
197 244
198 245 // Scale
199 246 $output .= '<p><label for="' . $this->get_field_id('scale') . '">' . __('Scale:', 'coolclock') . '</label> ';
200 247 $output .= '<select class="select" id="' . $this->get_field_id('scale') . '" name="' . $this->get_field_name('scale') . '">';
201 248 foreach ( CoolClock::$clock_types as $key => $value ) {
202 - $output .= '<option value="' . $key . '"';
203 - $output .= ( $key == $instance['scale'] ) ? ' selected="selected">' : '>';
249 + $output .= '<option value="' . $key . '" ' . selected( $key, strtolower($instance['scale']), false ) . '">';
204 250 $output .= ( isset($type_names[$key]) ) ? $type_names[$key] : $value;
205 251 $output .= '</option>';
206 - } unset($value);
252 + }
207 253 $output .= '</select></p>';
208 254
209 - // Align
210 - $output .= '<p><label for="' . $this->get_field_id('align') . '">' . __('Align:', 'coolclock') . '</label> ';
211 - $output .= '<select class="select" id="' . $this->get_field_id('align') . '" name="' . $this->get_field_name('align') . '">';
212 - $output .= '<option value=""';
213 - $output .= ( $instance['align'] == '' ) ? ' selected="selected">' : '>';
214 - $output .= __('none', 'coolclock') . '</option>';
215 - $output .= '<option value="left"';
216 - $output .= ( $instance['align'] == 'left' ) ? ' selected="selected">' : '>';
217 - $output .= __('left', 'coolclock') . '</option>';
218 - $output .= '<option value="right"';
219 - $output .= ( $instance['align'] == 'right' ) ? ' selected="selected">' : '>';
220 - $output .= __('right', 'coolclock') . '</option>';
221 - $output .= '<option value="center"';
222 - $output .= ( $instance['align'] == 'center' ) ? ' selected="selected">' : '>';
223 - $output .= __('center', 'coolclock') . '</option>';
255 + // Show digital
256 + if ( $instance['showdigital'] == 'true' || $instance['showdigital'] == '1' )
257 + $instance['showdigital'] = 'digital12'; // backward compat
258 +
259 + $output .= '<p><label for="' . $this->get_field_id('showdigital') . '">' . __('Show digital:', 'coolclock') . '</label> ';
260 + $output .= '<select class="select" id="' . $this->get_field_id('showdigital') . '" name="' . $this->get_field_name('showdigital') . '">';
261 + foreach ( CoolClock::$showdigital_options as $key => $value ) {
262 + $output .= '<option value="' . $key . '" ' . selected( $key, $instance['showdigital'], false ) . '>';
263 + $output .= ( isset($showdigital_names[$key]) ) ? $showdigital_names[$key] : $value;
264 + $output .= '</option>';
265 + }
224 266 $output .= '</select></p>';
225 267
226 - // Subtext
227 - $output .= '<p><label for="' . $this->get_field_id('subtext') . '">' . __('Subtext:', 'coolclock') . '</label> ';
228 - $output .= '<input class="widefat" id="' . $this->get_field_id('subtext') . '" name="' . $this->get_field_name('subtext') . '" type="text" value="' . $subtext . '" /> ' . __('(basic HTML allowed)', 'coolclock') . '</p>';
268 + $output .= '<p><label for="' . $this->get_field_id('fontcolor') . '">' . __('Digital font color:', 'coolclock') . '</label> ';
269 + $output .= '<input id="' . $this->get_field_id('fontcolor') . '" name="' . $this->get_field_name('fontcolor') . '" type="text" value="' . $instance['fontcolor'] . '" /> <span class="description"><em>' . __('(use a valid HTML color code or name)', 'coolclock') . '</em></span></p>';
270 + $output .= '</fieldset>';
229 271
272 + $advanced .= '<p class="description"><a href="https://premium.status301.com/downloads/coolclock-advanced/">' . __('More digital font options &raquo;', 'coolclock') . '</a></p>
273 + <fieldset><legend>' . __( 'Background', 'coolclock' ) . '</legend><p class="description"><a href="https://premium.status301.com/downloads/coolclock-advanced/">' . __('Available in the Advanced extension &raquo;', 'coolclock') . '</a></p></fieldset>';
274 +
230 275 // Advanced filter
231 - $advanced_form = '<p><strong>' . __('Background') . '</strong></p><p><a href="http://premium.status301.net/downloads/coolclock-advanced/">' . __('Available in the Advanced extension &raquo;', 'coolclock') . '</a></p>';
276 + $output .= apply_filters( 'coolclock_widget_form_advanced', $advanced, $this, $instance, $defaults );
232 277
233 - $output .= apply_filters( 'coolclock_widget_form_advanced', $advanced_form, $this, $instance, $defaults );
278 + $output .= '</div>';
234 279
235 - if ( class_exists( 'CoolClockAdvanced' ) && isset(CoolClockAdvanced::$plugin_version) && version_compare( CoolClockAdvanced::$plugin_version, '6.1', '<' ) ) { // add an upgrade notice
236 - $output .= '<div class="update-nag"><strong>' . __('Please upgrade the CoolClock - Advanced extension.', 'coolclock') . '</strong> '. ' <a href="http://premium.status301.net/account/" target="_blank">' . __('Please log in with your account credentials here.', 'coolclock') . '</a>' . __('You can download the new version using the link in the downloads list.', 'coolclock') . '</div>';
280 + if ( class_exists( 'CoolClockAdvanced' ) && isset(CoolClockAdvanced::$plugin_version) && version_compare( CoolClockAdvanced::$plugin_version, '7.1', '<' ) ) { // add an upgrade notice
281 + $output .= '<div class="update-nag"><strong>' . __('Please upgrade the CoolClock - Advanced extension.', 'coolclock') . '</strong> '. ' <a href="https://premium.status301.com/account/" target="_blank">' . __('Please log in with your account credentials here.', 'coolclock') . '</a>' . __('You can download the new version using the link in the downloads list.', 'coolclock') . '</div>';
237 282 }
238 283
239 - echo $output;
240 -
284 + // wp_kses_post() strips form controls (input/select/option/textarea/style),
285 + // which would silently break this settings screen. Extend the allowed
286 + // tags with what an admin settings form actually needs instead.
287 + $allowed_html = array_merge(
288 + wp_kses_allowed_html( 'post' ),
289 + array(
290 + 'style' => array( 'type' => true ),
291 + 'input' => array(
292 + 'id' => true,
293 + 'class' => true,
294 + 'name' => true,
295 + 'type' => true,
296 + 'value' => true,
297 + 'min' => true,
298 + 'step' => true,
299 + 'checked' => true,
300 + ),
301 + 'select' => array(
302 + 'id' => true,
303 + 'class' => true,
304 + 'name' => true,
305 + ),
306 + 'option' => array(
307 + 'value' => true,
308 + 'selected' => true,
309 + ),
310 + 'textarea' => array(
311 + 'id' => true,
312 + 'class' => true,
313 + 'name' => true,
314 + ),
315 + )
316 + );
317 + echo wp_kses( $output, $allowed_html );
241 318 }
242 319 }