Skip to content

Commit a708224

Browse files
committed
Move help icon to variable.
DRY
1 parent f3a61f4 commit a708224

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

src/inc/settings.php

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,19 @@ function ableplayer_update_setting( $key, $value = '' ) {
6868
* @return string|void
6969
*/
7070
function ableplayer_settings_field( $args = array(), $context = 'settings' ) {
71-
$name = ( isset( $args['name'] ) ) ? $args['name'] : '';
72-
$label = ( isset( $args['label'] ) ) ? $args['label'] : '';
73-
$default = ( isset( $args['default'] ) ) ? $args['default'] : '';
74-
$note = ( isset( $args['note'] ) ) ? $args['note'] : '';
75-
$atts = ( isset( $args['atts'] ) ) ? $args['atts'] : array();
76-
$type = ( isset( $args['type'] ) ) ? $args['type'] : 'text';
77-
$echo = ( isset( $args['echo'] ) ) ? $args['echo'] : true;
78-
$wrap = ( isset( $args['wrap'] ) ) ? $args['wrap'] : array();
79-
$position = ( isset( $args['position'] ) ) ? $args['position'] : 'bottom';
80-
$id = ( isset( $args['id'] ) ) ? $args['id'] : $name;
81-
$element = '';
82-
$close = '';
71+
$name = ( isset( $args['name'] ) ) ? $args['name'] : '';
72+
$label = ( isset( $args['label'] ) ) ? $args['label'] : '';
73+
$default = ( isset( $args['default'] ) ) ? $args['default'] : '';
74+
$note = ( isset( $args['note'] ) ) ? $args['note'] : '';
75+
$atts = ( isset( $args['atts'] ) ) ? $args['atts'] : array();
76+
$type = ( isset( $args['type'] ) ) ? $args['type'] : 'text';
77+
$echo = ( isset( $args['echo'] ) ) ? $args['echo'] : true;
78+
$wrap = ( isset( $args['wrap'] ) ) ? $args['wrap'] : array();
79+
$position = ( isset( $args['position'] ) ) ? $args['position'] : 'bottom';
80+
$id = ( isset( $args['id'] ) ) ? $args['id'] : $name;
81+
$help_icon = "<i class='dashicons dashicons-editor-help' aria-hidden='true'></i>";
82+
$element = '';
83+
$close = '';
8384
if ( ! empty( $wrap ) ) {
8485
$el = isset( $wrap['element'] ) ? $wrap['element'] : 'p';
8586
$class = '';
@@ -129,7 +130,7 @@ function ableplayer_settings_field( $args = array(), $context = 'settings' ) {
129130
case 'number':
130131
if ( $note ) {
131132
$note = sprintf( str_replace( '%', '', $note ), "<code>$value</code>" );
132-
$note = "<span id='$id-note' class='ableplayer-input-description'><i class='dashicons dashicons-editor-help' aria-hidden='true'></i>$note</span>";
133+
$note = "<span id='$id-note' class='ableplayer-input-description'>$help_icon$note</span>";
133134
$aria = " aria-describedby='$id-note'";
134135
} else {
135136
$note = '';
@@ -145,7 +146,7 @@ function ableplayer_settings_field( $args = array(), $context = 'settings' ) {
145146
case 'textarea':
146147
if ( $note ) {
147148
$note = sprintf( $note, "<code>$value</code>" );
148-
$note = "<span id='$id-note' class='ableplayer-input-description'><i class='dashicons dashicons-editor-help' aria-hidden='true'></i>$note</span>";
149+
$note = "<span id='$id-note' class='ableplayer-input-description'>$help_icon$note</span>";
149150
$aria = " aria-describedby='$id-note'";
150151
} else {
151152
$note = '';
@@ -156,7 +157,7 @@ function ableplayer_settings_field( $args = array(), $context = 'settings' ) {
156157
case 'checkbox-single':
157158
$checked = checked( 'true', ableplayer_get_settings( $name ), false );
158159
if ( $note ) {
159-
$note = "<span id='$id-note' class='ableplayer-input-description'><i class='dashicons dashicons-editor-help' aria-hidden='true'></i>" . sprintf( $note, "<code>$value</code>" ) . '</span>';
160+
$note = "<span id='$id-note' class='ableplayer-input-description'>$help_icon" . sprintf( $note, "<code>$value</code>" ) . '</span>';
160161
$aria = " aria-describedby='$id-note'";
161162
} else {
162163
$note = '';
@@ -168,7 +169,7 @@ function ableplayer_settings_field( $args = array(), $context = 'settings' ) {
168169
case 'radio':
169170
if ( $note ) {
170171
$note = sprintf( $note, "<code>$value</code>" );
171-
$note = "<span id='$id-note' class='ableplayer-input-description'><i class='dashicons dashicons-editor-help' aria-hidden='true'></i>$note</span>";
172+
$note = "<span id='$id-note' class='ableplayer-input-description'>$help_icon$note</span>";
172173
$aria = " aria-describedby='$id-note'";
173174
} else {
174175
$note = '';
@@ -193,7 +194,7 @@ function ableplayer_settings_field( $args = array(), $context = 'settings' ) {
193194
case 'select':
194195
if ( $note ) {
195196
$note = sprintf( $note, "<code>$value</code>" );
196-
$note = "<span id='$id-note' class='ableplayer-input-description'><i class='dashicons dashicons-editor-help' aria-hidden='true'></i>$note</span>";
197+
$note = "<span id='$id-note' class='ableplayer-input-description'>$help_icon$note</span>";
197198
$aria = " aria-describedby='$id-note'";
198199
} else {
199200
$note = '';

0 commit comments

Comments
 (0)