@@ -147,6 +147,21 @@ function admin_init() {
147147 }
148148 }
149149
150+ /**
151+ * Get field description for display
152+ *
153+ * @param array $args settings field args
154+ */
155+ public function get_field_description ( $ args ) {
156+ if ( ! empty ( $ args ['desc ' ] ) ) {
157+ $ desc = sprintf ( '<p class="description">%s</p> ' , $ args ['desc ' ] );
158+ } else {
159+ $ desc = '' ;
160+ }
161+
162+ return $ desc ;
163+ }
164+
150165 /**
151166 * Displays a text field for a settings field
152167 *
@@ -159,7 +174,7 @@ function callback_text( $args ) {
159174 $ type = isset ( $ args ['type ' ] ) ? $ args ['type ' ] : 'text ' ;
160175
161176 $ html = sprintf ( '<input type="%1$s" class="%2$s-text" id="%3$s[%4$s]" name="%3$s[%4$s]" value="%5$s"/> ' , $ type , $ size , $ args ['section ' ], $ args ['id ' ], $ value );
162- $ html .= sprintf ( ' <span class="description"> %s</span> ' , $ args[ ' desc ' ] );
177+ $ html .= $ this -> get_field_description ( $ args );
163178
164179 echo $ html ;
165180 }
@@ -191,9 +206,12 @@ function callback_checkbox( $args ) {
191206
192207 $ value = esc_attr ( $ this ->get_option ( $ args ['id ' ], $ args ['section ' ], $ args ['std ' ] ) );
193208
194- $ html = sprintf ( '<input type="hidden" name="%1$s[%2$s]" value="off" /> ' , $ args ['section ' ], $ args ['id ' ] );
209+ $ html = '<fieldset> ' ;
210+ $ html .= sprintf ( '<label for="wpuf-%1$s[%2$s]"> ' , $ args ['section ' ], $ args ['id ' ] );
211+ $ html .= sprintf ( '<input type="hidden" name="%1$s[%2$s]" value="off" /> ' , $ args ['section ' ], $ args ['id ' ] );
195212 $ html .= sprintf ( '<input type="checkbox" class="checkbox" id="wpuf-%1$s[%2$s]" name="%1$s[%2$s]" value="on" %3$s /> ' , $ args ['section ' ], $ args ['id ' ], checked ( $ value , 'on ' , false ) );
196- $ html .= sprintf ( '<label for="wpuf-%1$s[%2$s]"> %3$s</label> ' , $ args ['section ' ], $ args ['id ' ], $ args ['desc ' ] );
213+ $ html .= sprintf ( '%1$s</label> ' , $ args ['desc ' ] );
214+ $ html .= '</fieldset> ' ;
197215
198216 echo $ html ;
199217 }
@@ -207,13 +225,15 @@ function callback_multicheck( $args ) {
207225
208226 $ value = $ this ->get_option ( $ args ['id ' ], $ args ['section ' ], $ args ['std ' ] );
209227
210- $ html = '' ;
228+ $ html = '<fieldset> ' ;
211229 foreach ( $ args ['options ' ] as $ key => $ label ) {
212230 $ checked = isset ( $ value [$ key ] ) ? $ value [$ key ] : '0 ' ;
213- $ html .= sprintf ( '<input type="checkbox" class="checkbox" id="wpuf-%1$s[%2$s][%3$s]" name="%1$s[%2$s][%3$s]" value="%3$s"%4$s /> ' , $ args ['section ' ], $ args ['id ' ], $ key , checked ( $ checked , $ key , false ) );
214- $ html .= sprintf ( '<label for="wpuf-%1$s[%2$s][%4$s]"> %3$s</label><br> ' , $ args ['section ' ], $ args ['id ' ], $ label , $ key );
231+ $ html .= sprintf ( '<label for="wpuf-%1$s[%2$s][%3$s]"> ' , $ args ['section ' ], $ args ['id ' ], $ key );
232+ $ html .= sprintf ( '<input type="checkbox" class="checkbox" id="wpuf-%1$s[%2$s][%3$s]" name="%1$s[%2$s][%3$s]" value="%3$s" %4$s /> ' , $ args ['section ' ], $ args ['id ' ], $ key , checked ( $ checked , $ key , false ) );
233+ $ html .= sprintf ( '%1$s</label><br> ' , $ label );
215234 }
216- $ html .= sprintf ( '<span class="description"> %s</label> ' , $ args ['desc ' ] );
235+ $ html .= $ this ->get_field_description ( $ args );
236+ $ html .= '</fieldset> ' ;
217237
218238 echo $ html ;
219239 }
@@ -227,12 +247,14 @@ function callback_radio( $args ) {
227247
228248 $ value = $ this ->get_option ( $ args ['id ' ], $ args ['section ' ], $ args ['std ' ] );
229249
230- $ html = '' ;
250+ $ html = '<fieldset> ' ;
231251 foreach ( $ args ['options ' ] as $ key => $ label ) {
232- $ html .= sprintf ( '<input type="radio" class="radio" id="wpuf-%1$s[%2$s][%3$s]" name="%1$s[%2$s]" value="%3$s"%4$s /> ' , $ args ['section ' ], $ args ['id ' ], $ key , checked ( $ value , $ key , false ) );
233- $ html .= sprintf ( '<label for="wpuf-%1$s[%2$s][%4$s]"> %3$s</label><br> ' , $ args ['section ' ], $ args ['id ' ], $ label , $ key );
252+ $ html .= sprintf ( '<label for="wpuf-%1$s[%2$s][%3$s]"> ' , $ args ['section ' ], $ args ['id ' ], $ key );
253+ $ html .= sprintf ( '<input type="radio" class="radio" id="wpuf-%1$s[%2$s][%3$s]" name="%1$s[%2$s]" value="%3$s" %4$s /> ' , $ args ['section ' ], $ args ['id ' ], $ key , checked ( $ value , $ key , false ) );
254+ $ html .= sprintf ( '%1$s</label><br> ' , $ label );
234255 }
235- $ html .= sprintf ( '<span class="description"> %s</label> ' , $ args ['desc ' ] );
256+ $ html .= $ this ->get_field_description ( $ args );
257+ $ html .= '</fieldset> ' ;
236258
237259 echo $ html ;
238260 }
@@ -252,7 +274,7 @@ function callback_select( $args ) {
252274 $ html .= sprintf ( '<option value="%s"%s>%s</option> ' , $ key , selected ( $ value , $ key , false ), $ label );
253275 }
254276 $ html .= sprintf ( '</select> ' );
255- $ html .= sprintf ( ' <span class="description"> %s</span> ' , $ args[ ' desc ' ] );
277+ $ html .= $ this -> get_field_description ( $ args );
256278
257279 echo $ html ;
258280 }
@@ -268,7 +290,7 @@ function callback_textarea( $args ) {
268290 $ size = isset ( $ args ['size ' ] ) && !is_null ( $ args ['size ' ] ) ? $ args ['size ' ] : 'regular ' ;
269291
270292 $ html = sprintf ( '<textarea rows="5" cols="55" class="%1$s-text" id="%2$s[%3$s]" name="%2$s[%3$s]">%4$s</textarea> ' , $ size , $ args ['section ' ], $ args ['id ' ], $ value );
271- $ html .= sprintf ( ' <br><span class="description"> %s</span> ' , $ args[ ' desc ' ] );
293+ $ html .= $ this -> get_field_description ( $ args );
272294
273295 echo $ html ;
274296 }
@@ -277,9 +299,10 @@ function callback_textarea( $args ) {
277299 * Displays a textarea for a settings field
278300 *
279301 * @param array $args settings field args
302+ * @return string
280303 */
281304 function callback_html ( $ args ) {
282- echo $ args[ ' desc ' ] ;
305+ echo $ this -> get_field_description ( $ args ) ;
283306 }
284307
285308 /**
@@ -307,7 +330,7 @@ function callback_wysiwyg( $args ) {
307330
308331 echo '</div> ' ;
309332
310- echo sprintf ( ' <br><span class="description"> %s</span> ' , $ args[ ' desc ' ] );
333+ echo $ this -> get_field_description ( $ args );
311334 }
312335
313336 /**
@@ -323,8 +346,7 @@ function callback_file( $args ) {
323346
324347 $ html = sprintf ( '<input type="text" class="%1$s-text wpsa-url" id="%2$s[%3$s]" name="%2$s[%3$s]" value="%4$s"/> ' , $ size , $ args ['section ' ], $ args ['id ' ], $ value );
325348 $ html .= '<input type="button" class="button wpsa-browse" value=" ' .__ ( 'Browse ' ).'" /> ' ;
326-
327- $ html .= sprintf ( '<span class="description"> %s</span> ' , $ args ['desc ' ] );
349+ $ html .= $ this ->get_field_description ( $ args );
328350
329351 echo $ html ;
330352 }
@@ -340,7 +362,7 @@ function callback_password( $args ) {
340362 $ size = isset ( $ args ['size ' ] ) && !is_null ( $ args ['size ' ] ) ? $ args ['size ' ] : 'regular ' ;
341363
342364 $ html = sprintf ( '<input type="password" class="%1$s-text" id="%2$s[%3$s]" name="%2$s[%3$s]" value="%4$s"/> ' , $ size , $ args ['section ' ], $ args ['id ' ], $ value );
343- $ html .= sprintf ( ' <span class="description"> %s</span> ' , $ args[ ' desc ' ] );
365+ $ html .= $ this -> get_field_description ( $ args );
344366
345367 echo $ html ;
346368 }
@@ -356,7 +378,7 @@ function callback_color( $args ) {
356378 $ size = isset ( $ args ['size ' ] ) && !is_null ( $ args ['size ' ] ) ? $ args ['size ' ] : 'regular ' ;
357379
358380 $ html = sprintf ( '<input type="text" class="%1$s-text wp-color-picker-field" id="%2$s[%3$s]" name="%2$s[%3$s]" value="%4$s" data-default-color="%5$s" /> ' , $ size , $ args ['section ' ], $ args ['id ' ], $ value , $ args ['std ' ] );
359- $ html .= sprintf ( ' <span class="description" style="display:block;"> %s</span> ' , $ args[ ' desc ' ] );
381+ $ html .= $ this -> get_field_description ( $ args );
360382
361383 echo $ html ;
362384 }
@@ -448,25 +470,23 @@ function show_navigation() {
448470 */
449471 function show_forms () {
450472 ?>
451- <div class="metabox-holder ">
452- <div class="postbox ">
453- <?php foreach ( $ this ->settings_sections as $ form ) { ?>
473+ <form method="post" action="options.php ">
474+ <div class="metabox-holder ">
475+ <?php foreach ( $ this ->settings_sections as $ form ): ?>
454476 <div id="<?php echo $ form ['id ' ]; ?> " class="group">
455- <form method="post" action="options.php">
456-
457- <?php do_action ( 'wsa_form_top_ ' . $ form ['id ' ], $ form ); ?>
458- <?php settings_fields ( $ form ['id ' ] ); ?>
459- <?php do_settings_sections ( $ form ['id ' ] ); ?>
460- <?php do_action ( 'wsa_form_bottom_ ' . $ form ['id ' ], $ form ); ?>
461-
462- <div style="padding-left: 10px">
463- <?php submit_button (); ?>
464- </div>
465- </form>
477+ <?php
478+ do_action ( 'wsa_form_top_ ' . $ form ['id ' ], $ form );
479+ settings_fields ( $ form ['id ' ] );
480+ do_settings_sections ( $ form ['id ' ] );
481+ do_action ( 'wsa_form_bottom_ ' . $ form ['id ' ], $ form );
482+ ?>
483+ <div style="padding-left: 10px">
484+ <?php submit_button (); ?>
485+ </div>
466486 </div>
467- <?php } ?>
487+ <?php endforeach ; ?>
468488 </div>
469- </div >
489+ </form >
470490 <?php
471491 $ this ->script ();
472492 }
0 commit comments