Skip to content

Commit 67899cd

Browse files
committed
code formatting
1 parent e5ed957 commit 67899cd

File tree

1 file changed

+49
-47
lines changed

1 file changed

+49
-47
lines changed

src/class.settings-api.php

Lines changed: 49 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@ function set_fields( $fields ) {
8383

8484
function add_field( $section, $field ) {
8585
$defaults = array(
86-
'name' => '',
86+
'name' => '',
8787
'label' => '',
88-
'desc' => '',
89-
'type' => 'text'
88+
'desc' => '',
89+
'type' => 'text'
9090
);
9191

9292
$arg = wp_parse_args( $field, $defaults );
@@ -129,16 +129,16 @@ function admin_init() {
129129
$type = isset( $option['type'] ) ? $option['type'] : 'text';
130130

131131
$args = array(
132-
'id' => $option['name'],
133-
'label_for' => $args['label_for'] = "{$section}[{$option['name']}]",
134-
'desc' => isset( $option['desc'] ) ? $option['desc'] : '',
135-
'name' => $option['label'],
136-
'section' => $section,
137-
'size' => isset( $option['size'] ) ? $option['size'] : null,
138-
'options' => isset( $option['options'] ) ? $option['options'] : '',
139-
'std' => isset( $option['default'] ) ? $option['default'] : '',
132+
'id' => $option['name'],
133+
'label_for' => $args['label_for'] = "{$section}[{$option['name']}]",
134+
'desc' => isset( $option['desc'] ) ? $option['desc'] : '',
135+
'name' => $option['label'],
136+
'section' => $section,
137+
'size' => isset( $option['size'] ) ? $option['size'] : null,
138+
'options' => isset( $option['options'] ) ? $option['options'] : '',
139+
'std' => isset( $option['default'] ) ? $option['default'] : '',
140140
'sanitize_callback' => isset( $option['sanitize_callback'] ) ? $option['sanitize_callback'] : '',
141-
'type' => $type,
141+
'type' => $type,
142142
);
143143

144144
add_settings_field( $section . '[' . $option['name'] . ']', $option['label'], array( $this, 'callback_' . $type ), $section, $section, $args );
@@ -174,11 +174,11 @@ public function get_field_description( $args ) {
174174
function callback_text( $args ) {
175175

176176
$value = esc_attr( $this->get_option( $args['id'], $args['section'], $args['std'] ) );
177-
$size = isset( $args['size'] ) && !is_null( $args['size'] ) ? $args['size'] : 'regular';
178-
$type = isset( $args['type'] ) ? $args['type'] : 'text';
177+
$size = isset( $args['size'] ) && !is_null( $args['size'] ) ? $args['size'] : 'regular';
178+
$type = isset( $args['type'] ) ? $args['type'] : 'text';
179179

180-
$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 );
181-
$html .= $this->get_field_description( $args );
180+
$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 );
181+
$html .= $this->get_field_description( $args );
182182

183183
echo $html;
184184
}
@@ -210,12 +210,12 @@ function callback_checkbox( $args ) {
210210

211211
$value = esc_attr( $this->get_option( $args['id'], $args['section'], $args['std'] ) );
212212

213-
$html = '<fieldset>';
214-
$html .= sprintf( '<label for="wpuf-%1$s[%2$s]">', $args['section'], $args['id'] );
215-
$html .= sprintf( '<input type="hidden" name="%1$s[%2$s]" value="off" />', $args['section'], $args['id'] );
216-
$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 ) );
217-
$html .= sprintf( '%1$s</label>', $args['desc'] );
218-
$html .= '</fieldset>';
213+
$html = '<fieldset>';
214+
$html .= sprintf( '<label for="wpuf-%1$s[%2$s]">', $args['section'], $args['id'] );
215+
$html .= sprintf( '<input type="hidden" name="%1$s[%2$s]" value="off" />', $args['section'], $args['id'] );
216+
$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 ) );
217+
$html .= sprintf( '%1$s</label>', $args['desc'] );
218+
$html .= '</fieldset>';
219219

220220
echo $html;
221221
}
@@ -228,14 +228,15 @@ function callback_checkbox( $args ) {
228228
function callback_multicheck( $args ) {
229229

230230
$value = $this->get_option( $args['id'], $args['section'], $args['std'] );
231+
$html = '<fieldset>';
231232

232-
$html = '<fieldset>';
233233
foreach ( $args['options'] as $key => $label ) {
234234
$checked = isset( $value[$key] ) ? $value[$key] : '0';
235-
$html .= sprintf( '<label for="wpuf-%1$s[%2$s][%3$s]">', $args['section'], $args['id'], $key );
236-
$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 ) );
237-
$html .= sprintf( '%1$s</label><br>', $label );
235+
$html .= sprintf( '<label for="wpuf-%1$s[%2$s][%3$s]">', $args['section'], $args['id'], $key );
236+
$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 ) );
237+
$html .= sprintf( '%1$s</label><br>', $label );
238238
}
239+
239240
$html .= $this->get_field_description( $args );
240241
$html .= '</fieldset>';
241242

@@ -250,13 +251,14 @@ function callback_multicheck( $args ) {
250251
function callback_radio( $args ) {
251252

252253
$value = $this->get_option( $args['id'], $args['section'], $args['std'] );
254+
$html = '<fieldset>';
253255

254-
$html = '<fieldset>';
255256
foreach ( $args['options'] as $key => $label ) {
256257
$html .= sprintf( '<label for="wpuf-%1$s[%2$s][%3$s]">', $args['section'], $args['id'], $key );
257258
$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 ) );
258259
$html .= sprintf( '%1$s</label><br>', $label );
259260
}
261+
260262
$html .= $this->get_field_description( $args );
261263
$html .= '</fieldset>';
262264

