Skip to content

Commit 5024ef9

Browse files
committed
Fix all PHPCS issues
1 parent e589213 commit 5024ef9

File tree

1 file changed

+34
-34
lines changed

1 file changed

+34
-34
lines changed

includes/classes/SettingsApi.php

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ class SettingsApi {
9191
* @param string $slug Slug for the settings page.
9292
* @param int|null $position Menu position for the settings page.
9393
* @param bool $top_level If it's a top level menu.
94+
* @param string $icon_url URL to use for an icon.
9495
*/
9596
public function __construct( $page_title, $menu_title, $capability, $slug, $position = null, $top_level = false, $icon_url = '' ) {
9697

@@ -251,8 +252,8 @@ public function admin_init() {
251252
$section['desc'] = '<div class="inside">' . $section['desc'] . '</div>';
252253

253254
// Create the callback for description.
254-
$callback = function() use ( $section ) {
255-
echo str_replace( '"', '\"', $section['desc'] );
255+
$callback = function () use ( $section ) {
256+
echo wp_kses_post( str_replace( '"', '\"', $section['desc'] ) );
256257
};
257258

258259
} elseif ( isset( $section['callback'] ) ) {
@@ -349,7 +350,7 @@ public function admin_init() {
349350
* @param array $args = [)
350351
*/
351352

352-
// @param string $id
353+
// @param string $id
353354
$field_id = $section . '[' . $field['id'] . ']';
354355

355356
add_settings_field(
@@ -374,7 +375,6 @@ public function admin_init() {
374375
*/
375376
register_setting( $section['id'], $section['id'], [ $this, 'sanitize_fields' ] );
376377
} // foreach ended.
377-
378378
} // admin_init() ended.
379379

380380
/**
@@ -462,7 +462,7 @@ public function callback_title( $args ) {
462462

463463
$html = '';
464464

465-
echo $html;
465+
echo wp_kses_post( $html );
466466
}
467467

468468
/**
@@ -479,7 +479,7 @@ public function callback_text( $args ) {
479479
$html = sprintf( '<input type="%1$s" class="%2$s-text" id="%3$s[%4$s]" name="%3$s[%4$s]" value="%5$s"placeholder="%6$s"/>', $type, $size, $args['section'], $args['id'], $value, $args['placeholder'] );
480480
$html .= $this->get_field_description( $args );
481481

482-
echo $html;
482+
echo wp_kses_post( $html );
483483
}
484484

485485
/**
@@ -525,7 +525,7 @@ public function callback_checkbox( $args ) {
525525
$html .= sprintf( '%1$s</label>', $args['desc'] );
526526
$html .= '</fieldset>';
527527

528-
echo $html;
528+
echo wp_kses_post( $html );
529529
}
530530

531531
/**
@@ -543,15 +543,15 @@ public function callback_multicheck( $args ) {
543543
$label = is_array( $item ) ? $item['label'] : $item;
544544
$checked = isset( $value[ $key ] ) ? $value[ $key ] : '0';
545545

546-
$html .= sprintf( '<label for="' . $this->slug . '-%1$s[%2$s][%3$s]">', $args['section'], $args['id'], $key );
547-
$html .= sprintf( '<input type="checkbox" class="checkbox" id="' . $this->slug . '-%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 ) );
548-
$html .= sprintf( '%1$s</label><br>', $label );
549-
$html .= $this->get_field_description( $item );
546+
$html .= sprintf( '<label for="' . $this->slug . '-%1$s[%2$s][%3$s]">', $args['section'], $args['id'], $key );
547+
$html .= sprintf( '<input type="checkbox" class="checkbox" id="' . $this->slug . '-%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 ) );
548+
$html .= sprintf( '%1$s</label><br>', $label );
549+
$html .= $this->get_field_description( $item );
550550
}
551551
$html .= $this->get_field_description( $args );
552552
$html .= '</fieldset>';
553553

554-
echo $html;
554+
echo wp_kses_post( $html );
555555
}
556556

557557
/**
@@ -572,7 +572,7 @@ public function callback_radio( $args ) {
572572
$html .= $this->get_field_description( $args );
573573
$html .= '</fieldset>';
574574

575-
echo $html;
575+
echo wp_kses_post( $html );
576576
}
577577

578578
/**
@@ -592,7 +592,7 @@ public function callback_select( $args ) {
592592
$html .= sprintf( '</select>' );
593593
$html .= $this->get_field_description( $args );
594594

595-
echo $html;
595+
echo wp_kses_post( $html );
596596
}
597597

598598
/**
@@ -608,7 +608,7 @@ public function callback_textarea( $args ) {
608608
$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 );
609609
$html .= $this->get_field_description( $args );
610610

611-
echo $html;
611+
echo wp_kses_post( $html );
612612
}
613613

614614
/**
@@ -619,7 +619,7 @@ public function callback_textarea( $args ) {
619619
* @return void
620620
*/
621621
public function callback_html( $args ) {
622-
echo $this->get_field_description( $args );
622+
echo wp_kses_post( $this->get_field_description( $args ) );
623623
}
624624

625625
/**
@@ -647,7 +647,7 @@ public function callback_wysiwyg( $args ) {
647647

648648
echo '</div>';
649649

650-
echo $this->get_field_description( $args );
650+
echo wp_kses_post( $this->get_field_description( $args ) );
651651
}
652652

653653
/**
@@ -668,7 +668,7 @@ public function callback_file( $args ) {
668668
$html .= '<input type="button" class="button eighteen73-browse" value="' . $label . '" />';
669669
$html .= $this->get_field_description( $args );
670670

671-
echo $html;
671+
echo wp_kses_post( $html );
672672
}
673673

674674
/**
@@ -690,7 +690,7 @@ public function callback_image( $args ) {
690690
$html .= $this->get_field_description( $args );
691691
$html .= '<p class="eighteen73-image-preview"><img src=""/></p>';
692692

693-
echo $html;
693+
echo wp_kses_post( $html );
694694
}
695695

696696
/**
@@ -706,7 +706,7 @@ public function callback_password( $args ) {
706706
$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 );
707707
$html .= $this->get_field_description( $args );
708708

709-
echo $html;
709+
echo wp_kses_post( $html );
710710
}
711711

712712
/**
@@ -722,7 +722,7 @@ public function callback_color( $args ) {
722722
$html = sprintf( '<input type="text" class="%1$s-text color-picker" id="%2$s[%3$s]" name="%2$s[%3$s]" value="%4$s" data-default-color="%5$s" placeholder="%6$s" />', $size, $args['section'], $args['id'], $value, $args['std'], $args['placeholder'] );
723723
$html .= $this->get_field_description( $args );
724724

725-
echo $html;
725+
echo wp_kses_post( $html );
726726
}
727727

728728
/**
@@ -735,26 +735,26 @@ public function callback_separator( $args ) {
735735

736736
$html = '';
737737
$html .= '<div class="eighteen73-settings-separator"></div>';
738-
echo $html;
738+
echo wp_kses_post( $html );
739739
}
740740

741741
/**
742742
* Get the value of a settings field
743743
*
744-
* @param string $option settings field name.
745-
* @param string $section the section name this field belongs to.
746-
* @param string $default default text if it's not found.
744+
* @param string $option settings field name.
745+
* @param string $section the section name this field belongs to.
746+
* @param string $fallback default text if it's not found.
747747
* @return string
748748
*/
749-
public function get_option( $option, $section, $default = '' ) {
749+
public function get_option( $option, $section, $fallback = '' ) {
750750

751751
$options = get_option( $section );
752752

753753
if ( isset( $options[ $option ] ) ) {
754754
return $options[ $option ];
755755
}
756756

757-
return $default;
757+
return $fallback;
758758
}
759759

760760
/**
@@ -786,11 +786,11 @@ public function admin_menu() {
786786
/**
787787
* Sets a submenu.
788788
*
789-
* @param string $page_title
790-
* @param string $menu_title
791-
* @param string $menu_slug
792-
* @param array $callback
793-
* @param int|null $position
789+
* @param string $page_title Page title for the submenu page.
790+
* @param string $menu_title Menu title for the submenu page.
791+
* @param string $menu_slug Slug for the settings page.
792+
* @param array $callback The callback for the submenu.
793+
* @param int|null $position Menu position for the submenu page.
794794
*/
795795
public function set_submenu( $page_title, $menu_title, $menu_slug, $callback, $position = null ) {
796796
if ( empty( $page_title ) || empty( $menu_title ) || empty( $menu_slug ) || empty( $callback ) || ! is_array( $callback ) ) {
@@ -838,7 +838,7 @@ public function admin_submenus() {
838838
*/
839839
public function plugin_page() {
840840
echo '<div class="wrap">';
841-
echo '<h1>' . $this->page_title . '</h1>';
841+
echo '<h1>' . esc_html( $this->page_title ) . '</h1>';
842842
$this->show_navigation();
843843
$this->show_forms();
844844
echo '</div>';
@@ -860,7 +860,7 @@ public function show_navigation() {
860860

861861
$html .= '</h2>';
862862

863-
echo $html;
863+
echo wp_kses_post( $html );
864864
}
865865

866866
/**

0 commit comments

Comments
 (0)