@@ -271,12 +273,13 @@ function callback_radio( $args ) {
271273
function callback_select( $args ) {
272274

273275
$value = esc_attr( $this->get_option( $args['id'], $args['section'], $args['std'] ) );
274-
$size = isset( $args['size'] ) && !is_null( $args['size'] ) ? $args['size'] : 'regular';
276+
$size = isset( $args['size'] ) && !is_null( $args['size'] ) ? $args['size'] : 'regular';
277+
$html = sprintf( '<select class="%1$s" name="%2$s[%3$s]" id="%2$s[%3$s]">', $size, $args['section'], $args['id'] );
275278

276-
$html = sprintf( '<select class="%1$s" name="%2$s[%3$s]" id="%2$s[%3$s]">', $size, $args['section'], $args['id'] );
277279
foreach ( $args['options'] as $key => $label ) {
278280
$html .= sprintf( '<option value="%s"%s>%s</option>', $key, selected( $value, $key, false ), $label );
279281
}
282+
280283
$html .= sprintf( '</select>' );
281284
$html .= $this->get_field_description( $args );
282285

@@ -291,10 +294,10 @@ function callback_select( $args ) {
291294
function callback_textarea( $args ) {
292295

293296
$value = esc_textarea( $this->get_option( $args['id'], $args['section'], $args['std'] ) );
294-
$size = isset( $args['size'] ) && !is_null( $args['size'] ) ? $args['size'] : 'regular';
297+
$size = isset( $args['size'] ) && !is_null( $args['size'] ) ? $args['size'] : 'regular';
295298

296-
$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 );
297-
$html .= $this->get_field_description( $args );
299+
$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 );
300+
$html .= $this->get_field_description( $args );
298301

299302
echo $html;
300303
}
@@ -317,15 +320,16 @@ function callback_html( $args ) {
317320
function callback_wysiwyg( $args ) {
318321

319322
$value = $this->get_option( $args['id'], $args['section'], $args['std'] );
320-
$size = isset( $args['size'] ) && !is_null( $args['size'] ) ? $args['size'] : '500px';
323+
$size = isset( $args['size'] ) && !is_null( $args['size'] ) ? $args['size'] : '500px';
321324

322325
echo '<div style="max-width: ' . $size . ';">';
323326

324327
$editor_settings = array(
325-
'teeny' => true,
328+
'teeny' => true,
326329
'textarea_name' => $args['section'] . '[' . $args['id'] . ']',
327330
'textarea_rows' => 10
328331
);
332+
329333
if ( isset( $args['options'] ) && is_array( $args['options'] ) ) {
330334
$editor_settings = array_merge( $editor_settings, $args['options'] );
331335
}
@@ -345,15 +349,13 @@ function callback_wysiwyg( $args ) {
345349
function callback_file( $args ) {
346350

347351
$value = esc_attr( $this->get_option( $args['id'], $args['section'], $args['std'] ) );
348-
$size = isset( $args['size'] ) && !is_null( $args['size'] ) ? $args['size'] : 'regular';
349-
$id = $args['section'] . '[' . $args['id'] . ']';
350-
$label = isset( $args['options']['button_label'] ) ?
351-
$args['options']['button_label'] :
352-
__( 'Choose File' );
352+
$size = isset( $args['size'] ) && !is_null( $args['size'] ) ? $args['size'] : 'regular';
353+
$id = $args['section'] . '[' . $args['id'] . ']';
354+
$label = isset( $args['options']['button_label'] ) ? $args['options']['button_label'] : __( 'Choose File' );
353355

354356
$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 );
355-
$html .= '<input type="button" class="button wpsa-browse" value="' . $label . '" />';
356-
$html .= $this->get_field_description( $args );
357+
$html .= '<input type="button" class="button wpsa-browse" value="' . $label . '" />';
358+
$html .= $this->get_field_description( $args );
357359

358360
echo $html;
359361
}
@@ -366,10 +368,10 @@ function callback_file( $args ) {
366368
function callback_password( $args ) {
367369

368370
$value = esc_attr( $this->get_option( $args['id'], $args['section'], $args['std'] ) );
369-
$size = isset( $args['size'] ) && !is_null( $args['size'] ) ? $args['size'] : 'regular';
371+
$size = isset( $args['size'] ) && !is_null( $args['size'] ) ? $args['size'] : 'regular';
370372

371-
$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 );
372-
$html .= $this->get_field_description( $args );
373+
$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 );
374+
$html .= $this->get_field_description( $args );
373375

374376
echo $html;
375377
}
@@ -382,10 +384,10 @@ function callback_password( $args ) {
382384
function callback_color( $args ) {
383385

384386
$value = esc_attr( $this->get_option( $args['id'], $args['section'], $args['std'] ) );
385-
$size = isset( $args['size'] ) && !is_null( $args['size'] ) ? $args['size'] : 'regular';
387+
$size = isset( $args['size'] ) && !is_null( $args['size'] ) ? $args['size'] : 'regular';
386388

387-
$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'] );
388-
$html .= $this->get_field_description( $args );
389+
$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'] );
390+
$html .= $this->get_field_description( $args );
389391

390392
echo $html;
391393
}

0 commit comments

Comments
 (0)